From c90d44d5f26ca51193762e92d0d2fb1382203595 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 6 Apr 2024 11:39:11 +0100 Subject: [PATCH 01/17] initial work --- .vscode/settings.json | 2 +- check.sh | 5 +- crates/bevy_mod_scripting_core/Cargo.toml | 12 +- .../bevy_mod_scripting_core/src/bindings.rs | 253 ++++++++++++++++++ crates/bevy_mod_scripting_core/src/error.rs | 19 ++ crates/bevy_mod_scripting_core/src/hosts.rs | 2 +- crates/bevy_mod_scripting_core/src/lib.rs | 1 + 7 files changed, 279 insertions(+), 15 deletions(-) create mode 100644 crates/bevy_mod_scripting_core/src/bindings.rs diff --git a/.vscode/settings.json b/.vscode/settings.json index 3cf59b30..c6115b53 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,7 +11,7 @@ "rust-analyzer.rustc.source": "discover", "rust-analyzer.linkedProjects": [ "./crates/bevy_api_gen/Cargo.toml", - // "./crates/macro_tests/Cargo.toml", + "./crates/macro_tests/Cargo.toml", "Cargo.toml", ], "rust-analyzer.check.invocationStrategy": "per_workspace", diff --git a/check.sh b/check.sh index b7f544a8..d2754df1 100755 --- a/check.sh +++ b/check.sh @@ -2,9 +2,10 @@ unset RUSTUP_TOOLCHAIN CURRENT_DIR=$(basename "$PWD") - if [[ "$CURRENT_DIR" == "bevy_api_gen" ]]; then cargo clippy --all-targets --message-format=json +elif [[ "$CURRENT_DIR" == "macro_tests" ]]; then + cargo clippy --all-targets --message-format=json else - cargo clippy --workspace --all-targets --message-format=json --features="lua54 lua_script_api rhai rhai_script_api teal rune bevy/file_watcher bevy/multi-threaded" + cargo clippy --workspace --all-targets --message-format=json --features="lua54 lua_script_api rhai rhai_script_api teal rune bevy/file_watcher bevy/multi-threaded" fi \ No newline at end of file diff --git a/crates/bevy_mod_scripting_core/Cargo.toml b/crates/bevy_mod_scripting_core/Cargo.toml index b09b6df8..4a005fee 100644 --- a/crates/bevy_mod_scripting_core/Cargo.toml +++ b/crates/bevy_mod_scripting_core/Cargo.toml @@ -21,17 +21,7 @@ doc_always = [] [dependencies] -bevy = { workspace = true, default-features = false, features = [ - "bevy_asset", - "bevy_gltf", - "bevy_animation", - "bevy_core_pipeline", - "bevy_ui", - "bevy_pbr", - "bevy_render", - "bevy_text", - "bevy_sprite", -] } +bevy = { workspace = true, default-features = false, features = ["bevy_asset"] } bevy_event_priority = { path = "../bevy_event_priority", version = "0.6.0" } thiserror = "1.0.31" paste = "1.0.7" diff --git a/crates/bevy_mod_scripting_core/src/bindings.rs b/crates/bevy_mod_scripting_core/src/bindings.rs new file mode 100644 index 00000000..f71aba79 --- /dev/null +++ b/crates/bevy_mod_scripting_core/src/bindings.rs @@ -0,0 +1,253 @@ +//! Traits and structs needed to support the creation of bindings for scripting languages. + +// reflection gives us access to `dyn Reflect` objects via their type name, +// Scripting languages only really support `Clone` objects so if we want to support references, +// we need wrapper types which have owned and ref variants. +// we need traits which let us go from &dyn Reflect to a wrapper type + +use std::{ + any::{Any, TypeId}, + sync::{Arc, Mutex}, +}; + +use bevy::{ + ecs::{component::ComponentId, entity::Entity, world::World}, + ptr::Ptr, + reflect::{ParsedPath, Reflect, ReflectFromPtr, ReflectPath, ReflectPathError, TypeRegistry}, +}; + +use crate::error::ReflectionError; + +/// A wrapper for a `dyn Reflect` struct +pub enum Wrapper { + Owned(Arc>), + Ref(ReflectReference), +} + +/// An accessor to a `dyn Reflect` struct, stores a base ID of the type and a reflection path +pub struct ReflectReference { + base: ReflectId, + // TODO: experiment with Fixed capacity vec, boxed array etc, compromise between heap allocation and runtime cost + // needs benchmarks first though + /// The path from the top level type to the actual value we want to access + reflect_path: Vec>, +} + +impl ReflectReference { + /// Retrieves the underlying `dyn Reflect` object given a world + /// - If the reference is to a component and the entity no longer exists, returns `None` + /// - If the resource or component ID's are invalid will panic + /// - In the future if the underlying reference is NOT to a Component or Resource ReflectId this will return None, i.e. for Bundles + pub fn reflect<'w>( + &self, + world: &'w World, + type_registry: &TypeRegistry, + ) -> Result<&'w dyn Reflect, ReflectionError> { + let type_id = self.base.type_id(world); + + // all Reflect types should have this derived + let from_ptr_data: &ReflectFromPtr = type_registry + .get_type_data(type_id) + .expect("FromPtr is not registered for this type, cannot retrieve reflect reference"); + + let ptr = self.base.get_ptr(world)?; + + // Safety: we use the same type_id to both + // 1) retrieve the ptr + // 2) retrieve the ReflectFromPtr type data + // so the as_reflect implementation should match and this is sound + debug_assert_eq!(from_ptr_data.type_id(), type_id, "Invariant violated"); + let mut base = unsafe { from_ptr_data.as_reflect(ptr) }; + + for elem in self.reflect_path.iter().skip(1) { + base = elem + .reflect_element(base) + .map_err(|e| ReflectionError::Other(e.to_string()))?; + } + + Ok(base) + } + + pub fn reflect_mut<'w>( + &self, + world: &'w mut World, + type_registry: &TypeRegistry, + ) -> Result<&'w mut dyn Reflect, ReflectionError> { + let type_id = self.base.type_id(world); + + // all Reflect types should have this derived + let from_ptr_data: &ReflectFromPtr = type_registry + .get_type_data(type_id) + .expect("FromPtr is not registered for this type, cannot retrieve reflect reference"); + + let ptr = self.base.get_ptr(world)?; + + // Safety: we use the same type_id to both + // 1) retrieve the ptr + // 2) retrieve the ReflectFromPtr type data + // so the as_reflect implementation should match and this is sound + debug_assert_eq!(from_ptr_data.type_id(), type_id, "Invariant violated"); + let mut base = unsafe { from_ptr_data.as_reflect_mut(ptr) }; + + for elem in self.reflect_path.iter().skip(1) { + base = elem + .reflect_mut(base) + .map_err(|e| ReflectionError::Other(e.to_string()))?; + } + + Ok(base) + } +} + +#[derive(Clone, Copy, Debug)] +pub enum ReflectId { + Component(ComponentId, Entity), + Resource(ComponentId), + // Bundle(BundleId), +} + +impl ReflectId { + pub fn type_id(self, world: &World) -> TypeId { + match self { + ReflectId::Component(id, _) | ReflectId::Resource(id) => world + .components() + .get_info(id) + .expect("Invalid component id") + .type_id() + .expect("Expected rust type"), + } + } + + pub fn get_ptr(self, world: &World) -> Result { + match self { + ReflectId::Component(id, entity) => { + world + .get_by_id(entity, id) + .ok_or_else(|| ReflectionError::InvalidBaseReference { + base: format!("{:?}", self), + reason: "Entity no longer exists, or componentId is no longer valid" + .to_string(), + }) + } + ReflectId::Resource(id) => { + world + .get_resource_by_id(id) + .ok_or_else(|| ReflectionError::InvalidBaseReference { + base: format!("{:?}", self), + reason: "Resource no longer exists, or componentId is no longer valid" + .to_string(), + }) + } + } + } +} + +/// An element in the reflection path, the base reference included +#[derive(Clone)] +pub enum ReflectionPathElem<'a> { + /// A standard reflection path, i.e. `.field_name[vec_index]`, pre-parsed since we construct once potentially use many times + Reflection(ParsedPath), + /// a deferred reflection + DeferredReflection(DeferredReflection<'a>), +} + +impl std::fmt::Debug for ReflectionPathElem<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Reflection(arg0) => f.debug_tuple("Reflection").field(arg0).finish(), + Self::DeferredReflection(_) => f.write_str("DeferredReflection"), + } + } +} + +impl<'a> ReflectPath<'a> for ReflectionPathElem<'a> { + fn reflect_element(self, root: &dyn Reflect) -> Result<&dyn Reflect, ReflectPathError<'a>> { + match self { + ReflectionPathElem::Reflection(path) => path.reflect_element(root), + ReflectionPathElem::DeferredReflection(f) => (f.get)(root), + } + } + + fn reflect_element_mut( + self, + root: &mut dyn Reflect, + ) -> Result<&mut dyn Reflect, ReflectPathError<'a>> { + match self { + ReflectionPathElem::Reflection(path) => path.reflect_element_mut(root), + ReflectionPathElem::DeferredReflection(defref) => (defref.get_mut)(root), + } + } +} + +/// A ReflectPath which can perform arbitrary operations on the root object to produce a sub-reference +#[derive(Clone)] +pub struct DeferredReflection<'a> { + get: Arc Result<&dyn Reflect, ReflectPathError<'a>> + Send + Sync>, + get_mut: Arc< + dyn Fn(&mut dyn Reflect) -> Result<&mut dyn Reflect, ReflectPathError<'a>> + Send + Sync, + >, +} + +#[cfg(test)] +mod test { + use bevy::ecs::{component::Component, system::Resource}; + + use super::*; + + #[derive(Component, Reflect)] + struct TestComponent { + strings: Vec, + } + + #[derive(Resource, Reflect, Default)] + struct TestResource { + bytes: Vec, + } + + #[test] + fn test_reflect_reference() { + let mut world = World::default(); + let component_id = world.init_component::(); + let resource_id = world.init_resource::(); + + let type_registry = TypeRegistry::new(); + + let entity = world + .spawn(TestComponent { + strings: vec![String::from("hello")], + }) + .id(); + + world.insert_resource(TestResource { bytes: vec![42] }); + + let component_reflect_ref = ReflectReference { + base: ReflectId::Component(component_id, entity), + reflect_path: vec![ReflectionPathElem::Reflection( + ParsedPath::parse_static(".strings[0]").unwrap(), + )], + }; + + assert_eq!( + component_reflect_ref + .reflect(&world, &type_registry) + .unwrap() + .downcast_ref(), + Some(&String::from("hello")) + ); + + let resource_reflect_ref = ReflectReference { + base: ReflectId::Resource(resource_id), + reflect_path: vec![ReflectionPathElem::Reflection( + ParsedPath::parse_static(".bytes[0]").unwrap(), + )], + }; + + assert_eq!( + resource_reflect_ref + .reflect(&world, &type_registry) + .unwrap() + .downcast_ref(), + Some(&42) + ); + } +} diff --git a/crates/bevy_mod_scripting_core/src/error.rs b/crates/bevy_mod_scripting_core/src/error.rs index 3f0dd2be..99a7541a 100644 --- a/crates/bevy_mod_scripting_core/src/error.rs +++ b/crates/bevy_mod_scripting_core/src/error.rs @@ -1,3 +1,5 @@ +use std::borrow::Cow; + use thiserror::Error; #[derive(Error, Debug, Clone)] @@ -28,3 +30,20 @@ impl ScriptError { Self::Other(other.to_string()) } } + +#[derive(Error, Debug, Clone)] +pub enum ReflectionError { + #[error("Base reference `{base}` is invalid. {reason}")] + InvalidBaseReference { base: String, reason: String }, + #[error("Insuficient provenance error while accessing `{path}`. {msg}")] + InsufficientProvenance { path: String, msg: String }, + #[error("Invalid reflection path: `{path}`. {msg}")] + InvalidReflectionPath { path: String, msg: String }, + #[error("Cannot downcast from `{from}` to `{to}`")] + CannotDowncast { + from: Cow<'static, str>, + to: Cow<'static, str>, + }, + #[error("{0}")] + Other(String), +} diff --git a/crates/bevy_mod_scripting_core/src/hosts.rs b/crates/bevy_mod_scripting_core/src/hosts.rs index 9e8ff585..6d6ebc19 100644 --- a/crates/bevy_mod_scripting_core/src/hosts.rs +++ b/crates/bevy_mod_scripting_core/src/hosts.rs @@ -1,5 +1,5 @@ //! All script host related stuff -use bevy::{asset::Asset, ecs::schedule::ScheduleLabel, prelude::*}; +use bevy::{ecs::schedule::ScheduleLabel, prelude::*}; use std::{ collections::HashMap, iter::once, diff --git a/crates/bevy_mod_scripting_core/src/lib.rs b/crates/bevy_mod_scripting_core/src/lib.rs index 617571c8..9664545a 100644 --- a/crates/bevy_mod_scripting_core/src/lib.rs +++ b/crates/bevy_mod_scripting_core/src/lib.rs @@ -7,6 +7,7 @@ use event::ScriptLoaded; use systems::script_event_handler; pub mod asset; +pub mod bindings; pub mod docs; pub mod error; pub mod event; From ca16a98495b5018c95592fa100ad6cea60e742d8 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 6 Apr 2024 16:04:02 +0100 Subject: [PATCH 02/17] finish basic TypeId based reflect machinery including deferred reflection --- .../bevy_mod_scripting_core/src/bindings.rs | 339 +++++++++++++----- 1 file changed, 250 insertions(+), 89 deletions(-) diff --git a/crates/bevy_mod_scripting_core/src/bindings.rs b/crates/bevy_mod_scripting_core/src/bindings.rs index f71aba79..6dd4bfe1 100644 --- a/crates/bevy_mod_scripting_core/src/bindings.rs +++ b/crates/bevy_mod_scripting_core/src/bindings.rs @@ -6,14 +6,18 @@ // we need traits which let us go from &dyn Reflect to a wrapper type use std::{ - any::{Any, TypeId}, + any::TypeId, sync::{Arc, Mutex}, }; use bevy::{ - ecs::{component::ComponentId, entity::Entity, world::World}, + ecs::{ + change_detection::MutUntyped, entity::Entity, world::unsafe_world_cell::UnsafeWorldCell, + }, ptr::Ptr, - reflect::{ParsedPath, Reflect, ReflectFromPtr, ReflectPath, ReflectPathError, TypeRegistry}, + reflect::{ + ParsedPath, Reflect, ReflectFromPtr, ReflectPath, ReflectPathError, TypeInfo, TypeRegistry, + }, }; use crate::error::ReflectionError; @@ -25,41 +29,54 @@ pub enum Wrapper { } /// An accessor to a `dyn Reflect` struct, stores a base ID of the type and a reflection path +/// safe to build but to reflect on the value inside you need to ensure aliasing rules are upheld +#[derive(Debug)] pub struct ReflectReference { - base: ReflectId, + pub base: ReflectBase, // TODO: experiment with Fixed capacity vec, boxed array etc, compromise between heap allocation and runtime cost // needs benchmarks first though /// The path from the top level type to the actual value we want to access - reflect_path: Vec>, + pub reflect_path: Vec, } impl ReflectReference { - /// Retrieves the underlying `dyn Reflect` object given a world - /// - If the reference is to a component and the entity no longer exists, returns `None` - /// - If the resource or component ID's are invalid will panic - /// - In the future if the underlying reference is NOT to a Component or Resource ReflectId this will return None, i.e. for Bundles - pub fn reflect<'w>( + /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell + /// # Safety + /// - The caller must ensure the cell has permission to access the underlying value + /// - The caller must ensure no aliasing mut references to the same value exist at all at the same time + /// - This includes the AppTypeRegistry resource if it is being borrowed from the world! + pub unsafe fn reflect<'w>( &self, - world: &'w World, + world: UnsafeWorldCell<'w>, type_registry: &TypeRegistry, ) -> Result<&'w dyn Reflect, ReflectionError> { - let type_id = self.base.type_id(world); - // all Reflect types should have this derived let from_ptr_data: &ReflectFromPtr = type_registry - .get_type_data(type_id) + .get_type_data(self.base.type_id) .expect("FromPtr is not registered for this type, cannot retrieve reflect reference"); - let ptr = self.base.get_ptr(world)?; + let ptr = self + .base + .base_id + .get_ptr(self.base.type_id, world) + .ok_or_else(|| ReflectionError::InvalidBaseReference { + base: self.base.display_with_type_name(type_registry), + reason: "Base reference is invalid, is the component/resource initialized? does the entity exist?".to_string(), + })?; - // Safety: we use the same type_id to both + // (Ptr) Safety: we use the same type_id to both // 1) retrieve the ptr // 2) retrieve the ReflectFromPtr type data - // so the as_reflect implementation should match and this is sound - debug_assert_eq!(from_ptr_data.type_id(), type_id, "Invariant violated"); + // (UnsafeWorldCell) Safety: + // we already have access to &world so no &mut world exists + debug_assert_eq!( + from_ptr_data.type_id(), + self.base.type_id, + "Invariant violated" + ); let mut base = unsafe { from_ptr_data.as_reflect(ptr) }; - for elem in self.reflect_path.iter().skip(1) { + for elem in self.reflect_path.iter() { base = elem .reflect_element(base) .map_err(|e| ReflectionError::Other(e.to_string()))?; @@ -68,30 +85,46 @@ impl ReflectReference { Ok(base) } - pub fn reflect_mut<'w>( + /// Retrieves mutable reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell + /// # Safety + /// - The caller must ensure the cell has permission to access the underlying value + /// - The caller must ensure no aliasing mut references to the same value exist at all at the same time + /// - This includes the AppTypeRegistry resource if it is being borrowed from the world! + pub unsafe fn reflect_mut<'w>( &self, - world: &'w mut World, + world: UnsafeWorldCell<'w>, type_registry: &TypeRegistry, ) -> Result<&'w mut dyn Reflect, ReflectionError> { - let type_id = self.base.type_id(world); - // all Reflect types should have this derived let from_ptr_data: &ReflectFromPtr = type_registry - .get_type_data(type_id) + .get_type_data(self.base.type_id) .expect("FromPtr is not registered for this type, cannot retrieve reflect reference"); - let ptr = self.base.get_ptr(world)?; - - // Safety: we use the same type_id to both + let ptr = self + .base + .base_id + .get_ptr_mut(self.base.type_id, world) + .ok_or_else(|| ReflectionError::InvalidBaseReference { + base: self.base.display_with_type_name(type_registry), + reason: "Base reference is invalid, is the component/resource initialized? does the entity exist?".to_string(), + })? + .into_inner(); + + // (Ptr) Safety: we use the same type_id to both // 1) retrieve the ptr // 2) retrieve the ReflectFromPtr type data - // so the as_reflect implementation should match and this is sound - debug_assert_eq!(from_ptr_data.type_id(), type_id, "Invariant violated"); + // (UnsafeWorldCell) Safety: + // we already have access to &world so no &mut world exists + debug_assert_eq!( + from_ptr_data.type_id(), + self.base.type_id, + "Invariant violated" + ); let mut base = unsafe { from_ptr_data.as_reflect_mut(ptr) }; - for elem in self.reflect_path.iter().skip(1) { + for elem in self.reflect_path.iter() { base = elem - .reflect_mut(base) + .reflect_element_mut(base) .map_err(|e| ReflectionError::Other(e.to_string()))?; } @@ -99,44 +132,79 @@ impl ReflectReference { } } +#[derive(Clone, Copy, Debug)] +pub struct ReflectBase { + type_id: TypeId, + base_id: ReflectId, +} + +impl ReflectBase { + pub fn type_name(&self, type_registry: &TypeRegistry) -> &'static str { + type_registry + .get_type_info(self.type_id) + .map(TypeInfo::type_path) + .unwrap_or("") + } + + pub fn display_with_type_name(&self, type_registry: &TypeRegistry) -> String { + format!( + "ReflectBase({}, {:?})", + self.type_name(type_registry), + self.base_id + ) + } +} + #[derive(Clone, Copy, Debug)] pub enum ReflectId { - Component(ComponentId, Entity), - Resource(ComponentId), + Component(Entity), + Resource, // Bundle(BundleId), } impl ReflectId { - pub fn type_id(self, world: &World) -> TypeId { + /// Retrieves the pointer to the underlying `dyn Reflect` object valid for the 'w lifteime of the world cell + /// + /// # Safety + /// - The caller must ensure the cell has permission to access the underlying value + /// - The caller must ensure no aliasing mutable references to the same value exist at the same time + pub unsafe fn get_ptr(self, type_id: TypeId, world: UnsafeWorldCell<'_>) -> Option> { match self { - ReflectId::Component(id, _) | ReflectId::Resource(id) => world - .components() - .get_info(id) - .expect("Invalid component id") - .type_id() - .expect("Expected rust type"), + ReflectId::Component(entity) => { + let component_id = world.components().get_id(type_id)?; + // Safety: the caller ensures invariants hold + world.get_entity(entity)?.get_by_id(component_id) + } + ReflectId::Resource => { + let component_id = world.components().get_resource_id(type_id)?; + + // Safety: the caller ensures invariants hold + world.get_resource_by_id(component_id) + } } } - pub fn get_ptr(self, world: &World) -> Result { + /// Retrieves the pointer to the underlying `dyn Reflect` object valid for the 'w lifteime of the world cell + /// + /// # Safety + /// - The caller must ensure the cell has permission to access the underlying value + /// - The caller must ensure no aliasing references to the same value exist at all at the same time + pub unsafe fn get_ptr_mut( + self, + type_id: TypeId, + world: UnsafeWorldCell<'_>, + ) -> Option> { match self { - ReflectId::Component(id, entity) => { - world - .get_by_id(entity, id) - .ok_or_else(|| ReflectionError::InvalidBaseReference { - base: format!("{:?}", self), - reason: "Entity no longer exists, or componentId is no longer valid" - .to_string(), - }) + ReflectId::Component(entity) => { + let component_id = world.components().get_id(type_id)?; + // Safety: the caller ensures invariants hold + world.get_entity(entity)?.get_mut_by_id(component_id) } - ReflectId::Resource(id) => { - world - .get_resource_by_id(id) - .ok_or_else(|| ReflectionError::InvalidBaseReference { - base: format!("{:?}", self), - reason: "Resource no longer exists, or componentId is no longer valid" - .to_string(), - }) + ReflectId::Resource => { + let component_id = world.components().get_id(type_id)?; + + // Safety: the caller ensures invariants hold + world.get_resource_mut_by_id(component_id) } } } @@ -144,14 +212,14 @@ impl ReflectId { /// An element in the reflection path, the base reference included #[derive(Clone)] -pub enum ReflectionPathElem<'a> { +pub enum ReflectionPathElem { /// A standard reflection path, i.e. `.field_name[vec_index]`, pre-parsed since we construct once potentially use many times Reflection(ParsedPath), /// a deferred reflection - DeferredReflection(DeferredReflection<'a>), + DeferredReflection(DeferredReflection), } -impl std::fmt::Debug for ReflectionPathElem<'_> { +impl std::fmt::Debug for ReflectionPathElem { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Reflection(arg0) => f.debug_tuple("Reflection").field(arg0).finish(), @@ -160,18 +228,21 @@ impl std::fmt::Debug for ReflectionPathElem<'_> { } } -impl<'a> ReflectPath<'a> for ReflectionPathElem<'a> { - fn reflect_element(self, root: &dyn Reflect) -> Result<&dyn Reflect, ReflectPathError<'a>> { +impl<'a> ReflectPath<'a> for &'a ReflectionPathElem { + fn reflect_element<'r>( + self, + root: &'r dyn Reflect, + ) -> Result<&'r dyn Reflect, ReflectPathError<'a>> { match self { ReflectionPathElem::Reflection(path) => path.reflect_element(root), ReflectionPathElem::DeferredReflection(f) => (f.get)(root), } } - fn reflect_element_mut( + fn reflect_element_mut<'r>( self, - root: &mut dyn Reflect, - ) -> Result<&mut dyn Reflect, ReflectPathError<'a>> { + root: &'r mut dyn Reflect, + ) -> Result<&'r mut dyn Reflect, ReflectPathError<'a>> { match self { ReflectionPathElem::Reflection(path) => path.reflect_element_mut(root), ReflectionPathElem::DeferredReflection(defref) => (defref.get_mut)(root), @@ -181,16 +252,23 @@ impl<'a> ReflectPath<'a> for ReflectionPathElem<'a> { /// A ReflectPath which can perform arbitrary operations on the root object to produce a sub-reference #[derive(Clone)] -pub struct DeferredReflection<'a> { - get: Arc Result<&dyn Reflect, ReflectPathError<'a>> + Send + Sync>, +pub struct DeferredReflection { + get: Arc Result<&dyn Reflect, ReflectPathError<'static>> + Send + Sync>, get_mut: Arc< - dyn Fn(&mut dyn Reflect) -> Result<&mut dyn Reflect, ReflectPathError<'a>> + Send + Sync, + dyn Fn(&mut dyn Reflect) -> Result<&mut dyn Reflect, ReflectPathError<'static>> + + Send + + Sync, >, } #[cfg(test)] mod test { - use bevy::ecs::{component::Component, system::Resource}; + use std::sync::RwLock; + + use bevy::{ + ecs::{component::Component, reflect::AppTypeRegistry, system::Resource, world::World}, + reflect::TypeRegistryArc, + }; use super::*; @@ -204,14 +282,27 @@ mod test { bytes: Vec, } - #[test] - fn test_reflect_reference() { + fn setup_world() -> (World, Arc>) { let mut world = World::default(); - let component_id = world.init_component::(); - let resource_id = world.init_resource::(); + world.init_component::(); + world.init_resource::(); + + let mut type_registry = TypeRegistry::new(); + type_registry.register::(); + type_registry.register::(); + + let type_registry = Arc::new(RwLock::new(type_registry)); - let type_registry = TypeRegistry::new(); + world.insert_resource(AppTypeRegistry(TypeRegistryArc { + internal: type_registry.clone(), + })); + (world, type_registry) + } + + #[test] + fn test_parsed_path() { + let (mut world, type_registry) = setup_world(); let entity = world .spawn(TestComponent { strings: vec![String::from("hello")], @@ -221,33 +312,103 @@ mod test { world.insert_resource(TestResource { bytes: vec![42] }); let component_reflect_ref = ReflectReference { - base: ReflectId::Component(component_id, entity), + base: ReflectBase { + base_id: ReflectId::Component(entity), + type_id: TypeId::of::(), + }, reflect_path: vec![ReflectionPathElem::Reflection( ParsedPath::parse_static(".strings[0]").unwrap(), )], }; - assert_eq!( - component_reflect_ref - .reflect(&world, &type_registry) - .unwrap() - .downcast_ref(), - Some(&String::from("hello")) - ); + let type_registry = &type_registry.read().unwrap(); + // Safety: + // - we have unique access to world, and nothing else is accessing it + // - we are not accessing type registry via the cell + unsafe { + assert_eq!( + component_reflect_ref + .reflect(world.as_unsafe_world_cell_readonly(), type_registry) + .unwrap() + .downcast_ref::(), + Some(&String::from("hello")) + ); + } let resource_reflect_ref = ReflectReference { - base: ReflectId::Resource(resource_id), + base: ReflectBase { + base_id: ReflectId::Resource, + type_id: TypeId::of::(), + }, reflect_path: vec![ReflectionPathElem::Reflection( ParsedPath::parse_static(".bytes[0]").unwrap(), )], }; - assert_eq!( - resource_reflect_ref - .reflect(&world, &type_registry) + // Safety: + // - we have unique access to world, and nothing else is accessing it + // - we are not accessing type registry via the cell + unsafe { + assert_eq!( + resource_reflect_ref + .reflect(world.as_unsafe_world_cell(), type_registry) + .unwrap() + .downcast_ref(), + Some(&42u8) + ); + } + } + + #[test] + fn test_parsed_and_deferred_path() { + let (mut world, type_registry) = setup_world(); + let entity = world + .spawn(TestComponent { + strings: vec![String::from("hello")], + }) + .id(); + + world.insert_resource(TestResource { bytes: vec![42] }); + + let component_reflect_ref = ReflectReference { + base: ReflectBase { + base_id: ReflectId::Component(entity), + type_id: TypeId::of::(), + }, + reflect_path: vec![ + ReflectionPathElem::Reflection(ParsedPath::parse_static(".strings").unwrap()), + ReflectionPathElem::DeferredReflection(DeferredReflection { + get: Arc::new(|root| { + let strings = root.downcast_ref::>().unwrap(); + Ok(strings.first().unwrap()) + }), + get_mut: Arc::new(|root| { + let strings = root.downcast_mut::>().unwrap(); + Ok(strings.first_mut().unwrap()) + }), + }), + ], + }; + + let type_registry = &type_registry.read().unwrap(); + // Safety: + // - we have unique access to world, and nothing else is accessing it + // - we are not accessing type registry via the cell + // - we drop the mutable access before the immutable access + unsafe { + *component_reflect_ref + .reflect_mut(world.as_unsafe_world_cell(), type_registry) .unwrap() - .downcast_ref(), - Some(&42) - ); + .downcast_mut::() + .unwrap() = String::from("world"); + + assert_eq!( + component_reflect_ref + .reflect(world.as_unsafe_world_cell_readonly(), type_registry) + .unwrap() + .downcast_ref::(), + Some(&String::from("world")) + ); + } } } From f426e6ffcd5f77fefad9c7ed2969ae7abecc8597 Mon Sep 17 00:00:00 2001 From: makspll Date: Mon, 8 Apr 2024 02:44:56 +0100 Subject: [PATCH 03/17] Define mechanisms for safe parallel world access via fine locks --- .../bevy_mod_scripting_core/src/bindings.rs | 492 +++++++++++++----- crates/bevy_mod_scripting_core/src/error.rs | 10 +- crates/bevy_mod_scripting_core/src/lib.rs | 4 +- .../bevy_mod_scripting_lua/src/bindings.rs | 38 ++ .../bevy_mod_scripting_lua/src/lib.rs | 5 +- 5 files changed, 421 insertions(+), 128 deletions(-) create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings.rs diff --git a/crates/bevy_mod_scripting_core/src/bindings.rs b/crates/bevy_mod_scripting_core/src/bindings.rs index 6dd4bfe1..914e29e1 100644 --- a/crates/bevy_mod_scripting_core/src/bindings.rs +++ b/crates/bevy_mod_scripting_core/src/bindings.rs @@ -1,18 +1,21 @@ +//! # Motivation +//! //! Traits and structs needed to support the creation of bindings for scripting languages. +//! reflection gives us access to `dyn Reflect` objects via their type name, +//! Scripting languages only really support `Clone` objects so if we want to support references, +//! we need wrapper types which have owned and ref variants. +//! we need traits which let us go from &dyn Reflect to a wrapper type. -// reflection gives us access to `dyn Reflect` objects via their type name, -// Scripting languages only really support `Clone` objects so if we want to support references, -// we need wrapper types which have owned and ref variants. -// we need traits which let us go from &dyn Reflect to a wrapper type - -use std::{ - any::TypeId, - sync::{Arc, Mutex}, -}; +use parking_lot::RwLock; +use std::{any::TypeId, cell::RefCell, collections::HashMap, marker::PhantomData, sync::Arc}; use bevy::{ ecs::{ - change_detection::MutUntyped, entity::Entity, world::unsafe_world_cell::UnsafeWorldCell, + change_detection::MutUntyped, + component::ComponentId, + entity::Entity, + system::Resource, + world::{unsafe_world_cell::UnsafeWorldCell, World}, }, ptr::Ptr, reflect::{ @@ -22,34 +25,224 @@ use bevy::{ use crate::error::ReflectionError; -/// A wrapper for a `dyn Reflect` struct +pub type AllocationId = usize; + +/// Allocator used to allocate and deallocate `dyn Reflect` values +/// Used to be able to ensure lifetime of the values we are accessing as well as optimize allocations +#[derive(Resource, Default)] +pub struct ScriptAllocator { + // TODO: experiment with object pools, sparse set etc. + pub allocations: HashMap>, +} + +impl ScriptAllocator { + /// Allocates a new [`Reflect`] value and returns an [`AllocationId`] which can be used to access it later + pub fn allocate(&mut self, value: Arc) -> AllocationId { + let id = self.allocations.len(); + self.allocations.insert(id, value); + id + } + + /// Deallocates the [`Reflect`] value with the given [`AllocationId`] + pub fn deallocate(&mut self, id: AllocationId) { + self.allocations.remove(&id); + } + + /// Runs a garbage collection pass on the allocations, removing any allocations which have no more strong references + /// Needs to be run periodically to prevent memory leaks + pub fn clean_garbage_allocations(&mut self) { + self.allocations.retain(|_, v| Arc::strong_count(v) > 1); + } +} + +/// A wrapper for a `dyn Reflect` struct, can either be owned or a reference pub enum Wrapper { - Owned(Arc>), + Owned(Arc, AllocationId), Ref(ReflectReference), } +/// Describes kinds of base value we are accessing via reflection +#[derive(PartialEq, Eq, Copy, Clone)] +pub enum ReflectAccessKind { + ComponentOrResource, + Owned, +} + +/// Describes the id pointing to the base value we are accessing via reflection, for components and resources this is the ComponentId +/// for script owned values this is an allocationId, this is used to ensure we have permission to access the value. +#[derive(PartialEq, Eq, Copy, Clone)] +pub struct ReflectAccessId { + kind: ReflectAccessKind, + id: usize, +} + +pub struct WorldAccessGuard<'w> { + cell: UnsafeWorldCell<'w>, + // TODO: lotta indirection here, can we make this better? + accesses: RefCell>>>>, +} + +impl<'w> WorldAccessGuard<'w> { + /// Creates a new [`WorldAccessGuard`] for the given mutable borrow of the world + pub fn new(world: &'w mut World) -> Self { + Self { + cell: world.as_unsafe_world_cell(), + accesses: Default::default(), + } + } + + /// Retrieves the underlying unsafe world cell, with no additional guarantees of safety + /// proceed with caution and only use this if you understand what you're doing + pub fn as_unsafe_world_cell(&self) -> UnsafeWorldCell<'w> { + self.cell + } + + /// Retrieves the underlying read only unsafe world cell, with no additional guarantees of safety + /// proceed with caution and only use this if you understand what you're doing + pub fn as_unsafe_world_cell_readonly(&self) -> UnsafeWorldCell<'w> { + self.cell + } + + fn make_access_if_not_exists(&self, id: ReflectAccessId) { + self.accesses + .borrow_mut() + .entry(id.id) + .or_insert_with(|| Arc::new(RwLock::new(WorldAccess(id, PhantomData)))); + } + + pub fn get_access(&self, raid: ReflectAccessId) -> Arc>> { + self.make_access_if_not_exists(raid); + let locks = self.accesses.borrow(); + let val = locks.get(&raid.id).expect("access not present"); + val.clone() + } + + /// Get access to the given component_id, this is the only way to access a component/resource safely (in the context of the world access guard) + /// since you can only access this component_id through a RwLock, there is no way to break aliasing rules. + /// Additionally the 'w lifetime prevents you from storing this access outside the lifetime of the underlying cell + pub fn get_component_access(&self, cid: ComponentId) -> Arc>> { + let access_id = ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: cid.index(), + }; + self.get_access(access_id) + } + + /// Get access to the given component_id, this is the only way to access a component/resource safely (in the context of the world access guard) + /// since you can only access this component_id through a RwLock, there is no way to break aliasing rules. + /// Additionally the 'w lifetime prevents you from storing this access outside the lifetime of the underlying cell + pub fn get_resource_access(&self, cid: ComponentId) -> Arc>> { + self.get_component_access(cid) + } + + pub fn get_owned_access(&self, id: AllocationId) -> Arc>> { + let access_id = ReflectAccessId { + kind: ReflectAccessKind::Owned, + id, + }; + self.get_access(access_id) + } +} + +/// Having this is permission to access the contained [`ReflectAccessId`], there is no way to access anything safely through a [`WorldAccessGuard`] +/// without having a [`WorldAccess`] instance for that particular [`ReflectAccessId`]. +/// +/// If you do own a [`WorldAccess`] for some [`ReflectAccessId`], you can read and write to it safely. +/// If you only have an immutable borrow of [`WorldAccess`] you can only read it safely. +/// If you have a mutable borrow of [`WorldAccess`] you can read and write to it safely. +pub struct WorldAccess<'a>(pub ReflectAccessId, PhantomData<&'a usize>); + +// pub struct + /// An accessor to a `dyn Reflect` struct, stores a base ID of the type and a reflection path /// safe to build but to reflect on the value inside you need to ensure aliasing rules are upheld #[derive(Debug)] pub struct ReflectReference { - pub base: ReflectBase, + pub base: ReflectBaseType, // TODO: experiment with Fixed capacity vec, boxed array etc, compromise between heap allocation and runtime cost // needs benchmarks first though /// The path from the top level type to the actual value we want to access pub reflect_path: Vec, } +// just a dummy standin for unregistered types +struct UnregisteredType; + impl ReflectReference { + /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell. + /// If the underlying componentId is not the same as the one we have access to, an error is returned. + pub fn reflect<'w>( + &'w self, + world: UnsafeWorldCell<'w>, + access: &WorldAccess<'w>, + type_registry: &TypeRegistry, + ) -> Result<&'w dyn Reflect, ReflectionError> { + if access.0 == self.base.base_id.get_reflect_access_id() { + // Safety: since we have read access to the underlying componentId we can safely access the component + return unsafe { self.reflect_unsafe(world, type_registry) }; + } + Err(ReflectionError::InsufficientAccess { + base: self.base.display_with_type_name(type_registry), + reason: format!( + "Invalid access, instead got permission to read: {}", + ReflectBaseType { + type_id: world + .components() + .get_info(ComponentId::new(access.0.id)) + .and_then(|c| c.type_id()) + .unwrap_or(TypeId::of::()), + base_id: self.base.base_id.clone() + } + .display_with_type_name(type_registry), + ) + .to_owned(), + }) + } + + /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell. + /// If the underlying componentId is not the same as the one we have access to, an error is returned. + pub fn reflect_mut<'w>( + &'w self, + world: UnsafeWorldCell<'w>, + access: &mut WorldAccess<'w>, + type_registry: &TypeRegistry, + ) -> Result<&'w mut dyn Reflect, ReflectionError> { + if access.0 == self.base.base_id.get_reflect_access_id() { + // Safety: since we have write access to the underlying reflect access id we can safely access the component + return unsafe { self.reflect_mut_unsafe(world, type_registry) }; + } + + Err(ReflectionError::InsufficientAccess { + base: self.base.display_with_type_name(type_registry), + reason: format!( + "Invalid access, instead got permission to mutate: {}", + ReflectBaseType { + type_id: world + .components() + .get_info(ComponentId::new(access.0.id)) + .and_then(|c| c.type_id()) + .unwrap_or(TypeId::of::()), + base_id: self.base.base_id.clone() + } + .display_with_type_name(type_registry), + ) + .to_owned(), + }) + } + /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell /// # Safety /// - The caller must ensure the cell has permission to access the underlying value /// - The caller must ensure no aliasing mut references to the same value exist at all at the same time - /// - This includes the AppTypeRegistry resource if it is being borrowed from the world! - pub unsafe fn reflect<'w>( - &self, + pub unsafe fn reflect_unsafe<'w>( + &'w self, world: UnsafeWorldCell<'w>, type_registry: &TypeRegistry, ) -> Result<&'w dyn Reflect, ReflectionError> { + if let ReflectBase::Owned(weak, _) = &self.base.base_id { + // safety: + return Ok(weak.as_ref()); + }; // all Reflect types should have this derived let from_ptr_data: &ReflectFromPtr = type_registry .get_type_data(self.base.type_id) @@ -58,7 +251,8 @@ impl ReflectReference { let ptr = self .base .base_id - .get_ptr(self.base.type_id, world) + .clone() + .into_ptr(world) .ok_or_else(|| ReflectionError::InvalidBaseReference { base: self.base.display_with_type_name(type_registry), reason: "Base reference is invalid, is the component/resource initialized? does the entity exist?".to_string(), @@ -89,12 +283,16 @@ impl ReflectReference { /// # Safety /// - The caller must ensure the cell has permission to access the underlying value /// - The caller must ensure no aliasing mut references to the same value exist at all at the same time - /// - This includes the AppTypeRegistry resource if it is being borrowed from the world! - pub unsafe fn reflect_mut<'w>( - &self, + pub unsafe fn reflect_mut_unsafe<'w>( + &'w self, world: UnsafeWorldCell<'w>, type_registry: &TypeRegistry, ) -> Result<&'w mut dyn Reflect, ReflectionError> { + if let ReflectBase::Owned(weak, _) = &self.base.base_id { + // Safety: caller promises this is fine :) + return Ok(unsafe { &mut *(Arc::as_ptr(weak) as *mut _) }); + }; + // all Reflect types should have this derived let from_ptr_data: &ReflectFromPtr = type_registry .get_type_data(self.base.type_id) @@ -103,7 +301,8 @@ impl ReflectReference { let ptr = self .base .base_id - .get_ptr_mut(self.base.type_id, world) + .clone() + .into_ptr_mut(world) .ok_or_else(|| ReflectionError::InvalidBaseReference { base: self.base.display_with_type_name(type_registry), reason: "Base reference is invalid, is the component/resource initialized? does the entity exist?".to_string(), @@ -132,16 +331,16 @@ impl ReflectReference { } } -#[derive(Clone, Copy, Debug)] -pub struct ReflectBase { +#[derive(Clone, Debug)] +pub struct ReflectBaseType { type_id: TypeId, - base_id: ReflectId, + base_id: ReflectBase, } -impl ReflectBase { - pub fn type_name(&self, type_registry: &TypeRegistry) -> &'static str { +impl ReflectBaseType { + pub fn type_name(type_id: TypeId, type_registry: &TypeRegistry) -> &'static str { type_registry - .get_type_info(self.type_id) + .get_type_info(type_id) .map(TypeInfo::type_path) .unwrap_or("") } @@ -149,38 +348,37 @@ impl ReflectBase { pub fn display_with_type_name(&self, type_registry: &TypeRegistry) -> String { format!( "ReflectBase({}, {:?})", - self.type_name(type_registry), + Self::type_name(self.type_id, type_registry), self.base_id ) } } -#[derive(Clone, Copy, Debug)] -pub enum ReflectId { - Component(Entity), - Resource, - // Bundle(BundleId), +/// The Id of the kind of reflection base being pointed to +#[derive(Clone, Debug)] +pub enum ReflectBase { + Component(Entity, ComponentId), + Resource(ComponentId), + Owned(Arc, AllocationId), } -impl ReflectId { +impl ReflectBase { /// Retrieves the pointer to the underlying `dyn Reflect` object valid for the 'w lifteime of the world cell /// /// # Safety /// - The caller must ensure the cell has permission to access the underlying value /// - The caller must ensure no aliasing mutable references to the same value exist at the same time - pub unsafe fn get_ptr(self, type_id: TypeId, world: UnsafeWorldCell<'_>) -> Option> { + pub unsafe fn into_ptr(self, world: UnsafeWorldCell<'_>) -> Option> { match self { - ReflectId::Component(entity) => { - let component_id = world.components().get_id(type_id)?; + ReflectBase::Component(entity, component_id) => { // Safety: the caller ensures invariants hold world.get_entity(entity)?.get_by_id(component_id) } - ReflectId::Resource => { - let component_id = world.components().get_resource_id(type_id)?; - + ReflectBase::Resource(component_id) => { // Safety: the caller ensures invariants hold world.get_resource_by_id(component_id) } + _ => None, } } @@ -189,23 +387,30 @@ impl ReflectId { /// # Safety /// - The caller must ensure the cell has permission to access the underlying value /// - The caller must ensure no aliasing references to the same value exist at all at the same time - pub unsafe fn get_ptr_mut( - self, - type_id: TypeId, - world: UnsafeWorldCell<'_>, - ) -> Option> { + pub unsafe fn into_ptr_mut(self, world: UnsafeWorldCell<'_>) -> Option> { match self { - ReflectId::Component(entity) => { - let component_id = world.components().get_id(type_id)?; + ReflectBase::Component(entity, component_id) => { // Safety: the caller ensures invariants hold world.get_entity(entity)?.get_mut_by_id(component_id) } - ReflectId::Resource => { - let component_id = world.components().get_id(type_id)?; - + ReflectBase::Resource(component_id) => { // Safety: the caller ensures invariants hold world.get_resource_mut_by_id(component_id) } + _ => None, + } + } + + pub fn get_reflect_access_id(&self) -> ReflectAccessId { + match self { + ReflectBase::Component(_, cid) | ReflectBase::Resource(cid) => ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: cid.index(), + }, + ReflectBase::Owned(_, id) => ReflectAccessId { + kind: ReflectAccessKind::Owned, + id: *id, + }, } } } @@ -263,14 +468,9 @@ pub struct DeferredReflection { #[cfg(test)] mod test { - use std::sync::RwLock; - - use bevy::{ - ecs::{component::Component, reflect::AppTypeRegistry, system::Resource, world::World}, - reflect::TypeRegistryArc, - }; use super::*; + use bevy::ecs::{component::Component, world::World}; #[derive(Component, Reflect)] struct TestComponent { @@ -282,27 +482,21 @@ mod test { bytes: Vec, } - fn setup_world() -> (World, Arc>) { + fn setup_world() -> (World, TypeRegistry, ComponentId, ComponentId) { let mut world = World::default(); - world.init_component::(); - world.init_resource::(); + let component_id = world.init_component::(); + let resource_id = world.init_resource::(); let mut type_registry = TypeRegistry::new(); type_registry.register::(); type_registry.register::(); - let type_registry = Arc::new(RwLock::new(type_registry)); - - world.insert_resource(AppTypeRegistry(TypeRegistryArc { - internal: type_registry.clone(), - })); - - (world, type_registry) + (world, type_registry, component_id, resource_id) } #[test] fn test_parsed_path() { - let (mut world, type_registry) = setup_world(); + let (mut world, type_registry, component_id, resource_id) = setup_world(); let entity = world .spawn(TestComponent { strings: vec![String::from("hello")], @@ -310,10 +504,11 @@ mod test { .id(); world.insert_resource(TestResource { bytes: vec![42] }); + let world = WorldAccessGuard::new(&mut world); let component_reflect_ref = ReflectReference { - base: ReflectBase { - base_id: ReflectId::Component(entity), + base: ReflectBaseType { + base_id: ReflectBase::Component(entity, component_id), type_id: TypeId::of::(), }, reflect_path: vec![ReflectionPathElem::Reflection( @@ -321,23 +516,22 @@ mod test { )], }; - let type_registry = &type_registry.read().unwrap(); - // Safety: - // - we have unique access to world, and nothing else is accessing it - // - we are not accessing type registry via the cell - unsafe { - assert_eq!( - component_reflect_ref - .reflect(world.as_unsafe_world_cell_readonly(), type_registry) - .unwrap() - .downcast_ref::(), - Some(&String::from("hello")) - ); - } + let component_access = world.get_component_access(component_id); + assert_eq!( + component_reflect_ref + .reflect( + world.as_unsafe_world_cell_readonly(), + &component_access.read(), + &type_registry, + ) + .unwrap() + .downcast_ref::(), + Some(&String::from("hello")) + ); let resource_reflect_ref = ReflectReference { - base: ReflectBase { - base_id: ReflectId::Resource, + base: ReflectBaseType { + base_id: ReflectBase::Resource(resource_id), type_id: TypeId::of::(), }, reflect_path: vec![ReflectionPathElem::Reflection( @@ -345,23 +539,23 @@ mod test { )], }; - // Safety: - // - we have unique access to world, and nothing else is accessing it - // - we are not accessing type registry via the cell - unsafe { - assert_eq!( - resource_reflect_ref - .reflect(world.as_unsafe_world_cell(), type_registry) - .unwrap() - .downcast_ref(), - Some(&42u8) - ); - } + let resource_access = world.get_component_access(resource_id); + assert_eq!( + resource_reflect_ref + .reflect( + world.as_unsafe_world_cell(), + &resource_access.read(), + &type_registry, + ) + .unwrap() + .downcast_ref(), + Some(&42u8) + ); } #[test] fn test_parsed_and_deferred_path() { - let (mut world, type_registry) = setup_world(); + let (mut world, type_registry, component_id, _) = setup_world(); let entity = world .spawn(TestComponent { strings: vec![String::from("hello")], @@ -369,10 +563,11 @@ mod test { .id(); world.insert_resource(TestResource { bytes: vec![42] }); + let world = WorldAccessGuard::new(&mut world); let component_reflect_ref = ReflectReference { - base: ReflectBase { - base_id: ReflectId::Component(entity), + base: ReflectBaseType { + base_id: ReflectBase::Component(entity, component_id), type_id: TypeId::of::(), }, reflect_path: vec![ @@ -390,25 +585,86 @@ mod test { ], }; - let type_registry = &type_registry.read().unwrap(); - // Safety: - // - we have unique access to world, and nothing else is accessing it - // - we are not accessing type registry via the cell - // - we drop the mutable access before the immutable access - unsafe { - *component_reflect_ref - .reflect_mut(world.as_unsafe_world_cell(), type_registry) + let component_access = world.get_component_access(component_id); + *component_reflect_ref + .reflect_mut( + world.as_unsafe_world_cell(), + &mut component_access.write(), + &type_registry, + ) + .unwrap() + .downcast_mut::() + .unwrap() = String::from("world"); + + assert_eq!( + component_reflect_ref + .reflect( + world.as_unsafe_world_cell_readonly(), + &component_access.read(), + &type_registry, + ) .unwrap() - .downcast_mut::() - .unwrap() = String::from("world"); - - assert_eq!( - component_reflect_ref - .reflect(world.as_unsafe_world_cell_readonly(), type_registry) - .unwrap() - .downcast_ref::(), - Some(&String::from("world")) - ); - } + .downcast_ref::(), + Some(&String::from("world")) + ); + } + + #[test] + fn test_script_alloc_access() { + let (mut world, type_registry, _, _) = setup_world(); + + let world = WorldAccessGuard::new(&mut world); + let mut script_allocator = ScriptAllocator::default(); + let allocation_id = script_allocator.allocate(Arc::new("hello".to_string())); + + let owned_reflect_ref = ReflectReference { + base: ReflectBaseType { + base_id: ReflectBase::Owned( + script_allocator + .allocations + .get(&allocation_id) + .unwrap() + .clone(), + allocation_id, + ), + type_id: TypeId::of::(), + }, + reflect_path: vec![], + }; + + let owned_access = world.get_owned_access(allocation_id); + + assert_eq!( + owned_reflect_ref + .reflect( + world.as_unsafe_world_cell_readonly(), + &owned_access.read(), + &type_registry, + ) + .unwrap() + .downcast_ref::(), + Some(&String::from("hello")) + ); + + let onwed_access_read = owned_access.read(); + assert!( + world.get_owned_access(allocation_id).try_write().is_none(), + "Mutable borrow allowed while immutable borrow exists" + ); + drop(onwed_access_read) + } + + #[test] + fn test_invalid_runtime_access() { + let mut world = World::new(); + let world = WorldAccessGuard::new(&mut world); + let access = world.get_component_access(ComponentId::new(0)); + let access2 = world.get_component_access(ComponentId::new(0)); + let access = access.read(); + assert!( + access2.try_write().is_none(), + "Immutable and Mutable borrow allowed at the same time" + ); + drop(access); } } diff --git a/crates/bevy_mod_scripting_core/src/error.rs b/crates/bevy_mod_scripting_core/src/error.rs index 99a7541a..07003bd0 100644 --- a/crates/bevy_mod_scripting_core/src/error.rs +++ b/crates/bevy_mod_scripting_core/src/error.rs @@ -1,5 +1,3 @@ -use std::borrow::Cow; - use thiserror::Error; #[derive(Error, Debug, Clone)] @@ -35,15 +33,13 @@ impl ScriptError { pub enum ReflectionError { #[error("Base reference `{base}` is invalid. {reason}")] InvalidBaseReference { base: String, reason: String }, + #[error("Cannot safely access `{base}`. {reason}")] + InsufficientAccess { base: String, reason: String }, #[error("Insuficient provenance error while accessing `{path}`. {msg}")] InsufficientProvenance { path: String, msg: String }, #[error("Invalid reflection path: `{path}`. {msg}")] InvalidReflectionPath { path: String, msg: String }, - #[error("Cannot downcast from `{from}` to `{to}`")] - CannotDowncast { - from: Cow<'static, str>, - to: Cow<'static, str>, - }, + #[error("{0}")] Other(String), } diff --git a/crates/bevy_mod_scripting_core/src/lib.rs b/crates/bevy_mod_scripting_core/src/lib.rs index 9664545a..0c121fcc 100644 --- a/crates/bevy_mod_scripting_core/src/lib.rs +++ b/crates/bevy_mod_scripting_core/src/lib.rs @@ -3,6 +3,7 @@ use crate::{ hosts::{APIProvider, APIProviders, ScriptHost}, }; use bevy::{ecs::schedule::ScheduleLabel, prelude::*}; +use bindings::ScriptAllocator; use event::ScriptLoaded; use systems::script_event_handler; @@ -44,7 +45,8 @@ pub struct ScriptingPlugin; impl Plugin for ScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { - app.add_event::(); + app.add_event::() + .init_resource::(); } } diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings.rs new file mode 100644 index 00000000..d2b1691a --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings.rs @@ -0,0 +1,38 @@ +//! Lua specific traits and types relevant to binding rust types to Lua types + +// /// Trait for types which can be converted into a value representible in a scripting language from a reference, +// pub trait RefIntoLua: Reflect { +// fn ref_into_script_value(&self, ctxt: ScriptContext) -> ScriptValueType; +// } + +// /// Type data corresponding to the [`RefIntoScriptValue`] trait +// pub struct ReflectRefIntoScriptValue { +// pub ref_into_script_value: fn(&dyn Reflect, ctxt: ScriptContext) -> ScriptValueType, +// } + +// impl Clone for ReflectRefIntoScriptValue { +// fn clone(&self) -> Self { +// Self { +// ref_into_script_value: self.ref_into_script_value, +// } +// } +// } + +// /// Trait for types which be converted from a value representible in a scripting language to a reference to the original type. +// pub trait ScriptValueToRef: Reflect { +// fn script_value_to_ref(script_value: &ScriptValueType, ctxt: ScriptContext) -> &Self; +// } + +// /// Type data corresponding to the [`ScriptValueToRef`] trait +// pub struct ReflectScriptValueToRef { +// pub script_value_to_ref: +// fn(script_value: &ScriptValueType, ctxt: ScriptContext) -> &dyn Reflect, +// } + +// impl Clone for ReflectScriptValueToRef { +// fn clone(&self) -> Self { +// Self { +// script_value_to_ref: self.script_value_to_ref, +// } +// } +// } diff --git a/crates/languages/bevy_mod_scripting_lua/src/lib.rs b/crates/languages/bevy_mod_scripting_lua/src/lib.rs index d356fade..29863ada 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/lib.rs @@ -5,15 +5,16 @@ use crate::{ use bevy::{ecs::schedule::ScheduleLabel, prelude::*}; use bevy_mod_scripting_core::{prelude::*, systems::*, world::WorldPointerGuard}; -use std::fmt; -use std::marker::PhantomData; use std::sync::Mutex; +use std::{fmt, marker::PhantomData}; use tealr::mlu::mlua::{prelude::*, Function}; pub mod assets; +pub mod bindings; pub mod docs; pub mod util; pub use tealr; + pub mod prelude { pub use crate::{ assets::{LuaFile, LuaLoader}, From 5e4df7642a6c746414a6034da92375113fd90a0a Mon Sep 17 00:00:00 2001 From: makspll Date: Mon, 8 Apr 2024 11:02:04 +0100 Subject: [PATCH 04/17] add system for cleaning garbage, and extract allocator to module, add more safe api to guard --- .../bevy_mod_scripting_core/src/allocator.rs | 52 +++ .../bevy_mod_scripting_core/src/bindings.rs | 313 +++++++++++++----- crates/bevy_mod_scripting_core/src/lib.rs | 9 +- crates/bevy_mod_scripting_core/src/systems.rs | 9 +- 4 files changed, 283 insertions(+), 100 deletions(-) create mode 100644 crates/bevy_mod_scripting_core/src/allocator.rs diff --git a/crates/bevy_mod_scripting_core/src/allocator.rs b/crates/bevy_mod_scripting_core/src/allocator.rs new file mode 100644 index 00000000..d943538b --- /dev/null +++ b/crates/bevy_mod_scripting_core/src/allocator.rs @@ -0,0 +1,52 @@ +use bevy::ecs::system::Resource; +use bevy::reflect::Reflect; + +use std::sync::Arc; + +use std::collections::HashMap; + +pub type AllocationId = usize; + +/// Allocator used to allocate and deallocate `dyn Reflect` values +/// Used to be able to ensure we have a "common root" for values allocated outside the world. +#[derive(Resource, Default)] +pub struct ReflectAllocator { + // TODO: experiment with object pools, sparse set etc. + pub allocations: HashMap>, +} + +impl ReflectAllocator { + /// Allocates a new [`Reflect`] value and returns an [`AllocationId`] which can be used to access it later + pub fn allocate(&mut self, value: Arc) -> AllocationId { + let id = self.allocations.len(); + self.allocations.insert(id, value); + id + } + + /// Deallocates the [`Reflect`] value with the given [`AllocationId`] + pub fn deallocate(&mut self, id: AllocationId) { + self.allocations.remove(&id); + } + + /// Runs a garbage collection pass on the allocations, removing any allocations which have no more strong references + /// Needs to be run periodically to prevent memory leaks + pub fn clean_garbage_allocations(&mut self) { + self.allocations.retain(|_, v| Arc::strong_count(v) > 1); + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_reflect_allocator() { + let mut allocator = ReflectAllocator::default(); + let value = Arc::new(0); + allocator.allocate(value.clone()); + assert_eq!(allocator.allocations.len(), 1); + drop(value); + allocator.clean_garbage_allocations(); + assert_eq!(allocator.allocations.len(), 0); + } +} diff --git a/crates/bevy_mod_scripting_core/src/bindings.rs b/crates/bevy_mod_scripting_core/src/bindings.rs index 914e29e1..03f1fcbc 100644 --- a/crates/bevy_mod_scripting_core/src/bindings.rs +++ b/crates/bevy_mod_scripting_core/src/bindings.rs @@ -4,18 +4,16 @@ //! reflection gives us access to `dyn Reflect` objects via their type name, //! Scripting languages only really support `Clone` objects so if we want to support references, //! we need wrapper types which have owned and ref variants. -//! we need traits which let us go from &dyn Reflect to a wrapper type. - use parking_lot::RwLock; use std::{any::TypeId, cell::RefCell, collections::HashMap, marker::PhantomData, sync::Arc}; use bevy::{ ecs::{ change_detection::MutUntyped, - component::ComponentId, + component::{Component, ComponentId}, entity::Entity, system::Resource, - world::{unsafe_world_cell::UnsafeWorldCell, World}, + world::{unsafe_world_cell::UnsafeWorldCell, Mut, World}, }, ptr::Ptr, reflect::{ @@ -23,37 +21,7 @@ use bevy::{ }, }; -use crate::error::ReflectionError; - -pub type AllocationId = usize; - -/// Allocator used to allocate and deallocate `dyn Reflect` values -/// Used to be able to ensure lifetime of the values we are accessing as well as optimize allocations -#[derive(Resource, Default)] -pub struct ScriptAllocator { - // TODO: experiment with object pools, sparse set etc. - pub allocations: HashMap>, -} - -impl ScriptAllocator { - /// Allocates a new [`Reflect`] value and returns an [`AllocationId`] which can be used to access it later - pub fn allocate(&mut self, value: Arc) -> AllocationId { - let id = self.allocations.len(); - self.allocations.insert(id, value); - id - } - - /// Deallocates the [`Reflect`] value with the given [`AllocationId`] - pub fn deallocate(&mut self, id: AllocationId) { - self.allocations.remove(&id); - } - - /// Runs a garbage collection pass on the allocations, removing any allocations which have no more strong references - /// Needs to be run periodically to prevent memory leaks - pub fn clean_garbage_allocations(&mut self) { - self.allocations.retain(|_, v| Arc::strong_count(v) > 1); - } -} +use crate::{allocator::AllocationId, error::ReflectionError}; /// A wrapper for a `dyn Reflect` struct, can either be owned or a reference pub enum Wrapper { @@ -142,6 +110,136 @@ impl<'w> WorldAccessGuard<'w> { }; self.get_access(access_id) } + + pub fn get_component( + &self, + access: &WorldAccess, + entity: Entity, + ) -> Result, ReflectionError> { + let component_id = match self.cell.components().component_id::() { + Some(id) => id, + None => return Ok(None), + }; + + if access.0 + == (ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: component_id.index(), + }) + { + // Safety: we have the correct access id + return unsafe { Ok(self.cell.get_entity(entity).and_then(|e| e.get::())) }; + } else { + Err(ReflectionError::InsufficientAccess { + base: format!("Component<{}>", std::any::type_name::()), + reason: format!( + "Invalid access, instead got permission to read: {}", + self.cell + .components() + .get_info(ComponentId::new(access.0.id)) + .map(|info| info.name()) + .unwrap_or("") + ), + }) + } + } + + pub fn get_component_mut( + &self, + access: &mut WorldAccess, + entity: Entity, + ) -> Result>, ReflectionError> { + let component_id = match self.cell.components().component_id::() { + Some(id) => id, + None => return Ok(None), + }; + + if access.0 + == (ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: component_id.index(), + }) + { + // Safety: we have the correct access id + return unsafe { Ok(self.cell.get_entity(entity).and_then(|e| e.get_mut::())) }; + } else { + Err(ReflectionError::InsufficientAccess { + base: format!("Component<{}>", std::any::type_name::()), + reason: format!( + "Invalid access, instead got permission to read: {}", + self.cell + .components() + .get_info(ComponentId::new(access.0.id)) + .map(|info| info.name()) + .unwrap_or("") + ), + }) + } + } + + pub fn get_resource( + &self, + access: &WorldAccess, + ) -> Result, ReflectionError> { + let resource_id = match self.cell.components().resource_id::() { + Some(id) => id, + None => return Ok(None), + }; + + if access.0 + == (ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: resource_id.index(), + }) + { + // Safety: we have the correct access id + return unsafe { Ok(self.cell.get_resource::()) }; + } else { + Err(ReflectionError::InsufficientAccess { + base: format!("Resource<{}>", std::any::type_name::()), + reason: format!( + "Invalid access, instead got permission to read: {}", + self.cell + .components() + .get_info(ComponentId::new(access.0.id)) + .map(|info| info.name()) + .unwrap_or("") + ), + }) + } + } + + pub fn get_resource_mut( + &self, + access: &mut WorldAccess, + ) -> Result>, ReflectionError> { + let resource_id = match self.cell.components().resource_id::() { + Some(id) => id, + None => return Ok(None), + }; + + if access.0 + == (ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: resource_id.index(), + }) + { + // Safety: we have the correct access id + return unsafe { Ok(self.cell.get_resource_mut::()) }; + } else { + Err(ReflectionError::InsufficientAccess { + base: format!("Resource<{}>", std::any::type_name::()), + reason: format!( + "Invalid access, instead got permission to read: {}", + self.cell + .components() + .get_info(ComponentId::new(access.0.id)) + .map(|info| info.name()) + .unwrap_or("") + ), + }) + } + } } /// Having this is permission to access the contained [`ReflectAccessId`], there is no way to access anything safely through a [`WorldAccessGuard`] @@ -201,6 +299,8 @@ impl ReflectReference { /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell. /// If the underlying componentId is not the same as the one we have access to, an error is returned. + /// + /// If we are accessing a component or resource, it's marked as changed pub fn reflect_mut<'w>( &'w self, world: UnsafeWorldCell<'w>, @@ -469,15 +569,17 @@ pub struct DeferredReflection { #[cfg(test)] mod test { + use crate::allocator::ReflectAllocator; + use super::*; - use bevy::ecs::{component::Component, world::World}; + use bevy::ecs::{component::Component, system::Resource, world::World}; - #[derive(Component, Reflect)] + #[derive(Component, Reflect, PartialEq, Eq, Debug)] struct TestComponent { strings: Vec, } - #[derive(Resource, Reflect, Default)] + #[derive(Resource, Reflect, Default, PartialEq, Eq, Debug)] struct TestResource { bytes: Vec, } @@ -495,15 +597,14 @@ mod test { } #[test] - fn test_parsed_path() { - let (mut world, type_registry, component_id, resource_id) = setup_world(); + fn test_component_access() { + let (mut world, type_registry, component_id, _) = setup_world(); let entity = world .spawn(TestComponent { strings: vec![String::from("hello")], }) .id(); - world.insert_resource(TestResource { bytes: vec![42] }); let world = WorldAccessGuard::new(&mut world); let component_reflect_ref = ReflectReference { @@ -511,101 +612,129 @@ mod test { base_id: ReflectBase::Component(entity, component_id), type_id: TypeId::of::(), }, - reflect_path: vec![ReflectionPathElem::Reflection( - ParsedPath::parse_static(".strings[0]").unwrap(), - )], + reflect_path: vec![ + ReflectionPathElem::Reflection(ParsedPath::parse_static(".strings").unwrap()), + ReflectionPathElem::DeferredReflection(DeferredReflection { + get: Arc::new(|root| { + let strings = root.downcast_ref::>().unwrap(); + Ok(strings.first().unwrap()) + }), + get_mut: Arc::new(|root| { + let strings = root.downcast_mut::>().unwrap(); + Ok(strings.first_mut().unwrap()) + }), + }), + ], }; let component_access = world.get_component_access(component_id); + + *component_reflect_ref + .reflect_mut( + world.as_unsafe_world_cell(), + &mut component_access.write(), + &type_registry, + ) + .unwrap() + .downcast_mut::() + .unwrap() = "world".to_owned(); + assert_eq!( - component_reflect_ref - .reflect( - world.as_unsafe_world_cell_readonly(), - &component_access.read(), - &type_registry, - ) + world + .get_component::(&component_access.read(), entity) .unwrap() - .downcast_ref::(), - Some(&String::from("hello")) + .unwrap(), + &TestComponent { + strings: vec![String::from("world")] + } ); - let resource_reflect_ref = ReflectReference { - base: ReflectBaseType { - base_id: ReflectBase::Resource(resource_id), - type_id: TypeId::of::(), - }, - reflect_path: vec![ReflectionPathElem::Reflection( - ParsedPath::parse_static(".bytes[0]").unwrap(), - )], + *world + .get_component_mut::(&mut component_access.write(), entity) + .unwrap() + .unwrap() + .as_mut() = TestComponent { + strings: vec![String::from("typed_world")], }; - let resource_access = world.get_component_access(resource_id); assert_eq!( - resource_reflect_ref + component_reflect_ref .reflect( world.as_unsafe_world_cell(), - &resource_access.read(), - &type_registry, + &component_access.read(), + &type_registry ) .unwrap() - .downcast_ref(), - Some(&42u8) + .downcast_ref::() + .unwrap(), + &"typed_world".to_owned() ); } #[test] - fn test_parsed_and_deferred_path() { - let (mut world, type_registry, component_id, _) = setup_world(); - let entity = world - .spawn(TestComponent { - strings: vec![String::from("hello")], - }) - .id(); + fn test_resource_access() { + let (mut world, type_registry, _, resource_id) = setup_world(); - world.insert_resource(TestResource { bytes: vec![42] }); + world.insert_resource(TestResource { bytes: vec![42u8] }); let world = WorldAccessGuard::new(&mut world); - let component_reflect_ref = ReflectReference { + let resource_reflect_ref = ReflectReference { base: ReflectBaseType { - base_id: ReflectBase::Component(entity, component_id), - type_id: TypeId::of::(), + base_id: ReflectBase::Resource(resource_id), + type_id: TypeId::of::(), }, reflect_path: vec![ - ReflectionPathElem::Reflection(ParsedPath::parse_static(".strings").unwrap()), + ReflectionPathElem::Reflection(ParsedPath::parse_static(".bytes").unwrap()), ReflectionPathElem::DeferredReflection(DeferredReflection { get: Arc::new(|root| { - let strings = root.downcast_ref::>().unwrap(); + let strings = root.downcast_ref::>().unwrap(); Ok(strings.first().unwrap()) }), get_mut: Arc::new(|root| { - let strings = root.downcast_mut::>().unwrap(); + let strings = root.downcast_mut::>().unwrap(); Ok(strings.first_mut().unwrap()) }), }), ], }; - let component_access = world.get_component_access(component_id); - *component_reflect_ref + let resource_access = world.get_resource_access(resource_id); + + *resource_reflect_ref .reflect_mut( world.as_unsafe_world_cell(), - &mut component_access.write(), + &mut resource_access.write(), &type_registry, ) .unwrap() - .downcast_mut::() - .unwrap() = String::from("world"); + .downcast_mut::() + .unwrap() = 42u8; assert_eq!( - component_reflect_ref + world + .get_resource::(&resource_access.read()) + .unwrap() + .unwrap(), + &TestResource { bytes: vec![42u8] } + ); + + *world + .get_resource_mut::(&mut resource_access.write()) + .unwrap() + .unwrap() + .as_mut() = TestResource { bytes: vec![69u8] }; + + assert_eq!( + resource_reflect_ref .reflect( - world.as_unsafe_world_cell_readonly(), - &component_access.read(), - &type_registry, + world.as_unsafe_world_cell(), + &resource_access.read(), + &type_registry ) .unwrap() - .downcast_ref::(), - Some(&String::from("world")) + .downcast_ref::() + .unwrap(), + &69u8 ); } @@ -614,7 +743,7 @@ mod test { let (mut world, type_registry, _, _) = setup_world(); let world = WorldAccessGuard::new(&mut world); - let mut script_allocator = ScriptAllocator::default(); + let mut script_allocator = ReflectAllocator::default(); let allocation_id = script_allocator.allocate(Arc::new("hello".to_string())); let owned_reflect_ref = ReflectReference { diff --git a/crates/bevy_mod_scripting_core/src/lib.rs b/crates/bevy_mod_scripting_core/src/lib.rs index 0c121fcc..d12f9762 100644 --- a/crates/bevy_mod_scripting_core/src/lib.rs +++ b/crates/bevy_mod_scripting_core/src/lib.rs @@ -2,11 +2,12 @@ use crate::{ event::ScriptErrorEvent, hosts::{APIProvider, APIProviders, ScriptHost}, }; +use allocator::ReflectAllocator; use bevy::{ecs::schedule::ScheduleLabel, prelude::*}; -use bindings::ScriptAllocator; use event::ScriptLoaded; -use systems::script_event_handler; +use systems::{garbage_collector, script_event_handler}; +pub mod allocator; pub mod asset; pub mod bindings; pub mod docs; @@ -15,6 +16,7 @@ pub mod event; pub mod hosts; pub mod systems; pub mod world; + pub mod prelude { // general pub use { @@ -46,7 +48,8 @@ pub struct ScriptingPlugin; impl Plugin for ScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { app.add_event::() - .init_resource::(); + .init_resource::() + .add_systems(PostUpdate, garbage_collector); } } diff --git a/crates/bevy_mod_scripting_core/src/systems.rs b/crates/bevy_mod_scripting_core/src/systems.rs index 1ce4f340..8262a334 100644 --- a/crates/bevy_mod_scripting_core/src/systems.rs +++ b/crates/bevy_mod_scripting_core/src/systems.rs @@ -4,16 +4,15 @@ use bevy::{ecs::system::SystemState, prelude::*}; use bevy_event_priority::PriorityEventReader; use crate::{ + allocator::ReflectAllocator, event::ScriptLoaded, prelude::{APIProviders, Script, ScriptCollection, ScriptContexts, ScriptData, ScriptHost}, ScriptErrorEvent, }; -/// Labels for scripting related systems -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemSet)] -pub enum ScriptSystemSet { - /// event handling systems are always marked with this label - EventHandling, +/// Cleans up dangling script allocations +pub fn garbage_collector(mut allocator: ResMut) { + allocator.clean_garbage_allocations() } /// Handles creating contexts for new/modified scripts From aff886aff34ca787b3b2f56749b64ac5d378c173 Mon Sep 17 00:00:00 2001 From: makspll Date: Mon, 8 Apr 2024 11:03:37 +0100 Subject: [PATCH 05/17] add doc --- crates/bevy_mod_scripting_core/src/bindings.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bevy_mod_scripting_core/src/bindings.rs b/crates/bevy_mod_scripting_core/src/bindings.rs index 03f1fcbc..04fd3fb0 100644 --- a/crates/bevy_mod_scripting_core/src/bindings.rs +++ b/crates/bevy_mod_scripting_core/src/bindings.rs @@ -44,6 +44,7 @@ pub struct ReflectAccessId { id: usize, } +/// Provides safe access to the world via [`WorldAccess`] permissions, which enforce aliasing rules at runtime in multi-thread environments pub struct WorldAccessGuard<'w> { cell: UnsafeWorldCell<'w>, // TODO: lotta indirection here, can we make this better? From dcf79dd4ca47decc970be1edb04be1320424ad8f Mon Sep 17 00:00:00 2001 From: makspll Date: Mon, 8 Apr 2024 14:30:03 +0100 Subject: [PATCH 06/17] remove setup_runtime hooks --- crates/bevy_api_gen/templates/footer.tera | 9 - crates/bevy_api_gen/templates/mod.tera | 9 - .../bevy_mod_scripting_core/src/bindings.rs | 1 + crates/bevy_mod_scripting_core/src/hosts.rs | 61 +- crates/bevy_script_api/src/core_providers.rs | 13 - .../src/providers/bevy_core.rs | 8 - .../bevy_script_api/src/providers/bevy_ecs.rs | 100 +- .../src/providers/bevy_hierarchy.rs | 22 +- .../src/providers/bevy_input.rs | 410 +- .../src/providers/bevy_reflect.rs | 5432 ++++++++--------- .../src/providers/bevy_time.rs | 48 +- .../src/providers/bevy_transform.rs | 126 +- .../src/providers/bevy_window.rs | 430 +- crates/bevy_script_api/src/providers/mod.rs | 8 - crates/bevy_script_api/src/rhai/bevy/mod.rs | 12 +- .../bevy_mod_scripting_lua/src/lib.rs | 16 +- .../bevy_mod_scripting_rhai/src/lib.rs | 16 +- .../bevy_mod_scripting_rune/src/lib.rs | 25 +- 18 files changed, 3306 insertions(+), 3440 deletions(-) diff --git a/crates/bevy_api_gen/templates/footer.tera b/crates/bevy_api_gen/templates/footer.tera index b14a4794..2e550553 100644 --- a/crates/bevy_api_gen/templates/footer.tera +++ b/crates/bevy_api_gen/templates/footer.tera @@ -53,15 +53,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for {{ "A P I Provider" | prefi Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn register_with_app(&self, app: &mut bevy::app::App) { {% for item in items %} app.register_foreign_lua_type::<{{ item.import_path }}>(); diff --git a/crates/bevy_api_gen/templates/mod.tera b/crates/bevy_api_gen/templates/mod.tera index 95dd89ce..f63f56f6 100644 --- a/crates/bevy_api_gen/templates/mod.tera +++ b/crates/bevy_api_gen/templates/mod.tera @@ -52,15 +52,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for {{ api_name }} { Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn register_with_app(&self, app: &mut bevy::app::App) { {% for crate in crates %} {% set crate_name = crate.name %} diff --git a/crates/bevy_mod_scripting_core/src/bindings.rs b/crates/bevy_mod_scripting_core/src/bindings.rs index 04fd3fb0..997b704e 100644 --- a/crates/bevy_mod_scripting_core/src/bindings.rs +++ b/crates/bevy_mod_scripting_core/src/bindings.rs @@ -45,6 +45,7 @@ pub struct ReflectAccessId { } /// Provides safe access to the world via [`WorldAccess`] permissions, which enforce aliasing rules at runtime in multi-thread environments +#[derive(Clone)] pub struct WorldAccessGuard<'w> { cell: UnsafeWorldCell<'w>, // TODO: lotta indirection here, can we make this better? diff --git a/crates/bevy_mod_scripting_core/src/hosts.rs b/crates/bevy_mod_scripting_core/src/hosts.rs index 6d6ebc19..7318ebef 100644 --- a/crates/bevy_mod_scripting_core/src/hosts.rs +++ b/crates/bevy_mod_scripting_core/src/hosts.rs @@ -11,7 +11,6 @@ use crate::{ docs::DocFragment, error::ScriptError, event::{ScriptEvent, ScriptLoaded}, - world::WorldPointer, }; /// Describes the target set of scripts this event should @@ -138,6 +137,43 @@ pub trait ScriptHost: Send + Sync + 'static + Default + Resource { fn register_with_app_in_set(app: &mut App, schedule: impl ScheduleLabel, set: impl SystemSet); } +/// Implementors can override the way that each callback is handled, this can be used to provide temporary values such as the word handle. +/// There can only be one [`RuntimeProvider`] per script host, so be careful about what your APIProviders expect! +pub trait RuntimeProvider: 'static { + /// The type of script context the APIProvider works with, must be the same as the ScriptContext of the target ScriptHost. + type ScriptContext: Send + Sync + 'static; + + /// the type of script engine/context the API is attached to, this must be the same as the APITarget of the ScriptHost meant to receive it. + type APITarget: Send + Sync + 'static; + + /// The type of event being handled by the runtime + type Event: Send + Sync + 'static; + + fn handle_event( + &mut self, + ctx: &mut Self::ScriptContext, + script_data: &ScriptData, + event: &Self::Event, + ) -> Result<(), ScriptError>; + + /// Provides the runtime if it's different from the context + fn get_mut(&mut self) -> Option<&mut Self::APITarget> { + None + } +} + +/// The resource containing a runtime provider for a particular set of type parameters +#[derive(Resource)] +pub struct RuntimeProviderContainer { + pub provider: Box< + dyn RuntimeProvider< + Event = H::ScriptEvent, + ScriptContext = H::ScriptContext, + APITarget = H::APITarget, + >, + >, +} + /// Implementors can modify a script context in order to enable /// API access. ScriptHosts call `attach_api` when creating scripts pub trait APIProvider: 'static + Send + Sync { @@ -154,16 +190,6 @@ pub trait APIProvider: 'static + Send + Sync { /// engine. For one-time setup use `Self::setup_script` fn attach_api(&mut self, api: &mut Self::APITarget) -> Result<(), ScriptError>; - /// Hook executed every time a script is about to handle events, most notably used to "refresh" world pointers - fn setup_script_runtime( - &mut self, - _world_ptr: WorldPointer, - _script_data: &ScriptData, - _ctx: &mut Self::ScriptContext, - ) -> Result<(), ScriptError> { - Ok(()) - } - /// Setup meant to be executed once for every single script. Use this if you need to consistently setup scripts. /// For API's use `Self::attach_api` instead. fn setup_script( @@ -216,19 +242,6 @@ impl APIProviders { Ok(()) } - pub fn setup_runtime_all( - &mut self, - world_ptr: WorldPointer, - script_data: &ScriptData, - ctx: &mut T::ScriptContext, - ) -> Result<(), ScriptError> { - for p in self.providers.iter_mut() { - p.setup_script_runtime(world_ptr.clone(), script_data, ctx)?; - } - - Ok(()) - } - pub fn setup_all( &mut self, script_data: &ScriptData, diff --git a/crates/bevy_script_api/src/core_providers.rs b/crates/bevy_script_api/src/core_providers.rs index 0e1196ea..0b411cbf 100644 --- a/crates/bevy_script_api/src/core_providers.rs +++ b/crates/bevy_script_api/src/core_providers.rs @@ -80,19 +80,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for LuaCoreBevyAPIProvider { Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx.get_mut().expect("Could not get context"); - let globals = ctx.globals(); - globals - .set("world", crate::lua::bevy::LuaWorld::new(world_ptr)) - .map_err(bevy_mod_scripting_core::error::ScriptError::new_other) - } - fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/bevy_core.rs b/crates/bevy_script_api/src/providers/bevy_core.rs index 2b74a658..ed8492c8 100644 --- a/crates/bevy_script_api/src/providers/bevy_core.rs +++ b/crates/bevy_script_api/src/providers/bevy_core.rs @@ -81,14 +81,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyCoreAPIProvider { ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); } diff --git a/crates/bevy_script_api/src/providers/bevy_ecs.rs b/crates/bevy_script_api/src/providers/bevy_ecs.rs index 4e188b17..718cfb2e 100644 --- a/crates/bevy_script_api/src/providers/bevy_ecs.rs +++ b/crates/bevy_script_api/src/providers/bevy_ecs.rs @@ -12,6 +12,23 @@ use bevy_script_api::{ derive(clone), remote = "bevy::ecs::entity::Entity", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &entity::Entity) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::entity::Entity; + +"#, + r#" /// Creates a new entity ID with the specified `index` and a generation of 1. /// # Note /// Spawning a specific `entity` value is __rarely the right choice__. Most apps should favor @@ -64,23 +81,6 @@ use bevy_script_api::{ #[lua(kind = "Method")] fn generation(self) -> u32; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &entity::Entity) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::entity::Entity; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -95,12 +95,6 @@ pub struct Entity {} derive(clone), remote = "bevy::ecs::component::ComponentId", functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" /// Creates a new [`ComponentId`]. /// The `index` is a unique value associated with each type of component in a given world. /// Usually, this value is taken from a counter incremented for each type of component registered with the world. @@ -118,8 +112,8 @@ pub struct Entity {} "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::component::ComponentId; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -132,6 +126,12 @@ pub struct Entity {} )] fn eq(&self, #[proxy] other: &component::ComponentId) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::component::ComponentId; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -147,13 +147,14 @@ pub struct ComponentId(); remote = "bevy::ecs::component::Tick", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &component::Tick) -> bool; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::component::Tick; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -193,14 +194,13 @@ pub struct ComponentId(); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::component::Tick; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &component::Tick) -> bool; "#, r#" @@ -216,6 +216,12 @@ pub struct Tick {} derive(clone), remote = "bevy::ecs::component::ComponentTicks", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::component::ComponentTicks; + +"#, + r#" /// Returns `true` if the component or resource was added after the system last ran. #[lua(kind = "Method")] @@ -271,12 +277,6 @@ pub struct Tick {} #[lua(kind = "MutatingMethod")] fn set_changed(&mut self, #[proxy] change_tick: bevy::ecs::component::Tick) -> (); -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::component::ComponentTicks; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -372,14 +372,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider { ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/bevy_hierarchy.rs b/crates/bevy_script_api/src/providers/bevy_hierarchy.rs index ad20f27d..837439d3 100644 --- a/crates/bevy_script_api/src/providers/bevy_hierarchy.rs +++ b/crates/bevy_script_api/src/providers/bevy_hierarchy.rs @@ -33,6 +33,13 @@ pub struct Children(); derive(), remote = "bevy::hierarchy::prelude::Parent", functions[r#" +/// Gets the [`Entity`] ID of the parent. + + #[lua(kind = "Method", output(proxy))] + fn get(&self) -> bevy::ecs::entity::Entity; + +"#, + r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -48,13 +55,6 @@ pub struct Children(); #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); -"#, - r#" -/// Gets the [`Entity`] ID of the parent. - - #[lua(kind = "Method", output(proxy))] - fn get(&self) -> bevy::ecs::entity::Entity; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -109,14 +109,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyHierarchyAPIProvider { ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/bevy_input.rs b/crates/bevy_script_api/src/providers/bevy_input.rs index 30c24657..bc84022f 100644 --- a/crates/bevy_script_api/src/providers/bevy_input.rs +++ b/crates/bevy_script_api/src/providers/bevy_input.rs @@ -13,12 +13,6 @@ use bevy_script_api::{ derive(clone), remote = "bevy::input::gamepad::Gamepad", functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" /// Creates a new [`Gamepad`]. #[lua(kind = "Function", output(proxy))] @@ -27,8 +21,8 @@ use bevy_script_api::{ "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::Gamepad; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -41,6 +35,12 @@ use bevy_script_api::{ )] fn eq(&self, #[proxy] other: &gamepad::Gamepad) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::Gamepad; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -57,30 +57,15 @@ pub struct Gamepad { derive(clone), remote = "bevy::input::gamepad::GamepadAxis", functions[r#" -/// Creates a new [`GamepadAxis`]. -/// # Examples -/// ``` -/// # use bevy_input::gamepad::{GamepadAxis, GamepadAxisType, Gamepad}; -/// # -/// let gamepad_axis = GamepadAxis::new( -/// Gamepad::new(1), -/// GamepadAxisType::LeftStickX, -/// ); -/// ``` - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - axis_type: bevy::input::gamepad::GamepadAxisType, - ) -> bevy::input::gamepad::GamepadAxis; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadAxis; "#, r#" @@ -95,9 +80,24 @@ pub struct Gamepad { "#, r#" +/// Creates a new [`GamepadAxis`]. +/// # Examples +/// ``` +/// # use bevy_input::gamepad::{GamepadAxis, GamepadAxisType, Gamepad}; +/// # +/// let gamepad_axis = GamepadAxis::new( +/// Gamepad::new(1), +/// GamepadAxisType::LeftStickX, +/// ); +/// ``` - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadAxis; + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::input::gamepad::Gamepad, + #[proxy] + axis_type: bevy::input::gamepad::GamepadAxisType, + ) -> bevy::input::gamepad::GamepadAxis; "#, r#" @@ -162,6 +162,18 @@ pub struct GamepadAxisType {} )] fn eq(&self, #[proxy] other: &gamepad::GamepadButton) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadButton; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" /// Creates a new [`GamepadButton`]. @@ -183,18 +195,6 @@ pub struct GamepadAxisType {} button_type: bevy::input::gamepad::GamepadButtonType, ) -> bevy::input::gamepad::GamepadButton; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButton; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -253,12 +253,6 @@ pub struct GamepadButtonType {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::keyboard::KeyCode; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" @@ -270,6 +264,12 @@ pub struct GamepadButtonType {} )] fn eq(&self, #[proxy] other: &keyboard::KeyCode) -> bool; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -285,8 +285,13 @@ pub struct KeyCode {} remote = "bevy::input::mouse::MouseButton", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &mouse::MouseButton) -> bool; "#, r#" @@ -297,13 +302,8 @@ pub struct KeyCode {} "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &mouse::MouseButton) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -358,6 +358,12 @@ pub struct TouchInput { remote = "bevy::input::keyboard::Key", functions[r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -372,12 +378,6 @@ pub struct TouchInput { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::keyboard::Key; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -393,8 +393,13 @@ pub struct Key {} remote = "bevy::input::keyboard::KeyboardInput", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &keyboard::KeyboardInput) -> bool; "#, r#" @@ -405,13 +410,8 @@ pub struct Key {} "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &keyboard::KeyboardInput) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -437,14 +437,14 @@ pub struct KeyboardInput { remote = "bevy::input::keyboard::NativeKey", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::NativeKey; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::NativeKey; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -507,6 +507,12 @@ pub struct NativeKeyCode {} remote = "bevy::input::mouse::MouseButtonInput", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::MouseButtonInput; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -521,12 +527,6 @@ pub struct NativeKeyCode {} #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseButtonInput; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -581,12 +581,6 @@ pub struct MouseMotion { remote = "bevy::input::mouse::MouseScrollUnit", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -601,6 +595,12 @@ pub struct MouseMotion { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::mouse::MouseScrollUnit; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -616,6 +616,12 @@ pub struct MouseScrollUnit {} remote = "bevy::input::mouse::MouseWheel", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::MouseWheel; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -624,12 +630,6 @@ pub struct MouseScrollUnit {} )] fn eq(&self, #[proxy] other: &mouse::MouseWheel) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseWheel; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -652,6 +652,12 @@ pub struct MouseWheel { remote = "bevy::input::touch::ForceTouch", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touch::ForceTouch; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -660,12 +666,6 @@ pub struct MouseWheel { )] fn eq(&self, #[proxy] other: &touch::ForceTouch) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touch::ForceTouch; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -692,14 +692,14 @@ pub struct ForceTouch {} "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touch::TouchPhase; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touch::TouchPhase; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -716,12 +716,6 @@ pub struct TouchPhase {} remote = "bevy::input::touchpad::TouchpadMagnify", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touchpad::TouchpadMagnify; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -730,6 +724,12 @@ pub struct TouchPhase {} )] fn eq(&self, #[proxy] other: &touchpad::TouchpadMagnify) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touchpad::TouchpadMagnify; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -773,6 +773,23 @@ pub struct TouchpadRotate(f32); derive(clone), remote = "bevy::input::gamepad::AxisSettings", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::AxisSettings) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::AxisSettings; + +"#, + r#" /// Get the value above which inputs will be rounded up to 1.0. #[lua(kind = "Method")] @@ -875,23 +892,6 @@ pub struct TouchpadRotate(f32); old_value: std::option::Option, ) -> std::option::Option; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::AxisSettings; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::AxisSettings) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -941,6 +941,12 @@ pub struct ButtonAxisSettings { derive(clone), remote = "bevy::input::gamepad::ButtonSettings", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::ButtonSettings; + +"#, + r#" /// Returns `true` if the button is pressed. /// A button is considered pressed if the `value` passed is greater than or equal to the press threshold. @@ -987,12 +993,6 @@ pub struct ButtonAxisSettings { #[lua(kind = "MutatingMethod")] fn set_release_threshold(&mut self, value: f32) -> f32; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::ButtonSettings; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1008,6 +1008,17 @@ pub struct ButtonSettings {} remote = "bevy::input::gamepad::GamepadAxisChangedEvent", functions[r#" + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadAxisChangedEvent) -> bool; + +"#, + r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::gamepad::GamepadAxisChangedEvent; @@ -1024,17 +1035,6 @@ pub struct ButtonSettings {} value: f32, ) -> bevy::input::gamepad::GamepadAxisChangedEvent; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadAxisChangedEvent) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1055,16 +1055,9 @@ pub struct GamepadAxisChangedEvent { derive(clone), remote = "bevy::input::gamepad::GamepadButtonChangedEvent", functions[r#" -/// Creates a [`GamepadButtonChangedEvent`]. - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - button_type: bevy::input::gamepad::GamepadButtonType, - value: f32, - ) -> bevy::input::gamepad::GamepadButtonChangedEvent; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadButtonChangedEvent; "#, r#" @@ -1079,9 +1072,16 @@ pub struct GamepadAxisChangedEvent { "#, r#" +/// Creates a [`GamepadButtonChangedEvent`]. - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonChangedEvent; + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::input::gamepad::Gamepad, + #[proxy] + button_type: bevy::input::gamepad::GamepadButtonType, + value: f32, + ) -> bevy::input::gamepad::GamepadButtonChangedEvent; "#, r#" @@ -1104,12 +1104,6 @@ pub struct GamepadButtonChangedEvent { remote = "bevy::input::gamepad::GamepadButtonInput", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonInput; - -"#, - r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); @@ -1124,6 +1118,12 @@ pub struct GamepadButtonChangedEvent { )] fn eq(&self, #[proxy] other: &gamepad::GamepadButtonInput) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadButtonInput; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1172,6 +1172,17 @@ pub struct GamepadConnection {} derive(clone), remote = "bevy::input::gamepad::GamepadConnectionEvent", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadConnectionEvent) -> bool; + +"#, + r#" /// Creates a [`GamepadConnectionEvent`]. #[lua(kind = "Function", output(proxy))] @@ -1202,17 +1213,6 @@ pub struct GamepadConnection {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::gamepad::GamepadConnectionEvent; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadConnectionEvent) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1233,12 +1233,6 @@ pub struct GamepadConnectionEvent { remote = "bevy::input::gamepad::GamepadEvent", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadEvent; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -1247,6 +1241,12 @@ pub struct GamepadConnectionEvent { )] fn eq(&self, #[proxy] other: &gamepad::GamepadEvent) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadEvent; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1283,6 +1283,19 @@ pub struct GamepadSettings { derive(clone), remote = "bevy::input::ButtonState", functions[r#" +/// Is this button pressed? + + #[lua(kind = "Method")] + fn is_pressed(&self) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -1298,19 +1311,6 @@ pub struct GamepadSettings { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::ButtonState; -"#, - r#" -/// Is this button pressed? - - #[lua(kind = "Method")] - fn is_pressed(&self) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1326,25 +1326,25 @@ pub struct ButtonState {} remote = "bevy::input::gamepad::GamepadInfo", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadInfo; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadInfo) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadInfo; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadInfo) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -1498,14 +1498,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/bevy_reflect.rs b/crates/bevy_script_api/src/providers/bevy_reflect.rs index bd5f61d0..747729b8 100644 --- a/crates/bevy_script_api/src/providers/bevy_reflect.rs +++ b/crates/bevy_script_api/src/providers/bevy_reflect.rs @@ -3710,12 +3710,11 @@ pub struct RangeFull {} functions[r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] rhs: &glam::Quat) -> bool; + fn clone(&self) -> bevy::math::Quat; "#, r#" @@ -3731,105 +3730,6 @@ pub struct RangeFull {} )] fn sub(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; -"#, - r#" -/// Divides a quaternion by a scalar value. -/// The quotient is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Quat; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - 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( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; - -"#, - r#" -/// Adds two quaternions. -/// The sum is not guaranteed to be normalized. -/// Note that addition is not the same as combining the rotations represented by the -/// two quaternions! That corresponds to multiplication. - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; - -"#, - r#" -/// Multiplies a quaternion by a scalar value. -/// The product is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Quat; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Quat; - -"#, - 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( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - "#, r#" /// Creates a new rotation quaternion. @@ -4207,19 +4107,24 @@ pub struct RangeFull {} "#, r#" +/// Adds two quaternions. +/// The sum is not guaranteed to be normalized. +/// Note that addition is not the same as combining the rotations represented by the +/// two quaternions! That corresponds to multiplication. #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "add", + metamethod = "Add", )] - fn neg(self) -> bevy::math::Quat; + fn add(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; "#, r#" -/// Rotates the [`Direction3d`] using a [`Quat`]. +/// Multiplies a quaternion by a scalar value. +/// The product is not guaranteed to be normalized. #[lua( as_trait = "std::ops::Mul", @@ -4228,26 +4133,24 @@ pub struct RangeFull {} composite = "mul", metamethod = "Mul", )] - fn mul( - self, - #[proxy] - direction: bevy::math::primitives::Direction3d, - ) -> bevy::math::primitives::Direction3d; + fn mul(self, rhs: f32) -> bevy::math::Quat; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct Quat(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Vec3", - functions[r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Quat; + +"#, + r#" +/// Divides a quaternion by a scalar value. +/// The quotient is not guaranteed to be normalized. #[lua( as_trait = "std::ops::Div", @@ -4256,7 +4159,7 @@ pub struct Quat(); composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn div(self, rhs: f32) -> bevy::math::Quat; "#, r#" @@ -4268,19 +4171,22 @@ pub struct Quat(); composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Vec3; + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, 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( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" @@ -4291,32 +4197,57 @@ pub struct Quat(); composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &glam::Vec3) -> bool; + fn eq(&self, #[proxy] rhs: &glam::Quat) -> bool; "#, 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( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, rhs: f32) -> bevy::math::Vec3; + fn mul(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; "#, r#" +/// Rotates the [`Direction3d`] using a [`Quat`]. #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::Vec3; + fn mul( + self, + #[proxy] + direction: bevy::math::primitives::Direction3d, + ) -> bevy::math::primitives::Direction3d; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct Quat(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Vec3", + functions[r#" #[lua( as_trait = "std::ops::Add", @@ -4329,98 +4260,38 @@ pub struct Quat(); "#, r#" +/// Creates a new vector. - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Vec3; + #[lua(kind = "Function", output(proxy))] + fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3; "#, r#" +/// Creates a vector with all elements set to `v`. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(kind = "Function", output(proxy))] + fn splat(v: f32) -> bevy::math::Vec3; "#, 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( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(kind = "Function", output(proxy))] + fn select( + #[proxy] + mask: bevy::math::BVec3, + #[proxy] + if_true: bevy::math::Vec3, + #[proxy] + if_false: bevy::math::Vec3, + ) -> bevy::math::Vec3; "#, r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f32) -> bevy::math::Vec3; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: f32) -> bevy::math::Vec3; - -"#, - 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::BVec3, - #[proxy] - if_true: bevy::math::Vec3, - #[proxy] - if_false: bevy::math::Vec3, - ) -> bevy::math::Vec3; - -"#, - r#" -/// Creates a new vector from an array. +/// Creates a new vector from an array. #[lua(kind = "Function", output(proxy))] fn from_array(a: [f32; 3]) -> bevy::math::Vec3; @@ -4947,6 +4818,28 @@ pub struct Quat(); #[lua(kind = "Method", output(proxy))] fn as_u64vec3(&self) -> bevy::math::U64Vec3; +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec3; + "#, r#" @@ -4959,6 +4852,113 @@ pub struct Quat(); )] fn div(self, rhs: f32) -> bevy::math::Vec3; +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f32) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::Vec3) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -4998,6 +4998,36 @@ pub struct Vec3 { )] fn eq(&self, #[proxy] other: &glam::IVec2) -> bool; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + "#, r#" @@ -5008,19 +5038,19 @@ pub struct Vec3 { composite = "sub", metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn sub(self, rhs: i32) -> bevy::math::IVec2; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn rem(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" @@ -5032,19 +5062,19 @@ pub struct Vec3 { composite = "rem", metamethod = "Mod", )] - fn rem(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn rem(self, rhs: i32) -> bevy::math::IVec2; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "add", + metamethod = "Add", )] - fn neg(self) -> bevy::math::IVec2; + fn add(self, rhs: i32) -> bevy::math::IVec2; "#, r#" @@ -5056,7 +5086,7 @@ pub struct Vec3 { composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: i32) -> bevy::math::IVec2; + fn sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" @@ -5070,23 +5100,47 @@ pub struct Vec3 { "#, r#" -/// Creates a new vector. - #[lua(kind = "Function", output(proxy))] - fn new(x: i32, y: i32) -> bevy::math::IVec2; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: i32) -> bevy::math::IVec2; "#, r#" -/// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] - fn splat(v: i32) -> bevy::math::IVec2; - -"#, - 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 + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::IVec2; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: i32, y: i32) -> bevy::math::IVec2; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: i32) -> bevy::math::IVec2; + +"#, + 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))] @@ -5424,18 +5478,6 @@ pub struct Vec3 { #[lua(kind = "Method", output(proxy))] fn saturating_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i32) -> bevy::math::IVec2; - "#, r#" @@ -5448,59 +5490,17 @@ pub struct Vec3 { )] fn add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i32) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: i32) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i32) -> bevy::math::IVec2; - "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn mul(self, rhs: i32) -> bevy::math::IVec2; "#, r#" @@ -5532,46 +5532,6 @@ pub struct IVec2 { remote = "bevy::math::IVec3", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: i32) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" - #[lua( as_trait = "std::ops::Div", kind = "MetaFunction", @@ -5581,77 +5541,6 @@ pub struct IVec2 { )] fn div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i32) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::IVec3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i32) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i32) -> bevy::math::IVec3; - "#, r#" /// Creates a new vector. @@ -6010,78 +5899,270 @@ pub struct IVec2 { r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "add", + metamethod = "Add", )] - fn mul(self, rhs: i32) -> bevy::math::IVec3; + fn add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "sub", + metamethod = "Sub", )] - fn neg(self) -> bevy::math::IVec3; + fn sub(self, rhs: i32) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn add(self, rhs: i32) -> bevy::math::IVec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct IVec3 { - x: i32, - y: i32, - z: i32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::IVec4", - functions[r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "mul", + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: i32) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::IVec3) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i32) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i32) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct IVec3 { + x: i32, + y: i32, + z: i32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::IVec4", + functions[r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i32) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", metamethod = "Mul", )] fn mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::IVec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: i32) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i32) -> bevy::math::IVec4; + "#, r#" /// Creates a new vector. @@ -6415,46 +6496,12 @@ pub struct IVec3 { #[lua(kind = "Method", output(proxy))] fn saturating_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: i32) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i32) -> bevy::math::IVec4; - "#, r#" #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::IVec4; - "#, r#" @@ -6465,7 +6512,7 @@ pub struct IVec3 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn div(self, rhs: i32) -> bevy::math::IVec4; "#, r#" @@ -6477,7 +6524,7 @@ pub struct IVec3 { composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: i32) -> bevy::math::IVec4; + fn sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -6491,76 +6538,29 @@ pub struct IVec3 { )] fn add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i32) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i32) -> bevy::math::IVec4; - "#, r#" #[lua( as_trait = "std::ops::Neg", kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "neg", + metamethod = "Unm", )] - fn eq(&self, #[proxy] other: &glam::IVec4) -> bool; + fn neg(self) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "mul", + metamethod = "Mul", )] - fn rem(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn mul(self, rhs: i32) -> bevy::math::IVec4; "#, r#" @@ -6595,42 +6595,13 @@ pub struct IVec4 { functions[r#" #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i64) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::I64Vec2) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "div", + metamethod = "Div", )] - fn neg(self) -> bevy::math::I64Vec2; + fn div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -6642,31 +6613,19 @@ pub struct IVec4 { composite = "sub", metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn sub(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, rhs: i64) -> bevy::math::I64Vec2; + fn rem(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -6678,7 +6637,7 @@ pub struct IVec4 { composite = "rem", metamethod = "Mod", )] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn rem(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" @@ -6690,29 +6649,7 @@ pub struct IVec4 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::I64Vec2; + fn div(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" @@ -6724,31 +6661,31 @@ pub struct IVec4 { composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: i64) -> bevy::math::I64Vec2; + fn sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "neg", + metamethod = "Unm", )] - fn div(self, rhs: i64) -> bevy::math::I64Vec2; + fn neg(self) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec2; + fn add(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" @@ -7047,103 +6984,260 @@ pub struct IVec4 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::I64Vec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i64) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct I64Vec2 { + x: i64, + y: i64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::I64Vec3", + functions[r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::I64Vec3; "#, r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct I64Vec2 { - x: i64, - y: i64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::I64Vec3", - functions[r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "neg", + metamethod = "Unm", )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn neg(self) -> bevy::math::I64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "add", + metamethod = "Add", )] - fn div(self, rhs: i64) -> bevy::math::I64Vec3; + fn add(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" @@ -7503,64 +7597,13 @@ pub struct I64Vec2 { r#" #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::I64Vec3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "div", + metamethod = "Div", )] - fn add(self, rhs: i64) -> bevy::math::I64Vec3; + fn div(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" @@ -7578,61 +7621,18 @@ pub struct I64Vec2 { r#" #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i64) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn eq(&self, #[proxy] other: &glam::I64Vec3) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i64) -> bevy::math::I64Vec3; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -7662,35 +7662,29 @@ pub struct I64Vec3 { )] fn sub(self, rhs: i64) -> bevy::math::I64Vec4; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "add", + metamethod = "Add", )] - fn div(self, rhs: i64) -> bevy::math::I64Vec4; + fn add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, rhs: i64) -> bevy::math::I64Vec4; + fn mul(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" @@ -7704,6 +7698,18 @@ pub struct I64Vec3 { )] fn sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + "#, r#" @@ -7715,6 +7721,18 @@ pub struct I64Vec3 { )] fn eq(&self, #[proxy] other: &glam::I64Vec4) -> bool; +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i64) -> bevy::math::I64Vec4; + "#, r#" @@ -7725,7 +7743,7 @@ pub struct I64Vec3 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn div(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" @@ -7749,18 +7767,6 @@ pub struct I64Vec3 { )] fn clone(&self) -> bevy::math::I64Vec4; -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec4; - "#, r#" @@ -7771,7 +7777,7 @@ pub struct I64Vec3 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn add(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" @@ -7783,7 +7789,7 @@ pub struct I64Vec3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: i64) -> bevy::math::I64Vec4; + fn mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -7797,18 +7803,6 @@ pub struct I64Vec3 { )] fn neg(self) -> bevy::math::I64Vec4; -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - "#, r#" /// Creates a new vector. @@ -8142,6 +8136,12 @@ pub struct I64Vec3 { #[lua(kind = "Method", output(proxy))] fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -8162,83 +8162,6 @@ pub struct I64Vec4 { remote = "bevy::math::UVec2", functions[r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u32) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u32) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::UVec2) -> bool; - -"#, - r#" - #[lua( as_trait = "std::ops::Sub", kind = "MetaFunction", @@ -8532,13 +8455,13 @@ pub struct I64Vec4 { r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "sub", + metamethod = "Sub", )] - fn add(self, rhs: u32) -> bevy::math::UVec2; + fn sub(self, rhs: u32) -> bevy::math::UVec2; "#, r#" @@ -8556,103 +8479,88 @@ pub struct I64Vec4 { r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "add", + metamethod = "Add", )] - fn div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn add(self, rhs: u32) -> bevy::math::UVec2; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "rem", + metamethod = "Mod", )] - fn sub(self, rhs: u32) -> bevy::math::UVec2; + fn rem(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::UVec2; + fn eq(&self, #[proxy] other: &glam::UVec2) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct UVec2 { - x: u32, - y: u32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::UVec3", - functions[r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "add", + metamethod = "Add", )] - fn sub(self, rhs: u32) -> bevy::math::UVec3; + fn add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Div", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "div", + metamethod = "Div", )] - fn eq(&self, #[proxy] other: &glam::UVec3) -> bool; + fn div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "rem", - metamethod = "Mod", )] - fn rem(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn clone(&self) -> bevy::math::UVec2; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u32) -> bevy::math::UVec2; "#, r#" @@ -8664,19 +8572,58 @@ pub struct UVec2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: u32) -> bevy::math::UVec3; + fn mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u32) -> bevy::math::UVec2; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct UVec2 { + x: u32, + y: u32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::UVec3", + functions[r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "add", + metamethod = "Add", )] - fn sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -8984,13 +8931,24 @@ pub struct UVec2 { r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn rem(self, rhs: u32) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::UVec3) -> bool; "#, r#" @@ -9002,17 +8960,25 @@ pub struct UVec2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn mul(self, rhs: u32) -> bevy::math::UVec3; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Sub", + kind = "MetaFunction", output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn clone(&self) -> bevy::math::UVec3; + fn sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -9026,6 +8992,18 @@ pub struct UVec2 { )] fn add(self, rhs: u32) -> bevy::math::UVec3; +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + "#, r#" @@ -9060,7 +9038,29 @@ pub struct UVec2 { composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: u32) -> bevy::math::UVec3; + fn rem(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u32) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::UVec3; "#, r#" @@ -9093,30 +9093,6 @@ pub struct UVec3 { remote = "bevy::math::UVec4", functions[r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u32) -> bevy::math::UVec4; - -"#, - r#" - #[lua( as_trait = "std::ops::Div", kind = "MetaFunction", @@ -9126,30 +9102,6 @@ pub struct UVec3 { )] fn div(self, rhs: u32) -> bevy::math::UVec4; -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u32) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - "#, r#" /// Creates a new vector. @@ -9435,17 +9387,24 @@ pub struct UVec3 { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::UVec4; + fn eq(&self, #[proxy] other: &glam::UVec4) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u32) -> bevy::math::UVec4; "#, r#" @@ -9459,6 +9418,40 @@ pub struct UVec3 { )] fn add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + "#, r#" @@ -9475,25 +9468,31 @@ pub struct UVec3 { r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "sub", + metamethod = "Sub", )] - fn add(self, rhs: u32) -> bevy::math::UVec4; + fn sub(self, rhs: u32) -> bevy::math::UVec4; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn rem(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -9511,12 +9510,13 @@ pub struct UVec3 { r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Rem", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "rem", + metamethod = "Mod", )] - fn eq(&self, #[proxy] other: &glam::UVec4) -> bool; + fn rem(self, rhs: u32) -> bevy::math::UVec4; "#, r#" @@ -9542,34 +9542,22 @@ pub struct UVec4 { x: u32, y: u32, z: u32, - w: u32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::U64Vec2", - functions[r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" + w: u32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::U64Vec2", + functions[r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "div", + metamethod = "Div", )] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn div(self, rhs: u64) -> bevy::math::U64Vec2; "#, r#" @@ -9581,7 +9569,7 @@ pub struct UVec4 { composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: u64) -> bevy::math::U64Vec2; + fn rem(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -9605,19 +9593,7 @@ pub struct UVec4 { composite = "add", metamethod = "Add", )] - fn add(self, rhs: u64) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -9629,31 +9605,29 @@ pub struct UVec4 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: u64) -> bevy::math::U64Vec2; + fn div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn rem(self, rhs: u64) -> bevy::math::U64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "div", - metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn clone(&self) -> bevy::math::U64Vec2; "#, r#" @@ -9670,17 +9644,25 @@ pub struct UVec4 { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Sub", + kind = "MetaFunction", output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn clone(&self) -> bevy::math::U64Vec2; + fn sub(self, rhs: u64) -> bevy::math::U64Vec2; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -9692,7 +9674,25 @@ pub struct UVec4 { composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec2; + fn sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u64) -> bevy::math::U64Vec2; "#, r#" @@ -9991,59 +9991,6 @@ pub struct U64Vec2 { derive(clone), remote = "bevy::math::U64Vec3", functions[r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::U64Vec3) -> bool; - -"#, - r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] @@ -10348,11 +10295,103 @@ pub struct U64Vec2 { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Add", + kind = "MetaFunction", output(proxy), + composite = "add", + metamethod = "Add", )] - fn clone(&self) -> bevy::math::U64Vec3; + fn add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -10364,31 +10403,66 @@ pub struct U64Vec2 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: u64) -> bevy::math::U64Vec3; + fn div(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::U64Vec3) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "sub", + metamethod = "Sub", )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct U64Vec3 { + x: u64, + y: u64, + z: u64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::U64Vec4", + functions[r#" #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "add", - metamethod = "Add", )] - fn add(self, rhs: u64) -> bevy::math::U64Vec3; + fn clone(&self) -> bevy::math::U64Vec4; "#, r#" @@ -10400,19 +10474,19 @@ pub struct U64Vec2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "div", + metamethod = "Div", )] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn div(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" @@ -10424,7 +10498,19 @@ pub struct U64Vec2 { composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec3; + fn sub(self, rhs: u64) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" @@ -10436,35 +10522,19 @@ pub struct U64Vec2 { composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: u64) -> bevy::math::U64Vec3; + fn rem(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct U64Vec3 { - x: u64, - y: u64, - z: u64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::U64Vec4", - functions[r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -10478,23 +10548,17 @@ pub struct U64Vec3 { )] fn rem(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, rhs: u64) -> bevy::math::U64Vec4; + fn add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -10780,25 +10844,19 @@ pub struct U64Vec3 { "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::U64Vec4) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec4; + fn eq(&self, #[proxy] other: &glam::U64Vec4) -> bool; "#, r#" @@ -10810,7 +10868,7 @@ pub struct U64Vec3 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: u64) -> bevy::math::U64Vec4; + fn div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -10826,13 +10884,31 @@ pub struct U64Vec3 { "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct U64Vec4 { + x: u64, + y: u64, + z: u64, + w: u64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Vec2", + functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::U64Vec4; + fn eq(&self, #[proxy] other: &glam::Vec2) -> bool; "#, r#" @@ -10844,7 +10920,7 @@ pub struct U64Vec3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" @@ -10856,60 +10932,29 @@ pub struct U64Vec3 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec4; + fn add(self, rhs: f32) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "sub", - metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn clone(&self) -> bevy::math::Vec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct U64Vec4 { - x: u64, - y: u64, - z: u64, - w: u64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Vec2", - functions[r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "rem", + metamethod = "Mod", )] - fn div(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn rem(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" @@ -10927,47 +10972,49 @@ pub struct U64Vec4 { r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "add", + metamethod = "Add", )] - fn mul(self, rhs: f32) -> bevy::math::Vec2; + fn add(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "div", + metamethod = "Div", )] - fn neg(self) -> bevy::math::Vec2; + fn div(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "mul", + metamethod = "Mul", )] - fn rem(self, rhs: f32) -> bevy::math::Vec2; + fn mul(self, rhs: f32) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Div", + kind = "MetaFunction", output(proxy), + composite = "div", + metamethod = "Div", )] - fn clone(&self) -> bevy::math::Vec2; + fn div(self, rhs: f32) -> bevy::math::Vec2; "#, r#" @@ -10985,37 +11032,25 @@ pub struct U64Vec4 { r#" #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "neg", + metamethod = "Unm", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn neg(self) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, rhs: f32) -> bevy::math::Vec2; + fn rem(self, rhs: f32) -> bevy::math::Vec2; "#, r#" @@ -11584,41 +11619,6 @@ pub struct U64Vec4 { #[lua(kind = "Method", output(proxy))] fn as_u64vec2(&self) -> bevy::math::U64Vec2; -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::Vec2) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -11649,42 +11649,6 @@ pub struct Vec2 { remote = "bevy::math::Vec3A", functions[r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - #[lua( as_trait = "std::ops::Add", kind = "MetaFunction", @@ -11698,36 +11662,13 @@ pub struct Vec2 { r#" #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f32) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Vec3A) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "mul", + metamethod = "Mul", )] - fn rem(self, rhs: f32) -> bevy::math::Vec3A; + fn mul(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" @@ -12301,25 +12242,25 @@ pub struct Vec2 { r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "div", + metamethod = "Div", )] - fn add(self, rhs: f32) -> bevy::math::Vec3A; + fn div(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "div", + metamethod = "Div", )] - fn mul(self, rhs: f32) -> bevy::math::Vec3A; + fn div(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" @@ -12335,25 +12276,24 @@ pub struct Vec2 { r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "eq", + metamethod = "Eq", )] - fn neg(self) -> bevy::math::Vec3A; + fn eq(&self, #[proxy] rhs: &glam::Vec3A) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, rhs: f32) -> bevy::math::Vec3A; + fn sub(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -12369,39 +12309,15 @@ pub struct Vec2 { "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct Vec3A(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Vec4", - functions[r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "rem", + metamethod = "Mod", )] - fn div(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn rem(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" @@ -12413,28 +12329,19 @@ pub struct Vec3A(); composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Vec4; + fn add(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Sub", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn eq(&self, #[proxy] rhs: &glam::Vec4) -> bool; + fn sub(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" @@ -12446,91 +12353,100 @@ pub struct Vec3A(); composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "neg", + metamethod = "Unm", )] - fn add(self, rhs: f32) -> bevy::math::Vec4; + fn neg(self) -> bevy::math::Vec3A; "#, r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} "#, r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct Vec3A(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Vec4", + functions[r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", + composite = "eq", + metamethod = "Eq", )] - fn div(self, rhs: f32) -> bevy::math::Vec4; + fn eq(&self, #[proxy] rhs: &glam::Vec4) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "neg", - metamethod = "Unm", )] - fn neg(self) -> bevy::math::Vec4; + fn clone(&self) -> bevy::math::Vec4; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, rhs: f32) -> bevy::math::Vec4; + fn add(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, rhs: f32) -> bevy::math::Vec4; + fn mul(self, rhs: f32) -> bevy::math::Vec4; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "neg", + metamethod = "Unm", )] - fn rem(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn neg(self) -> bevy::math::Vec4; "#, r#" @@ -13051,6 +12967,66 @@ pub struct Vec3A(); #[lua(kind = "Method", output(proxy))] fn as_u64vec4(&self) -> bevy::math::U64Vec4; +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f32) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + "#, r#" @@ -13061,7 +13037,31 @@ pub struct Vec3A(); composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Vec4; + fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f32) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -13090,8 +13090,13 @@ pub struct Vec4(); remote = "bevy::math::BVec2", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::BVec2) -> bool; "#, r#" @@ -13149,13 +13154,8 @@ pub struct Vec4(); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::BVec2) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -13193,6 +13193,22 @@ pub struct BVec2 { )] fn eq(&self, #[proxy] other: &glam::BVec3) -> bool; +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec3; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" /// Creates a new vector mask. @@ -13246,22 +13262,6 @@ pub struct BVec2 { #[lua(kind = "MutatingMethod")] fn set(&mut self, index: usize, value: bool) -> (); -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec3; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -13280,16 +13280,6 @@ pub struct BVec3 { derive(clone), remote = "bevy::math::BVec4", functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec4; - -"#, - r#" /// Creates a new vector mask. #[lua(kind = "Function", output(proxy))] @@ -13341,12 +13331,6 @@ pub struct BVec3 { #[lua(kind = "MutatingMethod")] fn set(&mut self, index: usize, value: bool) -> (); -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" @@ -13358,6 +13342,22 @@ pub struct BVec3 { )] fn eq(&self, #[proxy] other: &glam::BVec4) -> bool; +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec4; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -13378,6 +13378,42 @@ pub struct BVec4 { remote = "bevy::math::DVec2", functions[r#" + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -13390,13 +13426,13 @@ pub struct BVec4 { r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, rhs: f64) -> bevy::math::DVec2; + fn rem(self, rhs: f64) -> bevy::math::DVec2; "#, r#" @@ -13966,36 +14002,82 @@ pub struct BVec4 { "#, r#" -/// Casts all elements of `self` to `u32`. +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec2(&self) -> bevy::math::UVec2; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec2(&self) -> bevy::math::I64Vec2; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec2(&self) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DVec2; + +"#, + r#" - #[lua(kind = "Method", output(proxy))] - fn as_uvec2(&self) -> bevy::math::UVec2; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DVec2; "#, r#" -/// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f64) -> bevy::math::DVec2; "#, r#" -/// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, rhs: f64) -> bevy::math::DVec2; + fn add(self, rhs: f64) -> bevy::math::DVec2; "#, r#" @@ -14019,7 +14101,46 @@ pub struct BVec4 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: f64) -> bevy::math::DVec2; + fn div(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct DVec2 { + x: f64, + y: f64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::DVec3", + functions[r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" @@ -14031,7 +14152,7 @@ pub struct BVec4 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn div(self, rhs: f64) -> bevy::math::DVec3; "#, r#" @@ -14043,53 +14164,66 @@ pub struct BVec4 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn add(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::DVec3) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, rhs: f64) -> bevy::math::DVec2; + fn mul(self, rhs: f64) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "add", + metamethod = "Add", )] - fn neg(self) -> bevy::math::DVec2; + fn add(self, rhs: f64) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "sub", + metamethod = "Sub", )] - fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn sub(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Sub", + kind = "MetaFunction", output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn clone(&self) -> bevy::math::DVec2; + fn sub(self, rhs: f64) -> bevy::math::DVec3; "#, r#" @@ -14101,46 +14235,29 @@ pub struct BVec4 { composite = "rem", metamethod = "Mod", )] - fn rem(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn rem(self, rhs: f64) -> bevy::math::DVec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DVec3; + "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct DVec2 { - x: f64, - y: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DVec3", - functions[r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "neg", + metamethod = "Unm", )] - fn sub(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn neg(self) -> bevy::math::DVec3; "#, r#" @@ -14659,180 +14776,63 @@ pub struct DVec2 { 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(kind = "Method", output(proxy))] - fn any_orthogonal_vector(&self) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn any_orthonormal_vector(&self) -> bevy::math::DVec3; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3a(&self) -> bevy::math::Vec3A; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" +/// The output vector is not necessarily unit length. For that use +/// [`Self::any_orthonormal_vector()`] instead. - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn any_orthogonal_vector(&self) -> bevy::math::DVec3; "#, 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( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::DVec3) -> bool; + #[lua(kind = "Method", output(proxy))] + fn any_orthonormal_vector(&self) -> bevy::math::DVec3; "#, r#" +/// Casts all elements of `self` to `f32`. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn as_vec3(&self) -> bevy::math::Vec3; "#, r#" +/// Casts all elements of `self` to `f32`. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f64) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn as_vec3a(&self) -> bevy::math::Vec3A; "#, r#" +/// Casts all elements of `self` to `i32`. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f64) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" +/// Casts all elements of `self` to `u32`. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f64) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" +/// Casts all elements of `self` to `i64`. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f64) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, r#" +/// Casts all elements of `self` to `u64`. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, r#" @@ -14850,13 +14850,13 @@ pub struct DVec2 { r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "div", + metamethod = "Div", )] - fn add(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn div(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" @@ -14890,37 +14890,23 @@ pub struct DVec3 { functions[r#" #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f64) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "div", - metamethod = "Div", )] - fn div(self, rhs: f64) -> bevy::math::DVec4; + fn clone(&self) -> bevy::math::DVec4; "#, r#" @@ -14932,42 +14918,19 @@ pub struct DVec3 { composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: f64) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f64) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::DVec4) -> bool; + fn rem(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "add", + metamethod = "Add", )] - fn sub(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn add(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" @@ -15511,37 +15474,61 @@ pub struct DVec3 { r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, rhs: f64) -> bevy::math::DVec4; + fn rem(self, rhs: f64) -> bevy::math::DVec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "div", + metamethod = "Div", )] - fn add(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn div(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "sub", + metamethod = "Sub", )] - fn rem(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn sub(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f64) -> bevy::math::DVec4; "#, r#" @@ -15553,17 +15540,30 @@ pub struct DVec3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn mul(self, rhs: f64) -> bevy::math::DVec4; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::DVec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", output(proxy), + composite = "add", + metamethod = "Add", )] - fn clone(&self) -> bevy::math::DVec4; + fn add(self, rhs: f64) -> bevy::math::DVec4; "#, r#" @@ -15593,33 +15593,9 @@ pub struct DVec4 { } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( - derive(clone), - remote = "bevy::math::Mat2", - functions[r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Mat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; - -"#, - r#" + derive(clone), + remote = "bevy::math::Mat2", + functions[r#" /// Creates a 2x2 matrix from two column vectors. #[lua(kind = "Function", output(proxy))] @@ -15801,13 +15777,23 @@ pub struct DVec4 { r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Mat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "neg", + metamethod = "Unm", )] - fn sub(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + fn neg(self) -> bevy::math::Mat2; "#, r#" @@ -15845,6 +15831,18 @@ pub struct DVec4 { )] fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + "#, r#" @@ -15860,11 +15858,13 @@ pub struct DVec4 { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Add", + kind = "MetaFunction", output(proxy), + composite = "add", + metamethod = "Add", )] - fn clone(&self) -> bevy::math::Mat2; + fn add(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; "#, r#" @@ -15906,34 +15906,25 @@ pub struct Mat2(); functions[r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "neg", + metamethod = "Unm", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn neg(self) -> bevy::math::Mat3; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Sub", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Mat3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn clone(&self) -> bevy::math::Mat3; + fn sub(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; "#, r#" @@ -15945,7 +15936,7 @@ pub struct Mat2(); composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3; + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" @@ -15957,67 +15948,64 @@ pub struct Mat2(); composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + fn mul(self, rhs: f32) -> bevy::math::Mat3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + fn eq(&self, #[proxy] rhs: &glam::Mat3) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "add", + metamethod = "Add", )] - fn mul(self, rhs: f32) -> bevy::math::Mat3; + fn add(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; "#, r#" #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "sub", - metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + fn clone(&self) -> bevy::math::Mat3; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::Mat3; + fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; "#, r#" @@ -16312,6 +16300,18 @@ pub struct Mat2(); #[lua(kind = "Method", output(proxy))] fn as_dmat3(&self) -> bevy::math::DMat3; +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -16648,6 +16648,16 @@ pub struct Mat3 { #[lua(kind = "Method", output(proxy))] fn as_dmat3(&self) -> bevy::math::DMat3; +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Mat3A; + "#, r#" @@ -16658,18 +16668,19 @@ pub struct Mat3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Mat3A; + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] rhs: &glam::Mat3A) -> bool; + fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, r#" @@ -16681,19 +16692,19 @@ pub struct Mat3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3A; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -16707,16 +16718,6 @@ pub struct Mat3 { )] fn add(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Mat3A; - "#, r#" @@ -16727,7 +16728,7 @@ pub struct Mat3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn mul(self, rhs: f32) -> bevy::math::Mat3A; "#, r#" @@ -16745,25 +16746,24 @@ pub struct Mat3 { r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "sub", + metamethod = "Sub", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + fn sub(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3A; + fn eq(&self, #[proxy] rhs: &glam::Mat3A) -> bool; "#, r#" @@ -16795,79 +16795,21 @@ fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; - -"#, - r#" +"#] +)] +pub struct Mat3A { + #[lua(output(proxy))] + x_axis: bevy::math::Vec3A, + #[lua(output(proxy))] + y_axis: bevy::math::Vec3A, + #[lua(output(proxy))] + z_axis: bevy::math::Vec3A, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Mat4", + functions[r#" #[lua( as_trait = "std::ops::Mul", @@ -16878,29 +16820,6 @@ pub struct Mat3A { )] fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Mat4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; - "#, r#" /// Creates a 4x4 matrix from four column vectors. @@ -17454,6 +17373,65 @@ pub struct Mat3A { #[lua(kind = "Method", output(proxy))] fn as_dmat4(&self) -> bevy::math::DMat4; +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Mat4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + "#, r#" @@ -17466,6 +17444,28 @@ pub struct Mat3A { )] fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Mat4; +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Mat4; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -17513,40 +17513,6 @@ pub struct Mat4 { derive(clone), remote = "bevy::math::DMat2", functions[r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DMat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DMat2; - -"#, - r#" /// Creates a 2x2 matrix from two column vectors. #[lua(kind = "Function", output(proxy))] @@ -17741,6 +17707,27 @@ pub struct Mat4 { )] fn mul(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DMat2) -> bool; + "#, r#" @@ -17757,12 +17744,13 @@ pub struct Mat4 { r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Neg", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "neg", + metamethod = "Unm", )] - fn eq(&self, #[proxy] rhs: &glam::DMat2) -> bool; + fn neg(self) -> bevy::math::DMat2; "#, r#" @@ -17776,6 +17764,18 @@ pub struct Mat4 { )] fn mul(self, rhs: f64) -> bevy::math::DMat2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -17819,6 +17819,75 @@ pub struct DMat2 { derive(clone), remote = "bevy::math::DMat3", functions[r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DMat3) -> bool; + +"#, + r#" /// Creates a 3x3 matrix from three column vectors. #[lua(kind = "Function", output(proxy))] @@ -18107,64 +18176,6 @@ pub struct DMat2 { #[lua(kind = "Method", output(proxy))] fn as_mat3(&self) -> bevy::math::Mat3; -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DMat3; - "#, r#" @@ -18201,17 +18212,6 @@ pub struct DMat2 { )] fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DMat3) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -18271,72 +18271,70 @@ pub struct DMat3 { r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DMat4; + fn eq(&self, #[proxy] rhs: &glam::DMat4) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + fn mul(self, rhs: f64) -> bevy::math::DMat4; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] rhs: &glam::DMat4) -> bool; + fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "neg", + metamethod = "Unm", )] - fn sub(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + fn neg(self) -> bevy::math::DMat4; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "add", + metamethod = "Add", )] - fn mul(self, rhs: f64) -> bevy::math::DMat4; + fn add(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; "#, r#" #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "mul", - metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + fn clone(&self) -> bevy::math::DMat4; "#, r#" @@ -18873,23 +18871,25 @@ pub struct DMat3 { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::DMat4; + fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DMat4; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "sub", + metamethod = "Sub", )] - fn neg(self) -> bevy::math::DMat4; + fn sub(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; "#, r#" @@ -18938,63 +18938,6 @@ pub struct DMat4 { derive(clone), remote = "bevy::math::Affine2", functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Affine2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Affine2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Affine2; - -"#, - r#" /// Creates an affine transform from three column vectors. #[lua(kind = "Function", output(proxy))] @@ -19144,24 +19087,81 @@ pub struct DMat4 { "#, 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/). +/// 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(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Affine2, 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::Affine2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Affine2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Affine2) -> bool; + +"#, + r#" - #[lua(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Affine2, max_abs_diff: f32) -> bool; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Affine2; "#, r#" -/// Return the inverse of this transform. -/// Note that if the transform is not invertible the result will be invalid. - #[lua(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::Affine2; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, r#" @@ -19471,46 +19471,46 @@ pub struct Affine2 { r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] rhs: &glam::Affine3A) -> bool; + fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::Affine3A; + fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Affine3A; "#, r#" #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "mul", - metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Affine3A; + fn clone(&self) -> bevy::math::Affine3A; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + fn eq(&self, #[proxy] rhs: &glam::Affine3A) -> bool; "#, r#" @@ -19531,6 +19531,51 @@ pub struct Affine3A { derive(clone), remote = "bevy::math::DAffine2", functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DAffine2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DAffine2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DAffine2) -> bool; + +"#, + r#" /// Creates an affine transform from three column vectors. #[lua(kind = "Function", output(proxy))] @@ -19692,51 +19737,6 @@ pub struct Affine3A { #[lua(kind = "Method", output(proxy))] fn inverse(&self) -> bevy::math::DAffine2; -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DAffine2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DAffine2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DAffine2) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -19766,6 +19766,27 @@ pub struct DAffine2 { )] fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DAffine3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DAffine3) -> bool; + "#, r#" /// Creates an affine transform from three column vectors. @@ -20026,19 +20047,124 @@ pub struct DAffine2 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DAffine3, max_abs_diff: f64) -> bool; + #[lua(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DAffine3, 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::DAffine3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DAffine3; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct DAffine3 { + #[lua(output(proxy))] + matrix3: bevy::math::DMat3, + #[lua(output(proxy))] + translation: bevy::math::DVec3, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::DQuat", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DQuat) -> bool; + +"#, + r#" +/// Divides a quaternion by a scalar value. +/// The quotient is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DQuat; + +"#, + r#" +/// Subtracts the `rhs` quaternion from `self`. +/// The difference is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + +"#, + r#" +/// Adds two quaternions. +/// The sum is not guaranteed to be normalized. +/// Note that addition is not the same as combining the rotations represented by the +/// two quaternions! That corresponds to multiplication. + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" -/// Return the inverse of this transform. -/// Note that if the transform is not invertible the result will be invalid. +/// 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(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::DAffine3; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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( as_trait = "std::ops::Mul", @@ -20047,18 +20173,21 @@ pub struct DAffine2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DAffine3; + fn mul(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" +/// Multiplies a quaternion by a scalar value. +/// The product is not guaranteed to be normalized. #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] rhs: &glam::DAffine3) -> bool; + fn mul(self, rhs: f64) -> bevy::math::DQuat; "#, r#" @@ -20068,27 +20197,22 @@ pub struct DAffine2 { kind = "Method", output(proxy), )] - fn clone(&self) -> bevy::math::DAffine3; + fn clone(&self) -> bevy::math::DQuat; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DQuat; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct DAffine3 { - #[lua(output(proxy))] - matrix3: bevy::math::DMat3, - #[lua(output(proxy))] - translation: bevy::math::DVec3, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::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`. @@ -20452,130 +20576,6 @@ pub struct DAffine3 { #[lua(kind = "Method", output(proxy))] fn as_f32(self) -> bevy::math::Quat; -"#, - r#" -/// Divides a quaternion by a scalar value. -/// The quotient is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f64) -> bevy::math::DQuat; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DQuat; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DQuat) -> bool; - -"#, - r#" -/// Adds two quaternions. -/// The sum is not guaranteed to be normalized. -/// Note that addition is not the same as combining the rotations represented by the -/// two quaternions! That corresponds to multiplication. - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DQuat; - -"#, - r#" -/// Multiplies a quaternion by a scalar value. -/// The product is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DQuat; - -"#, - r#" -/// Subtracts the `rhs` quaternion from `self`. -/// The difference is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; - -"#, - 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( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -20596,6 +20596,17 @@ pub struct DQuat { remote = "bevy::math::EulerRot", functions[r#" + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::EulerRot) -> bool; + +"#, + r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); @@ -20609,17 +20620,6 @@ pub struct DQuat { )] fn clone(&self) -> bevy::math::EulerRot; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::EulerRot) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -20634,17 +20634,6 @@ pub struct EulerRot {} derive(clone), remote = "bevy::math::BVec3A", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::BVec3A) -> bool; - -"#, - r#" /// Creates a new vector mask. #[lua(kind = "Function", output(proxy))] @@ -20706,6 +20695,17 @@ pub struct EulerRot {} )] fn clone(&self) -> bevy::math::BVec3A; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::BVec3A) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -20719,17 +20719,7 @@ pub struct BVec3A(); #[proxy( derive(clone), remote = "bevy::math::BVec4A", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec4A; - -"#, - r#" + functions[r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -20792,6 +20782,16 @@ pub struct BVec3A(); #[lua(kind = "MutatingMethod")] fn set(&mut self, index: usize, value: bool) -> (); +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec4A; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -20806,15 +20806,14 @@ pub struct BVec4A(); derive(clone), remote = "bevy::math::primitives::Direction2d", functions[r#" -/// Create a [`Direction2d`] from a [`Vec2`] that is already normalized. -/// # Warning -/// `value` must be normalized, i.e it's length must be `1.0`. - #[lua(kind = "Function", output(proxy))] - fn new_unchecked( - #[proxy] - value: bevy::math::Vec2, - ) -> bevy::math::primitives::Direction2d; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction2d) -> bool; "#, r#" @@ -20840,14 +20839,15 @@ pub struct BVec4A(); "#, r#" +/// Create a [`Direction2d`] from a [`Vec2`] that is already normalized. +/// # Warning +/// `value` must be normalized, i.e it's length must be `1.0`. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction2d) -> bool; + #[lua(kind = "Function", output(proxy))] + fn new_unchecked( + #[proxy] + value: bevy::math::Vec2, + ) -> bevy::math::primitives::Direction2d; "#, r#" @@ -20865,22 +20865,22 @@ pub struct Direction2d(); functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::primitives::Circle; + fn eq(&self, #[proxy] other: &bevy_math::primitives::Circle) -> bool; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Circle) -> bool; + fn clone(&self) -> bevy::math::primitives::Circle; "#, r#" @@ -20935,27 +20935,6 @@ pub struct Circle { derive(clone), remote = "bevy::math::primitives::Ellipse", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Ellipse) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Ellipse; - -"#, - r#" /// Create a new `Ellipse` from half of its width and height. /// This corresponds to the two perpendicular radii defining the ellipse. @@ -20991,6 +20970,27 @@ pub struct Circle { #[lua(kind = "Method")] fn area(&self) -> f32; +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Ellipse; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Ellipse) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -21016,15 +21016,6 @@ pub struct Ellipse { )] fn clone(&self) -> bevy::math::primitives::Plane2d; -"#, - r#" -/// Create a new `Plane2d` from a normal -/// # Panics -/// Panics if the given `normal` is zero (or very close to zero), or non-finite. - - #[lua(kind = "Function", output(proxy))] - fn new(#[proxy] normal: bevy::math::Vec2) -> bevy::math::primitives::Plane2d; - "#, r#" @@ -21036,6 +21027,15 @@ pub struct Ellipse { )] fn eq(&self, #[proxy] other: &bevy_math::primitives::Plane2d) -> bool; +"#, + r#" +/// Create a new `Plane2d` from a normal +/// # Panics +/// Panics if the given `normal` is zero (or very close to zero), or non-finite. + + #[lua(kind = "Function", output(proxy))] + fn new(#[proxy] normal: bevy::math::Vec2) -> bevy::math::primitives::Plane2d; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -21055,22 +21055,22 @@ pub struct Plane2d { functions[r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Line2d) -> bool; + fn clone(&self) -> bevy::math::primitives::Line2d; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::primitives::Line2d; + fn eq(&self, #[proxy] other: &bevy_math::primitives::Line2d) -> bool; "#, r#" @@ -21098,6 +21098,16 @@ pub struct Line2d { )] fn eq(&self, #[proxy] other: &bevy_math::primitives::Segment2d) -> bool; +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Segment2d; + "#, r#" /// Create a new `Segment2d` from a direction and full length of the segment @@ -21123,16 +21133,6 @@ pub struct Line2d { #[lua(kind = "Method", output(proxy))] fn point2(&self) -> bevy::math::Vec2; -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Segment2d; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -21153,12 +21153,11 @@ pub struct Segment2d { functions[r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Triangle2d) -> bool; + fn clone(&self) -> bevy::math::primitives::Triangle2d; "#, r#" @@ -21200,11 +21199,12 @@ pub struct Segment2d { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::primitives::Triangle2d; + fn eq(&self, #[proxy] other: &bevy_math::primitives::Triangle2d) -> bool; "#, r#" @@ -21222,6 +21222,16 @@ pub struct Triangle2d { derive(clone), remote = "bevy::math::primitives::Rectangle", functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Rectangle; + +"#, + r#" /// Create a new `Rectangle` from a full width and height #[lua(kind = "Function", output(proxy))] @@ -21276,16 +21286,6 @@ pub struct Triangle2d { #[lua(kind = "Method", output(proxy))] fn closest_point(&self, #[proxy] point: bevy::math::Vec2) -> bevy::math::Vec2; -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Rectangle; - "#, r#" @@ -21436,6 +21436,13 @@ pub struct RegularPolygon { derive(clone), remote = "bevy::math::primitives::Capsule2d", functions[r#" +/// Create a new `Capsule2d` from a radius and length + + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule2d; + +"#, + r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -21445,13 +21452,6 @@ pub struct RegularPolygon { )] fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule2d) -> bool; -"#, - r#" -/// Create a new `Capsule2d` from a radius and length - - #[lua(kind = "Function", output(proxy))] - fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule2d; - "#, r#" @@ -21481,13 +21481,13 @@ pub struct Capsule2d { functions[r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "neg", + metamethod = "Unm", )] - fn mul(self, rhs: f32) -> bevy::math::Vec3; + fn neg(self) -> bevy::math::primitives::Direction3d; "#, r#" @@ -21510,18 +21510,6 @@ pub struct Capsule2d { )] fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction3d) -> bool; -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::primitives::Direction3d; - "#, r#" /// Create a [`Direction3d`] from a [`Vec3`] that is already normalized. @@ -21534,6 +21522,18 @@ pub struct Capsule2d { value: bevy::math::Vec3, ) -> bevy::math::primitives::Direction3d; +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec3; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -21556,17 +21556,6 @@ pub struct Direction3d(); )] fn clone(&self) -> bevy::math::primitives::Sphere; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Sphere) -> bool; - "#, r#" /// Create a new [`Sphere`] from a `radius` @@ -21604,6 +21593,17 @@ pub struct Direction3d(); #[lua(kind = "Method", output(proxy))] fn closest_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Sphere) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -21620,6 +21620,15 @@ pub struct Sphere { derive(clone), remote = "bevy::math::primitives::Plane3d", functions[r#" +/// Create a new `Plane3d` from a normal +/// # Panics +/// Panics if the given `normal` is zero (or very close to zero), or non-finite. + + #[lua(kind = "Function", output(proxy))] + fn new(#[proxy] normal: bevy::math::Vec3) -> bevy::math::primitives::Plane3d; + +"#, + r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -21639,15 +21648,6 @@ pub struct Sphere { )] fn clone(&self) -> bevy::math::primitives::Plane3d; -"#, - r#" -/// Create a new `Plane3d` from a normal -/// # Panics -/// Panics if the given `normal` is zero (or very close to zero), or non-finite. - - #[lua(kind = "Function", output(proxy))] - fn new(#[proxy] normal: bevy::math::Vec3) -> bevy::math::primitives::Plane3d; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -21702,17 +21702,6 @@ pub struct Line3d { remote = "bevy::math::primitives::Segment3d", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Segment3d) -> bool; - -"#, - r#" - #[lua( as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", kind = "Method", @@ -21745,6 +21734,17 @@ pub struct Line3d { #[lua(kind = "Method", output(proxy))] fn point2(&self) -> bevy::math::Vec3; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Segment3d) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -21765,11 +21765,12 @@ pub struct Segment3d { functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::primitives::Cuboid; + fn eq(&self, #[proxy] other: &bevy_math::primitives::Cuboid) -> bool; "#, r#" @@ -21835,12 +21836,11 @@ pub struct Segment3d { r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Cuboid) -> bool; + fn clone(&self) -> bevy::math::primitives::Cuboid; "#, r#" @@ -21867,6 +21867,17 @@ pub struct Cuboid { )] fn clone(&self) -> bevy::math::primitives::Cylinder; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Cylinder) -> bool; + "#, r#" /// Create a new `Cylinder` from a radius and full height @@ -21910,17 +21921,6 @@ pub struct Cuboid { #[lua(kind = "Method")] fn volume(&self) -> f32; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Cylinder) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -21940,22 +21940,22 @@ pub struct Cylinder { functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::primitives::Capsule3d; + fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule3d) -> bool; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule3d) -> bool; + fn clone(&self) -> bevy::math::primitives::Capsule3d; "#, r#" @@ -22085,22 +22085,22 @@ pub struct Cone { functions[r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::ConicalFrustum) -> bool; + fn clone(&self) -> bevy::math::primitives::ConicalFrustum; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::primitives::ConicalFrustum; + fn eq(&self, #[proxy] other: &bevy_math::primitives::ConicalFrustum) -> bool; "#, r#" @@ -22120,17 +22120,6 @@ pub struct ConicalFrustum { derive(clone), remote = "bevy::math::primitives::Torus", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Torus) -> bool; - -"#, - r#" /// Create a new `Torus` from an inner and outer radius. /// The inner radius is the radius of the hole, and the outer radius /// is the radius of the entire object @@ -22182,6 +22171,17 @@ pub struct ConicalFrustum { )] fn clone(&self) -> bevy::math::primitives::Torus; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Torus) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -22200,23 +22200,18 @@ pub struct Torus { remote = "bevy::math::IRect", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::IRect; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] other: &bevy_math::IRect) -> bool; + fn clone(&self) -> bevy::math::IRect; "#, r#" @@ -22488,8 +22483,13 @@ pub struct Torus { "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::IRect) -> bool; "#, r#" @@ -22792,22 +22792,22 @@ pub struct IRect { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::Rect; + fn eq(&self, #[proxy] other: &bevy_math::Rect) -> bool; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] other: &bevy_math::Rect) -> bool; + fn clone(&self) -> bevy::math::Rect; "#, r#" @@ -22829,19 +22829,12 @@ pub struct Rect { remote = "bevy::math::URect", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] other: &bevy_math::URect) -> bool; + fn clone(&self) -> bevy::math::URect; "#, r#" @@ -23114,11 +23107,18 @@ pub struct Rect { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::URect; + fn eq(&self, #[proxy] other: &bevy_math::URect) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -23523,6 +23523,22 @@ pub struct NonZeroIsize(); derive(clone), remote = "bevy::utils::Uuid", functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::utils::Uuid; + +"#, + r#" /// Returns the version number of the UUID. /// This represents the algorithm used to generate the value. /// This method is the future-proof alternative to [`Uuid::get_version`]. @@ -23848,22 +23864,6 @@ pub struct NonZeroIsize(); #[lua(kind = "Function", output(proxy))] fn from_bytes_le(b: [u8; 16]) -> bevy::utils::Uuid; -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::utils::Uuid; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" /// Creates a random UUID. @@ -24671,14 +24671,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyReflectAPIProvider { ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/bevy_time.rs b/crates/bevy_script_api/src/providers/bevy_time.rs index 34c0cff2..38c46a8d 100644 --- a/crates/bevy_script_api/src/providers/bevy_time.rs +++ b/crates/bevy_script_api/src/providers/bevy_time.rs @@ -50,12 +50,6 @@ pub struct Real {} remote = "bevy::time::prelude::Timer", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::time::prelude::Timer; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -391,6 +385,12 @@ pub struct Real {} #[lua(kind = "Method")] fn times_finished_this_tick(&self) -> u32; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::time::prelude::Timer; + "#, r#" @@ -412,6 +412,12 @@ pub struct Timer {} remote = "bevy::time::prelude::TimerMode", functions[r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -420,12 +426,6 @@ pub struct Timer {} )] fn eq(&self, #[proxy] other: &timer::TimerMode) -> bool; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" @@ -465,8 +465,8 @@ pub struct Virtual {} remote = "bevy::time::Stopwatch", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::time::Stopwatch; "#, r#" @@ -616,12 +616,6 @@ pub struct Virtual {} #[lua(kind = "MutatingMethod")] fn reset(&mut self) -> (); -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::time::Stopwatch; - "#, r#" @@ -633,6 +627,12 @@ pub struct Virtual {} )] fn eq(&self, #[proxy] other: &stopwatch::Stopwatch) -> bool; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -709,14 +709,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyTimeAPIProvider { ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/bevy_transform.rs b/crates/bevy_script_api/src/providers/bevy_transform.rs index c9e46db5..2ab43435 100644 --- a/crates/bevy_script_api/src/providers/bevy_transform.rs +++ b/crates/bevy_script_api/src/providers/bevy_transform.rs @@ -26,26 +26,9 @@ use bevy_script_api::{ fn mul( self, #[proxy] - global_transform: bevy::transform::components::GlobalTransform, + transform: bevy::transform::components::Transform, ) -> bevy::transform::components::GlobalTransform; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &components::global_transform::GlobalTransform) -> bool; - "#, r#" @@ -56,23 +39,18 @@ use bevy_script_api::{ composite = "mul", metamethod = "Mul", )] - fn mul( - self, - #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::GlobalTransform; + fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; + fn eq(&self, #[proxy] other: &components::global_transform::GlobalTransform) -> bool; "#, r#" @@ -255,21 +233,9 @@ use bevy_script_api::{ "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GlobalTransform(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::transform::components::Transform", - functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::transform::components::Transform; + fn clone(&self) -> bevy::transform::components::GlobalTransform; "#, r#" @@ -284,11 +250,23 @@ pub struct GlobalTransform(); fn mul( self, #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::Transform; + global_transform: bevy::transform::components::GlobalTransform, + ) -> bevy::transform::components::GlobalTransform; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GlobalTransform(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::transform::components::Transform", + functions[r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -298,22 +276,6 @@ pub struct GlobalTransform(); )] fn eq(&self, #[proxy] other: &components::transform::Transform) -> bool; -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul( - self, - #[proxy] - global_transform: bevy::transform::components::GlobalTransform, - ) -> bevy::transform::components::GlobalTransform; - "#, r#" /// Creates a new [`Transform`] at the position `(x, y, z)`. In 2d, the `z` component @@ -629,6 +591,38 @@ pub struct GlobalTransform(); #[lua(kind = "Method")] fn is_finite(&self) -> bool; +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul( + self, + #[proxy] + transform: bevy::transform::components::Transform, + ) -> bevy::transform::components::Transform; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul( + self, + #[proxy] + global_transform: bevy::transform::components::GlobalTransform, + ) -> bevy::transform::components::GlobalTransform; + "#, r#" @@ -641,6 +635,12 @@ pub struct GlobalTransform(); )] fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::transform::components::Transform; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -724,14 +724,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyTransformAPIProvider { ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/bevy_window.rs b/crates/bevy_script_api/src/providers/bevy_window.rs index 5815cca5..2844d7db 100644 --- a/crates/bevy_script_api/src/providers/bevy_window.rs +++ b/crates/bevy_script_api/src/providers/bevy_window.rs @@ -15,6 +15,12 @@ use bevy_script_api::{ remote = "bevy::window::prelude::CursorEntered", functions[r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::prelude::CursorEntered; @@ -29,12 +35,6 @@ use bevy_script_api::{ )] fn eq(&self, #[proxy] other: &event::CursorEntered) -> bool; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -88,14 +88,14 @@ pub struct CursorIcon {} remote = "bevy::window::prelude::CursorLeft", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::CursorLeft; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::CursorLeft; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -161,6 +161,12 @@ pub struct CursorMoved { remote = "bevy::window::prelude::FileDragAndDrop", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::FileDragAndDrop; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -175,12 +181,6 @@ pub struct CursorMoved { #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::FileDragAndDrop; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -196,12 +196,6 @@ pub struct FileDragAndDrop {} remote = "bevy::window::prelude::Ime", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::Ime; - -"#, - r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); @@ -216,6 +210,12 @@ pub struct FileDragAndDrop {} )] fn eq(&self, #[proxy] other: &event::Ime) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::Ime; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -231,8 +231,8 @@ pub struct Ime {} remote = "bevy::window::prelude::MonitorSelection", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::MonitorSelection; "#, r#" @@ -248,8 +248,8 @@ pub struct Ime {} "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::MonitorSelection; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -269,6 +269,12 @@ pub struct MonitorSelection {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::prelude::ReceivedCharacter; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" @@ -280,12 +286,6 @@ pub struct MonitorSelection {} )] fn eq(&self, #[proxy] other: &event::ReceivedCharacter) -> bool; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -305,6 +305,12 @@ pub struct ReceivedCharacter { derive(clone), remote = "bevy::window::prelude::Window", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::Window; + +"#, + r#" /// Setting to true will attempt to maximize the window. /// Setting to false will attempt to un-maximize the window. @@ -359,12 +365,6 @@ pub struct ReceivedCharacter { #[lua(kind = "Method")] fn scale_factor(&self) -> f32; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::Window; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -414,8 +414,13 @@ pub struct Window { remote = "bevy::window::prelude::WindowMoved", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowMoved) -> bool; "#, r#" @@ -426,13 +431,8 @@ pub struct Window { "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowMoved) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -453,23 +453,6 @@ pub struct WindowMoved { derive(clone), remote = "bevy::window::prelude::WindowPosition", functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::WindowPosition; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowPosition) -> bool; - -"#, - r#" /// Creates a new [`WindowPosition`] at a position. #[lua(kind = "Function", output(proxy))] @@ -496,6 +479,23 @@ pub struct WindowMoved { monitor: bevy::window::prelude::MonitorSelection, ) -> (); +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::WindowPosition; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowPosition) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -510,11 +510,14 @@ pub struct WindowPosition {} derive(clone), remote = "bevy::window::prelude::WindowResizeConstraints", functions[r#" -/// Checks if the constraints are valid. -/// Will output warnings if it isn't. - #[lua(kind = "Method", output(proxy))] - fn check_constraints(&self) -> bevy::window::prelude::WindowResizeConstraints; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowResizeConstraints) -> bool; "#, r#" @@ -524,14 +527,11 @@ pub struct WindowPosition {} "#, r#" +/// Checks if the constraints are valid. +/// Will output warnings if it isn't. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowResizeConstraints) -> bool; + #[lua(kind = "Method", output(proxy))] + fn check_constraints(&self) -> bevy::window::prelude::WindowResizeConstraints; "#, r#" @@ -553,6 +553,12 @@ pub struct WindowResizeConstraints { remote = "bevy::window::WindowResized", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowResized; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -561,12 +567,6 @@ pub struct WindowResizeConstraints { )] fn eq(&self, #[proxy] other: &event::WindowResized) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowResized; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -590,12 +590,6 @@ pub struct WindowResized { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::WindowCreated; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" @@ -607,6 +601,12 @@ pub struct WindowResized { )] fn eq(&self, #[proxy] other: &event::WindowCreated) -> bool; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -625,13 +625,8 @@ pub struct WindowCreated { remote = "bevy::window::WindowClosed", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowClosed) -> bool; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowClosed; "#, r#" @@ -642,8 +637,13 @@ pub struct WindowCreated { "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowClosed; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowClosed) -> bool; "#, r#" @@ -663,25 +663,25 @@ pub struct WindowClosed { remote = "bevy::window::WindowCloseRequested", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowCloseRequested; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowCloseRequested) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowCloseRequested; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowCloseRequested) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -701,14 +701,14 @@ pub struct WindowCloseRequested { remote = "bevy::window::WindowDestroyed", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowDestroyed; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowDestroyed; "#, r#" @@ -739,17 +739,6 @@ pub struct WindowDestroyed { remote = "bevy::window::RequestRedraw", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::RequestRedraw) -> bool; - -"#, - r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::RequestRedraw; @@ -759,6 +748,17 @@ pub struct WindowDestroyed { #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::RequestRedraw) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -774,14 +774,14 @@ pub struct RequestRedraw {} remote = "bevy::window::WindowFocused", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowFocused; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowFocused; "#, r#" @@ -852,12 +852,6 @@ pub struct WindowOccluded { remote = "bevy::window::WindowScaleFactorChanged", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowScaleFactorChanged; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -866,6 +860,12 @@ pub struct WindowOccluded { )] fn eq(&self, #[proxy] other: &event::WindowScaleFactorChanged) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowScaleFactorChanged; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -885,6 +885,12 @@ pub struct WindowScaleFactorChanged { remote = "bevy::window::WindowBackendScaleFactorChanged", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowBackendScaleFactorChanged; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -893,12 +899,6 @@ pub struct WindowScaleFactorChanged { )] fn eq(&self, #[proxy] other: &event::WindowBackendScaleFactorChanged) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowBackendScaleFactorChanged; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -918,6 +918,12 @@ pub struct WindowBackendScaleFactorChanged { remote = "bevy::window::WindowThemeChanged", functions[r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -932,12 +938,6 @@ pub struct WindowBackendScaleFactorChanged { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::WindowThemeChanged; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -958,25 +958,25 @@ pub struct WindowThemeChanged { remote = "bevy::window::ApplicationLifetime", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::ApplicationLifetime; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::ApplicationLifetime) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::ApplicationLifetime; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::ApplicationLifetime) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -993,12 +993,6 @@ pub struct ApplicationLifetime {} remote = "bevy::window::PrimaryWindow", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::PrimaryWindow; - -"#, - r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); @@ -1013,6 +1007,12 @@ pub struct ApplicationLifetime {} )] fn eq(&self, #[proxy] other: &window::PrimaryWindow) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::PrimaryWindow; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1053,6 +1053,12 @@ pub struct Cursor { remote = "bevy::window::CursorGrabMode", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::CursorGrabMode; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -1067,12 +1073,6 @@ pub struct Cursor { #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::CursorGrabMode; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1088,8 +1088,8 @@ pub struct CursorGrabMode {} remote = "bevy::window::CompositeAlphaMode", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::CompositeAlphaMode; "#, r#" @@ -1105,8 +1105,8 @@ pub struct CursorGrabMode {} "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::CompositeAlphaMode; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -1123,6 +1123,12 @@ pub struct CompositeAlphaMode {} remote = "bevy::window::WindowResolution", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowResolution; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -1235,12 +1241,6 @@ pub struct CompositeAlphaMode {} scale_factor_override: std::option::Option, ) -> (); -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowResolution; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1256,13 +1256,8 @@ pub struct WindowResolution {} remote = "bevy::window::WindowMode", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowMode) -> bool; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowMode; "#, r#" @@ -1273,8 +1268,13 @@ pub struct WindowResolution {} "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowMode; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowMode) -> bool; "#, r#" @@ -1291,14 +1291,14 @@ pub struct WindowMode {} remote = "bevy::window::WindowLevel", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowLevel; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowLevel; "#, r#" @@ -1337,14 +1337,14 @@ pub struct WindowLevel {} "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::PresentMode; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::PresentMode; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -1369,6 +1369,12 @@ pub struct PresentMode {} )] fn eq(&self, #[proxy] other: &window::InternalWindowState) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::InternalWindowState; + "#, r#" /// Consumes the current maximize request, if it exists. This should only be called by window backends. @@ -1383,12 +1389,6 @@ pub struct PresentMode {} #[lua(kind = "MutatingMethod")] fn take_minimize_request(&mut self) -> std::option::Option; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::InternalWindowState; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1404,8 +1404,8 @@ pub struct InternalWindowState {} remote = "bevy::window::WindowTheme", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowTheme; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -1421,8 +1421,8 @@ pub struct InternalWindowState {} "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowTheme; "#, r#" @@ -1493,13 +1493,6 @@ pub struct WindowRef {} #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); -"#, - r#" -/// Fetch the entity of this window reference - - #[lua(kind = "Method", output(proxy))] - fn entity(&self) -> bevy::ecs::entity::Entity; - "#, r#" @@ -1511,6 +1504,13 @@ pub struct WindowRef {} )] fn eq(&self, #[proxy] other: &window::NormalizedWindowRef) -> bool; +"#, + r#" +/// Fetch the entity of this window reference + + #[lua(kind = "Method", output(proxy))] + fn entity(&self) -> bevy::ecs::entity::Entity; + "#, r#" @@ -1630,14 +1630,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyWindowAPIProvider { ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/mod.rs b/crates/bevy_script_api/src/providers/mod.rs index 62a19bbb..9f965d0c 100644 --- a/crates/bevy_script_api/src/providers/mod.rs +++ b/crates/bevy_script_api/src/providers/mod.rs @@ -59,14 +59,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for LuaBevyAPIProvider { ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } fn register_with_app(&self, app: &mut bevy::app::App) { bevy_ecs::BevyEcsAPIProvider.register_with_app(app); bevy_transform::BevyTransformAPIProvider.register_with_app(app); diff --git a/crates/bevy_script_api/src/rhai/bevy/mod.rs b/crates/bevy_script_api/src/rhai/bevy/mod.rs index 4ab540e1..3b0548f2 100644 --- a/crates/bevy_script_api/src/rhai/bevy/mod.rs +++ b/crates/bevy_script_api/src/rhai/bevy/mod.rs @@ -1,5 +1,5 @@ use bevy::prelude::Entity; -use bevy_mod_scripting_core::{prelude::*, world::WorldPointer}; +use bevy_mod_scripting_core::prelude::*; #[allow(deprecated)] use bevy_mod_scripting_rhai::{ @@ -228,16 +228,6 @@ impl APIProvider for RhaiBevyAPIProvider { Ok(()) } - fn setup_script_runtime( - &mut self, - world_ptr: WorldPointer, - _script_data: &ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), ScriptError> { - ctx.scope.set_value("world", ScriptWorld::new(world_ptr)); - Ok(()) - } - fn setup_script( &mut self, script_data: &ScriptData, diff --git a/crates/languages/bevy_mod_scripting_lua/src/lib.rs b/crates/languages/bevy_mod_scripting_lua/src/lib.rs index 29863ada..2d296163 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/lib.rs @@ -3,7 +3,7 @@ use crate::{ docs::LuaDocFragment, }; use bevy::{ecs::schedule::ScheduleLabel, prelude::*}; -use bevy_mod_scripting_core::{prelude::*, systems::*, world::WorldPointerGuard}; +use bevy_mod_scripting_core::{prelude::*, systems::*}; use std::sync::Mutex; use std::{fmt, marker::PhantomData}; @@ -148,18 +148,9 @@ impl ScriptHost for LuaScriptHost { world: &mut World, events: &[Self::ScriptEvent], ctxs: impl Iterator, &'a mut Self::ScriptContext)>, - providers: &mut APIProviders, + _providers: &mut APIProviders, ) { - // safety: - // - we have &mut World access - // - we do not use the original reference again anywhere in this function - let world = unsafe { WorldPointerGuard::new(world) }; - ctxs.for_each(|(script_data, ctx)| { - providers - .setup_runtime_all(world.clone(), &script_data, ctx) - .expect("Could not setup script runtime"); - let ctx = ctx.get_mut().expect("Poison error in context"); // event order is preserved, but scripts can't rely on any temporal @@ -178,10 +169,9 @@ impl ScriptHost for LuaScriptHost { }; if let Err(error) = f.call::<_, ()>(event.args.clone()) { - let mut world = world.write(); let mut state: CachedScriptState = world.remove_resource().unwrap(); - let (_, mut error_wrt, _) = state.event_state.get_mut(&mut world); + let (_, mut error_wrt, _) = state.event_state.get_mut(world); let error = ScriptError::RuntimeError { script: script_data.name.to_owned(), diff --git a/crates/languages/bevy_mod_scripting_rhai/src/lib.rs b/crates/languages/bevy_mod_scripting_rhai/src/lib.rs index cbb0eb16..9d2020fc 100644 --- a/crates/languages/bevy_mod_scripting_rhai/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_rhai/src/lib.rs @@ -3,7 +3,7 @@ use crate::{ docs::RhaiDocFragment, }; use bevy::{ecs::schedule::ScheduleLabel, prelude::*}; -use bevy_mod_scripting_core::{prelude::*, systems::*, world::WorldPointerGuard}; +use bevy_mod_scripting_core::{prelude::*, systems::*}; use rhai::*; use std::marker::PhantomData; @@ -146,18 +146,9 @@ impl ScriptHost for RhaiScriptHost< world: &mut World, events: &[Self::ScriptEvent], ctxs: impl Iterator, &'a mut Self::ScriptContext)>, - providers: &mut APIProviders, + _providers: &mut APIProviders, ) { - // safety: - // - we have &mut World access - // - we do not use the original reference again anywhere in this function - let world = unsafe { WorldPointerGuard::new(world) }; - ctxs.for_each(|(fd, ctx)| { - providers - .setup_runtime_all(world.clone(), &fd, ctx) - .expect("Failed to setup script runtime"); - for event in events.iter() { // check if this script should handle this event if !event.recipients().is_recipient(&fd) { @@ -172,13 +163,12 @@ impl ScriptHost for RhaiScriptHost< ) { Ok(v) => v, Err(e) => { - let mut world = world.write(); let mut state: CachedScriptState = world.remove_resource().unwrap(); match *e { EvalAltResult::ErrorFunctionNotFound(..) => {} _ => { - let (_, mut error_wrt, _) = state.event_state.get_mut(&mut world); + let (_, mut error_wrt, _) = state.event_state.get_mut(world); let error = ScriptError::RuntimeError { script: fd.name.to_string(), diff --git a/crates/languages/bevy_mod_scripting_rune/src/lib.rs b/crates/languages/bevy_mod_scripting_rune/src/lib.rs index 4c7dc065..20395b31 100644 --- a/crates/languages/bevy_mod_scripting_rune/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_rune/src/lib.rs @@ -4,7 +4,6 @@ use bevy::prelude::*; use bevy_mod_scripting_core::{ prelude::*, systems::{self, CachedScriptState}, - world::{WorldPointer, WorldPointerGuard}, }; use prelude::{RuneDocFragment, RuneFile, RuneLoader}; use rune::{ @@ -85,11 +84,10 @@ impl RuneScriptHost { /// Helper function to handle errors from a Rune virtual machine. /// #[cold] - fn handle_rune_error(world: WorldPointer, error: VmError, script_data: &ScriptData<'_>) { - let mut world = world.write(); + fn handle_rune_error(world: &mut World, error: VmError, script_data: &ScriptData<'_>) { let mut state: CachedScriptState = world.remove_resource().unwrap(); - let (_, mut error_wrt, _) = state.event_state.get_mut(&mut world); + let (_, mut error_wrt, _) = state.event_state.get_mut(world); let error = ScriptError::RuntimeError { script: script_data.name.to_owned(), @@ -221,23 +219,13 @@ impl ScriptHost for RuneScriptHost { world: &mut World, events: &[Self::ScriptEvent], ctxs: impl Iterator, &'a mut Self::ScriptContext)>, - providers: &mut APIProviders, + _providers: &mut APIProviders, ) { // Grab the cached Vm. let RuneVm(mut vm) = world.remove_non_send_resource::().unwrap(/* invariant */); { - // Safety: - // - we have &mut World access - // - we do not use the original reference again anywhere in this block. - // - the guard is dropped at the end of this block. - let world = unsafe { WorldPointerGuard::new(world) }; - ctxs.for_each(|(script_data, ctx)| { - providers - .setup_runtime_all(world.clone(), &script_data, ctx) - .expect("Could not setup script runtime"); - for event in events { if !event.recipients().is_recipient(&script_data) { continue; @@ -251,19 +239,16 @@ impl ScriptHost for RuneScriptHost { { Ok(exec) => exec, Err(error) => { - Self::handle_rune_error(world.clone(), error, &script_data); + Self::handle_rune_error(world, error, &script_data); continue; } }; if let VmResult::Err(error) = exec.complete() { - Self::handle_rune_error(world.clone(), error, &script_data); + Self::handle_rune_error(world, error, &script_data); } } }); - - // explictly release the pointer to world. - drop(world); } world.insert_non_send_resource(RuneVm(vm)); From e33b3e058b48573490c6e53e96c9f4464889d9e9 Mon Sep 17 00:00:00 2001 From: makspll Date: Sun, 14 Apr 2024 18:21:33 +0100 Subject: [PATCH 07/17] beginning of new trait system for script api --- .vscode/settings.json | 4 +- Cargo.toml | 9 +- assets/scripts/event_recipients.lua | 3 +- check.sh | 2 +- crates/bevy_api_gen/src/args.rs | 7 +- crates/bevy_api_gen/templates/footer.tera | 56 +- crates/bevy_api_gen/templates/header.tera | 3 +- crates/bevy_api_gen/templates/mod.tera | 47 +- crates/bevy_event_priority/Cargo.toml | 20 - crates/bevy_event_priority/readme.md | 3 - crates/bevy_event_priority/src/lib.rs | 412 - crates/bevy_mod_scripting_core/Cargo.toml | 3 +- .../bevy_mod_scripting_core/src/allocator.rs | 54 +- crates/bevy_mod_scripting_core/src/asset.rs | 92 +- .../bevy_mod_scripting_core/src/bindings.rs | 571 +- .../bevy_mod_scripting_core/src/commands.rs | 146 + crates/bevy_mod_scripting_core/src/context.rs | 152 + crates/bevy_mod_scripting_core/src/docs.rs | 22 +- crates/bevy_mod_scripting_core/src/error.rs | 108 +- crates/bevy_mod_scripting_core/src/event.rs | 242 +- crates/bevy_mod_scripting_core/src/handler.rs | 37 + crates/bevy_mod_scripting_core/src/hosts.rs | 461 - crates/bevy_mod_scripting_core/src/lib.rs | 290 +- crates/bevy_mod_scripting_core/src/proxy.rs | 633 + crates/bevy_mod_scripting_core/src/runtime.rs | 36 + crates/bevy_mod_scripting_core/src/script.rs | 42 + crates/bevy_mod_scripting_core/src/systems.rs | 571 +- crates/bevy_script_api/Cargo.toml | 41 - crates/bevy_script_api/readme.md | 3 - crates/bevy_script_api/src/common/bevy/mod.rs | 304 - crates/bevy_script_api/src/common/mod.rs | 2 - crates/bevy_script_api/src/common/std.rs | 139 - crates/bevy_script_api/src/core_providers.rs | 101 - crates/bevy_script_api/src/error.rs | 37 - crates/bevy_script_api/src/lib.rs | 45 - crates/bevy_script_api/src/lua/bevy/mod.rs | 296 - crates/bevy_script_api/src/lua/mod.rs | 306 - crates/bevy_script_api/src/lua/std.rs | 474 - crates/bevy_script_api/src/lua/util.rs | 300 - .../src/providers/bevy_core.rs | 87 - .../bevy_script_api/src/providers/bevy_ecs.rs | 382 - .../src/providers/bevy_hierarchy.rs | 116 - .../src/providers/bevy_input.rs | 1537 - .../src/providers/bevy_reflect.rs | 24756 ---------------- .../src/providers/bevy_time.rs | 720 - .../src/providers/bevy_transform.rs | 731 - .../src/providers/bevy_window.rs | 1674 -- crates/bevy_script_api/src/providers/mod.rs | 72 - crates/bevy_script_api/src/rhai/bevy/mod.rs | 262 - crates/bevy_script_api/src/rhai/mod.rs | 194 - crates/bevy_script_api/src/rhai/std.rs | 427 - crates/bevy_script_api/src/script_ref.rs | 185 - crates/bevy_script_api/src/sub_reflect.rs | 389 - crates/bevy_script_api/src/wrappers.rs | 107 - .../bevy_mod_scripting_lua/src/assets.rs | 282 +- .../bevy_mod_scripting_lua/src/bindings.rs | 38 - .../src/bindings/mod.rs | 6 + .../src/bindings/traits.rs | 167 + .../bevy_mod_scripting_lua/src/docs.rs | 58 +- .../bevy_mod_scripting_lua/src/lib.rs | 287 +- .../bevy_mod_scripting_rhai/src/assets.rs | 44 - .../bevy_mod_scripting_rhai/src/docs.rs | 17 - .../bevy_mod_scripting_rhai/src/lib.rs | 494 +- .../bevy_mod_scripting_rune/src/assets.rs | 46 - .../bevy_mod_scripting_rune/src/docs.rs | 17 - .../bevy_mod_scripting_rune/src/lib.rs | 511 +- examples/lua/event_recipients.rs | 173 +- src/documentation/main.rs | 2 +- src/lib.rs | 10 +- 69 files changed, 3587 insertions(+), 36278 deletions(-) delete mode 100644 crates/bevy_event_priority/Cargo.toml delete mode 100644 crates/bevy_event_priority/readme.md delete mode 100644 crates/bevy_event_priority/src/lib.rs create mode 100644 crates/bevy_mod_scripting_core/src/commands.rs create mode 100644 crates/bevy_mod_scripting_core/src/context.rs create mode 100644 crates/bevy_mod_scripting_core/src/handler.rs delete mode 100644 crates/bevy_mod_scripting_core/src/hosts.rs create mode 100644 crates/bevy_mod_scripting_core/src/proxy.rs create mode 100644 crates/bevy_mod_scripting_core/src/runtime.rs create mode 100644 crates/bevy_mod_scripting_core/src/script.rs delete mode 100644 crates/bevy_script_api/Cargo.toml delete mode 100644 crates/bevy_script_api/readme.md delete mode 100644 crates/bevy_script_api/src/common/bevy/mod.rs delete mode 100644 crates/bevy_script_api/src/common/mod.rs delete mode 100644 crates/bevy_script_api/src/common/std.rs delete mode 100644 crates/bevy_script_api/src/core_providers.rs delete mode 100644 crates/bevy_script_api/src/error.rs delete mode 100644 crates/bevy_script_api/src/lib.rs delete mode 100644 crates/bevy_script_api/src/lua/bevy/mod.rs delete mode 100644 crates/bevy_script_api/src/lua/mod.rs delete mode 100644 crates/bevy_script_api/src/lua/std.rs delete mode 100644 crates/bevy_script_api/src/lua/util.rs delete mode 100644 crates/bevy_script_api/src/providers/bevy_core.rs delete mode 100644 crates/bevy_script_api/src/providers/bevy_ecs.rs delete mode 100644 crates/bevy_script_api/src/providers/bevy_hierarchy.rs delete mode 100644 crates/bevy_script_api/src/providers/bevy_input.rs delete mode 100644 crates/bevy_script_api/src/providers/bevy_reflect.rs delete mode 100644 crates/bevy_script_api/src/providers/bevy_time.rs delete mode 100644 crates/bevy_script_api/src/providers/bevy_transform.rs delete mode 100644 crates/bevy_script_api/src/providers/bevy_window.rs delete mode 100644 crates/bevy_script_api/src/providers/mod.rs delete mode 100644 crates/bevy_script_api/src/rhai/bevy/mod.rs delete mode 100644 crates/bevy_script_api/src/rhai/mod.rs delete mode 100644 crates/bevy_script_api/src/rhai/std.rs delete mode 100644 crates/bevy_script_api/src/script_ref.rs delete mode 100644 crates/bevy_script_api/src/sub_reflect.rs delete mode 100644 crates/bevy_script_api/src/wrappers.rs delete mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings.rs create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/traits.rs delete mode 100644 crates/languages/bevy_mod_scripting_rhai/src/assets.rs delete mode 100644 crates/languages/bevy_mod_scripting_rhai/src/docs.rs delete mode 100644 crates/languages/bevy_mod_scripting_rune/src/assets.rs delete mode 100644 crates/languages/bevy_mod_scripting_rune/src/docs.rs diff --git a/.vscode/settings.json b/.vscode/settings.json index c6115b53..51072e25 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,8 +10,8 @@ }, "rust-analyzer.rustc.source": "discover", "rust-analyzer.linkedProjects": [ - "./crates/bevy_api_gen/Cargo.toml", - "./crates/macro_tests/Cargo.toml", + // "./crates/bevy_api_gen/Cargo.toml", + // "./crates/macro_tests/Cargo.toml", "Cargo.toml", ], "rust-analyzer.check.invocationStrategy": "per_workspace", diff --git a/Cargo.toml b/Cargo.toml index b1ae0117..d7462c0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ luajit = ["bevy_mod_scripting_lua/luajit", "lua"] luajit52 = ["bevy_mod_scripting_lua/luajit52", "lua"] # optional -lua_script_api = ["bevy_script_api/lua"] +# 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"] @@ -55,7 +55,7 @@ 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"] ## rune rune = ["bevy_mod_scripting_rune"] @@ -66,7 +66,7 @@ bevy_mod_scripting_core = { workspace = true } bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.6.0", optional = true } bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.6.0", optional = true } bevy_mod_scripting_rune = { path = "crates/languages/bevy_mod_scripting_rune", version = "0.6.0", optional = true } -bevy_script_api = { path = "crates/bevy_script_api", version = "0.6.0", optional = true } +# bevy_script_api = { path = "crates/bevy_script_api", version = "0.6.0", optional = true } [workspace.dependencies] @@ -84,8 +84,7 @@ rhai-rand = "0.1" [workspace] members = [ "crates/bevy_mod_scripting_core", - "crates/bevy_event_priority", - "crates/bevy_script_api", + # "crates/bevy_script_api", "crates/languages/bevy_mod_scripting_lua", "crates/languages/bevy_mod_scripting_lua_derive", "crates/languages/bevy_mod_scripting_rhai", diff --git a/assets/scripts/event_recipients.lua b/assets/scripts/event_recipients.lua index 2aa50e25..c4679656 100644 --- a/assets/scripts/event_recipients.lua +++ b/assets/scripts/event_recipients.lua @@ -1,4 +1,3 @@ function on_event(id) - print(string.format("on_event, script_id: %d, Handling:", script_id)) - print(string.format("\t-> id: %d", id)) + print(string.format("LUA: event_recipients::on_event(%d) called on entity: %s", id, entity)) end diff --git a/check.sh b/check.sh index d2754df1..130fa7f3 100755 --- a/check.sh +++ b/check.sh @@ -7,5 +7,5 @@ if [[ "$CURRENT_DIR" == "bevy_api_gen" ]]; then elif [[ "$CURRENT_DIR" == "macro_tests" ]]; then cargo clippy --all-targets --message-format=json else - cargo clippy --workspace --all-targets --message-format=json --features="lua54 lua_script_api rhai rhai_script_api teal rune bevy/file_watcher bevy/multi-threaded" + cargo clippy --all-targets --workspace --message-format=json --features="lua54 rhai teal rune bevy/file_watcher bevy/multi-threaded" fi \ No newline at end of file diff --git a/crates/bevy_api_gen/src/args.rs b/crates/bevy_api_gen/src/args.rs index 15e0d3f8..6582e949 100644 --- a/crates/bevy_api_gen/src/args.rs +++ b/crates/bevy_api_gen/src/args.rs @@ -188,7 +188,12 @@ pub enum Command { /// The name of the API, this will be passed to the `collect.rs` template, which by default will be used as the APIProvider name and the /// title of the documentation. - #[arg(short, long, value_name = "NAME", default_value = "LuaBevyAPIProvider")] + #[arg( + short, + long, + value_name = "NAME", + default_value = "LuaBevyScriptingPlugin" + )] api_name: String, }, } diff --git a/crates/bevy_api_gen/templates/footer.tera b/crates/bevy_api_gen/templates/footer.tera index 2e550553..05083f92 100644 --- a/crates/bevy_api_gen/templates/footer.tera +++ b/crates/bevy_api_gen/templates/footer.tera @@ -16,46 +16,32 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { } } -pub struct {{ "A P I Provider" | prefix_cratename | convert_case(case="upper_camel")}}; -impl bevy_mod_scripting_core::hosts::APIProvider for {{ "A P I Provider" | prefix_cratename | convert_case(case="upper_camel") }} { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - - fn attach_api(&mut self, ctx: &mut Self::APITarget) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx - .get_mut() - .expect("Unable to acquire lock on Lua context"); - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx) - .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other(e.to_string())) - } - - fn get_doc_fragment(&self) -> Option { - Some(bevy_mod_scripting_lua::docs::LuaDocFragment::new("{{ "A P I" | prefix_cratename | convert_case(case="upper_camel") }}", |tw| { - tw - .document_global_instance::().expect("Something went wrong documenting globals") - {% for item in items %} - .process_type::<{{ item.ident | prefix_lua }}>() - {% if item.has_static_methods %} - .process_type::>() - {% endif %} - {% endfor %} - } - )) - } +fn {{ "ContextInitializer" | prefix_cratename | convert_case(case="snake") }} (_: &bevy_mod_scripting_core::script::ScriptId, ctx: &mut bevy_mod_scripting_lua::prelude::Lua) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } +pub struct {{ "ScriptingPlugin" | prefix_cratename | convert_case(case="upper_camel")}}; - fn register_with_app(&self, app: &mut bevy::app::App) { +impl bevy::app::Plugin for {{ "ScriptingPlugin" | prefix_cratename | convert_case(case="upper_camel")}} { + fn build(&self, app: &mut bevy::prelude::App) { {% for item in items %} app.register_foreign_lua_type::<{{ item.import_path }}>(); {% endfor %} + app.add_context_initializer::<()>({{ "ContextInitializer" | prefix_cratename | convert_case(case="snake") }}); + app.add_documentation_fragment( + bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new("{{ "A P I" | prefix_cratename | convert_case(case="upper_camel") }}", |tw| { + tw + .document_global_instance::().expect("Something went wrong documenting globals") + {% for item in items %} + .process_type::<{{ item.ident | prefix_lua }}>() + {% if item.has_static_methods %} + .process_type::>() + {% endif %} + {% endfor %} + } + ) + ); } } \ No newline at end of file diff --git a/crates/bevy_api_gen/templates/header.tera b/crates/bevy_api_gen/templates/header.tera index e40a725a..67f3dbe4 100644 --- a/crates/bevy_api_gen/templates/header.tera +++ b/crates/bevy_api_gen/templates/header.tera @@ -12,4 +12,5 @@ use super::{{crate}}::*; extern crate self as bevy_script_api; {% endif %} -use bevy_script_api::{lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld}; \ No newline at end of file +use bevy_script_api::{lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld}; +use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; \ No newline at end of file diff --git a/crates/bevy_api_gen/templates/mod.tera b/crates/bevy_api_gen/templates/mod.tera index f63f56f6..7f7a7ed7 100644 --- a/crates/bevy_api_gen/templates/mod.tera +++ b/crates/bevy_api_gen/templates/mod.tera @@ -11,53 +11,14 @@ extern crate self as bevy_script_api; {% endif %} -use bevy_mod_scripting_core::docs::DocFragment; - - pub struct {{ api_name }}; -impl bevy_mod_scripting_core::hosts::APIProvider for {{ api_name }} { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - - fn attach_api(&mut self, ctx: &mut Self::APITarget) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - {% for crate in crates %} - {% set crate_name = crate.name %} - {{ crate_name }}::{{ "A P I Provider" | prefix(val=crate_name) | convert_case(case="upper_camel")}}.attach_api(ctx)?; - {% endfor %} - Ok(()) - } - - fn get_doc_fragment(&self) -> Option { - [ +impl bevy::app::Plugin for {{ api_name }} { + fn build(&self, app: &mut bevy::prelude::App) { {% for crate in crates %} - {% set crate_name = crate.name %} - {{ crate_name }}::{{ "A P I Provider" | prefix(val=crate_name) | convert_case(case="upper_camel")}}.get_doc_fragment(), - {% endfor %} - ] - .into_iter() - .filter_map(|a: Option<_>| a) - .fold(None, |a, b| match a { - Some(a) => Some(a.merge(b)), - None => Some(b), - }) - } - - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - - fn register_with_app(&self, app: &mut bevy::app::App) { - {% for crate in crates %} - {% set crate_name = crate.name %} - {{ crate_name }}::{{ "A P I Provider" | prefix(val=crate_name) | convert_case(case="upper_camel")}}.register_with_app(app); + {% set crate_name = crate.name %} + {{ crate_name }}::{{ "ScriptingPlugin" | prefix(val=crate_name) | convert_case(case="upper_camel")}}.build(app); {% endfor %} } } - {% endfilter %} \ No newline at end of file diff --git a/crates/bevy_event_priority/Cargo.toml b/crates/bevy_event_priority/Cargo.toml deleted file mode 100644 index b6f3594f..00000000 --- a/crates/bevy_event_priority/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "bevy_event_priority" -version = "0.6.0" -authors = ["Maksymilian Mozolewski "] -edition = "2021" -license = "MIT OR Apache-2.0" -description = "Bevy plugin providing priority based event handling" -repository = "https://github.com/makspll/bevy_mod_scripting" -homepage = "https://github.com/makspll/bevy_mod_scripting" -keywords = ["bevy", "gamedev", "scripting", "lua"] -categories = ["game-development"] -readme = "readme.md" - - -[lib] -name = "bevy_event_priority" -path = "src/lib.rs" - -[dependencies] -bevy = { workspace = true, default-features = false } diff --git a/crates/bevy_event_priority/readme.md b/crates/bevy_event_priority/readme.md deleted file mode 100644 index d29e4756..00000000 --- a/crates/bevy_event_priority/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# bevy_event_priority - -This crate is a part of the ["bevy_mod_scripting" workspace](https://github.com/makspll/bevy_mod_scripting). \ No newline at end of file diff --git a/crates/bevy_event_priority/src/lib.rs b/crates/bevy_event_priority/src/lib.rs deleted file mode 100644 index 98e7546e..00000000 --- a/crates/bevy_event_priority/src/lib.rs +++ /dev/null @@ -1,412 +0,0 @@ -use bevy::ecs::system::SystemParam; -use bevy::prelude::*; -use std::marker::PhantomData; -use std::sync::atomic::Ordering::Relaxed; -use std::{collections::BinaryHeap, sync::atomic::AtomicU32}; - -pub trait PriorityEvent: Send + Sync + 'static {} -impl PriorityEvent for E {} - -#[derive(Debug)] -struct EventInstance { - prio: u32, - event_id: u32, - event: E, -} - -impl EventInstance { - fn new(event: E, prio: u32) -> Self { - static COUNTER: AtomicU32 = AtomicU32::new(0); - - Self { - prio, - event_id: COUNTER.fetch_add(1, Relaxed), - event, - } - } -} - -impl PartialEq for EventInstance { - fn eq(&self, other: &Self) -> bool { - self.prio == other.prio && self.event_id == other.event_id - } -} -impl Eq for EventInstance {} - -impl Ord for EventInstance { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - match self.prio.cmp(&other.prio) { - std::cmp::Ordering::Equal => self.event_id.cmp(&other.event_id), - v => v, - } - .reverse() - } -} -impl PartialOrd for EventInstance { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -impl Clone for EventInstance { - fn clone(&self) -> Self { - Self { - prio: self.prio, - event_id: self.event_id, - event: self.event.clone(), - } - } -} - -/// An event priority queue. -/// Used when the ordering of events should be influenced by other factors. -/// This implementation does NOT provide double buffering. -/// Writers and readers are expected to remove events as soon as they are read, -/// this implies a one to one mapping between events and event handlers. -#[derive(Debug, Resource)] -pub struct PriorityEvents { - events: BinaryHeap>, -} - -impl Default for PriorityEvents { - fn default() -> Self { - Self { - events: BinaryHeap::new(), - } - } -} - -#[derive(SystemParam)] -pub struct PriorityEventReader<'w, 's, E: PriorityEvent> { - events: ResMut<'w, PriorityEvents>, - #[system_param(ignore)] - marker: PhantomData<&'s usize>, -} - -pub struct PriorityIterator<'w, E: PriorityEvent> { - min: u32, - max: u32, - events: &'w mut PriorityEvents, -} - -impl<'w, E: PriorityEvent> Iterator for PriorityIterator<'w, E> { - type Item = E; - - fn next(&mut self) -> Option { - while let Some(e) = self.events.events.peek() { - if e.prio > self.min { - return None; - } else if e.prio < self.max { - // discard events which should have already run - self.events.events.pop(); - } else { - break; - }; - } - - self.events.events.pop().map(|e| e.event) - } -} - -impl<'s, E: PriorityEvent> PriorityEventReader<'_, 's, E> { - /// Iterates over events this reader has not seen yet, while also clearing them. - /// Will not remove any events of priority lower than min (0 is highest, inf is lowest) - /// but will discard events of higher priority - /// i.e. will handle events in the priority range [min,max] (inclusive) - pub fn iter_prio_range(&mut self, max: u32, min: u32) -> impl Iterator + '_ { - PriorityIterator { - min, - max, - events: self.events.as_mut(), - } - } - - /// Determines the number of events available to be read, without consuming any - pub fn len(&self) -> usize { - self.events.events.len() - } - - /// Determines if there are any events to be read, without consuming any. - pub fn is_empty(&self) -> bool { - self.len() == 0 - } -} - -#[derive(SystemParam)] -pub struct PriorityEventWriter<'w, 's, E: PriorityEvent> { - events: ResMut<'w, PriorityEvents>, - - #[system_param(ignore)] - marker: PhantomData<&'s usize>, -} - -impl<'w, 's, E: PriorityEvent> PriorityEventWriter<'w, 's, E> { - pub fn send(&mut self, event: E, prio: u32) { - self.events.events.push(EventInstance::new(event, prio)); - } - - pub fn send_batch(&mut self, events: impl Iterator, prio: u32) { - self.events - .events - .extend(events.map(|v| EventInstance::new(v, prio))) - } - - pub fn send_default(&mut self, prio: u32) - where - E: Default, - { - self.events - .events - .push(EventInstance::new(E::default(), prio)) - } -} - -/// a convenience for initialising prioritised event types -pub trait AddPriorityEvent { - fn add_priority_event(&mut self) -> &mut Self; -} - -impl AddPriorityEvent for App { - fn add_priority_event(&mut self) -> &mut Self { - self.init_resource::>(); - - self - } -} - -#[cfg(test)] -mod tests { - use bevy::{ecs::system::SystemState, prelude::World}; - - use super::*; - - #[derive(Copy, Clone, PartialEq, Eq, Debug)] - struct TestEvent(usize); - - fn collect_events(events: BinaryHeap>) -> Vec { - events - .into_sorted_vec() - .iter() - .map(|e| e.event) - .rev() - .collect() - } - - #[test] - fn test_events() { - let mut world = World::new(); - let mut state_writer: SystemState> = - SystemState::new(&mut world); - let mut state_reader: SystemState> = - SystemState::new(&mut world); - - world.init_resource::>(); - - // stage 1 - - { - let mut w = state_writer.get_mut(&mut world); - - // system writes three events, out of order - w.send(TestEvent(0), 5); - w.send(TestEvent(1), 1); - w.send(TestEvent(2), 0); - } - - // events are send and ordered in decreasing priority order - assert_eq!( - collect_events(world.resource::>().events.clone()), - vec![TestEvent(2), TestEvent(1), TestEvent(0)] - ); - - // stage 2 - - { - let mut w = state_reader.get_mut(&mut world); - - // system reads only top event - w.iter_prio_range(0, 0).for_each(drop); - } - - // first event is consumed immediately - assert_eq!( - collect_events(world.resource::>().events.clone()), - vec![TestEvent(1), TestEvent(0)] - ); - - // stage 3 - - { - let mut w = state_reader.get_mut(&mut world); - - // system reads all events - w.iter_prio_range(1, 5).for_each(drop); - } - - // first event is consumed immediately - assert_eq!( - collect_events(world.resource::>().events.clone()), - Vec::default() - ); - } - - #[test] - fn test_not_cleared_events() { - let mut world = World::new(); - let mut state_writer: SystemState> = - SystemState::new(&mut world); - let mut state_reader: SystemState> = - SystemState::new(&mut world); - - world.init_resource::>(); - - // two systems run at different frequencies, both serve non-overlapping priorities - - // stage 1 - // system sends events of lower priority than it serves - { - let mut w = state_writer.get_mut(&mut world); - - w.send(TestEvent(0), 1); - } - { - let mut w = state_reader.get_mut(&mut world); - - w.iter_prio_range(0, 0).for_each(drop); - } - - assert_eq!( - collect_events(world.resource::>().events.clone()), - vec![TestEvent(0)] - ); - - // stage 2 - // same system runs writes another of the same event - - { - let mut w = state_writer.get_mut(&mut world); - - w.send(TestEvent(0), 1); - } - { - let mut w = state_reader.get_mut(&mut world); - - w.iter_prio_range(0, 0).for_each(drop); - } - - assert_eq!( - collect_events(world.resource::>().events.clone()), - vec![TestEvent(0), TestEvent(0)] - ); - - // stage 3 - // this time another system runs clearing those events - { - let mut w = state_reader.get_mut(&mut world); - - w.iter_prio_range(1, 1).for_each(drop); - } - assert_eq!( - collect_events(world.resource::>().events.clone()), - Vec::default() - ); - } - - #[test] - fn test_higher_prio_destroyed() { - let mut world = World::new(); - let mut state_writer: SystemState> = - SystemState::new(&mut world); - let mut state_reader: SystemState> = - SystemState::new(&mut world); - - world.init_resource::>(); - - // two systems run at different frequencies, both serve non-overlapping priorities - - // stage 1 - // system sends events of higher priority than another serves - { - let mut w = state_writer.get_mut(&mut world); - - w.send(TestEvent(0), 0); - } - - // stage 2 - // system receives event of higher priority than it serves - { - let mut w = state_reader.get_mut(&mut world); - - // event is not read but discarded - assert_eq!( - w.iter_prio_range(1, 1).collect::>(), - Vec::default() - ); - } - - // the event is cleared - assert_eq!( - collect_events(world.resource::>().events.clone()), - vec![] - ); - } - - #[test] - fn test_prio_range() { - let mut world = World::new(); - let mut state_writer: SystemState> = - SystemState::new(&mut world); - let mut state_reader: SystemState> = - SystemState::new(&mut world); - - world.init_resource::>(); - - // two systems run at different frequencies, both serve non-overlapping priorities - - // stage 1 - // system sends events of various priorities - { - let mut w = state_writer.get_mut(&mut world); - - w.send(TestEvent(0), 0); - w.send(TestEvent(1), 1); - w.send(TestEvent(2), 2); - w.send(TestEvent(3), 3); - w.send(TestEvent(4), 4); - w.send(TestEvent(5), 5); - } - - // stage 2 - // multiple systems in order of priority remove them one by one - { - let mut w = state_reader.get_mut(&mut world); - - assert_eq!( - w.iter_prio_range(0, 1).collect::>(), - vec![TestEvent(0), TestEvent(1)] - ); - - assert_eq!( - w.iter_prio_range(2, 2).collect::>(), - vec![TestEvent(2)] - ); - - assert_eq!( - w.iter_prio_range(3, 3).collect::>(), - vec![TestEvent(3)] - ); - - // 4 is discarded - assert_eq!( - w.iter_prio_range(5, 5).collect::>(), - vec![TestEvent(5)] - ); - } - - // the events are all cleared - assert_eq!( - collect_events(world.resource::>().events.clone()), - vec![] - ); - } -} diff --git a/crates/bevy_mod_scripting_core/Cargo.toml b/crates/bevy_mod_scripting_core/Cargo.toml index 4a005fee..12297108 100644 --- a/crates/bevy_mod_scripting_core/Cargo.toml +++ b/crates/bevy_mod_scripting_core/Cargo.toml @@ -22,8 +22,7 @@ doc_always = [] [dependencies] bevy = { workspace = true, default-features = false, features = ["bevy_asset"] } -bevy_event_priority = { path = "../bevy_event_priority", version = "0.6.0" } thiserror = "1.0.31" paste = "1.0.7" parking_lot = "0.12.1" -anyhow = "1.0.75" +lockable = "0.0.8" diff --git a/crates/bevy_mod_scripting_core/src/allocator.rs b/crates/bevy_mod_scripting_core/src/allocator.rs index d943538b..50384939 100644 --- a/crates/bevy_mod_scripting_core/src/allocator.rs +++ b/crates/bevy_mod_scripting_core/src/allocator.rs @@ -1,37 +1,73 @@ use bevy::ecs::system::Resource; use bevy::reflect::Reflect; - +use std::cell::UnsafeCell; +use std::collections::HashMap; +use std::fmt::{Display, Formatter}; +use std::rc::Rc; use std::sync::Arc; -use std::collections::HashMap; +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] +pub struct ReflectAllocationId(pub(self) usize); +impl ReflectAllocationId { + pub fn id(&self) -> usize { + self.0 + } +} -pub type AllocationId = usize; +#[derive(Clone, Debug)] +pub struct ReflectAllocation(pub(self) Arc>); + +unsafe impl Send for ReflectAllocation {} +unsafe impl Sync for ReflectAllocation {} + +impl ReflectAllocation { + pub fn get_ptr(&self) -> *mut dyn Reflect { + self.0.get() + } + pub fn new(value: Arc>) -> Self { + Self(value) + } +} + +impl Display for ReflectAllocationId { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} /// Allocator used to allocate and deallocate `dyn Reflect` values /// Used to be able to ensure we have a "common root" for values allocated outside the world. #[derive(Resource, Default)] pub struct ReflectAllocator { // TODO: experiment with object pools, sparse set etc. - pub allocations: HashMap>, + allocations: HashMap, } impl ReflectAllocator { /// Allocates a new [`Reflect`] value and returns an [`AllocationId`] which can be used to access it later - pub fn allocate(&mut self, value: Arc) -> AllocationId { - let id = self.allocations.len(); + pub fn allocate(&mut self, value: ReflectAllocation) -> ReflectAllocationId { + let id = ReflectAllocationId(self.allocations.len()); self.allocations.insert(id, value); id } + pub fn get(&self, id: ReflectAllocationId) -> Option { + self.allocations.get(&id).cloned() + } + + pub fn get_mut(&self, id: ReflectAllocationId) -> Option { + self.allocations.get(&id).cloned() + } + /// Deallocates the [`Reflect`] value with the given [`AllocationId`] - pub fn deallocate(&mut self, id: AllocationId) { + pub fn deallocate(&mut self, id: ReflectAllocationId) { self.allocations.remove(&id); } /// Runs a garbage collection pass on the allocations, removing any allocations which have no more strong references /// Needs to be run periodically to prevent memory leaks pub fn clean_garbage_allocations(&mut self) { - self.allocations.retain(|_, v| Arc::strong_count(v) > 1); + self.allocations.retain(|_, v| Arc::strong_count(&v.0) > 1); } } @@ -42,7 +78,7 @@ mod test { #[test] fn test_reflect_allocator() { let mut allocator = ReflectAllocator::default(); - let value = Arc::new(0); + let value = ReflectAllocation::new(Arc::new(UnsafeCell::new(0))); allocator.allocate(value.clone()); assert_eq!(allocator.allocations.len(), 1); drop(value); diff --git a/crates/bevy_mod_scripting_core/src/asset.rs b/crates/bevy_mod_scripting_core/src/asset.rs index 1dc86bb2..9369203a 100644 --- a/crates/bevy_mod_scripting_core/src/asset.rs +++ b/crates/bevy_mod_scripting_core/src/asset.rs @@ -1,8 +1,88 @@ -use bevy::asset::Asset; +use std::{ + borrow::Cow, + path::{Path, PathBuf}, +}; -/// All code assets share this common interface. -/// When adding a new code asset don't forget to implement asset loading -/// and inserting appropriate systems when registering with the app -pub trait CodeAsset: Asset { - fn bytes(&self) -> &[u8]; +use bevy::{ + asset::{Asset, AssetLoader, AsyncReadExt}, + ecs::system::Resource, + reflect::TypePath, + utils::BoxedFuture, +}; + +use crate::{prelude::ScriptError, script::ScriptId}; + +/// Represents a script loaded into memory as an asset +#[derive(Asset, TypePath)] +pub struct ScriptAsset { + pub content: Box<[u8]>, + /// The virtual filesystem path of the asset, used to map to the script Id for asset backed scripts + pub asset_path: PathBuf, + pub language: Cow<'static, str>, +} + +pub struct ScriptAssetLoader { + /// Used to set the language of the script + pub language: Cow<'static, str>, + /// The file extensions this loader should handle + pub extensions: &'static [&'static str], + /// preprocessor to run on the script before saving the content to an asset + pub preprocessor: Option Result<(), ScriptError> + Send + Sync>>, +} + +impl AssetLoader for ScriptAssetLoader { + type Asset = ScriptAsset; + + type Settings = (); + + type Error = ScriptError; + + fn load<'a>( + &'a self, + reader: &'a mut bevy::asset::io::Reader<'_>, + _settings: &'a Self::Settings, + load_context: &'a mut bevy::asset::LoadContext<'_>, + ) -> BoxedFuture<'a, Result> { + Box::pin(async move { + let mut content = Vec::new(); + reader + .read_to_end(&mut content) + .await + .map_err(|e| ScriptError::new_with_context(load_context.asset_path(), e.into()))?; + if let Some(processor) = &self.preprocessor { + processor(&mut content)?; + } + let asset = ScriptAsset { + content: content.into_boxed_slice(), + asset_path: load_context.path().to_owned(), + language: self.language.clone(), + }; + Ok(asset) + }) + } + + fn extensions(&self) -> &[&str] { + self.extensions + } +} + +#[derive(Clone, Copy, Resource)] +pub struct ScriptAssetSettings { + pub script_id_mapper: AssetPathToScriptIdMapper, +} + +impl Default for ScriptAssetSettings { + fn default() -> Self { + Self { + script_id_mapper: AssetPathToScriptIdMapper { + map: (|path: &Path| path.to_string_lossy().into_owned().into()), + }, + } + } +} + +/// Strategy for mapping asset paths to script ids, by default this is the identity function +#[derive(Clone, Copy)] +pub struct AssetPathToScriptIdMapper { + pub map: fn(&Path) -> ScriptId, } diff --git a/crates/bevy_mod_scripting_core/src/bindings.rs b/crates/bevy_mod_scripting_core/src/bindings.rs index 997b704e..2dbd3c06 100644 --- a/crates/bevy_mod_scripting_core/src/bindings.rs +++ b/crates/bevy_mod_scripting_core/src/bindings.rs @@ -4,8 +4,14 @@ //! reflection gives us access to `dyn Reflect` objects via their type name, //! Scripting languages only really support `Clone` objects so if we want to support references, //! we need wrapper types which have owned and ref variants. -use parking_lot::RwLock; -use std::{any::TypeId, cell::RefCell, collections::HashMap, marker::PhantomData, sync::Arc}; +use lockable::LockableHashMap; + +use std::{ + any::TypeId, + marker::PhantomData, + sync::{Arc, Weak}, + time::Duration, +}; use bevy::{ ecs::{ @@ -21,35 +27,91 @@ use bevy::{ }, }; -use crate::{allocator::AllocationId, error::ReflectionError}; - -/// A wrapper for a `dyn Reflect` struct, can either be owned or a reference -pub enum Wrapper { - Owned(Arc, AllocationId), - Ref(ReflectReference), -} +use crate::{allocator::ReflectAllocationId, error::ReflectionError, prelude::ReflectAllocator}; /// Describes kinds of base value we are accessing via reflection -#[derive(PartialEq, Eq, Copy, Clone)] +#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] pub enum ReflectAccessKind { ComponentOrResource, - Owned, + Allocation, } /// Describes the id pointing to the base value we are accessing via reflection, for components and resources this is the ComponentId /// for script owned values this is an allocationId, this is used to ensure we have permission to access the value. -#[derive(PartialEq, Eq, Copy, Clone)] +#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] pub struct ReflectAccessId { kind: ReflectAccessKind, id: usize, } +impl ReflectAccessId { + pub fn new_component_or_resource_id(id: ComponentId) -> Self { + Self { + kind: ReflectAccessKind::ComponentOrResource, + id: id.index(), + } + } + + pub fn new_owned_id(id: ReflectAllocationId) -> Self { + Self { + kind: ReflectAccessKind::Allocation, + id: id.id(), + } + } +} +/// While [`WorldAccessGuard`] prevents aliasing at runtime and also makes sure world exists as long as the guard itself, +/// borrows sadly do not persist the script-host boundary :(. That is to be expected, but instead we can make an abstraction which removes the lifetime parameter, making the outer type 'static, +/// while making sure the lifetime is still satisfied! +#[derive(Clone)] +pub struct WorldCallbackAccess(Weak>); + +impl WorldCallbackAccess { + /// Wraps a callback which requires access to the world in a 'static way via [`WorldCallbackAccess`]. + pub fn with_callback_access( + world: &mut World, + callback: impl FnOnce(&WorldCallbackAccess) -> T, + ) -> T { + // - the world cannot be dropped before the world drops since we have mutable reference to it in this entire function + // - nothing can alias inappropriately WorldAccessGuard since it's only instance is behind the raw Arc + let world_guard = Arc::new(WorldAccessGuard::new(world)); + let world_guard = unsafe { WorldCallbackAccess::new(Arc::downgrade(&world_guard)) }; + + callback(&world_guard) + } + + /// Creates a new [`WorldCallbackAccess`] with an erased lifetime. + /// + /// # Safety + /// - The caller must ensure the [`WorldAccessGuard`] must not outlive the 'w lifetime + /// - In practice this means that between the moment the original Arc is dropped, the lifetime 'w must be valid + /// - I.e. you *must* drop the original [`Arc`] before the original 'w scope ends + pub unsafe fn new<'w>(world: Weak>) -> Self { + // Safety: the caller ensures `WorldAccessGuard` does not outlive the original lifetime 'w + + let world = unsafe { + std::mem::transmute::>, Weak>>( + world, + ) + }; + + Self(world) + } + + /// Attempts to read the world access guard, if it still exists + pub fn read(&self) -> Option>> { + self.0.upgrade() + } +} + +/// Unit of world access +pub type WorldAccessUnit<'w> = WorldAccessWrite<'w>; + /// Provides safe access to the world via [`WorldAccess`] permissions, which enforce aliasing rules at runtime in multi-thread environments #[derive(Clone)] pub struct WorldAccessGuard<'w> { cell: UnsafeWorldCell<'w>, - // TODO: lotta indirection here, can we make this better? - accesses: RefCell>>>>, + // TODO: this is fairly hefty, explore other ways to hand out locks on WorldAccess + accesses: Arc>>>, } impl<'w> WorldAccessGuard<'w> { @@ -73,24 +135,76 @@ impl<'w> WorldAccessGuard<'w> { self.cell } - fn make_access_if_not_exists(&self, id: ReflectAccessId) { - self.accesses - .borrow_mut() - .entry(id.id) - .or_insert_with(|| Arc::new(RwLock::new(WorldAccess(id, PhantomData)))); + /// Tries to get access to the given reflect access id, if it's already returns `None`. If you want to wait for access, use [`WorldAccessGuard::get_access_timeout`] instead. + /// Remember to release this access once done with [`WorldAccessGuard::release_access`] or nobody else will be able to access this id!. + /// + /// Although forgetting to release access is safe, it's frankly quite rude and can lead to deadlocks. + pub fn get_access(&self, raid: ReflectAccessId) -> Option> { + let mut guard = self + .accesses + .blocking_lock(raid, lockable::SyncLimit::no_limit()) + .unwrap(); + let guard = guard.value_or_insert_with(|| { + Some(WorldAccessWrite { + raid, + _ph: PhantomData, + }) + }); + + if guard.is_some() { + guard.take() + } else { + // somebody has access to this already, we cannot access at the moment + None + } } - pub fn get_access(&self, raid: ReflectAccessId) -> Arc>> { - self.make_access_if_not_exists(raid); - let locks = self.accesses.borrow(); - let val = locks.get(&raid.id).expect("access not present"); - val.clone() + /// Blocking version of [`WorldAccessGuard::get_access`], waits for access to the given reflect access id. Will busy wait at the given intervals, untill the timeout is reached. + /// + /// # Panic + /// Will panic once access was not available after the timeout was reached + pub fn get_access_timeout( + &self, + raid: ReflectAccessId, + timeout: Duration, + interval: Duration, + ) -> WorldAccessUnit<'w> { + let mut access = self.get_access(raid); + let start = std::time::Instant::now(); + + while access.is_none() { + std::thread::sleep(interval); + access = self.get_access(raid); + if start.elapsed() > timeout { + panic!("Timeout reached while waiting for access to {:?}", raid); + } + } + access.unwrap() + } + + /// Releases access to the given reflect access id + pub fn release_access(&self, access: WorldAccessUnit<'w>) { + let mut guard = self + .accesses + .blocking_lock(access.raid, lockable::SyncLimit::no_limit()) + .unwrap(); + + let guard = guard + .value_mut() + .expect("Invariant violated, access should exist"); + + // should not be possible, we are the only ones who can instantiate WorldAccessUnit + debug_assert!( + guard.is_none(), + "Invariant violated, an access has been released by someone else already who shouldn't have been able to do so" + ); + *guard = Some(access); } /// Get access to the given component_id, this is the only way to access a component/resource safely (in the context of the world access guard) /// since you can only access this component_id through a RwLock, there is no way to break aliasing rules. /// Additionally the 'w lifetime prevents you from storing this access outside the lifetime of the underlying cell - pub fn get_component_access(&self, cid: ComponentId) -> Arc>> { + pub fn get_component_access(&self, cid: ComponentId) -> Option> { let access_id = ReflectAccessId { kind: ReflectAccessKind::ComponentOrResource, id: cid.index(), @@ -101,21 +215,23 @@ impl<'w> WorldAccessGuard<'w> { /// Get access to the given component_id, this is the only way to access a component/resource safely (in the context of the world access guard) /// since you can only access this component_id through a RwLock, there is no way to break aliasing rules. /// Additionally the 'w lifetime prevents you from storing this access outside the lifetime of the underlying cell - pub fn get_resource_access(&self, cid: ComponentId) -> Arc>> { + pub fn get_resource_access(&self, cid: ComponentId) -> Option> { self.get_component_access(cid) } - pub fn get_owned_access(&self, id: AllocationId) -> Arc>> { + /// Get access to the given allocation_id, this is the only way to access a script owned value safely (in the context of the world access guard) + pub fn get_allocation_access(&self, id: ReflectAllocationId) -> Option> { let access_id = ReflectAccessId { - kind: ReflectAccessKind::Owned, - id, + kind: ReflectAccessKind::Allocation, + id: id.id(), }; self.get_access(access_id) } + /// Get access to the given component, this is the only way to access a component/resource safely (in the context of the world access guard) pub fn get_component( &self, - access: &WorldAccess, + access: &WorldAccessWrite, entity: Entity, ) -> Result, ReflectionError> { let component_id = match self.cell.components().component_id::() { @@ -123,12 +239,10 @@ impl<'w> WorldAccessGuard<'w> { None => return Ok(None), }; - if access.0 - == (ReflectAccessId { - kind: ReflectAccessKind::ComponentOrResource, - id: component_id.index(), - }) - { + if access.can_read(ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: component_id.index(), + }) { // Safety: we have the correct access id return unsafe { Ok(self.cell.get_entity(entity).and_then(|e| e.get::())) }; } else { @@ -138,7 +252,7 @@ impl<'w> WorldAccessGuard<'w> { "Invalid access, instead got permission to read: {}", self.cell .components() - .get_info(ComponentId::new(access.0.id)) + .get_info(ComponentId::new(access.raid.id)) .map(|info| info.name()) .unwrap_or("") ), @@ -146,9 +260,10 @@ impl<'w> WorldAccessGuard<'w> { } } + /// Get access to the given component, this is the only way to access a component/resource safely (in the context of the world access guard) pub fn get_component_mut( &self, - access: &mut WorldAccess, + access: &mut WorldAccessWrite, entity: Entity, ) -> Result>, ReflectionError> { let component_id = match self.cell.components().component_id::() { @@ -156,12 +271,10 @@ impl<'w> WorldAccessGuard<'w> { None => return Ok(None), }; - if access.0 - == (ReflectAccessId { - kind: ReflectAccessKind::ComponentOrResource, - id: component_id.index(), - }) - { + if access.can_write(ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: component_id.index(), + }) { // Safety: we have the correct access id return unsafe { Ok(self.cell.get_entity(entity).and_then(|e| e.get_mut::())) }; } else { @@ -171,7 +284,7 @@ impl<'w> WorldAccessGuard<'w> { "Invalid access, instead got permission to read: {}", self.cell .components() - .get_info(ComponentId::new(access.0.id)) + .get_info(ComponentId::new(access.raid.id)) .map(|info| info.name()) .unwrap_or("") ), @@ -179,21 +292,20 @@ impl<'w> WorldAccessGuard<'w> { } } + /// Get access to the given resource pub fn get_resource( &self, - access: &WorldAccess, + access: &WorldAccessWrite, ) -> Result, ReflectionError> { let resource_id = match self.cell.components().resource_id::() { Some(id) => id, None => return Ok(None), }; - if access.0 - == (ReflectAccessId { - kind: ReflectAccessKind::ComponentOrResource, - id: resource_id.index(), - }) - { + if access.can_read(ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: resource_id.index(), + }) { // Safety: we have the correct access id return unsafe { Ok(self.cell.get_resource::()) }; } else { @@ -203,7 +315,7 @@ impl<'w> WorldAccessGuard<'w> { "Invalid access, instead got permission to read: {}", self.cell .components() - .get_info(ComponentId::new(access.0.id)) + .get_info(ComponentId::new(access.raid.id)) .map(|info| info.name()) .unwrap_or("") ), @@ -211,21 +323,20 @@ impl<'w> WorldAccessGuard<'w> { } } + /// Get access to the given resource, this is the only way to access a component/resource safely (in the context of the world access guard) pub fn get_resource_mut( &self, - access: &mut WorldAccess, + access: &mut WorldAccessWrite, ) -> Result>, ReflectionError> { let resource_id = match self.cell.components().resource_id::() { Some(id) => id, None => return Ok(None), }; - if access.0 - == (ReflectAccessId { - kind: ReflectAccessKind::ComponentOrResource, - id: resource_id.index(), - }) - { + if access.can_write(ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: resource_id.index(), + }) { // Safety: we have the correct access id return unsafe { Ok(self.cell.get_resource_mut::()) }; } else { @@ -235,7 +346,7 @@ impl<'w> WorldAccessGuard<'w> { "Invalid access, instead got permission to read: {}", self.cell .components() - .get_info(ComponentId::new(access.0.id)) + .get_info(ComponentId::new(access.raid.id)) .map(|info| info.name()) .unwrap_or("") ), @@ -250,13 +361,28 @@ impl<'w> WorldAccessGuard<'w> { /// If you do own a [`WorldAccess`] for some [`ReflectAccessId`], you can read and write to it safely. /// If you only have an immutable borrow of [`WorldAccess`] you can only read it safely. /// If you have a mutable borrow of [`WorldAccess`] you can read and write to it safely. -pub struct WorldAccess<'a>(pub ReflectAccessId, PhantomData<&'a usize>); +#[derive(Debug)] +pub struct WorldAccessWrite<'a> { + pub raid: ReflectAccessId, + pub(self) _ph: PhantomData<&'a usize>, +} + +impl<'w> WorldAccessWrite<'w> { + pub fn can_read(&self, raid: ReflectAccessId) -> bool { + self.raid == raid + } + + #[inline] + pub fn can_write(&self, raid: ReflectAccessId) -> bool { + self.can_read(raid) + } +} // pub struct /// An accessor to a `dyn Reflect` struct, stores a base ID of the type and a reflection path /// safe to build but to reflect on the value inside you need to ensure aliasing rules are upheld -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ReflectReference { pub base: ReflectBaseType, // TODO: experiment with Fixed capacity vec, boxed array etc, compromise between heap allocation and runtime cost @@ -269,67 +395,96 @@ pub struct ReflectReference { struct UnregisteredType; impl ReflectReference { + /// Returns `Ok(())` if the given access is sufficient to read the value or an appropriate error otherwise + pub fn expect_read_access<'w>( + &self, + access: &WorldAccessWrite<'w>, + type_registry: &TypeRegistry, + world: UnsafeWorldCell<'w>, + ) -> Result<(), ReflectionError> { + if !access.can_read(self.base.base_id.get_reflect_access_id()) { + Err(ReflectionError::InsufficientAccess { + base: self.base.display_with_type_name(type_registry), + reason: format!( + "Invalid access, instead got permission to read: {}", + ReflectBaseType { + type_id: world + .components() + .get_info(ComponentId::new(access.raid.id)) + .and_then(|c| c.type_id()) + .unwrap_or(TypeId::of::()), + base_id: self.base.base_id.clone() + } + .display_with_type_name(type_registry), + ) + .to_owned(), + }) + } else { + Ok(()) + } + } + + /// Returns `Ok(())` if the given access is sufficient to write to the value or an appropriate error otherwise + /// Note that this is not sufficient for write access, you also need to ensure the [`WorldAccessWrite`] won't be used to access the same value mutably elsewhere, + /// if you have a `&mut WorldAccessWrite` you can guarantee this statically. This function just checks that the access itself is for the right base with write access + pub fn expect_write_access<'w>( + &self, + access: &WorldAccessWrite<'w>, + type_registry: &TypeRegistry, + world: UnsafeWorldCell<'w>, + ) -> Result<(), ReflectionError> { + if !access.can_read(self.base.base_id.get_reflect_access_id()) { + Err(ReflectionError::InsufficientAccess { + base: self.base.display_with_type_name(type_registry), + reason: format!( + "Invalid access, instead got permission to write to: {}", + ReflectBaseType { + type_id: world + .components() + .get_info(ComponentId::new(access.raid.id)) + .and_then(|c| c.type_id()) + .unwrap_or(TypeId::of::()), + base_id: self.base.base_id.clone() + } + .display_with_type_name(type_registry), + ) + .to_owned(), + }) + } else { + Ok(()) + } + } + /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell. /// If the underlying componentId is not the same as the one we have access to, an error is returned. - pub fn reflect<'w>( - &'w self, + pub fn reflect<'w, 'c>( + &self, world: UnsafeWorldCell<'w>, - access: &WorldAccess<'w>, + access: &'c WorldAccessWrite<'w>, type_registry: &TypeRegistry, - ) -> Result<&'w dyn Reflect, ReflectionError> { - if access.0 == self.base.base_id.get_reflect_access_id() { - // Safety: since we have read access to the underlying componentId we can safely access the component - return unsafe { self.reflect_unsafe(world, type_registry) }; - } - Err(ReflectionError::InsufficientAccess { - base: self.base.display_with_type_name(type_registry), - reason: format!( - "Invalid access, instead got permission to read: {}", - ReflectBaseType { - type_id: world - .components() - .get_info(ComponentId::new(access.0.id)) - .and_then(|c| c.type_id()) - .unwrap_or(TypeId::of::()), - base_id: self.base.base_id.clone() - } - .display_with_type_name(type_registry), - ) - .to_owned(), - }) + allocator: Option<&'c ReflectAllocator>, + ) -> Result<&'c dyn Reflect, ReflectionError> { + self.expect_read_access(access, type_registry, world)?; + // Safety: since we have read access to the underlying componentId we can safely access the component + // and we can return a reference tied to its lifetime, which will prevent invalid aliasing + return unsafe { self.reflect_unsafe(world, type_registry, allocator) }; } /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell. /// If the underlying componentId is not the same as the one we have access to, an error is returned. /// /// If we are accessing a component or resource, it's marked as changed - pub fn reflect_mut<'w>( - &'w self, + pub fn reflect_mut<'w, 'c>( + &self, world: UnsafeWorldCell<'w>, - access: &mut WorldAccess<'w>, + access: &'c mut WorldAccessWrite<'w>, type_registry: &TypeRegistry, - ) -> Result<&'w mut dyn Reflect, ReflectionError> { - if access.0 == self.base.base_id.get_reflect_access_id() { - // Safety: since we have write access to the underlying reflect access id we can safely access the component - return unsafe { self.reflect_mut_unsafe(world, type_registry) }; - } - - Err(ReflectionError::InsufficientAccess { - base: self.base.display_with_type_name(type_registry), - reason: format!( - "Invalid access, instead got permission to mutate: {}", - ReflectBaseType { - type_id: world - .components() - .get_info(ComponentId::new(access.0.id)) - .and_then(|c| c.type_id()) - .unwrap_or(TypeId::of::()), - base_id: self.base.base_id.clone() - } - .display_with_type_name(type_registry), - ) - .to_owned(), - }) + allocator: Option<&'c ReflectAllocator>, + ) -> Result<&'c mut dyn Reflect, ReflectionError> { + self.expect_write_access(access, type_registry, world)?; + // Safety: since we have write access to the underlying reflect access id we can safely access the component + // and we can return a reference tied to its lifetime, which will prevent invalid aliasing + return unsafe { self.reflect_mut_unsafe(world, type_registry, allocator) }; } /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell @@ -337,13 +492,25 @@ impl ReflectReference { /// - The caller must ensure the cell has permission to access the underlying value /// - The caller must ensure no aliasing mut references to the same value exist at all at the same time pub unsafe fn reflect_unsafe<'w>( - &'w self, + &self, world: UnsafeWorldCell<'w>, type_registry: &TypeRegistry, + allocator: Option<&'w ReflectAllocator>, ) -> Result<&'w dyn Reflect, ReflectionError> { - if let ReflectBase::Owned(weak, _) = &self.base.base_id { - // safety: - return Ok(weak.as_ref()); + if let ReflectBase::Owned(id) = &self.base.base_id { + let allocator = allocator.ok_or_else(|| ReflectionError::AllocationError { + id: *id, + reason: "Allocator missing".to_owned(), + })?; + let arc = allocator + .get(*id) + .ok_or_else(|| ReflectionError::AllocationError { + id: *id, + reason: "Allocation was deallocated before it was accessed".to_owned(), + })?; + + // safety: caller promises it's fine :) + return Ok(unsafe { &*arc.get_ptr() }); }; // all Reflect types should have this derived let from_ptr_data: &ReflectFromPtr = type_registry @@ -384,15 +551,26 @@ impl ReflectReference { /// Retrieves mutable reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell /// # Safety /// - The caller must ensure the cell has permission to access the underlying value - /// - The caller must ensure no aliasing mut references to the same value exist at all at the same time + /// - The caller must ensure no other references to the same value exist at all at the same time (even if you have the correct access) pub unsafe fn reflect_mut_unsafe<'w>( - &'w self, + &self, world: UnsafeWorldCell<'w>, type_registry: &TypeRegistry, + allocator: Option<&'w ReflectAllocator>, ) -> Result<&'w mut dyn Reflect, ReflectionError> { - if let ReflectBase::Owned(weak, _) = &self.base.base_id { + if let ReflectBase::Owned(id) = &self.base.base_id { + let allocator = allocator.ok_or_else(|| ReflectionError::AllocationError { + id: *id, + reason: "Allocator missing".to_owned(), + })?; + let arc = allocator + .get_mut(*id) + .ok_or_else(|| ReflectionError::AllocationError { + id: *id, + reason: "Allocation was deallocated before it was accessed".to_owned(), + })?; // Safety: caller promises this is fine :) - return Ok(unsafe { &mut *(Arc::as_ptr(weak) as *mut _) }); + return Ok(unsafe { &mut *arc.get_ptr() }); }; // all Reflect types should have this derived @@ -435,8 +613,8 @@ impl ReflectReference { #[derive(Clone, Debug)] pub struct ReflectBaseType { - type_id: TypeId, - base_id: ReflectBase, + pub type_id: TypeId, + pub base_id: ReflectBase, } impl ReflectBaseType { @@ -461,7 +639,7 @@ impl ReflectBaseType { pub enum ReflectBase { Component(Entity, ComponentId), Resource(ComponentId), - Owned(Arc, AllocationId), + Owned(ReflectAllocationId), } impl ReflectBase { @@ -509,9 +687,9 @@ impl ReflectBase { kind: ReflectAccessKind::ComponentOrResource, id: cid.index(), }, - ReflectBase::Owned(_, id) => ReflectAccessId { - kind: ReflectAccessKind::Owned, - id: *id, + ReflectBase::Owned(id) => ReflectAccessId { + kind: ReflectAccessKind::Allocation, + id: id.id(), }, } } @@ -571,7 +749,9 @@ pub struct DeferredReflection { #[cfg(test)] mod test { - use crate::allocator::ReflectAllocator; + use std::cell::UnsafeCell; + + use crate::allocator::{ReflectAllocation, ReflectAllocator}; use super::*; use bevy::ecs::{component::Component, system::Resource, world::World}; @@ -598,6 +778,47 @@ mod test { (world, type_registry, component_id, resource_id) } + // #[test] + // fn doesnt_compile() { + // let (mut world, type_registry, c_id, _) = setup_world(); + + // let world = WorldAccessGuard::new(&mut world); + + // let reflect_ref = ReflectReference { + // base: ReflectBaseType { + // base_id: ReflectBase::Component(Entity::from_raw(0), c_id), + // type_id: TypeId::of::(), + // }, + // reflect_path: vec![], + // }; + + // let mut access = WorldAccess { + // raid: ReflectAccessId { + // kind: ReflectAccessKind::ComponentOrResource, + // id: c_id.index(), + // }, + // write: true, + // _ph: PhantomData, + // }; + + // let read = reflect_ref + // .reflect(world.as_unsafe_world_cell(), &access, None, &type_registry) + // .unwrap(); + + // // This shouldn't compile! borrow checker should prevent this + // let read_mut = reflect_ref + // .reflect_mut( + // world.as_unsafe_world_cell(), + // &mut access, + // None, + // &type_registry, + // ) + // .unwrap(); + + // drop(read); + // drop(read_mut); + // } + #[test] fn test_component_access() { let (mut world, type_registry, component_id, _) = setup_world(); @@ -629,13 +850,13 @@ mod test { ], }; - let component_access = world.get_component_access(component_id); - + let mut component_access = world.get_component_access(component_id).unwrap(); *component_reflect_ref .reflect_mut( world.as_unsafe_world_cell(), - &mut component_access.write(), + &mut component_access, &type_registry, + None, ) .unwrap() .downcast_mut::() @@ -643,7 +864,7 @@ mod test { assert_eq!( world - .get_component::(&component_access.read(), entity) + .get_component::(&component_access, entity) .unwrap() .unwrap(), &TestComponent { @@ -652,7 +873,7 @@ mod test { ); *world - .get_component_mut::(&mut component_access.write(), entity) + .get_component_mut::(&mut component_access, entity) .unwrap() .unwrap() .as_mut() = TestComponent { @@ -663,14 +884,22 @@ mod test { component_reflect_ref .reflect( world.as_unsafe_world_cell(), - &component_access.read(), - &type_registry + &component_access, + &type_registry, + None, ) .unwrap() .downcast_ref::() .unwrap(), &"typed_world".to_owned() ); + + world.release_access(component_access); + + assert!( + world.get_component_access(component_id).is_some(), + "access was not release correctly" + ); } #[test] @@ -700,13 +929,14 @@ mod test { ], }; - let resource_access = world.get_resource_access(resource_id); + let mut resource_access = world.get_resource_access(resource_id).unwrap(); *resource_reflect_ref .reflect_mut( world.as_unsafe_world_cell(), - &mut resource_access.write(), + &mut resource_access, &type_registry, + None, ) .unwrap() .downcast_mut::() @@ -714,14 +944,14 @@ mod test { assert_eq!( world - .get_resource::(&resource_access.read()) + .get_resource::(&resource_access) .unwrap() .unwrap(), &TestResource { bytes: vec![42u8] } ); *world - .get_resource_mut::(&mut resource_access.write()) + .get_resource_mut::(&mut resource_access) .unwrap() .unwrap() .as_mut() = TestResource { bytes: vec![69u8] }; @@ -730,14 +960,21 @@ mod test { resource_reflect_ref .reflect( world.as_unsafe_world_cell(), - &resource_access.read(), - &type_registry + &resource_access, + &type_registry, + None, ) .unwrap() .downcast_ref::() .unwrap(), &69u8 ); + + world.release_access(resource_access); + assert!( + world.get_resource_access(resource_id).is_some(), + "access was not release correctly" + ); } #[test] @@ -746,56 +983,72 @@ mod test { let world = WorldAccessGuard::new(&mut world); let mut script_allocator = ReflectAllocator::default(); - let allocation_id = script_allocator.allocate(Arc::new("hello".to_string())); + let allocation_id = script_allocator.allocate(ReflectAllocation::new(Arc::new( + UnsafeCell::new("hello".to_string()), + ))); let owned_reflect_ref = ReflectReference { base: ReflectBaseType { - base_id: ReflectBase::Owned( - script_allocator - .allocations - .get(&allocation_id) - .unwrap() - .clone(), - allocation_id, - ), + base_id: ReflectBase::Owned(allocation_id), type_id: TypeId::of::(), }, reflect_path: vec![], }; - let owned_access = world.get_owned_access(allocation_id); + let allocation_access = world.get_allocation_access(allocation_id).unwrap(); assert_eq!( owned_reflect_ref .reflect( world.as_unsafe_world_cell_readonly(), - &owned_access.read(), + &allocation_access, &type_registry, + Some(&script_allocator), ) .unwrap() .downcast_ref::(), Some(&String::from("hello")) ); - let onwed_access_read = owned_access.read(); assert!( - world.get_owned_access(allocation_id).try_write().is_none(), - "Mutable borrow allowed while immutable borrow exists" + world.get_allocation_access(allocation_id).is_none(), + "Multiple accesses to same base ID exist, safety violation" + ); + + world.release_access(allocation_access); + assert!( + world.get_allocation_access(allocation_id).is_some(), + "access was not release correctly" ); - drop(onwed_access_read) } #[test] + #[allow(clippy::drop_non_drop)] fn test_invalid_runtime_access() { let mut world = World::new(); let world = WorldAccessGuard::new(&mut world); let access = world.get_component_access(ComponentId::new(0)); - let access2 = world.get_component_access(ComponentId::new(0)); - let access = access.read(); assert!( - access2.try_write().is_none(), - "Immutable and Mutable borrow allowed at the same time" + world.get_component_access(ComponentId::new(0)).is_none(), + "access was allowed to alias" ); drop(access); } + + #[test] + #[should_panic] + fn test_double_release_panics() { + let mut world = World::new(); + let world = WorldAccessGuard::new(&mut world); + let access = world.get_component_access(ComponentId::new(0)).unwrap(); + world.release_access(access); + // This won't be possible in client code + world.release_access(WorldAccessWrite { + raid: ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: 0, + }, + _ph: PhantomData, + }); + } } diff --git a/crates/bevy_mod_scripting_core/src/commands.rs b/crates/bevy_mod_scripting_core/src/commands.rs new file mode 100644 index 00000000..33b90ca7 --- /dev/null +++ b/crates/bevy_mod_scripting_core/src/commands.rs @@ -0,0 +1,146 @@ +use std::marker::PhantomData; + +use bevy::{ + asset::Handle, + ecs::{system::Command, world::Mut}, + log::debug, +}; + +use crate::{ + asset::ScriptAsset, + context::{Context, ContextLoadingSettings, ScriptContexts}, + prelude::{Runtime, RuntimeContainer}, + script::{Script, ScriptId, Scripts}, +}; + +pub struct DeleteScript { + pub id: ScriptId, + // hack to make this Send, C does not need to be Send since it is not stored in the command + pub _ph: PhantomData, +} + +impl DeleteScript { + pub fn new(id: ScriptId) -> Self { + Self { + id, + _ph: PhantomData, + } + } +} + +impl Command for DeleteScript { + fn apply(self, world: &mut bevy::prelude::World) { + let settings = world + .get_resource::>() + .expect("No ScriptLoadingSettings resource found") + .clone(); + + world.resource_scope(|world, mut scripts: Mut| { + if let Some(script) = scripts.scripts.remove(&self.id) { + debug!("Deleting script with id: {}", self.id); + let mut ctxts = world.get_non_send_resource_mut::>(); + let ctxts = ctxts.as_deref_mut().unwrap(); + let assigner = settings + .assigner + .as_ref() + .expect("Could not find context assigner in settings"); + debug!("Removing script with id: {}", self.id); + (assigner.remove)(script.context_id, &script, ctxts) + } else { + bevy::log::error!( + "Attempted to delete script with id: {} but it does not exist, doing nothing!", + self.id + ); + } + }); + + world.insert_resource(settings); + } +} + +/// Creates new script with the given ID, if a script with the given ID already exists, this is treated as an update +/// +/// If script comes from an asset, expects it to be loaded, otherwise this command will fail to process the script. +pub struct CreateOrUpdateScript { + id: ScriptId, + content: Box<[u8]>, + asset: Option>, + // Hack to make this Send, C does not need to be Send since it is not stored in the command + _ph: std::marker::PhantomData, +} + +impl CreateOrUpdateScript { + pub fn new(id: ScriptId, content: Box<[u8]>, asset: Option>) -> Self { + Self { + id, + content, + asset, + _ph: std::marker::PhantomData, + } + } +} + +impl Command for CreateOrUpdateScript { + fn apply(self, world: &mut bevy::prelude::World) { + let settings = world + .get_resource::>() + .unwrap() + .clone(); + let mut contexts = world + .remove_non_send_resource::>() + .unwrap(); + let mut runtime = world + .remove_non_send_resource::>() + .unwrap(); + // assign context + let assigner = settings.assigner.clone().expect("No context assigner set"); + let builder = settings.loader.clone().expect("No context loader set"); + + world.resource_scope(|world, mut scripts: Mut| { + + // check if script already exists + + let mut script = scripts.scripts.get_mut(&self.id); + let previous_context_id = script.as_ref().map(|s| s.context_id); + debug!( + "CreateOrUpdateScript command applying with to (script_id: {}, previous_context_id: {:?})", + self.id, previous_context_id + ); + + // If None assign new context ID, otherwise assign the old one + // If re-loading and different from the previous one, the old one will be removed + let current_context_id = (assigner.assign)(script.as_deref(), &self.id, &self.content, &mut contexts); + let current_context_id = if let Some(id) = current_context_id { + id + } else { + let ctxt = (builder.load)(&self.id, &self.content, &settings.context_initializers, &settings.context_pre_handling_initializers, world, runtime.runtime.as_mut().unwrap()).unwrap(); + contexts.insert(ctxt) + }; + + if let Some(previous) = previous_context_id { + if previous != current_context_id { + debug!( + "Script is being moved to a new context with id: {}, removing up old context.", + current_context_id + ); + script.as_deref_mut().unwrap().context_id = current_context_id; + (assigner.remove)(previous, script.unwrap(), &mut contexts); + } + } + + + // now we can insert the actual script + scripts.scripts.insert( + self.id.clone(), + Script { + id: self.id, + asset: self.asset, + context_id: current_context_id, + }, + ); + }); + world.insert_resource(settings); + world.insert_non_send_resource(runtime); + world.insert_non_send_resource(contexts); + } +} diff --git a/crates/bevy_mod_scripting_core/src/context.rs b/crates/bevy_mod_scripting_core/src/context.rs new file mode 100644 index 00000000..169cd831 --- /dev/null +++ b/crates/bevy_mod_scripting_core/src/context.rs @@ -0,0 +1,152 @@ +use std::{collections::HashMap, sync::atomic::AtomicU32}; + +use bevy::ecs::{entity::Entity, system::Resource, world::World}; + +use crate::{ + prelude::{Runtime, ScriptError}, + script::{Script, ScriptId}, +}; + +pub trait Context: 'static {} +impl Context for T {} + +pub type ContextId = u32; + +#[derive(Resource)] +pub struct ScriptContexts { + pub(crate) contexts: HashMap, +} + +impl Default for ScriptContexts { + fn default() -> Self { + Self { + contexts: Default::default(), + } + } +} + +static CONTEXT_ID_COUNTER: AtomicU32 = AtomicU32::new(0); +impl ScriptContexts { + pub fn new() -> Self { + Self { + contexts: HashMap::new(), + } + } + + /// Allocates a new ContextId and inserts the context into the map + pub fn insert(&mut self, ctxt: T) -> ContextId { + let id = CONTEXT_ID_COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + self.contexts.insert(id, ctxt); + id + } + + /// Allocate new context id without inserting a context + pub fn allocate_id(&self) -> ContextId { + CONTEXT_ID_COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed) + } + + pub fn remove(&mut self, id: ContextId) -> Option { + self.contexts.remove(&id) + } +} + +/// Initializer run once after creating a context but before executing it for the first time +pub type ContextInitializer = fn(&ScriptId, &mut C) -> Result<(), ScriptError>; +/// Initializer run every time before executing or loading a script +pub type ContextPreHandlingInitializer = + fn(&ScriptId, Entity, &mut C) -> Result<(), ScriptError>; + +#[derive(Resource)] +pub struct ContextLoadingSettings { + pub loader: Option>, + pub assigner: Option>, + pub context_initializers: Vec>, + pub context_pre_handling_initializers: Vec>, +} + +impl Default for ContextLoadingSettings { + fn default() -> Self { + Self { + loader: None, + assigner: None, + context_initializers: Default::default(), + context_pre_handling_initializers: Default::default(), + } + } +} + +impl Clone for ContextLoadingSettings { + fn clone(&self) -> Self { + Self { + loader: self.loader.clone(), + assigner: self.assigner.clone(), + context_initializers: self.context_initializers.clone(), + context_pre_handling_initializers: self.context_pre_handling_initializers.clone(), + } + } +} + +/// A strategy for loading and reloading contexts +pub struct ContextBuilder { + pub load: fn( + script: &ScriptId, + content: &[u8], + &[ContextInitializer], + &[ContextPreHandlingInitializer], + &mut World, + runtime: &mut R, + ) -> Result, + pub reload: fn( + script: &ScriptId, + new_content: &[u8], + context: &mut C, + &[ContextInitializer], + &[ContextPreHandlingInitializer], + &mut World, + &mut R, + ) -> Result<(), ScriptError>, +} + +impl Clone for ContextBuilder { + fn clone(&self) -> Self { + Self { + load: self.load, + reload: self.reload, + } + } +} + +/// A strategy for assigning contexts to new and existing but re-loaded scripts as well as for managing old contexts +pub struct ContextAssigner { + /// Assign a context to the script, if script is `None`, this is a new script, otherwise it is an existing script with a context inside `contexts`. + /// Returning None means the script should be assigned a new context + pub assign: fn( + old_script: Option<&Script>, + script_id: &ScriptId, + new_content: &[u8], + contexts: &ScriptContexts, + ) -> Option, + + /// Handle the removal of the script, if any clean up in contexts is necessary perform it here. + /// This will also be called, when a script is assigned a contextId on reload different from the previous one + /// the context_id in that case will be the old context_id and the one stored in the script will be the old one + pub remove: fn(context_id: ContextId, script: &Script, contexts: &mut ScriptContexts), +} + +impl Default for ContextAssigner { + fn default() -> Self { + Self { + assign: |_, _, _, c| Some(c.allocate_id()), + remove: |id, _, c| _ = c.remove(id), + } + } +} + +impl Clone for ContextAssigner { + fn clone(&self) -> Self { + Self { + assign: self.assign, + remove: self.remove, + } + } +} diff --git a/crates/bevy_mod_scripting_core/src/docs.rs b/crates/bevy_mod_scripting_core/src/docs.rs index 8a2a2dfd..d186bcfe 100644 --- a/crates/bevy_mod_scripting_core/src/docs.rs +++ b/crates/bevy_mod_scripting_core/src/docs.rs @@ -1,10 +1,24 @@ -use crate::error::ScriptError; +use bevy::ecs::system::Resource; -/// A documentation piece exported by an `APIProvider` -pub trait DocFragment: 'static { +/// A documentation piece which can be used to make a piece of documentation, most often a module. +pub trait DocumentationFragment: 'static + Sized { + /// Merges two documentation fragments into one, retaining the title of the first fragment. fn merge(self, o: Self) -> Self; - fn gen_docs(self) -> Result<(), ScriptError>; + fn gen_docs(self) -> Result<(), Box>; /// Retrieves the name of the documentation fragment, most likely the name of your game! fn name(&self) -> &'static str; } + +#[derive(Resource)] +pub struct Documentation { + pub fragments: Vec, +} + +impl Default for Documentation { + fn default() -> Self { + Self { + fragments: Default::default(), + } + } +} diff --git a/crates/bevy_mod_scripting_core/src/error.rs b/crates/bevy_mod_scripting_core/src/error.rs index 07003bd0..c245aed8 100644 --- a/crates/bevy_mod_scripting_core/src/error.rs +++ b/crates/bevy_mod_scripting_core/src/error.rs @@ -1,31 +1,79 @@ use thiserror::Error; -#[derive(Error, Debug, Clone)] -pub enum ScriptError { - #[error("Runtime error in script `{script}` {msg}")] - RuntimeError { script: String, msg: String }, - #[error("Failed to load script asset for `{script}` {msg}")] - FailedToLoad { script: String, msg: String }, - #[error("Syntax error for script `{script}` {msg}")] - SyntaxError { script: String, msg: String }, - #[error("Callback method `{callback}` invalid for script `{script}` {msg}")] - InvalidCallback { - script: String, - callback: String, - msg: String, - }, - #[error("Failed to attach API for script `{script}` {msg}")] - FailedToAttachAPI { script: String, msg: String }, - #[error("Failed to generate documentation `{0}`")] - DocGenError(String), - #[error("{0}")] - Other(String), +use crate::{allocator::ReflectAllocationId, bindings::ReflectReference}; + +#[derive(Error, Debug)] +pub struct ScriptErrorWrapper(ScriptError); + +impl std::fmt::Display for ScriptErrorWrapper { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + +impl From for Box { + fn from(val: ScriptError) -> Self { + ScriptErrorWrapper(val).into() + } +} +/// An error with an optional script Context +#[derive(Debug)] +pub struct ScriptError { + pub script: Option, + pub additional_message: Option, + pub reason: Box, } impl ScriptError { - /// Create new `ScriptError::Other` from another error - pub fn new_other(other: T) -> Self { - Self::Other(other.to_string()) + pub fn new(reason: Box) -> Self { + Self { + script: None, + reason, + additional_message: None, + } + } + + pub fn new_with_context( + script: T, + reason: Box, + ) -> Self { + Self { + script: Some(script.to_string()), + reason, + additional_message: None, + } + } + + pub fn with_context(self, script: T) -> Self { + Self { + script: Some(script.to_string()), + reason: self.reason, + additional_message: self.additional_message, + } + } + + pub fn with_msg(self, msg: T) -> Self { + Self { + script: self.script, + reason: self.reason, + additional_message: Some(msg.to_string()), + } + } +} + +impl From for ScriptError { + fn from(value: T) -> Self { + Self::new(Box::new(value)) + } +} + +impl std::fmt::Display for ScriptError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if let Some(script) = &self.script { + write!(f, "Script `{}` failed: {}", script, self.reason) + } else { + write!(f, "Script failed: {}", self.reason) + } } } @@ -35,11 +83,17 @@ pub enum ReflectionError { InvalidBaseReference { base: String, reason: String }, #[error("Cannot safely access `{base}`. {reason}")] InsufficientAccess { base: String, reason: String }, - #[error("Insuficient provenance error while accessing `{path}`. {msg}")] - InsufficientProvenance { path: String, msg: String }, - #[error("Invalid reflection path: `{path}`. {msg}")] - InvalidReflectionPath { path: String, msg: String }, + #[error("Cannot downcast reference: {reference:?} to: {to}")] + CannotDowncast { + reference: ReflectReference, + to: String, + }, + #[error("Could not dereference script allocation with ID: {id}. {reason}")] + AllocationError { + id: ReflectAllocationId, + reason: String, + }, #[error("{0}")] Other(String), } diff --git a/crates/bevy_mod_scripting_core/src/event.rs b/crates/bevy_mod_scripting_core/src/event.rs index 7ba34707..2921d19c 100644 --- a/crates/bevy_mod_scripting_core/src/event.rs +++ b/crates/bevy_mod_scripting_core/src/event.rs @@ -1,6 +1,6 @@ -use bevy::prelude::Event; +use bevy::{ecs::entity::Entity, prelude::Event}; -use crate::{error::ScriptError, hosts::Recipients}; +use crate::{error::ScriptError, handler::Args, script::ScriptId}; /// An error coming from a script #[derive(Debug, Event)] @@ -8,15 +8,235 @@ pub struct ScriptErrorEvent { pub error: ScriptError, } -/// An event emitted when a script was loaded or re-loaded (with a hot-reload), -/// guaranteed to be sent for every script at least once and immediately after it's loaded. -#[derive(Clone, Debug, Event)] -pub struct ScriptLoaded { - pub sid: u32, +/// A string which disallows common invalid characters in callback labels, +/// particularly at the start of the string +/// +/// a valid callback label starts with a letter or underscore, and contains only ascii characters, as well as disallows some common keywords +#[derive(Clone, PartialEq, Eq, Hash, Debug)] +pub struct CallbackLabel(String); + +impl CallbackLabel { + fn filter_invalid(s: &str) -> String { + let mut out = String::with_capacity(s.len()); + let mut first = true; + for char in s.chars() { + if char == '_' + || ((!first && char.is_ascii_alphanumeric()) || char.is_ascii_alphabetic()) + { + out.push(char); + first = false; + } else { + continue; + } + } + if FORBIDDEN_KEYWORDS.contains(&s) { + String::default() + } else { + out + } + } + + pub fn new_lossy(label: &str) -> Self { + Self(Self::filter_invalid(label)) + } + + pub fn new(label: &str) -> Option { + let new_lossy = Self::new_lossy(label); + if new_lossy.0.len() != label.len() { + None + } else { + Some(new_lossy) + } + } +} + +pub trait IntoCallbackLabel { + fn into_callback_label() -> CallbackLabel; +} + +impl From<&str> for CallbackLabel { + fn from(s: &str) -> Self { + Self::new_lossy(s) + } +} +impl From for CallbackLabel { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + +impl AsRef for CallbackLabel { + fn as_ref(&self) -> &str { + &self.0 + } +} + +impl std::fmt::Display for CallbackLabel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_ref()) + } } -/// A trait for events to be handled by scripts -pub trait ScriptEvent: Send + Sync + Clone + Event + 'static { - /// Retrieves the recipient scripts for this event - fn recipients(&self) -> &Recipients; +/// Describes the designated recipients of a script event +#[derive(Clone, Debug)] +pub enum Recipients { + /// The event needs to be handled by all scripts + All, + /// The event is to be handled by a specific script + Script(ScriptId), + /// The event is to be handled by all the scripts on the specified entity + Entity(Entity), +} + +/// A callback event meant to trigger a callback in a subset/set of scripts in the world with the given arguments +#[derive(Clone, Event, Debug)] +pub struct ScriptCallbackEvent { + pub label: CallbackLabel, + pub recipients: Recipients, + pub args: A, +} + +impl ScriptCallbackEvent { + pub fn new>(label: L, args: A, recipients: Recipients) -> Self { + Self { + label: label.into(), + args, + recipients, + } + } + + pub fn new_for_all>(label: L, args: A) -> Self { + Self::new(label, args, Recipients::All) + } +} + +static FORBIDDEN_KEYWORDS: [&str; 82] = [ + // Lua + "and", + "break", + "do", + "else", + "elseif", + "end", + "false", + "for", + "function", + "if", + "in", + "local", + "nil", + "not", + "or", + "repeat", + "return", + "then", + "true", + "until", + "while", + // Rhai + "true", + "false", + "let", + "const", + "is_shared", + "if", + "else", + "switch", + "do", + "while", + "loop", + "until", + "for", + "in", + "continue", + "break", + "fn", + "private", + "is_def_fn", + "this", + "return", + "throw", + "try", + "catch", + "import", + "export", + "as", + "global", + "Fn", + "call", + "curry", + "type_of", + "print", + "debug", + "eval", + "is_def_var", + "var", + "static", + "is", + "goto", + "match", + "case", + "public", + "protected", + "new", + "use", + "with", + "module", + "package", + "super", + "spawn", + "thread", + "go", + "sync", + "async", + "await", + "yield", + "default", + "void", + "null", + "nil", +]; + +#[cfg(test)] +mod test { + use super::FORBIDDEN_KEYWORDS; + + #[test] + fn test_invalid_strings() { + FORBIDDEN_KEYWORDS.iter().for_each(|keyword| { + assert_eq!(super::CallbackLabel::new(keyword), None); + }); + } + + #[test] + fn test_bad_chars() { + let bad_chars = [ + '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '+', '=', '{', '}', '[', ']', + '|', '\\', ':', ';', '"', '\'', '<', '>', ',', '.', '?', '/', '`', '~', + ]; + bad_chars.iter().for_each(|char| { + assert_eq!(super::CallbackLabel::new(&format!("bad{}", char)), None); + }); + } + + #[test] + fn bad_first_letter() { + let bad_chars = [ + '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '@', '#', '$', '%', '^', '&', '*', + '(', ')', '-', '+', '=', '{', '}', '[', ']', '|', '\\', ':', ';', '"', '\'', '<', '>', + ',', '.', '?', '/', '`', '~', + ]; + bad_chars.iter().for_each(|char| { + assert_eq!(super::CallbackLabel::new(&format!("{}bad", char)), None); + }); + } + + #[test] + fn test_valid_idents() { + let valid = ["h", "_v", "hello", "_2d", "heloo_2", "_1231412"]; + valid.iter().for_each(|ident| { + assert!(super::CallbackLabel::new(ident).is_some()); + assert_eq!(super::CallbackLabel::new_lossy(ident).as_ref(), *ident); + }); + } } diff --git a/crates/bevy_mod_scripting_core/src/handler.rs b/crates/bevy_mod_scripting_core/src/handler.rs new file mode 100644 index 00000000..63bc1e08 --- /dev/null +++ b/crates/bevy_mod_scripting_core/src/handler.rs @@ -0,0 +1,37 @@ +use bevy::ecs::{entity::Entity, system::Resource, world::World}; + +use crate::{ + context::{Context, ContextPreHandlingInitializer}, + event::CallbackLabel, + prelude::ScriptError, + runtime::Runtime, + script::ScriptId, +}; + +pub trait Args: Clone + Send + Sync + 'static {} +impl Args for T {} + +pub type HandlerFn = fn( + args: A, + entity: Entity, + script_id: &ScriptId, + callback: &CallbackLabel, + context: &mut C, + pre_handling_initializers: &[ContextPreHandlingInitializer], + runtime: &mut R, + world: &mut World, +) -> Result<(), ScriptError>; + +/// A resource that holds the settings for the callback handler for a specific combination of type parameters +#[derive(Resource)] +pub struct CallbackSettings { + pub callback_handler: Option>, +} + +impl Default for CallbackSettings { + fn default() -> Self { + Self { + callback_handler: None, + } + } +} diff --git a/crates/bevy_mod_scripting_core/src/hosts.rs b/crates/bevy_mod_scripting_core/src/hosts.rs deleted file mode 100644 index 7318ebef..00000000 --- a/crates/bevy_mod_scripting_core/src/hosts.rs +++ /dev/null @@ -1,461 +0,0 @@ -//! All script host related stuff -use bevy::{ecs::schedule::ScheduleLabel, prelude::*}; -use std::{ - collections::HashMap, - iter::once, - sync::atomic::{AtomicU32, Ordering}, -}; - -use crate::{ - asset::CodeAsset, - docs::DocFragment, - error::ScriptError, - event::{ScriptEvent, ScriptLoaded}, -}; - -/// Describes the target set of scripts this event should -/// be handled by -#[derive(Clone, Debug)] -pub enum Recipients { - /// Send to all scripts - All, - /// Send only to scripts on the given entity - Entity(Entity), - /// Send to script with the given ID - ScriptID(u32), - // Send to script with the given name - ScriptName(String), -} - -#[derive(Debug)] -/// Data used to describe a script instance. -pub struct ScriptData<'a> { - pub sid: u32, - pub entity: Entity, - pub name: &'a str, -} - -impl Recipients { - /// Returns true if the given script is a recipient - pub fn is_recipient(&self, c: &ScriptData) -> bool { - match self { - Recipients::All => true, - Recipients::Entity(e) => e == &c.entity, - Recipients::ScriptID(i) => i == &c.sid, - Recipients::ScriptName(n) => n == c.name, - } - } -} - -impl Default for Recipients { - fn default() -> Self { - Self::All - } -} - -/// A script host is the interface between your rust application -/// and the scripts in some interpreted language. -pub trait ScriptHost: Send + Sync + 'static + Default + Resource { - /// the type of the persistent script context, representing the execution context of the script - type ScriptContext: Send + Sync + 'static; - /// the type of events picked up by lua callbacks - type ScriptEvent: ScriptEvent; - /// the type of asset representing the script files for this host - type ScriptAsset: CodeAsset; - /// the type representing the target of api providers, i.e. the - /// script engine or the script context itself - type APITarget: Send + Sync + 'static; - /// the type of each doc fragment - type DocTarget: DocFragment; - - /// Loads a script in byte array format, the script name can be used - /// to send useful errors. - fn load_script( - &mut self, - script: &[u8], - script_data: &ScriptData, - providers: &mut APIProviders, - ) -> Result; - - /// Perform one-off initialization of scripts (happens for every new or re-loaded script) - fn setup_script( - &mut self, - script_data: &ScriptData, - ctx: &mut Self::ScriptContext, - providers: &mut APIProviders, - ) -> Result<(), ScriptError>; - - /// the main point of contact with the bevy world. - /// Scripts are called with appropriate events in the event order - fn handle_events<'a>( - &mut self, - world_ptr: &mut World, - events: &[Self::ScriptEvent], - ctxs: impl Iterator, &'a mut Self::ScriptContext)>, - providers: &mut APIProviders, - ); - - /// Loads and runs script instantaneously without storing any script data into the world. - /// The script id is set to `u32::MAX`. - fn run_one_shot( - &mut self, - script: &[u8], - script_name: &str, - entity: Entity, - world: &mut World, - event: Self::ScriptEvent, - ) -> Result<(), ScriptError> { - let fd = ScriptData { - name: script_name, - sid: u32::MAX, - entity, - }; - - let mut providers: APIProviders = world.remove_resource().unwrap(); - let mut ctx = self.load_script(script, &fd, &mut providers).unwrap(); - self.setup_script(&fd, &mut ctx, &mut providers)?; - let events = [event; 1]; - - self.handle_events(world, &events, once((fd, &mut ctx)), &mut providers); - - world.insert_resource(providers); - - Ok(()) - } - - /// Registers the script host with the given app, and attaches handlers to deal with spawning/removing scripts in the given System Set. - /// - /// Ideally place after any game logic which can spawn/remove/modify scripts to avoid frame lag. (typically `PostUpdate`) - fn register_with_app(app: &mut App, schedule: impl ScheduleLabel) { - #[derive(SystemSet, Hash, Debug, Eq, PartialEq, Clone, Copy)] - struct DummySet; - - Self::register_with_app_in_set(app, schedule, DummySet); - } - - /// Similar to `register_with_app` but allows you to specify a system set to add the handler to. - fn register_with_app_in_set(app: &mut App, schedule: impl ScheduleLabel, set: impl SystemSet); -} - -/// Implementors can override the way that each callback is handled, this can be used to provide temporary values such as the word handle. -/// There can only be one [`RuntimeProvider`] per script host, so be careful about what your APIProviders expect! -pub trait RuntimeProvider: 'static { - /// The type of script context the APIProvider works with, must be the same as the ScriptContext of the target ScriptHost. - type ScriptContext: Send + Sync + 'static; - - /// the type of script engine/context the API is attached to, this must be the same as the APITarget of the ScriptHost meant to receive it. - type APITarget: Send + Sync + 'static; - - /// The type of event being handled by the runtime - type Event: Send + Sync + 'static; - - fn handle_event( - &mut self, - ctx: &mut Self::ScriptContext, - script_data: &ScriptData, - event: &Self::Event, - ) -> Result<(), ScriptError>; - - /// Provides the runtime if it's different from the context - fn get_mut(&mut self) -> Option<&mut Self::APITarget> { - None - } -} - -/// The resource containing a runtime provider for a particular set of type parameters -#[derive(Resource)] -pub struct RuntimeProviderContainer { - pub provider: Box< - dyn RuntimeProvider< - Event = H::ScriptEvent, - ScriptContext = H::ScriptContext, - APITarget = H::APITarget, - >, - >, -} - -/// Implementors can modify a script context in order to enable -/// API access. ScriptHosts call `attach_api` when creating scripts -pub trait APIProvider: 'static + Send + Sync { - /// the type of script engine/context the API is attached to, this must be the same as the APITarget of the ScriptHost meant to receive it. - type APITarget: Send + Sync + 'static; - /// The type of script context the APIProvider works with, must be the same as the ScriptContext of the target ScriptHost. - type ScriptContext: Send + Sync + 'static; - /// The type of documentation fragment produced by the APIProvider, must be the same as the DocTarget of the target ScriptHost. - type DocTarget: DocFragment; - - /// provide the given script context with the API permamently. - /// Depending on the host, API's may be attached on a per-script basis - /// or on a per-engine basis. Rhai for example allows you to decouple the State of each script from the - /// engine. For one-time setup use `Self::setup_script` - fn attach_api(&mut self, api: &mut Self::APITarget) -> Result<(), ScriptError>; - - /// Setup meant to be executed once for every single script. Use this if you need to consistently setup scripts. - /// For API's use `Self::attach_api` instead. - fn setup_script( - &mut self, - _script_data: &ScriptData, - _ctx: &mut Self::ScriptContext, - ) -> Result<(), ScriptError> { - Ok(()) - } - - /// Generate a piece of documentation to be merged with the other documentation fragments - /// provided by other API providers - fn get_doc_fragment(&self) -> Option { - None - } - - /// Some providers might provide additional types which need to be registered - /// with the reflection API to work. - fn register_with_app(&self, _app: &mut App) {} -} - -#[derive(Resource)] -/// Stores many API providers -pub struct APIProviders { - pub providers: Vec< - Box< - dyn APIProvider< - APITarget = T::APITarget, - DocTarget = T::DocTarget, - ScriptContext = T::ScriptContext, - >, - >, - >, -} - -impl Default for APIProviders { - fn default() -> Self { - Self { - providers: Default::default(), - } - } -} - -impl APIProviders { - pub fn attach_all(&mut self, ctx: &mut T::APITarget) -> Result<(), ScriptError> { - for p in self.providers.iter_mut() { - p.attach_api(ctx)?; - } - - Ok(()) - } - - pub fn setup_all( - &mut self, - script_data: &ScriptData, - ctx: &mut T::ScriptContext, - ) -> Result<(), ScriptError> { - for p in self.providers.iter_mut() { - p.setup_script(script_data, ctx)?; - } - - Ok(()) - } - - pub fn gen_all(&self) -> Result<(), ScriptError> { - let mut d: Option = None; - for p in self.providers.iter() { - if let Some(f) = p.get_doc_fragment() { - if let Some(prev) = d { - d = Some(prev.merge(f)) - } else { - d = Some(f) - } - } - } - d.map(|d| d.gen_docs()).unwrap_or_else(|| Ok(())) - } -} - -/// A resource storing the script contexts for each script instance. -/// The reason we need this is to split the world borrow in our handle event systems, but this -/// has the added benefit that users don't see the contexts at all, and we can provide -/// generic handling for each new/removed script in one place. -/// -/// We keep this public for now since there is no API for communicating with scripts -/// outside of events. Later this might change. -#[derive(Resource)] -pub struct ScriptContexts { - /// holds script contexts for all scripts given their instance ids. - /// This also stores contexts which are not fully loaded hence the Option - pub context_entities: HashMap, String)>, -} - -impl Default for ScriptContexts { - fn default() -> Self { - Self { - context_entities: Default::default(), - } - } -} - -impl ScriptContexts { - pub fn script_owner(&self, script_id: u32) -> Option { - self.context_entities.get(&script_id).map(|(e, _c, _n)| *e) - } - - pub fn insert_context(&mut self, fd: ScriptData, ctx: Option) { - self.context_entities - .insert(fd.sid, (fd.entity, ctx, fd.name.to_owned())); - } - - pub fn remove_context(&mut self, script_id: u32) { - self.context_entities.remove(&script_id); - } - - pub fn has_context(&self, script_id: u32) -> bool { - self.context_entities - .get(&script_id) - .map_or(false, |(_, c, _)| c.is_some()) - } - - pub fn is_empty(&self) -> bool { - self.context_entities.is_empty() - } -} - -/// A struct defining an instance of a script asset. -/// Multiple instances of the same script can exist on the same entity -#[derive(Debug, Reflect)] -pub struct Script { - /// a strong handle to the script asset - handle: Handle, - - /// the name of the script, usually its file name + relative asset path - name: String, - - /// uniquely identifies the script instance (scripts which use the same asset don't necessarily have the same ID) - id: u32, -} - -static COUNTER: AtomicU32 = AtomicU32::new(0); - -impl Script { - /// creates a new script instance with the given name and asset handle - /// automatically gives this script instance a unique ID. - /// No two scripts instances ever share the same ID - pub fn new(name: String, handle: Handle) -> Self { - Self { - handle, - name, - id: COUNTER.fetch_add(1, Ordering::Relaxed), - } - } - - #[inline(always)] - /// returns the name of the script - pub fn name(&self) -> &str { - &self.name - } - - #[inline(always)] - /// returns the asset handle which this script is executing - pub fn handle(&self) -> &Handle { - &self.handle - } - - #[inline(always)] - /// returns the unique ID of this script instance - pub fn id(&self) -> u32 { - self.id - } - - /// reloads the script by deleting the old context and inserting a new one - /// if the script context never existed, it will after this call. - pub(crate) fn reload_script( - host: &mut H, - script: &Script, - script_assets: &Assets, - providers: &mut APIProviders, - contexts: &mut ScriptContexts, - event_writer: &mut EventWriter, - ) { - debug!("reloading script {}", script.id); - - // retrieve owning entity - if let Some(entity) = contexts.script_owner(script.id()) { - // remove old context - contexts.remove_context(script.id()); - // insert new re-loaded context - Self::insert_new_script_context::( - host, - script, - entity, - script_assets, - providers, - contexts, - event_writer, - ); - } else { - // remove old context - contexts.remove_context(script.id()); - } - } - - /// checks if a script has loaded, and if so loads (`ScriptHost::load_script`), - /// sets up (`ScriptHost::setup_script`) and inserts its new context into the contexts resource - /// otherwise inserts None. Sends ScriptLoaded event if the script was loaded - pub(crate) fn insert_new_script_context( - host: &mut H, - new_script: &Script, - entity: Entity, - script_assets: &Assets, - providers: &mut APIProviders, - contexts: &mut ScriptContexts, - event_writer: &mut EventWriter, - ) { - let fd = ScriptData { - sid: new_script.id(), - entity, - name: new_script.name(), - }; - - let script = match script_assets.get(&new_script.handle) { - Some(s) => s, - None => { - // not loaded yet - debug!("Inserted script which hasn't loaded yet {:?}", fd); - contexts.insert_context(fd, None); - return; - } - }; - debug!("Inserted script {:?}", fd); - - match host.load_script(script.bytes(), &fd, providers) { - Ok(mut ctx) => { - host.setup_script(&fd, &mut ctx, providers) - .expect("Failed to setup script"); - contexts.insert_context(fd, Some(ctx)); - event_writer.send(ScriptLoaded { - sid: new_script.id(), - }); - } - Err(e) => { - warn! {"Error in loading script {}:\n{}", &new_script.name,e} - // this script will now never execute, unless manually reloaded - // but contexts are left in a valid state - contexts.insert_context(fd, None); - } - } - } -} - -#[derive(Component, Debug, Reflect)] -#[reflect(Component, Default)] -/// The component storing many scripts. -/// Scripts receive information about the entity they are attached to -/// Scripts have unique identifiers and hence multiple copies of the same script -/// can be attached to the same entity -pub struct ScriptCollection { - pub scripts: Vec>, -} - -impl Default for ScriptCollection { - fn default() -> Self { - Self { - scripts: Default::default(), - } - } -} diff --git a/crates/bevy_mod_scripting_core/src/lib.rs b/crates/bevy_mod_scripting_core/src/lib.rs index d12f9762..e6e1c0c8 100644 --- a/crates/bevy_mod_scripting_core/src/lib.rs +++ b/crates/bevy_mod_scripting_core/src/lib.rs @@ -1,217 +1,179 @@ -use crate::{ - event::ScriptErrorEvent, - hosts::{APIProvider, APIProviders, ScriptHost}, -}; +#![allow(clippy::arc_with_non_send_sync)] + +use crate::event::ScriptErrorEvent; use allocator::ReflectAllocator; -use bevy::{ecs::schedule::ScheduleLabel, prelude::*}; -use event::ScriptLoaded; -use systems::{garbage_collector, script_event_handler}; +use asset::{ScriptAsset, ScriptAssetLoader, ScriptAssetSettings}; +use bevy::prelude::*; +use context::{ + Context, ContextAssigner, ContextBuilder, ContextInitializer, ContextLoadingSettings, + ContextPreHandlingInitializer, ScriptContexts, +}; +use handler::{Args, CallbackSettings, HandlerFn}; +use prelude::{ + initialize_runtime, + runtime::{RuntimeInitializer, RuntimeSettings}, + sync_script_data, Documentation, DocumentationFragment, ScriptCallbackEvent, +}; +use runtime::{Runtime, RuntimeContainer}; +use script::Scripts; +use systems::garbage_collector; pub mod allocator; pub mod asset; pub mod bindings; +pub mod commands; +pub mod context; pub mod docs; pub mod error; pub mod event; -pub mod hosts; +pub mod handler; +pub mod proxy; +pub mod runtime; +pub mod script; pub mod systems; pub mod world; - pub mod prelude { - // general - pub use { - crate::asset::CodeAsset, - crate::docs::DocFragment, - crate::error::ScriptError, - crate::event::{ScriptErrorEvent, ScriptEvent}, - crate::hosts::{ - APIProvider, APIProviders, Recipients, Script, ScriptCollection, ScriptContexts, - ScriptData, ScriptHost, - }, - crate::systems::script_event_handler, - crate::{ - AddScriptApiProvider, AddScriptHost, AddScriptHostHandler, GenDocumentation, - ScriptingPlugin, - }, - bevy_event_priority::{ - AddPriorityEvent, PriorityEvent, PriorityEventReader, PriorityEventWriter, - PriorityEvents, PriorityIterator, - }, - }; + pub use {crate::docs::*, crate::error::*, crate::event::*, crate::systems::*, crate::*}; } -pub use bevy_event_priority as events; #[derive(Default)] -/// Bevy plugin enabling run-time scripting -pub struct ScriptingPlugin; +/// Bevy plugin enabling scripting within the bevy mod scripting framework +pub struct ScriptingPlugin { + /// Callback for initiating the runtime + pub runtime_builder: Option R>, + /// The handler used for executing callbacks in scripts + pub callback_handler: Option>, + /// The context builder for loading contexts + pub context_builder: Option>, + /// The context assigner for assigning contexts to scripts, if not provided default strategy of keeping each script in its own context is used + pub context_assigner: Option>, +} -impl Plugin for ScriptingPlugin { +impl Plugin for ScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { app.add_event::() + .add_event::>() .init_resource::() - .add_systems(PostUpdate, garbage_collector); + .init_resource::() + .init_resource::() + .init_asset::() + .register_asset_loader(ScriptAssetLoader { + language: "<>".into(), + extensions: &[], + preprocessor: None, + }) + // not every script host will have a runtime, for convenience we add a dummy runtime + .insert_non_send_resource::>(RuntimeContainer { + runtime: self.runtime_builder.map(|f| f()), + }) + .init_non_send_resource::>() + .init_non_send_resource::>() + .insert_resource::>(CallbackSettings { + callback_handler: self.callback_handler, + }) + .insert_resource::>(ContextLoadingSettings { + loader: self.context_builder.clone(), + assigner: Some(self.context_assigner.clone().unwrap_or_default()), + context_initializers: vec![], + context_pre_handling_initializers: vec![], + }) + .add_systems(PostUpdate, (garbage_collector, sync_script_data::)) + .add_systems(PostStartup, initialize_runtime::); } } -pub trait GenDocumentation { - fn update_documentation(&mut self) -> &mut Self; +pub trait AddRuntimeInitializer { + fn add_runtime_initializer(&mut self, initializer: RuntimeInitializer) -> &mut Self; } -impl GenDocumentation for App { - /// Updates/Generates documentation and any other artifacts required for script API's. Disabled in optimized builds unless `doc_always` feature is enabled. - fn update_documentation(&mut self) -> &mut Self { - #[cfg(any(debug_assertions, feature = "doc_always"))] - { - info!("Generating documentation"); - let w = &mut self.world; - let providers: &APIProviders = w.resource(); - if let Err(e) = providers.gen_all() { - error!("{}", e); - } - info!("Documentation generated"); - } - +impl AddRuntimeInitializer for App { + fn add_runtime_initializer(&mut self, initializer: RuntimeInitializer) -> &mut Self { + self.world.init_resource::>(); + self.world + .resource_mut::>() + .as_mut() + .initializers + .push(initializer); self } } -/// Trait for app builder notation -pub trait AddScriptHost { - /// registers the given script host with your app, - /// the given system set will contain systems handling script loading, re-loading, removal etc. - /// This system set will also send events related to the script lifecycle. - /// - /// Note: any systems which need to run the same frame a script is loaded must run after this set. - fn add_script_host(&mut self, schedule: impl ScheduleLabel) -> &mut Self; - - /// Similar to `add_script_host` but allows you to specify a system set to add the script host to. - fn add_script_host_to_set( +pub trait AddContextInitializer { + fn add_context_initializer( &mut self, - schedule: impl ScheduleLabel, - set: impl SystemSet, + initializer: ContextInitializer, ) -> &mut Self; } -impl AddScriptHost for App { - fn add_script_host_to_set( +impl AddContextInitializer for App { + fn add_context_initializer( &mut self, - schedule: impl ScheduleLabel, - set: impl SystemSet, - ) -> &mut Self - where - T: ScriptHost, - { - T::register_with_app_in_set(self, schedule, set); - self.init_resource::(); - self.add_event::(); - self - } - - fn add_script_host(&mut self, schedule: impl ScheduleLabel) -> &mut Self - where - T: ScriptHost, - { - T::register_with_app(self, schedule); - self.init_resource::(); - self.add_event::(); + initializer: ContextInitializer, + ) -> &mut Self { + self.world.init_resource::>(); + self.world + .resource_mut::>() + .as_mut() + .context_initializers + .push(initializer); self } } -pub trait AddScriptApiProvider { - fn add_api_provider( +pub trait AddContextPreHandlingInitializer { + fn add_context_pre_handling_initializer( &mut self, - provider: Box< - dyn APIProvider< - APITarget = T::APITarget, - DocTarget = T::DocTarget, - ScriptContext = T::ScriptContext, - >, - >, + initializer: ContextPreHandlingInitializer, ) -> &mut Self; } -impl AddScriptApiProvider for App { - fn add_api_provider( +impl AddContextPreHandlingInitializer for App { + fn add_context_pre_handling_initializer( &mut self, - provider: Box< - dyn APIProvider< - APITarget = T::APITarget, - DocTarget = T::DocTarget, - ScriptContext = T::ScriptContext, - >, - >, + initializer: ContextPreHandlingInitializer, ) -> &mut Self { - provider.register_with_app(self); - let w = &mut self.world; - let providers: &mut APIProviders = &mut w.resource_mut(); - providers.providers.push(provider); + self.world + .resource_mut::>() + .as_mut() + .context_pre_handling_initializers + .push(initializer); self } } -pub trait AddScriptHostHandler { - /// Enables this script host to handle events with priorities in the range [0,min_prio] (inclusive), - /// during from within the given set. - /// - /// Note: this is identical to adding the script_event_handler system manually, so if you require more complex setup, you can use the following: - /// ```rust,ignore - /// self.add_systems( - /// MySchedule, - /// script_event_handler:: - /// ); - /// ``` - /// - /// Think of event handler systems as event sinks, which collect and "unpack" the instructions in each event every frame. - /// Because events are also prioritised, you can enforce a particular order of execution for your events (within each frame) - /// regardless of where they were fired from. - /// - /// A good example of this is Unity [game loop's](https://docs.unity3d.com/Manual/ExecutionOrder.html) `onUpdate` and `onFixedUpdate`. - /// FixedUpdate runs *before* any physics while Update runs after physics and input events. - /// - /// In this crate you can achieve this by using a separate system set before and after your physics, - /// then assigning event priorities such that your events are forced to run at the points you want them to, for example: - /// - /// PrePhysics priority range [0,1] - /// PostPhysics priority range [2,4] - /// - /// | Priority | Handler | Event | - /// | -------- | ----------- | ------------ | - /// | 0 | PrePhysics | Start 0 | - /// | 1 | PrePhysics | FixedUpdate 1 | - /// | 2 | PostPhysics | OnCollision 2 | - /// | 3 | PostPhysics | OnMouse 3 | - /// | 4 | PostPhysics | Update 4 | - /// - /// Note: in this example, if your FixedUpdate event is fired *after* the handler system set has run, it will be discarded (since other handlers discard events of higher priority). - fn add_script_handler( - &mut self, - schedule: impl ScheduleLabel, - ) -> &mut Self; - - /// The same as `add_script_handler` but allows you to specify a system set to add the handler to. - fn add_script_handler_to_set( - &mut self, - schedule: impl ScheduleLabel, - set: impl SystemSet, - ) -> &mut Self; +pub trait StoreDocumentation { + /// Adds a documentation fragment to the documentation store. + fn add_documentation_fragment(&mut self, fragment: D) -> &mut Self; + /// Consumes all the stored documentation fragments, and merges them into one, then generates the documentation. + fn generate_docs(&mut self) -> Result<(), Box>; } -impl AddScriptHostHandler for App { - fn add_script_handler_to_set( - &mut self, - schedule: impl ScheduleLabel, - set: impl SystemSet, - ) -> &mut Self { - self.add_systems(schedule, script_event_handler::.in_set(set)); +impl StoreDocumentation for App { + fn add_documentation_fragment(&mut self, fragment: D) -> &mut Self { + self.world.init_non_send_resource::>(); + self.world + .non_send_resource_mut::>() + .as_mut() + .fragments + .push(fragment); self } - fn add_script_handler( - &mut self, - schedule: impl ScheduleLabel, - ) -> &mut Self { - self.add_systems(schedule, script_event_handler::); - self + fn generate_docs(&mut self) -> Result<(), Box> { + let mut docs = match self.world.remove_non_send_resource::>() { + Some(docs) => docs, + None => return Ok(()), + }; + + let mut top_fragment = match docs.fragments.pop() { + Some(fragment) => fragment, + None => return Ok(()), + }; + + for fragment in docs.fragments.into_iter() { + top_fragment = top_fragment.merge(fragment); + } + + top_fragment.gen_docs() } } diff --git a/crates/bevy_mod_scripting_core/src/proxy.rs b/crates/bevy_mod_scripting_core/src/proxy.rs new file mode 100644 index 00000000..e8f9f55e --- /dev/null +++ b/crates/bevy_mod_scripting_core/src/proxy.rs @@ -0,0 +1,633 @@ +//! Set of traits used to define how types are turned into and from proxies in Lua. +//! Proxies can either be logical "copies" or owned "direct representations" of the instance, or references to one via the [`bevy_mod_scripting_core::bindings::ReflectReference`] construct. +use std::num::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; + +use bevy::{ + reflect::{FromReflect, Reflect, TypeRegistry}, + utils::smallvec::SmallVec, +}; + +use crate::{ + bindings::{ReflectReference, WorldAccessGuard, WorldAccessUnit, WorldAccessWrite}, + prelude::{ReflectAllocator, ReflectionError}, +}; + +pub trait Proxied: Sized { + type Proxy: Clone + + AsRef + + Into + + From + + std::fmt::Debug; +} + +pub struct Proxy(pub T::Proxy); + +pub struct RefProxy(pub T::Proxy); + +pub struct RefMutProxy(pub T::Proxy); + +pub trait Unproxy<'w, 'c> { + type Output: 'c; + + fn collect_accesses( + &self, + _guard: &WorldAccessGuard<'w>, + _accesses: &mut SmallVec<[WorldAccessWrite<'w>; 1]>, + ) -> Result<(), ReflectionError> { + Ok(()) + } + + fn accesses_len(&self) -> usize { + 0 + } + + /// # Safety + /// - The caller must not use the accesses in the accesses list after the unproxy call to create a mutable reference, as this call might borrow mutably from the same access + unsafe fn unproxy( + &'c mut self, + guard: &WorldAccessGuard<'w>, + accesses: &'c [WorldAccessUnit<'w>], + type_registry: &TypeRegistry, + allocator: &'c ReflectAllocator, + ) -> Result; +} + +impl<'w, 'c, T: Proxied + FromReflect> Unproxy<'w, 'c> for Proxy { + type Output = T; + + unsafe fn unproxy( + &'c mut self, + guard: &WorldAccessGuard<'w>, + _accesses: &'c [WorldAccessUnit<'w>], + type_registry: &TypeRegistry, + allocator: &'c ReflectAllocator, + ) -> Result { + let reflect_ref: &ReflectReference = self.0.as_ref(); + let access = reflect_ref.base.base_id.get_reflect_access_id(); + let access = + guard + .get_access(access) + .ok_or_else(|| ReflectionError::InsufficientAccess { + base: std::any::type_name::().to_owned(), + reason: "Attempted to access the same component/resource/allocation in one Unproxying operation".to_owned(), + })?; + let out = reflect_ref.reflect( + guard.as_unsafe_world_cell(), + &access, + type_registry, + Some(allocator), + )?; + let out = T::from_reflect(out).ok_or_else(|| ReflectionError::CannotDowncast { + reference: reflect_ref.clone(), + to: std::any::type_name::().to_string(), + })?; + guard.release_access(access); + Ok(out) + } +} + +impl<'w, 'c, T: Proxied + Reflect + 'w> Unproxy<'w, 'c> for RefProxy { + type Output = &'c T; + + fn collect_accesses( + &self, + guard: &WorldAccessGuard<'w>, + accesses: &mut SmallVec<[WorldAccessUnit<'w>; 1]>, + ) -> Result<(), ReflectionError> { + let reflect_ref: &ReflectReference = self.0.as_ref(); + let access = reflect_ref.base.base_id.get_reflect_access_id(); + let access = + guard.get_access(access) + .ok_or_else(|| ReflectionError::InsufficientAccess { + base: std::any::type_name::().to_owned(), + reason: "Attempted to access the same component/resource/allocation in one Unproxying operation".to_owned(), + })?; + accesses.push(access); + Ok(()) + } + + unsafe fn unproxy( + &'c mut self, + guard: &WorldAccessGuard<'w>, + accesses: &'c [WorldAccessUnit<'w>], + type_registry: &TypeRegistry, + allocator: &'c ReflectAllocator, + ) -> Result { + let reflect_ref: &ReflectReference = self.0.as_ref(); + let access = accesses + .last() + .ok_or_else(|| ReflectionError::InsufficientAccess { + base: std::any::type_name::().to_owned(), + reason: "No access collected when unproxying".to_owned(), + })?; + + let out = reflect_ref.reflect( + guard.as_unsafe_world_cell(), + access, + type_registry, + Some(allocator), + )?; + let out = out + .downcast_ref() + .ok_or_else(|| ReflectionError::CannotDowncast { + reference: reflect_ref.clone(), + to: std::any::type_name::().to_string(), + })?; + Ok(out) + } + + fn accesses_len(&self) -> usize { + 1 + } +} + +impl<'w, 'c, T: Proxied + Reflect + 'w> Unproxy<'w, 'c> for RefMutProxy { + type Output = &'c mut T; + + fn collect_accesses( + &self, + guard: &WorldAccessGuard<'w>, + accesses: &mut SmallVec<[WorldAccessUnit<'w>; 1]>, + ) -> Result<(), ReflectionError> { + let reflect_ref: &ReflectReference = self.0.as_ref(); + let access = reflect_ref.base.base_id.get_reflect_access_id(); + let access = + guard.get_access(access) + .ok_or_else(|| ReflectionError::InsufficientAccess { + base: std::any::type_name::().to_owned(), + reason: "Attempted to access the same component/resource/allocation in one Unproxying operation".to_owned(), + })?; + accesses.push(access); + Ok(()) + } + + unsafe fn unproxy( + &'c mut self, + guard: &WorldAccessGuard<'w>, + accesses: &'c [WorldAccessUnit<'w>], + type_registry: &TypeRegistry, + allocator: &'c ReflectAllocator, + ) -> Result { + let reflect_ref: &ReflectReference = self.0.as_ref(); + accesses + .last() + .ok_or_else(|| ReflectionError::InsufficientAccess { + base: std::any::type_name::().to_owned(), + reason: "No access collected when unproxying".to_owned(), + }) + .and_then(|access| { + reflect_ref.expect_write_access(access, type_registry, guard.as_unsafe_world_cell()) + })?; + + // Safety: + // - we verified and we have the right access + // - the caller promises not to alias it from the root access + let out = unsafe { + reflect_ref.reflect_mut_unsafe( + guard.as_unsafe_world_cell(), + type_registry, + Some(allocator), + )? + }; + let out = out + .downcast_mut() + .ok_or_else(|| ReflectionError::CannotDowncast { + reference: reflect_ref.clone(), + to: std::any::type_name::().to_string(), + })?; + Ok(out) + } + + fn accesses_len(&self) -> usize { + 1 + } +} + +impl<'w, 'c, T: Unproxy<'w, 'c>> Unproxy<'w, 'c> for Vec { + type Output = Vec; + + fn collect_accesses( + &self, + guard: &WorldAccessGuard<'w>, + accesses: &mut SmallVec<[WorldAccessUnit<'w>; 1]>, + ) -> Result<(), ReflectionError> { + for item in self { + item.collect_accesses(guard, accesses)?; + } + Ok(()) + } + + fn accesses_len(&self) -> usize { + self.iter().map(|item| item.accesses_len()).sum() + } + + unsafe fn unproxy( + &'c mut self, + guard: &WorldAccessGuard<'w>, + accesses: &'c [WorldAccessUnit<'w>], + type_registry: &TypeRegistry, + allocator: &'c ReflectAllocator, + ) -> Result { + let mut out = Vec::with_capacity(self.len()); + let mut offset = 0; + for item in self { + let width = item.accesses_len(); + let unproxied = item.unproxy( + guard, + &accesses[offset..offset + width], + type_registry, + allocator, + )?; + out.push(unproxied); + offset += width; + } + Ok(out) + } +} + +impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for &T +where + T::Output: Copy, +{ + type Output = &'c T; + + unsafe fn unproxy( + &'c mut self, + _guard: &WorldAccessGuard<'w>, + _accesses: &'c [WorldAccessUnit<'w>], + _type_registry: &TypeRegistry, + _allocator: &'c ReflectAllocator, + ) -> Result { + Ok(self) + } +} + +impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for &mut T +where + T::Output: Copy, +{ + type Output = &'c mut T; + + unsafe fn unproxy( + &'c mut self, + _guard: &WorldAccessGuard<'w>, + _accesses: &'c [WorldAccessUnit<'w>], + _type_registry: &TypeRegistry, + _allocator: &'c ReflectAllocator, + ) -> Result { + Ok(*self) + } +} + +macro_rules! impl_by_move { + ($($ty:ty),*) => { + $(impl<'w, 'c> Unproxy<'w, 'c> for $ty { + type Output = $ty; + + unsafe fn unproxy( + &'c mut self, + _guard: &WorldAccessGuard<'w>, + _accesses: &'c [WorldAccessUnit<'w>], + _type_registry: &TypeRegistry, + _allocator: &'c ReflectAllocator, + ) -> Result { + Ok(*self) + } + })* + }; +} + +impl_by_move!(usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64, bool); +impl_by_move!( + NonZeroUsize, + NonZeroU8, + NonZeroU16, + NonZeroU32, + NonZeroU64, + NonZeroU128 +); + +macro_rules! impl_by_clone { + ($($ty:ty),*) => { + $(impl<'w, 'c> Unproxy<'w, 'c> for $ty { + type Output = $ty; + + unsafe fn unproxy( + &'c mut self, + _guard: &WorldAccessGuard<'w>, + _accesses: &'c [WorldAccessUnit<'w>], + _type_registry: &TypeRegistry, + _allocator: &'c ReflectAllocator, + ) -> Result { + Ok(self.clone()) + } + })* + }; +} + +impl_by_clone!(String); + +macro_rules! impl_tuple_unproxy { + ($(($ty:ident, $idx:tt)),*) => { + impl<'w, 'c, $($ty: Unproxy<'w, 'c>),*> Unproxy<'w, 'c> for ($($ty,)*) { + type Output = ($($ty::Output,)*); + + fn collect_accesses( + &self, + guard: &WorldAccessGuard<'w>, + accesses: &mut SmallVec<[WorldAccessWrite<'w>; 1]>, + ) -> Result<(), ReflectionError> { + $(self.$idx.collect_accesses(guard, accesses)?;)* + Ok(()) + } + + fn accesses_len(&self) -> usize { + let mut len = 0; + $(len += self.$idx.accesses_len();)* + len + } + + #[allow(unused_assignments)] + unsafe fn unproxy( + &'c mut self, + guard: &WorldAccessGuard<'w>, + accesses: &'c [WorldAccessUnit<'w>], + type_registry: &TypeRegistry, + allocator: &'c ReflectAllocator, + ) -> Result { + let mut offset = 0; + + Ok(($( + { + let width = self.$idx.accesses_len(); + let elem = self.$idx.unproxy(guard, &accesses[offset..offset+width], type_registry, allocator)?; + + offset += width; + elem + } + ,)*)) + + } + } + }; +} + +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12), (N, 13)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12), (N, 13), (O, 14)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12), (N, 13), (O, 14), (P, 15)); +#[rustfmt::skip] +impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12), (N, 13), (O, 14), (P, 15), (Q, 16)); + +#[cfg(test)] +mod test { + use std::{cell::UnsafeCell, sync::Arc}; + + use bevy::ecs::{component::Component, world::World}; + + use crate::{ + allocator::ReflectAllocation, + bindings::{ReflectBase, ReflectBaseType}, + }; + + use super::*; + + #[derive(Reflect, Component)] + struct Test(pub &'static str); + + impl Proxied for Test { + type Proxy = TestProxy; + } + + #[derive(Debug, Clone)] + struct TestProxy(ReflectReference); + + impl From for ReflectReference { + fn from(value: TestProxy) -> Self { + value.0 + } + } + + impl From for TestProxy { + fn from(value: ReflectReference) -> Self { + TestProxy(value) + } + } + + impl AsRef for TestProxy { + fn as_ref(&self) -> &ReflectReference { + &self.0 + } + } + + #[test] + pub fn test_proxy() { + let mut allocator = ReflectAllocator::default(); + let alloc_id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(Test( + "test", + ))))); + + let mut proxy = Proxy::(TestProxy(ReflectReference { + base: ReflectBaseType { + type_id: std::any::TypeId::of::(), + base_id: ReflectBase::Owned(alloc_id), + }, + reflect_path: vec![], + })); + let mut world = World::new(); + let mut accesses = SmallVec::new(); + let world = WorldAccessGuard::new(&mut world); + let type_registry = TypeRegistry::default(); + + proxy.collect_accesses(&world, &mut accesses).unwrap(); + let unproxied = unsafe { + proxy + .unproxy(&world, &accesses, &type_registry, &allocator) + .unwrap() + }; + assert_eq!(unproxied.0, "test"); + } + + #[test] + pub fn test_proxy_ref() { + let mut allocator = ReflectAllocator::default(); + let alloc_id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(Test( + "test", + ))))); + + let mut proxy = RefProxy::(TestProxy(ReflectReference { + base: ReflectBaseType { + type_id: std::any::TypeId::of::(), + base_id: ReflectBase::Owned(alloc_id), + }, + reflect_path: vec![], + })); + let mut world = World::new(); + let mut accesses = SmallVec::new(); + let world = WorldAccessGuard::new(&mut world); + let type_registry = TypeRegistry::default(); + + proxy.collect_accesses(&world, &mut accesses).unwrap(); + let unproxied = unsafe { + proxy + .unproxy(&world, &accesses, &type_registry, &allocator) + .unwrap() + }; + assert_eq!(unproxied.0, "test"); + } + + #[test] + pub fn test_proxy_ref_mut() { + let mut allocator = ReflectAllocator::default(); + let alloc_id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(Test( + "test", + ))))); + + let mut proxy = RefMutProxy::(TestProxy(ReflectReference { + base: ReflectBaseType { + type_id: std::any::TypeId::of::(), + base_id: ReflectBase::Owned(alloc_id), + }, + reflect_path: vec![], + })); + let mut world = World::new(); + let mut accesses = SmallVec::new(); + let world = WorldAccessGuard::new(&mut world); + let type_registry = TypeRegistry::default(); + + proxy.collect_accesses(&world, &mut accesses).unwrap(); + let unproxied = unsafe { + proxy + .unproxy(&world, &accesses, &type_registry, &allocator) + .unwrap() + }; + assert_eq!(unproxied.0, "test"); + } + + #[test] + pub fn test_vec_proxy_ref_mut() { + let mut allocator = ReflectAllocator::default(); + let alloc_id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(Test( + "test", + ))))); + + let mut proxy = vec![RefMutProxy::(TestProxy(ReflectReference { + base: ReflectBaseType { + type_id: std::any::TypeId::of::(), + base_id: ReflectBase::Owned(alloc_id), + }, + reflect_path: vec![], + }))]; + let mut world = World::new(); + let mut accesses = SmallVec::new(); + let world = WorldAccessGuard::new(&mut world); + let type_registry = TypeRegistry::default(); + + proxy.collect_accesses(&world, &mut accesses).unwrap(); + let unproxied = unsafe { + proxy + .unproxy(&world, &accesses, &type_registry, &allocator) + .unwrap() + }; + assert_eq!(unproxied[0].0, "test"); + } + + #[test] + pub fn test_vec_usize_ref() { + let allocator = ReflectAllocator::default(); + + let mut proxy = vec![&1]; + let mut world = World::new(); + let mut accesses = SmallVec::new(); + let world = WorldAccessGuard::new(&mut world); + let type_registry = TypeRegistry::default(); + + proxy.collect_accesses(&world, &mut accesses).unwrap(); + let unproxied = unsafe { + proxy + .unproxy(&world, &accesses, &type_registry, &allocator) + .unwrap() + }; + assert_eq!(unproxied[0], &42); + } + + #[test] + pub fn test_tuple_refs() { + let allocator = ReflectAllocator::default(); + + let mut proxy = (vec![&1], vec![&2, &4], vec![&3]); + let mut world = World::new(); + let mut accesses = SmallVec::new(); + let world = WorldAccessGuard::new(&mut world); + let type_registry = TypeRegistry::default(); + + proxy.collect_accesses(&world, &mut accesses).unwrap(); + let unproxied = unsafe { + proxy + .unproxy(&world, &accesses, &type_registry, &allocator) + .unwrap() + }; + assert_eq!(unproxied, (vec![&1], vec![&2, &4], vec![&3])); + } + + #[test] + pub fn test_invalid_access() { + let mut allocator = ReflectAllocator::default(); + + let allocation_id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new( + Test("test"), + )))); + + let reflect_ref = ReflectReference { + base: ReflectBaseType { + type_id: std::any::TypeId::of::(), + base_id: ReflectBase::Owned(allocation_id), + }, + reflect_path: vec![], + }; + + // mutable access to the same allocation + let proxy = vec![ + RefMutProxy::(TestProxy(reflect_ref.clone())), + RefMutProxy::(TestProxy(reflect_ref)), + ]; + + let mut world = World::new(); + let mut accesses = SmallVec::new(); + let world = WorldAccessGuard::new(&mut world); + + let result = proxy.collect_accesses(&world, &mut accesses); + assert!(matches!( + result, + Err(ReflectionError::InsufficientAccess { .. }) + )); + } +} diff --git a/crates/bevy_mod_scripting_core/src/runtime.rs b/crates/bevy_mod_scripting_core/src/runtime.rs new file mode 100644 index 00000000..65308299 --- /dev/null +++ b/crates/bevy_mod_scripting_core/src/runtime.rs @@ -0,0 +1,36 @@ +//! "Runtime" here refers to the execution evironment of scripts. This might be the VM executing bytecode or the interpreter executing source code. +//! The important thing is that there is only one runtime which is used to execute all scripts of a particular type or `context`. + +use bevy::ecs::system::Resource; + +pub trait Runtime: 'static {} +impl Runtime for T {} + +pub type RuntimeInitializer = fn(&mut R); + +#[derive(Clone, Resource)] +pub struct RuntimeSettings { + pub initializers: Vec>, +} + +impl Default for RuntimeSettings { + fn default() -> Self { + Self { + initializers: Default::default(), + } + } +} + +/// Stores a particular runtime. +#[derive(Resource)] +pub struct RuntimeContainer { + pub runtime: Option, +} + +impl Default for RuntimeContainer { + fn default() -> Self { + Self { + runtime: Default::default(), + } + } +} diff --git a/crates/bevy_mod_scripting_core/src/script.rs b/crates/bevy_mod_scripting_core/src/script.rs new file mode 100644 index 00000000..4d39427b --- /dev/null +++ b/crates/bevy_mod_scripting_core/src/script.rs @@ -0,0 +1,42 @@ +//! Everything to do with the way scripts and their contexts are stored and handled. + +use std::{borrow::Cow, collections::HashMap, ops::Deref}; + +use bevy::{asset::Handle, ecs::system::Resource, reflect::Reflect}; + +use crate::{asset::ScriptAsset, context::ContextId}; + +pub type ScriptId = Cow<'static, str>; + +#[derive(bevy::ecs::component::Component, Reflect)] +pub struct ScriptComponent(pub Vec); + +impl Deref for ScriptComponent { + type Target = Vec; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl ScriptComponent { + pub fn new(components: Vec) -> Self { + Self(components) + } +} + +/// All the scripts which are currently loaded or loading and their mapping to contexts +#[derive(Resource, Default, Clone)] +pub struct Scripts { + pub(crate) scripts: HashMap, +} + +/// A script +#[derive(Clone)] +pub struct Script { + pub id: ScriptId, + /// the asset holding the content of the script if it comes from an asset + pub asset: Option>, + /// The id of the context this script is currently assigned to + pub context_id: ContextId, +} diff --git a/crates/bevy_mod_scripting_core/src/systems.rs b/crates/bevy_mod_scripting_core/src/systems.rs index 8262a334..e3a97372 100644 --- a/crates/bevy_mod_scripting_core/src/systems.rs +++ b/crates/bevy_mod_scripting_core/src/systems.rs @@ -1,13 +1,16 @@ -use std::collections::HashSet; - use bevy::{ecs::system::SystemState, prelude::*}; -use bevy_event_priority::PriorityEventReader; +use std::any::type_name; use crate::{ allocator::ReflectAllocator, - event::ScriptLoaded, - prelude::{APIProviders, Script, ScriptCollection, ScriptContexts, ScriptData, ScriptHost}, - ScriptErrorEvent, + asset::{ScriptAsset, ScriptAssetSettings}, + commands::{CreateOrUpdateScript, DeleteScript}, + context::{Context, ContextLoadingSettings, ScriptContexts}, + event::{IntoCallbackLabel, ScriptCallbackEvent, ScriptErrorEvent}, + handler::{Args, CallbackSettings}, + prelude::RuntimeSettings, + runtime::{Runtime, RuntimeContainer}, + script::{ScriptComponent, Scripts}, }; /// Cleans up dangling script allocations @@ -15,213 +18,409 @@ pub fn garbage_collector(mut allocator: ResMut) { allocator.clean_garbage_allocations() } -/// Handles creating contexts for new/modified scripts -/// Scripts are likely not loaded instantly at this point, so most of the time -/// this system simply inserts an empty context -pub fn script_add_synchronizer( - query: Query< - ( - Entity, - &ScriptCollection, - Ref>, - ), - Changed>, - >, - mut host: ResMut, - mut providers: ResMut>, - script_assets: Res>, - mut contexts: ResMut>, - mut event_writer: EventWriter, +pub fn initialize_runtime( + mut runtime: NonSendMut>, + settings: Res>, ) { - debug!("Handling addition/modification of scripts"); - - query.iter().for_each(|(entity, new_scripts, tracker)| { - if tracker.is_added() { - new_scripts.scripts.iter().for_each(|new_script| { - Script::::insert_new_script_context::( - &mut host, - new_script, - entity, - &script_assets, - &mut providers, - &mut contexts, - &mut event_writer, - ) - }) - } else { - // changed but structure already exists in contexts - // find out what's changed - // we only care about added or removed scripts here - // if the script asset gets changed we deal with that elsewhere - - let context_ids = contexts - .context_entities - .iter() - .filter_map(|(sid, (e, _, _))| if *e == entity { Some(sid) } else { None }) - .cloned() - .collect::>(); - let script_ids = new_scripts - .scripts - .iter() - .map(|s| s.id()) - .collect::>(); + if let Some(r) = runtime.runtime.as_mut() { + for initializer in settings.initializers.iter() { + (initializer)(r); + } + }; +} - let removed_scripts = context_ids.difference(&script_ids); - let added_scripts = script_ids.difference(&context_ids); +/// Processes and reacts appropriately to script asset events, and queues commands to update the internal script state +pub fn sync_script_data( + mut events: EventReader>, + script_assets: Res>, + asset_settings: Res, + mut commands: Commands, +) { + for event in events.read() { + debug!("Responding to script asset event: {:?}", event); + let (id, remove) = match event { + // emitted when a new script asset is loaded for the first time + AssetEvent::Added { id } => (id, false), + AssetEvent::Modified { id } => (id, false), + AssetEvent::Removed { id } | AssetEvent::Unused { id } => (id, true), + _ => continue, + }; + // get the path + let asset = script_assets.get(*id); + let asset = asset.as_ref().expect("Asset was expected to be loaded!"); - for r in removed_scripts { - contexts.remove_context(*r); - } + let path = &asset.asset_path; + // convert it to script id + let converter = asset_settings.script_id_mapper.map; + let script_id = converter(path); - for a in added_scripts { - let script = new_scripts.scripts.iter().find(|e| &e.id() == a).unwrap(); - Script::::insert_new_script_context::( - &mut host, - script, - entity, - &script_assets, - &mut providers, - &mut contexts, - &mut event_writer, - ) - } + if !remove { + commands.add(CreateOrUpdateScript::::new( + script_id, + asset.content.clone(), + Some(script_assets.reserve_handle()), + )); + } else { + commands.add(DeleteScript::::new(script_id)); } - }) + } } -/// Handles the removal of script components and their contexts -pub fn script_remove_synchronizer( - mut query: RemovedComponents>, - mut contexts: ResMut>, -) { - for v in query.read() { - // we know that this entity used to have a script component - // ergo a script context must exist in ctxts, remove all scripts on the entity - let script_ids = contexts - .context_entities - .iter() - .filter_map(|(script_id, (entity, ..))| { - (entity.index() == v.index()).then_some(*script_id) - }) - .collect::>(); - for script_id in script_ids { - contexts.remove_context(script_id); +macro_rules! push_err_and_continue { + ($errors:ident, $expr:expr) => { + match $expr { + Ok(v) => v, + Err(e) => { + $errors.push(e); + continue; + } } - } + }; } -/// Reloads hot-reloaded scripts, or loads missing contexts for scripts which were added but not loaded -pub fn script_hot_reload_handler( - mut events: EventReader>, - mut host: ResMut, - scripts: Query<&ScriptCollection>, - script_assets: Res>, - mut providers: ResMut>, - mut contexts: ResMut>, - mut event_writer: EventWriter, +/// Passes events with the specified label to the script callback with the same name and runs the callback +pub fn event_handler( + world: &mut World, + params: &mut SystemState<( + EventReader>, + Res>, + Res>, + Res, + Query<(Entity, Ref)>, + )>, ) { - for e in events.read() { - let (handle, created) = match e { - AssetEvent::Modified { id } => (id, false), - AssetEvent::Added { id } => (id, true), - _ => continue, - }; + debug!("Handling events with label `{}`", L::into_callback_label()); + + let mut runtime_container = world + .remove_non_send_resource::>() + .unwrap_or_else(|| { + panic!( + "No runtime container for runtime {} found", + type_name::() + ) + }); + let runtime = runtime_container.runtime.as_mut().unwrap_or_else(|| { + panic!( + "No valid runtime in runtime container for runtime {}", + type_name::() + ) + }); + let mut script_contexts = world + .remove_non_send_resource::>() + .unwrap_or_else(|| panic!("No script contexts found for context {}", type_name::())); - // find script using this handle by handle id - // whether this script was modified or created - // if a script exists with this handle, we should reload it to load in a new context - // which at this point will be either None or Some(outdated context) - // both ways are fine - for scripts in scripts.iter() { - for script in &scripts.scripts { - // the script could have well loaded in the same frame that it was added - // in that case it will have a context attached and we do not want to reload it - if script.handle().id() == *handle - && !(contexts.has_context(script.id()) && created) - { - Script::::reload_script::( - &mut host, - script, - &script_assets, - &mut providers, - &mut contexts, - &mut event_writer, - ); + let (mut script_events, callback_settings, context_settings, scripts, entities) = + params.get_mut(world); + + let handler = *callback_settings + .callback_handler + .as_ref() + .unwrap_or_else(|| { + panic!( + "No handler registered for - Runtime: {}, Context: {}, Args: {}", + type_name::(), + type_name::(), + type_name::() + ) + }); + let pre_handling_initializers = context_settings.context_pre_handling_initializers.clone(); + let scripts = scripts.clone(); + let mut errors = Vec::default(); + + let events = script_events.read().cloned().collect::>(); + let entity_scripts = entities + .iter() + .map(|(e, s)| (e, s.0.clone())) + .collect::>(); + + for event in events + .into_iter() + .filter(|e| e.label == L::into_callback_label()) + { + for (entity, entity_scripts) in entity_scripts.iter() { + for script_id in entity_scripts.iter() { + match &event.recipients { + crate::event::Recipients::Script(target_script_id) + if target_script_id != script_id => + { + continue + } + crate::event::Recipients::Entity(target_entity) if target_entity != entity => { + continue + } + _ => (), } + debug!( + "Handling event for script {} on entity {:?}", + script_id, entity + ); + let script = match scripts.scripts.get(script_id) { + Some(s) => s, + None => { + info!( + "Script `{}` on entity `{:?}` is either still loading or doesn't exist, ignoring.", + script_id, entity + ); + continue; + } + }; + let ctxt = script_contexts + .contexts + .get_mut(&script.context_id) + .unwrap(); + + let handler_result = (handler)( + event.args.clone(), + *entity, + &script.id, + &L::into_callback_label(), + ctxt, + &pre_handling_initializers, + runtime, + world, + ); + + push_err_and_continue!(errors, handler_result) } } } + + world.insert_non_send_resource(runtime_container); + world.insert_non_send_resource(script_contexts); + + for error in errors { + let mut error_events = world + .get_resource_mut::>() + .expect("Missing events resource"); + + bevy::log::error!( + "Encountered error in event handling for - Runtime {}, Context: {}, Args: {}. {}", + type_name::(), + type_name::(), + type_name::(), + error.to_string() + ); + error_events.send(ScriptErrorEvent { error }); + } } -/// Lets the script host handle all script events -pub fn script_event_handler(world: &mut World) { - // we need to collect the events to drop the borrow of the world - let mut state: CachedScriptState = world.remove_resource().unwrap(); +#[cfg(test)] +mod test { + use std::{borrow::Cow, collections::HashMap}; - let events = state - .event_state - .get_mut(world) - .0 - .iter_prio_range(MAX, MIN) - .collect::>(); + use crate::{ + event::CallbackLabel, + handler::HandlerFn, + script::{Script, ScriptId}, + }; - world.insert_resource(state); + use super::*; + struct OnTestCallback; - // should help a lot with performance on frames where no events are fired - if events.is_empty() { - return; + impl IntoCallbackLabel for OnTestCallback { + fn into_callback_label() -> CallbackLabel { + "OnTest".into() + } } - let mut ctxts: ScriptContexts = world.remove_resource().unwrap(); - - let mut host: H = world.remove_resource().unwrap(); - let mut providers: APIProviders = world.remove_resource().unwrap(); - - // we need a resource scope to be able to simultaneously access the contexts as well - // as provide world access to scripts - // afaik there is not really a better way to do this in bevy just now - let ctx_iter = ctxts - .context_entities - .iter_mut() - .filter_map(|(sid, (entity, o, name))| { - let ctx = match o { - Some(v) => v, - None => return None, - }; - - Some(( - ScriptData { - sid: *sid, - entity: *entity, - name, - }, - ctx, - )) + struct TestRuntime { + pub invocations: Vec<(Entity, ScriptId)>, + } + + struct TestContext { + pub invocations: Vec, + } + + fn setup_app( + handler_fn: HandlerFn, + runtime: R, + contexts: HashMap, + scripts: HashMap, + ) -> App { + let mut app = App::new(); + + app.add_event::>(); + app.add_event::(); + app.insert_resource::>(CallbackSettings { + callback_handler: Some(handler_fn), + }); + app.add_systems(Update, event_handler::); + app.insert_resource::(Scripts { scripts }); + app.insert_non_send_resource::>(RuntimeContainer { + runtime: Some(runtime), }); + app.insert_non_send_resource::>(ScriptContexts { contexts }); + app + } - // safety: we have unique access to world, future accesses are protected - // by the lock in the pointer - host.handle_events(world, &events, ctx_iter, &mut providers); + #[test] + fn test_handler_called_with_right_args() { + let test_script_id = Cow::Borrowed("test_script"); + let test_ctxt_id = 0; + let test_script = Script { + id: test_script_id.clone(), + asset: None, + context_id: test_ctxt_id, + }; + let scripts = HashMap::from_iter(vec![(test_script_id.clone(), test_script.clone())]); + let contexts = HashMap::from_iter(vec![( + test_ctxt_id, + TestContext { + invocations: vec![], + }, + )]); + let runtime = TestRuntime { + invocations: vec![], + }; + let mut app = setup_app::( + |args, entity, script, _, ctxt, _, runtime, _| { + ctxt.invocations.push(args); + runtime.invocations.push((entity, script.clone())); + Ok(()) + }, + runtime, + contexts, + scripts, + ); + let test_entity_id = app + .world + .spawn(ScriptComponent(vec![test_script_id.clone()])) + .id(); - world.insert_resource(ctxts); - world.insert_resource(host); - world.insert_resource(providers); -} + app.world + .send_event(ScriptCallbackEvent::::new_for_all( + OnTestCallback::into_callback_label(), + "test_args".to_owned(), + )); + app.update(); -#[derive(Resource)] -/// system state for exclusive systems dealing with script events -pub struct CachedScriptState { - pub event_state: SystemState<( - PriorityEventReader<'static, 'static, H::ScriptEvent>, - EventWriter<'static, ScriptErrorEvent>, - EventReader<'static, 'static, ScriptLoaded>, - )>, -} + let test_context = app + .world + .get_non_send_resource::>() + .unwrap(); + let test_runtime = app + .world + .get_non_send_resource::>() + .unwrap(); -impl FromWorld for CachedScriptState { - fn from_world(world: &mut World) -> Self { - Self { - event_state: SystemState::new(world), - } + assert_eq!( + test_context + .contexts + .get(&test_ctxt_id) + .unwrap() + .invocations, + vec!["test_args"] + ); + + assert_eq!( + test_runtime + .runtime + .as_ref() + .unwrap() + .invocations + .iter() + .map(|(e, s)| (*e, s.clone())) + .collect::>(), + vec![(test_entity_id, test_script_id.clone())] + ); + } + + #[test] + fn test_handler_called_on_right_recipients() { + let test_script_id = Cow::Borrowed("test_script"); + let test_ctxt_id = 0; + let test_script = Script { + id: test_script_id.clone(), + asset: None, + context_id: test_ctxt_id, + }; + let scripts = HashMap::from_iter(vec![ + (test_script_id.clone(), test_script.clone()), + ( + "wrong".into(), + Script { + id: "wrong".into(), + asset: None, + context_id: 1, + }, + ), + ]); + let contexts = HashMap::from_iter(vec![ + ( + test_ctxt_id, + TestContext { + invocations: vec![], + }, + ), + ( + 1, + TestContext { + invocations: vec![], + }, + ), + ]); + let runtime = TestRuntime { + invocations: vec![], + }; + let mut app = setup_app::( + |args, entity, script, _, ctxt, _, runtime, _| { + ctxt.invocations.push(args); + runtime.invocations.push((entity, script.clone())); + Ok(()) + }, + runtime, + contexts, + scripts, + ); + let test_entity_id = app + .world + .spawn(ScriptComponent(vec![test_script_id.clone()])) + .id(); + + app.world.send_event(ScriptCallbackEvent::::new( + OnTestCallback::into_callback_label(), + "test_args_script".to_owned(), + crate::event::Recipients::Script(test_script_id.clone()), + )); + + app.world.send_event(ScriptCallbackEvent::::new( + OnTestCallback::into_callback_label(), + "test_args_entity".to_owned(), + crate::event::Recipients::Entity(test_entity_id), + )); + app.update(); + + let test_context = app + .world + .get_non_send_resource::>() + .unwrap(); + let test_runtime = app + .world + .get_non_send_resource::>() + .unwrap(); + + assert_eq!( + test_context + .contexts + .get(&test_ctxt_id) + .unwrap() + .invocations, + vec!["test_args_script", "test_args_entity"] + ); + + assert_eq!( + test_runtime + .runtime + .as_ref() + .unwrap() + .invocations + .iter() + .map(|(e, s)| (*e, s.clone())) + .collect::>(), + vec![ + (test_entity_id, test_script_id.clone()), + (test_entity_id, test_script_id.clone()) + ] + ); } } diff --git a/crates/bevy_script_api/Cargo.toml b/crates/bevy_script_api/Cargo.toml deleted file mode 100644 index 4f069e48..00000000 --- a/crates/bevy_script_api/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -[package] -name = "bevy_script_api" -version = "0.6.0" -authors = ["Maksymilian Mozolewski "] -edition = "2021" -license = "MIT OR Apache-2.0" -description = "Bevy API for multiple script languages, part of bevy_mod_scripting." -repository = "https://github.com/makspll/bevy_mod_scripting" -homepage = "https://github.com/makspll/bevy_mod_scripting" -keywords = ["bevy", "gamedev", "scripting", "lua", "rhai"] -categories = ["game-development"] -readme = "readme.md" - -[features] -lua = ["bevy_mod_scripting_lua", "bevy_mod_scripting_lua_derive"] -rhai = ["bevy_mod_scripting_rhai"] - -[dependencies] -bevy = { workspace = true, default-features = false, features = [ - "bevy_asset", - "bevy_gltf", - "bevy_animation", - "bevy_core_pipeline", - "bevy_ui", - "bevy_pbr", - "bevy_render", - "bevy_text", - "bevy_sprite", - "file_watcher", - "multi-threaded", -] } -bevy_mod_scripting_core = { workspace = true } -parking_lot = "0.12.1" -paste = "1.0.7" -thiserror = "1.0.32" -# lua -bevy_mod_scripting_lua = { path = "../languages/bevy_mod_scripting_lua", version = "0.6.0", optional = true } -bevy_mod_scripting_lua_derive = { path = "../languages/bevy_mod_scripting_lua_derive", version = "0.6.0", optional = true } -bevy_mod_scripting_rhai = { path = "../languages/bevy_mod_scripting_rhai", version = "0.6.0", optional = true } -smol_str = "0.2" -allocator-api2 = "0.2" diff --git a/crates/bevy_script_api/readme.md b/crates/bevy_script_api/readme.md deleted file mode 100644 index 2a766e09..00000000 --- a/crates/bevy_script_api/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# bevy_script_api - -This crate is a part of the ["bevy_mod_scripting" workspace](https://github.com/makspll/bevy_mod_scripting). \ No newline at end of file diff --git a/crates/bevy_script_api/src/common/bevy/mod.rs b/crates/bevy_script_api/src/common/bevy/mod.rs deleted file mode 100644 index 40cf4ab1..00000000 --- a/crates/bevy_script_api/src/common/bevy/mod.rs +++ /dev/null @@ -1,304 +0,0 @@ -use std::{ - ops::{Deref, DerefMut}, - sync::Arc, -}; - -use crate::ReflectReference; -/// Common functionality for all script hosts -use bevy::{ - ecs::system::Command, - prelude::{ - AppTypeRegistry, BuildWorldChildren, Children, DespawnChildrenRecursive, DespawnRecursive, - Entity, Parent, ReflectComponent, ReflectDefault, ReflectResource, - }, - reflect::{ - DynamicArray, DynamicEnum, DynamicList, DynamicMap, DynamicStruct, DynamicTuple, - DynamicTupleStruct, TypeRegistration, - }, -}; -use bevy_mod_scripting_core::{prelude::ScriptError, world::WorldPointer}; - -/// Helper trait for retrieving a world pointer from a script context. -pub trait GetWorld { - type Error; - fn get_world(&self) -> Result; -} - -#[derive(Clone)] -pub struct ScriptTypeRegistration(pub(crate) Arc); - -impl ScriptTypeRegistration { - pub fn new(arc: Arc) -> Self { - Self(arc) - } - - #[inline(always)] - pub fn short_name(&self) -> &str { - self.0.type_info().type_path_table().short_path() - } - - #[inline(always)] - pub fn type_name(&self) -> &'static str { - self.0.type_info().type_path_table().path() - } -} - -impl std::fmt::Debug for ScriptTypeRegistration { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_tuple("ScriptTypeRegistration") - .field(&self.0.type_info().type_path()) - .finish() - } -} - -impl std::fmt::Display for ScriptTypeRegistration { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(self.0.type_info().type_path()) - } -} - -impl Deref for ScriptTypeRegistration { - type Target = TypeRegistration; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -#[derive(Clone, Debug)] -pub struct ScriptWorld(WorldPointer); - -impl std::fmt::Display for ScriptWorld { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str("World") - } -} - -impl Deref for ScriptWorld { - type Target = WorldPointer; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl DerefMut for ScriptWorld { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - -impl AsRef for ScriptWorld { - fn as_ref(&self) -> &WorldPointer { - &self.0 - } -} - -impl From for WorldPointer { - fn from(val: ScriptWorld) -> Self { - val.0 - } -} - -impl ScriptWorld { - pub fn new(ptr: WorldPointer) -> Self { - Self(ptr) - } - pub fn get_children(&self, parent: Entity) -> Vec { - let w = self.read(); - w.get::(parent) - .map(|v| v.to_vec()) - .unwrap_or_default() - } - - pub fn get_parent(&self, entity: Entity) -> Option { - let w = self.read(); - w.get::(entity).map(|parent| parent.get()) - } - - pub fn push_child(&self, parent: Entity, child: Entity) { - let mut w = self.write(); - if let Some(mut entity) = w.get_entity_mut(parent) { - entity.push_children(&[child]); - } - } - - pub fn remove_children(&self, parent: Entity, children: &[Entity]) { - let mut w = self.write(); - - if let Some(mut entity) = w.get_entity_mut(parent) { - entity.remove_children(children); - } - } - - pub fn insert_children(&self, parent: Entity, index: usize, children: &[Entity]) { - let mut w = self.write(); - - if let Some(mut entity) = w.get_entity_mut(parent) { - entity.insert_children(index, children); - } - } - - pub fn despawn_children_recursive(&self, entity: Entity) { - let mut w = self.write(); - DespawnChildrenRecursive { entity }.apply(&mut w); - } - - pub fn despawn_recursive(&self, entity: Entity) { - let mut w = self.write(); - DespawnRecursive { entity }.apply(&mut w); - } - - pub fn get_type_by_name(&self, type_name: &str) -> Option { - let w = self.read(); - - let registry: &AppTypeRegistry = w.get_resource().unwrap(); - - let registry = registry.read(); - - registry - .get_with_short_type_path(type_name) - .or_else(|| registry.get_with_type_path(type_name)) - .map(|registration| ScriptTypeRegistration::new(Arc::new(registration.clone()))) - } - - pub fn add_default_component( - &self, - entity: Entity, - comp_type: ScriptTypeRegistration, - ) -> Result { - let mut w = self.write(); - - // Remove: AppTypeRegistry - let registry: AppTypeRegistry = w.remove_resource().unwrap(); - - let mut entity_ref = w - .get_entity_mut(entity) - .ok_or_else(|| ScriptError::Other(format!("Entity is not valid {:#?}", entity)))?; - - let component_data = comp_type.data::().ok_or_else(|| { - ScriptError::Other(format!("Not a component {}", comp_type.short_name())) - })?; - - let registry_lock = registry.read(); - - // this is just a formality - // TODO: maybe get an add_default impl added to ReflectComponent - // this means that we don't require ReflectDefault for adding components! - match comp_type.0.type_info(){ - bevy::reflect::TypeInfo::Struct(_) => component_data.insert(&mut entity_ref, &DynamicStruct::default(), ®istry_lock), - bevy::reflect::TypeInfo::TupleStruct(_) => component_data.insert(&mut entity_ref, &DynamicTupleStruct::default(), ®istry_lock), - bevy::reflect::TypeInfo::Tuple(_) => component_data.insert(&mut entity_ref, &DynamicTuple::default(), ®istry_lock), - bevy::reflect::TypeInfo::List(_) => component_data.insert(&mut entity_ref, &DynamicList::default(), ®istry_lock), - bevy::reflect::TypeInfo::Array(_) => component_data.insert(&mut entity_ref, &DynamicArray::new(Box::new([])), ®istry_lock), - bevy::reflect::TypeInfo::Map(_) => component_data.insert(&mut entity_ref, &DynamicMap::default(), ®istry_lock), - bevy::reflect::TypeInfo::Value(_) => component_data.insert(&mut entity_ref, - comp_type.data::().ok_or_else(|| - ScriptError::Other(format!("Component {} is a value or dynamic type with no `ReflectDefault` type_data, cannot instantiate sensible value",comp_type.short_name())))? - .default() - .as_ref(), - ®istry_lock), - bevy::reflect::TypeInfo::Enum(_) => component_data.insert(&mut entity_ref, &DynamicEnum::default(), ®istry_lock) - }; - // if we do not drop the lock here, line below will complain registry is still borrowed at drop - drop(registry_lock); - - // Insert: AppTypeRegistry - w.insert_resource(registry); - - Ok(ReflectReference::new_component_ref( - component_data.clone(), - entity, - self.clone().into(), - )) - } - - pub fn get_component( - &self, - entity: Entity, - comp_type: ScriptTypeRegistration, - ) -> Result, ScriptError> { - let w = self.read(); - - let entity_ref = w - .get_entity(entity) - .ok_or_else(|| ScriptError::Other(format!("Entity is not valid {:#?}", entity)))?; - - let component_data = comp_type.data::().ok_or_else(|| { - ScriptError::Other(format!("Not a component {}", comp_type.short_name())) - })?; - - Ok(component_data.reflect(entity_ref).map(|_component| { - ReflectReference::new_component_ref(component_data.clone(), entity, self.clone().into()) - })) - } - - pub fn has_component( - &self, - entity: Entity, - comp_type: ScriptTypeRegistration, - ) -> Result { - let w = self.read(); - let component_data = comp_type.data::().ok_or_else(|| { - ScriptError::Other(format!("Not a component {}", comp_type.short_name())) - })?; - - let entity_ref = w - .get_entity(entity) - .ok_or_else(|| ScriptError::Other(format!("Entity is not valid {:#?}", entity)))?; - - Ok(component_data.reflect(entity_ref).is_some()) - } - - pub fn remove_component( - &mut self, - entity: Entity, - comp_type: ScriptTypeRegistration, - ) -> Result<(), ScriptError> { - let mut w = self.write(); - - let mut entity_ref = w - .get_entity_mut(entity) - .ok_or_else(|| ScriptError::Other(format!("Entity is not valid {:#?}", entity)))?; - - let component_data = comp_type.data::().ok_or_else(|| { - ScriptError::Other(format!("Not a component {}", comp_type.short_name())) - })?; - component_data.remove(&mut entity_ref); - Ok(()) - } - - pub fn get_resource( - &self, - res_type: ScriptTypeRegistration, - ) -> Result, ScriptError> { - let w = self.read(); - - let resource_data = res_type.data::().ok_or_else(|| { - ScriptError::Other(format!("Not a resource {}", res_type.short_name())) - })?; - - Ok(resource_data.reflect(&w).map(|_res| { - ReflectReference::new_resource_ref(resource_data.clone(), self.clone().into()) - })) - } - - pub fn has_resource(&self, res_type: ScriptTypeRegistration) -> Result { - let w = self.read(); - - let resource_data = res_type.data::().ok_or_else(|| { - ScriptError::Other(format!("Not a resource {}", res_type.short_name())) - })?; - - Ok(resource_data.reflect(&w).is_some()) - } - pub fn remove_resource(&mut self, res_type: ScriptTypeRegistration) -> Result<(), ScriptError> { - let mut w = self.write(); - - let resource_data = res_type.data::().ok_or_else(|| { - ScriptError::Other(format!("Not a resource {}", res_type.short_name())) - })?; - resource_data.remove(&mut w); - Ok(()) - } -} diff --git a/crates/bevy_script_api/src/common/mod.rs b/crates/bevy_script_api/src/common/mod.rs deleted file mode 100644 index 70b747d3..00000000 --- a/crates/bevy_script_api/src/common/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod bevy; -pub mod std; diff --git a/crates/bevy_script_api/src/common/std.rs b/crates/bevy_script_api/src/common/std.rs deleted file mode 100644 index dcf85073..00000000 --- a/crates/bevy_script_api/src/common/std.rs +++ /dev/null @@ -1,139 +0,0 @@ -use std::marker::PhantomData; - -use bevy::reflect::{FromReflect, TypePath}; - -use crate::{error::ReflectionError, ReflectReference, ValueIndex}; - -pub struct ScriptVec { - pub(crate) ref_: ReflectReference, - _ph: PhantomData, -} - -impl Clone for ScriptVec { - fn clone(&self) -> Self { - Self { - ref_: self.ref_.clone(), - _ph: PhantomData, - } - } -} - -impl std::fmt::Debug for ScriptVec { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("ScriptVec") - .field("ref_", &self.ref_) - .finish() - } -} - -impl std::fmt::Display for ScriptVec { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let str = self - .ref_ - .get_typed(|s: &Vec| s.iter().map(|v| format!("{v}")).collect::>()) - .map_err(|_| std::fmt::Error)? - .join(","); - f.write_str("[")?; - f.write_str(&str)?; - f.write_str("]") - } -} - -impl ScriptVec { - pub fn new_ref(ref_: ReflectReference) -> Self { - Self { - ref_, - _ph: PhantomData, - } - } - - pub fn is_empty(&self) -> Result { - Ok(self.len()? == 0) - } - - pub fn len(&self) -> Result { - self.ref_.get_typed(|s: &Vec| s.len()) - } - - pub fn push(&mut self, val: T) -> Result<(), ReflectionError> { - self.ref_.get_mut_typed(|s: &mut Vec| { - s.push(val); - Ok(()) - })? - } - - pub fn pop(&mut self) -> Result, ReflectionError> { - self.ref_.get_mut_typed(|s: &mut Vec| s.pop()) - } - - pub fn clear(&mut self) -> Result<(), ReflectionError> { - self.ref_.get_mut_typed(|s: &mut Vec| { - s.clear(); - Ok(()) - })? - } - - pub fn insert(&mut self, idx: usize, val: T) -> Result<(), ReflectionError> { - self.ref_.get_mut_typed(|s: &mut Vec| { - s.insert(idx, val); - Ok(()) - })? - } - - pub fn remove(&mut self, idx: usize) -> Result { - self.ref_ - .get_mut_typed(|s: &mut Vec| Ok(s.remove(idx)))? - } -} - -impl ValueIndex for ScriptVec { - type Output = ReflectReference; - - fn index(&self, index: usize) -> Self::Output { - self.ref_.index(index) - } -} - -impl From> for ReflectReference { - fn from(v: ScriptVec) -> Self { - v.ref_ - } -} - -pub struct ScriptVecIterator { - current: usize, - len: usize, - base: ScriptVec, -} - -impl Iterator for ScriptVecIterator { - type Item = ReflectReference; - - fn next(&mut self) -> Option { - let nxt = (self.current < self.len).then(|| self.base.index(self.current)); - self.current += 1; - nxt - } -} - -impl IntoIterator for ScriptVec { - type Item = ReflectReference; - - type IntoIter = ScriptVecIterator; - - /// Converts the vector into an iterator over references - /// - /// # Panics - /// will panic if the base reference is invalid or mutably locked - fn into_iter(self) -> Self::IntoIter { - ScriptVecIterator { - current: 0, - // TODO?: end used to be an Option, and this check moved into the next method but - // I am not sure if this will ever realistically fail, so if you do get this exception happening - // hit me with an issue - // if len > 0, subtract 1, otherwise set to 0 - len: self.len().expect("Failed to get length of ScriptVec"), - base: self, - } - } -} diff --git a/crates/bevy_script_api/src/core_providers.rs b/crates/bevy_script_api/src/core_providers.rs deleted file mode 100644 index 0b411cbf..00000000 --- a/crates/bevy_script_api/src/core_providers.rs +++ /dev/null @@ -1,101 +0,0 @@ -use crate::lua::RegisterForeignLuaType; - -pub struct LuaCoreBevyAPIProvider; - -#[derive(Default)] -pub(crate) struct CoreBevyGlobals; - -crate::impl_tealr_generic!(pub(crate) struct T); - -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for CoreBevyGlobals { - 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<()> { - 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(()) - } -} - -impl bevy_mod_scripting_core::hosts::APIProvider for LuaCoreBevyAPIProvider { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - - fn attach_api( - &mut self, - ctx: &mut Self::APITarget, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx - .get_mut() - .expect("Unable to acquire lock on Lua context"); - bevy_mod_scripting_lua::tealr::mlu::set_global_env(CoreBevyGlobals, ctx) - .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other(e.to_string())) - } - - fn get_doc_fragment(&self) -> Option { - Some(bevy_mod_scripting_lua::docs::LuaDocFragment::new( - "CoreBevyAPI", - |tw| { - tw - .document_global_instance::().expect("Something went wrong documenting globals") - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - }, - )) - } - - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx.get_mut().expect("Could not get context"); - let globals = ctx.globals(); - globals - .set( - "entity", - crate::providers::bevy_ecs::LuaEntity::new(script_data.entity), - ) - .map_err(bevy_mod_scripting_core::error::ScriptError::new_other)?; - globals - .set::<_, crate::lua::bevy::LuaScriptData>("script", script_data.into()) - .map_err(bevy_mod_scripting_core::error::ScriptError::new_other)?; - - Ok(()) - } - - fn register_with_app(&self, app: &mut bevy::app::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::(); - app.register_foreign_lua_type::(); - } -} diff --git a/crates/bevy_script_api/src/error.rs b/crates/bevy_script_api/src/error.rs deleted file mode 100644 index aa2ae622..00000000 --- a/crates/bevy_script_api/src/error.rs +++ /dev/null @@ -1,37 +0,0 @@ -use std::borrow::Cow; -use thiserror::Error; - -#[derive(Error, Debug, Clone)] -pub enum ReflectionError { - #[error("Base reference `{base}` is invalid. {reason}")] - InvalidBaseReference { base: String, reason: String }, - #[error("Insuficient provenance error while accessing `{path}`. {msg}")] - InsufficientProvenance { path: String, msg: String }, - #[error("Invalid reflection path: `{path}`. {msg}")] - InvalidReflectionPath { path: String, msg: String }, - #[error("Cannot downcast from `{from}` to `{to}`")] - CannotDowncast { - from: Cow<'static, str>, - to: Cow<'static, str>, - }, - #[error("{0}")] - Other(String), -} - -#[cfg(feature = "lua")] -impl From for bevy_mod_scripting_lua::tealr::mlu::mlua::Error { - fn from(e: ReflectionError) -> Self { - bevy_mod_scripting_lua::tealr::mlu::mlua::Error::RuntimeError(e.to_string()) - } -} - -#[cfg(feature = "rhai")] -impl From for Box { - fn from(e: ReflectionError) -> Self { - bevy_mod_scripting_rhai::rhai::EvalAltResult::ErrorRuntime( - e.to_string().into(), - bevy_mod_scripting_rhai::rhai::Position::NONE, - ) - .into() - } -} diff --git a/crates/bevy_script_api/src/lib.rs b/crates/bevy_script_api/src/lib.rs deleted file mode 100644 index eee50f03..00000000 --- a/crates/bevy_script_api/src/lib.rs +++ /dev/null @@ -1,45 +0,0 @@ -extern crate bevy; - -pub mod error; -#[cfg(feature = "lua")] -pub mod lua; -#[cfg(feature = "rhai")] -pub mod rhai; - -pub mod common; - -#[cfg(feature = "lua")] -pub(crate) mod core_providers; -// for now providers do not support any other lang so just remove this whole module if they are not needed -#[cfg(feature = "lua")] -pub(crate) mod providers; - -pub mod script_ref; -pub mod sub_reflect; -pub mod wrappers; - -pub use {script_ref::*, sub_reflect::*}; - -pub mod prelude { - #[cfg(feature = "lua")] - pub use crate::{ - core_providers::LuaCoreBevyAPIProvider, - lua::{std::LuaVec, FromLuaProxy, IntoLuaProxy, LuaProxyable, ReflectLuaProxyable}, - providers::LuaBevyAPIProvider, - LuaProxy, - }; - - #[cfg(feature = "rhai")] - pub use crate::rhai::{ - bevy::RhaiBevyAPIProvider, - std::{RhaiCopy, RhaiVec}, - FromRhaiProxy, ReflectRhaiProxyable, RhaiProxyable, ToRhaiProxy, - }; - - pub use crate::{common::bevy::GetWorld, ValueIndex}; -} - -#[cfg(feature = "lua")] -pub use bevy_mod_scripting_lua_derive::LuaProxy; - -pub use parking_lot; diff --git a/crates/bevy_script_api/src/lua/bevy/mod.rs b/crates/bevy_script_api/src/lua/bevy/mod.rs deleted file mode 100644 index 69896455..00000000 --- a/crates/bevy_script_api/src/lua/bevy/mod.rs +++ /dev/null @@ -1,296 +0,0 @@ -use crate::common::bevy::{ScriptTypeRegistration, ScriptWorld}; -use crate::providers::bevy_ecs::LuaEntity; -use crate::{impl_from_lua_with_clone, impl_tealr_type}; - -use std::sync::Arc; - -use bevy::hierarchy::BuildWorldChildren; -use bevy::prelude::AppTypeRegistry; - -use bevy::prelude::ReflectResource; -use bevy_mod_scripting_core::prelude::*; -use bevy_mod_scripting_lua::tealr; - -use tealr::mlu::{ - mlua::{self}, - TealData, TealDataMethods, -}; - -use super::util::LuaIndex; - -pub type LuaTypeRegistration = ScriptTypeRegistration; -impl_tealr_type!(LuaTypeRegistration); -impl_from_lua_with_clone!(LuaTypeRegistration); - -impl TealData for LuaTypeRegistration { - fn add_methods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) { - methods.document_type("An object representing an existing and registered rust type."); - methods.document_type("Can be obtained via [`LuaWorld::get_type_by_name`]."); - } - - fn add_fields<'lua, F: tealr::mlu::TealDataFields<'lua, Self>>(fields: &mut F) { - fields.document("The [short name](https://docs.rs/bevy/latest/bevy/reflect/struct.TypeRegistration.html#method.get_short_name) of a type"); - fields.add_field_method_get("short_name", |_, s| Ok(s.short_name().to_string())); - - fields.document("The full name of the type"); - fields.add_field_method_get("type_name", |_, s| Ok(s.type_name())); - } -} - -#[derive(Debug)] -pub struct LuaScriptData { - sid: u32, -} - -impl From<&ScriptData<'_>> for LuaScriptData { - fn from(sd: &ScriptData) -> Self { - Self { sid: sd.sid } - } -} - -impl_tealr_type!(LuaScriptData); - -impl TealData for LuaScriptData { - fn add_fields<'lua, F: tealr::mlu::TealDataFields<'lua, Self>>(fields: &mut F) { - fields.document("The unique ID of this script"); - fields.add_field_method_get("sid", |_, s| Ok(s.sid)) - } - - fn add_methods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) { - methods.add_meta_method(tealr::mlu::mlua::MetaMethod::ToString, |_, s, ()| { - Ok(format!("{:?}", s)) - }); - } -} - -pub type LuaWorld = ScriptWorld; - -impl_tealr_type!(LuaWorld); -impl_from_lua_with_clone!(LuaWorld); - -impl TealData for LuaWorld { - fn add_methods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) { - methods.document_type("Represents the bevy world all scripts live in."); - methods.document_type("Provides ways to interact with and modify the world."); - - methods.add_meta_method(tealr::mlu::mlua::MetaMethod::ToString, |_, s, ()| { - Ok(format!("{s:?}")) - }); - - methods.document("Retrieves type information given either a short (`MyType`) or fully qualified rust type name (`MyModule::MyType`)."); - methods.document( - "Returns `nil` if no such type exists or if one wasn't registered on the rust side.", - ); - methods.document("\n"); - methods.document("This is used extensively in [`LuaWorld`]"); - methods.add_method("get_type_by_name", |_, world, type_name: String| { - let w = world.read(); - - let registry: &AppTypeRegistry = w.get_resource().unwrap(); - - let registry = registry.read(); - - Ok(registry - .get_with_short_type_path(&type_name) - .or_else(|| registry.get_with_type_path(&type_name)) - .map(|registration| LuaTypeRegistration::new(Arc::new(registration.clone())))) - }); - - methods.document("Inserts a component of the given type to the given entity by instantiating a default version of it."); - methods.document("The component can then be modified using field access."); - methods.add_method( - "add_default_component", - |_, world, (entity, comp_type): (LuaEntity, LuaTypeRegistration)| { - world - .add_default_component(entity.inner()?, comp_type) - .map_err(|e| mlua::Error::RuntimeError(e.to_string())) - }, - ); - - methods.document("Retrieves a component of the given type from the given entity."); - methods.document("If such a component does not exist returns `nil`."); - methods.add_method( - "get_component", - |_, world, (entity, comp_type): (LuaEntity, LuaTypeRegistration)| { - world - .get_component(entity.inner()?, comp_type) - .map_err(|e| mlua::Error::RuntimeError(e.to_string())) - }, - ); - - methods - .document("Returns `true` if the given entity contains a component of the given type."); - methods.add_method( - "has_component", - |_, world, (entity, comp_type): (LuaEntity, LuaTypeRegistration)| { - world - .has_component(entity.inner()?, comp_type) - .map_err(|e| mlua::Error::RuntimeError(e.to_string())) - }, - ); - - methods.document("Removes the given component from the given entity, does nothing if it doesn't exist on the entity."); - methods.add_method_mut( - "remove_component", - |_, world, (entity, comp_type): (LuaEntity, LuaTypeRegistration)| { - world - .remove_component(entity.inner()?, comp_type) - .map_err(|e| mlua::Error::RuntimeError(e.to_string())) - }, - ); - - methods.document("Retrieves a resource of the given type from the world."); - methods.document("If such a resource does not exist returns `nil`."); - methods.add_method("get_resource", |_, world, res_type: LuaTypeRegistration| { - world - .get_resource(res_type) - .map_err(|e| mlua::Error::RuntimeError(e.to_string())) - }); - - methods.document( - "Removes the given resource from the world, if one doesn't exist it does nothing.", - ); - methods.add_method( - "remove_resource", - |_, world, res_type: LuaTypeRegistration| { - let mut w = world.write(); - - let resource_data = res_type.data::().ok_or_else(|| { - mlua::Error::RuntimeError(format!("Not a resource {}", res_type.short_name())) - })?; - resource_data.remove(&mut w); - Ok(()) - }, - ); - - methods.document("Returns `true` if the world contains a resource of the given type."); - methods.add_method("has_resource", |_, world, res_type: LuaTypeRegistration| { - let w = world.read(); - - let resource_data = res_type.data::().ok_or_else(|| { - mlua::Error::RuntimeError(format!("Not a resource {}", res_type.short_name())) - })?; - - Ok(resource_data.reflect(&w).is_some()) - }); - - methods.document("Retrieves children entities of the parent entity if it has any."); - methods.add_method("get_children", |_, world, parent: LuaEntity| { - Ok(world - .get_children(parent.inner()?) - .into_iter() - .map(LuaEntity::new) - .collect::>()) - }); - - methods.document("Retrieves the parent entity of the given entity if it has any."); - methods.add_method("get_parent", |_, world, parent: LuaEntity| { - Ok(world.get_parent(parent.inner()?).map(LuaEntity::new)) - }); - - methods.document("Attaches children entities to the given parent entity."); - methods.add_method( - "push_children", - |_, world, (parent, children): (LuaEntity, Vec)| { - let mut w = world.write(); - let children = children - .iter() - .map(|e| e.inner()) - .collect::, _>>()?; - - if let Some(mut entity) = w.get_entity_mut(parent.inner()?) { - entity.push_children(&children); - } - - Ok(()) - }, - ); - - methods.document("Attaches child entity to the given parent entity."); - methods.add_method_mut( - "push_child", - |_, world, (parent, child): (LuaEntity, LuaEntity)| { - world.push_child(parent.inner()?, child.inner()?); - Ok(()) - }, - ); - - methods.document("Removes children entities from the given parent entity."); - methods.add_method( - "remove_children", - |_, world, (parent, children): (LuaEntity, Vec)| { - let children = children - .iter() - .map(|e| e.inner()) - .collect::, _>>()?; - - world.remove_children(parent.inner()?, &children); - Ok(()) - }, - ); - - methods.document("Removes child entity from the given parent entity."); - methods.add_method( - "remove_child", - |_, world, (parent, child): (LuaEntity, LuaEntity)| { - world.remove_children(parent.inner()?, &[child.inner()?]); - Ok(()) - }, - ); - - methods - .document("Inserts children entities to the given parent entity at the given index."); - methods.add_method( - "insert_children", - |_, world, (parent, index, children): (LuaEntity, LuaIndex, Vec)| { - let children = children - .iter() - .map(|e| e.inner()) - .collect::, _>>()?; - - world.insert_children(parent.inner()?, *index, &children); - Ok(()) - }, - ); - - methods.document("Inserts child entity to the given parent entity at the given index."); - methods.add_method( - "insert_child", - |_, world, (parent, index, child): (LuaEntity, LuaIndex, LuaEntity)| { - world.insert_children(parent.inner()?, *index, &[child.inner()?]); - Ok(()) - }, - ); - - methods.document("Despawns the given entity's children recursively"); - methods.add_method( - "despawn_children_recursive", - |_, world, entity: LuaEntity| { - world.despawn_children_recursive(entity.inner()?); - Ok(()) - }, - ); - - methods.document("Despawns the given entity and the entity's children recursively"); - methods.add_method("despawn_recursive", |_, world, entity: LuaEntity| { - world.despawn_recursive(entity.inner()?); - Ok(()) - }); - - methods.document("Spawns a new entity and returns its Entity ID"); - methods.add_method("spawn", |_, world, ()| { - let mut w = world.write(); - - Ok(LuaEntity::new(w.spawn(()).id())) - }); - - methods.document( - "Despawns the given entity if it exists, returns true if deletion was successfull", - ); - methods.add_method("despawn", |_, world, entity: LuaEntity| { - let mut w = world.write(); - - Ok(w.despawn(entity.inner()?)) - }); - } -} diff --git a/crates/bevy_script_api/src/lua/mod.rs b/crates/bevy_script_api/src/lua/mod.rs deleted file mode 100644 index 08bcb30b..00000000 --- a/crates/bevy_script_api/src/lua/mod.rs +++ /dev/null @@ -1,306 +0,0 @@ -use ::std::any::TypeId; -use ::std::borrow::Cow; - -use crate::common::bevy::GetWorld; -use crate::{impl_from_lua_with_clone, impl_tealr_type}; -use ::bevy::prelude::{App, AppTypeRegistry}; - -use ::bevy::reflect::{FromType, GetTypeRegistration, Reflect}; - -use bevy_mod_scripting_core::world::WorldPointer; -use bevy_mod_scripting_lua::tealr::{self, ToTypename}; - -use tealr::mlu::mlua::MetaMethod; -use tealr::mlu::{ - mlua::{self, FromLua, IntoLua, Lua, UserData, Value}, - TealData, TealDataMethods, -}; - -use crate::script_ref::{ReflectReference, ReflectedValue, ValueIndex}; - -use self::bevy::LuaWorld; -use self::util::to_host_idx; - -pub mod bevy; -pub mod std; -pub mod util; - -/// A trait allowing to register the [`LuaProxyable`] trait with the type registry for foreign types -/// -/// If you have access to the type you should prefer to use `#[reflect(LuaProxyable)]` instead. -/// This is exactly equivalent. -pub trait RegisterForeignLuaType { - /// Register an instance of `ReflecLuaProxyable` type data on this type's registration, - /// if a registration does not yet exist, creates one. - fn register_foreign_lua_type( - &mut self, - ) -> &mut Self; -} - -impl RegisterForeignLuaType for App { - fn register_foreign_lua_type( - &mut self, - ) -> &mut Self { - { - let registry = self.world.resource_mut::(); - let mut registry = registry.write(); - - let user_data = >::from_type(); - - if let Some(registration) = registry.get_mut(TypeId::of::()) { - registration.insert(user_data) - } else { - let mut registration = T::get_type_registration(); - registration.insert(user_data); - registry.add_registration(registration); - } - } - - self - } -} - -impl ValueIndex> for ReflectReference { - type Output = Result; - - fn index(&self, index: Value<'_>) -> Self::Output { - match index { - Value::Integer(idx) => Ok(self.index(to_host_idx(idx as usize))), - Value::String(field) => { - let str_ = field.to_str()?.to_string(); - // TODO: hopefully possible to use a &'_ str here - // but this requires Reflect implementation for &str - Ok(>>::index( - self, - str_.into(), - )) - } - _ => Err(mlua::Error::RuntimeError(format!( - "Cannot index a rust object with {:?}", - index - ))), - } - } -} - -/// For internal use only. -/// -/// Mainly necessary for separation of concerns on the [`ReflectReference`] type, but might have other uses potentially. -/// -/// This is not the same as [`LuaProxyable`], internally this in fact will use [`LuaProxyable`] so treating it like so will cause inifnite loops. -pub(crate) trait ApplyLua { - /// set the proxied object with the given lua value - fn apply_lua<'lua>(&mut self, ctx: &'lua Lua, v: Value<'lua>) -> mlua::Result<()>; -} -impl ApplyLua for ReflectReference { - /// Applies the given lua value to the proxied reflect type. Semantically equivalent to `Reflect::apply` - fn apply_lua<'lua>(&mut self, ctx: &'lua Lua, v: Value<'lua>) -> Result<(), mlua::Error> { - let luaworld = ctx.globals().get::<_, LuaWorld>("world").unwrap(); - - // remove typedata from the world to be able to manipulate world - let proxyable = { - let world = luaworld.read(); - let type_registry = world.resource::().read(); - type_registry - .get_type_data::(self.get(|s| s.type_id())?) - .cloned() - }; - - if let Some(ud) = proxyable { - return ud.apply_lua(self, ctx, v); - } else if let Value::UserData(v) = &v { - if v.is::() { - let b = v.take::().unwrap(); - self.apply(&b.into())?; - return Ok(()); - } - } - - Err(mlua::Error::RuntimeError(self.get(|s| - format!("Attempted to assign `{}` = {v:?}. Did you forget to call `app.register_foreign_lua_type::<{}>`?", - self.path, - s.get_represented_type_info().unwrap().type_path() - ))?) - ) - } -} - -impl<'lua> IntoLua<'lua> for ReflectReference { - /// Converts the LuaRef to the most convenient representation - /// checking conversions in this order: - /// - A primitive or bevy type which has a reflect interface is converted to a custom UserData exposing its API to lua conveniently - /// - A type implementing CustomUserData is converted with its `ref_to_lua` method - /// - Finally the method is represented as a `ReflectedValue` which exposes the Reflect interface - fn into_lua(self, ctx: &'lua Lua) -> mlua::Result> { - let world = self.world_ptr.clone(); - let world = world.read(); - - let typedata = &world.resource::(); - let g = typedata.read(); - - let type_id = self.get(|s| s.type_id())?; - if let Some(v) = g.get_type_data::(type_id) { - v.ref_to_lua(self, ctx) - } else { - ReflectedValue { ref_: self }.into_lua(ctx) - } - } -} - -impl ToTypename for ReflectReference { - fn to_typename() -> tealr::Type { - tealr::Type::new_single("ReflectedValue", tealr::KindOfType::External) - } -} - -impl_tealr_type!(ReflectedValue); -impl_from_lua_with_clone!(ReflectedValue); -impl TealData for ReflectedValue { - fn add_methods<'lua, T: TealDataMethods<'lua, Self>>(methods: &mut T) { - methods.document_type("This type represents a generic reflected value."); - methods.document_type("If you know the reflected value converts to a LuaType (via LuaProxyable), use the `as` operator to convert to said type."); - - methods.add_meta_method(MetaMethod::ToString, |_, val, ()| { - val.ref_.get(|s| Ok(format!("{:?}", &s)))? - }); - - methods.add_meta_method_mut(MetaMethod::Index, |_, val, field: Value| { - let r = val.ref_.index(field)?; - Ok(r) - }); - - methods.add_meta_method_mut( - MetaMethod::NewIndex, - |ctx, val, (field, new_val): (Value, Value)| { - val.ref_.index(field)?.apply_lua(ctx, new_val)?; - Ok(()) - }, - ); - } -} -/// A higher level trait for allowing types to be interpreted as custom lua proxy types (or just normal types, this interface is flexible). -/// Types implementing this trait can have [`ReflectLuaProxyable`] type data registrations inserted into the reflection API. -/// -/// Types registered via the reflection API this way can be accessed from Lua via [`ReflectReference`] objects (via field access). -pub trait LuaProxyable { - /// a version of [`mlua::ToLua::to_lua`] which does not consume the object. - /// - /// Note: The self reference is sourced from the given ReflectReference, attempting to get another mutable reference from the ReflectReference might - /// cause a runtime error to prevent breaking of aliasing rules - fn ref_to_lua(self_: ReflectReference, lua: &Lua) -> mlua::Result; - - /// similar to [`Reflect::apply`] - /// - /// Note: - /// The self reference is sourced from the given ReflectReference, attempting to get another reference from the ReflectReference might - /// cause a runtime error to prevent breaking of aliasing rules - fn apply_lua<'lua>( - self_: &mut ReflectReference, - lua: &'lua Lua, - new_val: Value<'lua>, - ) -> mlua::Result<()>; -} - -/// Exactly alike to [`mlua::ToLua`] -pub trait FromLuaProxy<'lua>: Sized { - fn from_lua_proxy(new_val: Value<'lua>, lua: &'lua Lua) -> mlua::Result; -} - -/// Exactly alike to [`mlua::FromLua`] -pub trait IntoLuaProxy<'lua> { - fn to_lua_proxy(self, lua: &'lua Lua) -> mlua::Result>; -} - -/// A struct providing type data for the `LuaProxyable` trait. -/// -/// This allows casting static methods from the `LuaProxyable trait`. -#[derive(Clone)] -pub struct ReflectLuaProxyable { - ref_to_lua: for<'lua> fn(ref_: ReflectReference, lua: &'lua Lua) -> mlua::Result>, - apply_lua: for<'lua> fn( - ref_: &mut ReflectReference, - lua: &'lua Lua, - new_val: Value<'lua>, - ) -> mlua::Result<()>, -} - -impl ReflectLuaProxyable { - pub fn ref_to_lua<'lua>( - &self, - ref_: ReflectReference, - lua: &'lua Lua, - ) -> mlua::Result> { - (self.ref_to_lua)(ref_, lua) - } - - pub fn apply_lua<'lua>( - &self, - ref_: &mut ReflectReference, - lua: &'lua Lua, - new_val: Value<'lua>, - ) -> mlua::Result<()> { - (self.apply_lua)(ref_, lua, new_val) - } -} - -impl ::bevy::reflect::FromType - for ReflectLuaProxyable -{ - fn from_type() -> Self { - Self { - ref_to_lua: T::ref_to_lua, - apply_lua: T::apply_lua, - } - } -} - -/// A dummy trait used to combat rust's orphan rules -/// -/// In the future when trait specialization is a thing, this might be a companion trait -/// to `RefLuaType` which allows non Clone types to be used -pub trait ValueLuaType {} - -impl LuaProxyable for T { - fn ref_to_lua(self_: ReflectReference, lua: &Lua) -> mlua::Result { - self_.get_typed(|s: &Self| s.clone().into_lua(lua))? - } - - fn apply_lua<'lua>( - self_: &mut ReflectReference, - _: &'lua Lua, - new_val: Value<'lua>, - ) -> mlua::Result<()> { - if let Value::UserData(v) = new_val { - let o = v.borrow::()?; - - self_.get_mut_typed(|s| *s = o.clone())?; - - Ok(()) - } else { - Err(mlua::Error::RuntimeError( - "Error in assigning to custom user data".to_owned(), - )) - } - } -} - -impl<'lua, T: Clone + UserData + FromLua<'lua> + Send + ValueLuaType + Reflect + 'static> - FromLuaProxy<'lua> for T -{ - fn from_lua_proxy(new_val: Value<'lua>, lua: &'lua Lua) -> mlua::Result { - T::from_lua(new_val, lua) - } -} - -impl<'lua, T: Clone + UserData + Send + ValueLuaType + Reflect + 'static> IntoLuaProxy<'lua> for T { - fn to_lua_proxy(self, lua: &'lua Lua) -> mlua::Result> { - self.into_lua(lua) - } -} - -impl GetWorld for Lua { - type Error = mlua::Error; - fn get_world(&self) -> Result { - self.globals().get::<_, LuaWorld>("world").map(Into::into) - } -} diff --git a/crates/bevy_script_api/src/lua/std.rs b/crates/bevy_script_api/src/lua/std.rs deleted file mode 100644 index fc36faec..00000000 --- a/crates/bevy_script_api/src/lua/std.rs +++ /dev/null @@ -1,474 +0,0 @@ -use std::sync::Arc; - -use bevy::reflect::FromReflect; -use bevy::reflect::Reflect; - -use bevy::reflect::TypePath; -use bevy_mod_scripting_lua::tealr; - -use bevy_mod_scripting_lua::tealr::ToTypename; -use tealr::mlu::mlua::MetaMethod; -use tealr::mlu::TypedFunction; -use tealr::mlu::{ - mlua::{self, FromLua, IntoLua, Lua, UserData, Value}, - TealData, TealDataMethods, -}; -use tealr::TypeBody; - -use paste::paste; - -use crate::common::std::ScriptVec; -use crate::{ - error::ReflectionError, - script_ref::{ReflectReference, ValueIndex}, - sub_reflect::ReflectionPathElement, -}; - -use super::util::to_lua_idx; -use super::util::LuaIndex; -use super::ApplyLua; -use super::FromLuaProxy; -use super::IntoLuaProxy; -use super::LuaProxyable; - -/// Implements custom user data for simple copy types which implement to and from lua -macro_rules! impl_proxyable_by_copy( - ( $($num_ty:ty),*) => { - paste! { - $( - impl $crate::lua::LuaProxyable for $num_ty { - fn ref_to_lua(self_: $crate::script_ref::ReflectReference,lua: & tealr::mlu::mlua::Lua) -> tealr::mlu::mlua::Result > { - self_.get_typed(|self_ : &Self| self_.into_lua(lua))? - } - - fn apply_lua< 'lua>(self_: &mut $crate::script_ref::ReflectReference,lua: & 'lua tealr::mlu::mlua::Lua,new_val:tealr::mlu::mlua::Value< 'lua>) -> tealr::mlu::mlua::Result<()> { - self_.set_val(Self::from_lua(new_val,lua)?)?; - Ok(()) - } - } - - impl <'lua>$crate::lua::FromLuaProxy<'lua> for $num_ty { - #[inline(always)] - fn from_lua_proxy(new_value: Value<'lua>, lua: &'lua Lua) -> tealr::mlu::mlua::Result { - Self::from_lua(new_value,lua) - } - } - - impl <'lua>$crate::lua::IntoLuaProxy<'lua> for $num_ty { - #[inline(always)] - fn to_lua_proxy(self, lua: &'lua Lua) -> tealr::mlu::mlua::Result> { - self.into_lua(lua) - } - } - )* - } - } -); - -impl_proxyable_by_copy!(bool); -impl_proxyable_by_copy!(f32, f64); -impl_proxyable_by_copy!(i8, i16, i32, i64, i128, isize); -impl_proxyable_by_copy!(u8, u16, u32, u64, u128, usize); - -impl LuaProxyable for String { - fn ref_to_lua(self_: ReflectReference, lua: &Lua) -> mlua::Result { - self_.get_typed(|self_: &String| self_.as_str().into_lua(lua))? - } - - fn apply_lua<'lua>( - self_: &mut ReflectReference, - lua: &'lua Lua, - new_val: Value<'lua>, - ) -> mlua::Result<()> { - self_.get_mut_typed(|self_| { - *self_ = Self::from_lua(new_val, lua)?; - Ok(()) - })? - } -} - -impl<'lua> FromLuaProxy<'lua> for String { - fn from_lua_proxy(new_val: Value<'lua>, lua: &'lua Lua) -> mlua::Result { - Self::from_lua(new_val, lua) - } -} - -impl<'lua> IntoLuaProxy<'lua> for String { - fn to_lua_proxy(self, lua: &'lua Lua) -> mlua::Result> { - self.into_lua(lua) - } -} - -impl FromLuaProxy<'a> + Clone> - LuaProxyable for Option -{ - fn ref_to_lua(self_: ReflectReference, lua: &Lua) -> mlua::Result { - self_.get_typed(|s: &Option| match s { - Some(_) => T::ref_to_lua( - self_.sub_ref(ReflectionPathElement::SubReflection { - label: "as_ref", - get: Arc::new(|ref_| { - ref_.downcast_ref::>() - .ok_or_else(|| ReflectionError::CannotDowncast { - from: ref_.get_represented_type_info().unwrap().type_path().into(), - to: stringify!(Option).into(), - })? - .as_ref() - .map(|t| t as &dyn Reflect) - .ok_or_else(|| { - ReflectionError::Other( - "Stale reference to Option. Cannot sub reflect.".to_owned(), - ) - }) - }), - get_mut: Arc::new(|ref_| { - ref_.downcast_mut::>() - // TODO: there is some weird borrow checker fuckery going on here - // i tried having from: ref_.get_represented_type_info().unwrap().type_path().into() instead of "Reflect" - // and lying this out in an if let expression, but nothing will satisfy the borrow checker here, so leaving this for now - .ok_or_else(|| ReflectionError::CannotDowncast { - from: "Reflect".into(), - to: stringify!(Option).into(), - })? - .as_mut() - .map(|t| t as &mut dyn Reflect) - .ok_or_else(|| { - ReflectionError::Other( - "Stale reference to Option. Cannot sub reflect.".to_owned(), - ) - }) - }), - }), - lua, - ), - None => Ok(Value::Nil), - })? - } - - fn apply_lua<'lua>( - self_: &mut ReflectReference, - lua: &'lua Lua, - new_val: Value<'lua>, - ) -> mlua::Result<()> { - if let Value::Nil = new_val { - self_.get_mut_typed(|s: &mut Option| { - *s = None; - Ok(()) - })? - } else { - // we need to do this in two passes, first - // ensure that the target type is the 'some' variant to allow a sub reference - let is_none = self_.get_typed(|s: &Option| s.is_none())?; - - if is_none { - return self_.get_mut_typed(|s: &mut Option| { - *s = Some(T::from_lua_proxy(new_val, lua)?); - Ok::<_, mlua::Error>(()) - })?; - } - - T::apply_lua( - &mut self_.sub_ref(ReflectionPathElement::SubReflection { - label: "", - get: Arc::new(|ref_| { - ref_.downcast_ref::>() - .ok_or_else(|| ReflectionError::CannotDowncast { - from: ref_.get_represented_type_info().unwrap().type_path().into(), - to: stringify!(Option).into(), - })? - .as_ref() - .map(|t| t as &dyn Reflect) - .ok_or_else(|| { - ReflectionError::Other( - "Stale reference to Option. Cannot sub reflect.".to_owned(), - ) - }) - }), - get_mut: Arc::new(|ref_| { - if ref_.is::>() { - ref_.downcast_mut::>() - .unwrap() - .as_mut() - .map(|t| t as &mut dyn Reflect) - .ok_or_else(|| { - ReflectionError::Other( - "Stale reference to Option. Cannot sub reflect.".to_owned(), - ) - }) - } else { - Err(ReflectionError::CannotDowncast { - from: ref_.get_represented_type_info().unwrap().type_path().into(), - to: stringify!(Option).into(), - }) - } - }), - }), - lua, - new_val, - ) - } - } -} - -impl<'lua, T: for<'a> FromLuaProxy<'a>> FromLuaProxy<'lua> for Option { - fn from_lua_proxy(new_val: Value<'lua>, lua: &'lua Lua) -> mlua::Result { - if let Value::Nil = new_val { - Ok(None) - } else { - T::from_lua_proxy(new_val, lua).map(Option::Some) - } - } -} - -impl<'lua, T: for<'a> IntoLuaProxy<'a>> IntoLuaProxy<'lua> for Option { - fn to_lua_proxy(self, lua: &'lua Lua) -> mlua::Result> { - match self { - Some(v) => v.to_lua_proxy(lua), - None => Ok(Value::Nil), - } - } -} - -/// A reference to a rust vec (vec reference proxy), does not need an owned variant since -/// lua can natively represent lists of things -pub type LuaVec = ScriptVec; - -impl< - T: ToTypename - + FromReflect - + TypePath - + LuaProxyable - + for<'a> FromLuaProxy<'a> - + for<'a> IntoLuaProxy<'a> - + std::fmt::Debug, - > UserData for LuaVec -{ - fn add_methods<'lua, M: tealr::mlu::mlua::UserDataMethods<'lua, Self>>(methods: &mut M) { - let mut x = tealr::mlu::UserDataWrapper::from_user_data_methods(methods); - ::add_methods(&mut x); - } - fn add_fields<'lua, F: tealr::mlu::mlua::UserDataFields<'lua, Self>>(fields: &mut F) { - let mut wrapper = tealr::mlu::UserDataWrapper::from_user_data_fields(fields); - ::add_fields(&mut wrapper) - } -} - -impl ToTypename for LuaVec { - /// Before tealr deprecated TypeName, this used to incorporate generics here, but right now I don't think they're supported anymore - fn to_typename() -> tealr::Type { - tealr::Type::new_single("LuaVec", tealr::KindOfType::External) - } -} - -impl< - T: ToTypename - + FromReflect - + TypePath - + LuaProxyable - + for<'a> FromLuaProxy<'a> - + for<'a> IntoLuaProxy<'a> - + std::fmt::Debug, - > TypeBody for LuaVec -{ - fn get_type_body() -> tealr::TypeGenerator { - let mut gen = tealr::RecordGenerator::new::(false); - gen.is_user_data = true; - ::add_fields(&mut gen); - ::add_methods(&mut gen); - gen.into() - } -} - -impl< - T: ToTypename - + FromReflect - + TypePath - + LuaProxyable - + for<'a> FromLuaProxy<'a> - + for<'a> IntoLuaProxy<'a>, - > TealData for LuaVec -{ - fn add_methods<'lua, M: TealDataMethods<'lua, Self>>(methods: &mut M) { - methods.document_type("A reference to the Vec Rust type."); - methods.document_type("All indexing begins at 1."); - - methods.add_meta_method(MetaMethod::ToString, |_, s, ()| { - Ok(s.ref_.get(|s| format!("{:?}", s))?) - }); - - methods.add_meta_method(MetaMethod::Index, |_, s, index: LuaIndex| { - Ok(s.index(*index)) - }); - - methods.add_meta_method_mut( - MetaMethod::NewIndex, - |ctx, s, (index, value): (LuaIndex, Value)| s.index(*index).apply_lua(ctx, value), - ); - - bevy_mod_scripting_lua::__cfg_feature_any_lua52_lua53_lua54_luajit52!( - methods.add_meta_method( - MetaMethod::Pairs, - |ctx, s, _: ()| { - let len = s.len()?; - let mut curr_idx = 0; - let ref_: ReflectReference = s.clone().into(); - TypedFunction::from_rust_mut( - move |ctx, ()| { - let o = if curr_idx < len { - ( - to_lua_idx(curr_idx).into_lua(ctx)?, - ref_.index(curr_idx).into_lua(ctx)?, - ) - } else { - (Value::Nil, Value::Nil) - }; - curr_idx += 1; - Ok(o) - }, - ctx, - ) - }, - ); - ); - methods.add_meta_method(MetaMethod::Len, |_, s, ()| Ok(s.len()?)); - - methods.add_method("to_table", |ctx, s, ()| { - let table = ctx.create_table()?; - let len = s.len()?; - - for i in 0..len { - table.raw_set(to_lua_idx(i), s.index(i).into_lua(ctx)?)?; - } - - Ok(table) - }); - - methods.add_method_mut("push", |ctx, s, v: Value| { - let new_val = T::from_lua_proxy(v, ctx)?; - s.push(new_val)?; - Ok(()) - }); - - methods.add_method_mut("pop", |ctx, s, ()| s.pop().map(|v| v.to_lua_proxy(ctx))?); - - methods.add_method_mut("clear", |_, s, ()| { - s.clear()?; - Ok(()) - }); - - methods.add_method_mut("insert", |ctx, s, (idx, v): (LuaIndex, Value<'lua>)| { - s.insert(*idx, T::from_lua_proxy(v, ctx)?)?; - Ok(()) - }); - - methods.add_method_mut("remove", |ctx, s, idx: LuaIndex| { - let removed = s.remove(*idx)?; - removed.to_lua_proxy(ctx) - }); - } -} - -impl< - T: ToTypename - + FromReflect - + TypePath - + LuaProxyable - + for<'a> FromLuaProxy<'a> - + for<'a> IntoLuaProxy<'a> - + std::fmt::Debug, - > LuaProxyable for Vec -{ - fn ref_to_lua(self_: ReflectReference, lua: &Lua) -> mlua::Result { - LuaVec::::new_ref(self_).into_lua(lua) - } - - fn apply_lua<'lua>( - self_: &mut ReflectReference, - lua: &'lua Lua, - new_val: Value<'lua>, - ) -> mlua::Result<()> { - match &new_val { - Value::UserData(ud) => { - let lua_vec = ud.borrow::>()?; - self_.apply(&lua_vec.ref_)?; - } - Value::Table(table) => { - let last_target_idx = self_.get_typed(|s: &Vec| s.len())? - 1; - // there is also another case to consider, Vec has a lua representation available as well (table) - // if we receive one of those, we should also apply it - for entry in table.clone().pairs::() { - let (lua_idx, v) = entry?; - let idx = lua_idx - 1; - if idx > last_target_idx { - // here we don't need to do anything special just use LuaProxyable impl - T::apply_lua(&mut self_.index(idx), lua, v)?; - } else { - // here we don't have anything to apply this to - // use FromLua impl - self_.get_mut_typed(|s: &mut Vec| { - s[idx] = T::from_lua_proxy(v, lua)?; - Ok::<_, mlua::Error>(()) - })??; - } - } - } - _ => { - return Err(mlua::Error::FromLuaConversionError { - from: new_val.type_name(), - to: "userdata or table", - message: Some("LuaVec can only be assigned with itself or a table".to_owned()), - }) - } - } - - Ok(()) - } -} - -impl< - 'lua, - T: ToTypename - + for<'a> FromLuaProxy<'a> - + for<'a> IntoLuaProxy<'a> - + Clone - + FromReflect - + TypePath - + LuaProxyable - + std::fmt::Debug, - > FromLuaProxy<'lua> for Vec -{ - fn from_lua_proxy(new_val: Value<'lua>, lua: &'lua Lua) -> mlua::Result { - match new_val { - Value::UserData(ud) => { - let lua_vec = ud.borrow::>()?; - lua_vec.ref_.get_typed(|s: &Vec| Ok(s.clone()))? - } - Value::Table(table) => { - // there is also another case to consider, Vec has a lua representation available as well (table) - // if we receive one of those, we should clone it one by one - table - .pairs::() - .map(|v| v.and_then(|(_, v)| T::from_lua_proxy(v, lua))) - .collect::, _>>() - } - _ => Err(mlua::Error::FromLuaConversionError { - from: new_val.type_name(), - to: "userdata or table", - message: Some("LuaVec can only be assigned with itself or a table".to_owned()), - }), - } - } -} - -impl<'lua, T: for<'a> IntoLuaProxy<'a> + Clone + FromReflect + LuaProxyable> IntoLuaProxy<'lua> - for Vec -{ - fn to_lua_proxy(self, lua: &'lua Lua) -> mlua::Result> { - let proxies = lua.create_table()?; - for (idx, elem) in self.into_iter().enumerate() { - proxies.raw_set(idx, elem.to_lua_proxy(lua)?)?; - } - - proxies.into_lua(lua) - } -} diff --git a/crates/bevy_script_api/src/lua/util.rs b/crates/bevy_script_api/src/lua/util.rs deleted file mode 100644 index 09ecadb6..00000000 --- a/crates/bevy_script_api/src/lua/util.rs +++ /dev/null @@ -1,300 +0,0 @@ -use bevy_mod_scripting_lua::{ - prelude::{FromLua, IntoLua, Lua, LuaError, LuaValue}, - tealr::{self, ToTypename}, -}; -use std::{ - marker::PhantomData, - ops::{Deref, DerefMut}, -}; - -/// Newtype abstraction of usize to represent a lua integer indexing things. -/// Lua is 1 based, host is 0 based, and this type performs this conversion automatically via ToLua and FromLua traits. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct LuaIndex(usize); - -impl ToTypename for LuaIndex { - fn to_typename() -> tealr::Type { - ::to_typename() - } -} - -impl Deref for LuaIndex { - type Target = usize; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl DerefMut for LuaIndex { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - -impl IntoLua<'_> for LuaIndex { - fn into_lua(self, lua: &Lua) -> Result { - to_lua_idx(self.0).into_lua(lua) - } -} - -impl FromLua<'_> for LuaIndex { - fn from_lua(value: LuaValue, lua: &Lua) -> Result { - Ok(LuaIndex(to_host_idx(usize::from_lua(value, lua)?))) - } -} - -/// Converts lua index to host index (Lua is 1 based, host is 0 based) -pub fn to_host_idx(lua_idx: usize) -> usize { - lua_idx - 1 -} - -/// Converts host index to lua index (Lua is 1 based, host is 0 based) -pub fn to_lua_idx(host_idx: usize) -> usize { - host_idx + 1 -} - -/// forwards the TypeName implementation of T, useful for internal 'fake' global instances -pub struct DummyTypeName { - _ph: PhantomData, -} - -impl DummyTypeName { - pub fn new( - _: &bevy_mod_scripting_lua::tealr::mlu::mlua::Lua, - ) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result { - Ok(Self { - _ph: PhantomData::, - }) - } -} - -impl<'lua, T> bevy_mod_scripting_lua::tealr::mlu::mlua::IntoLua<'lua> for DummyTypeName { - fn into_lua( - self, - _: &'lua bevy_mod_scripting_lua::tealr::mlu::mlua::Lua, - ) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result< - bevy_mod_scripting_lua::tealr::mlu::mlua::Value<'lua>, - > { - Ok(bevy_mod_scripting_lua::tealr::mlu::mlua::Value::Nil) - } -} - -impl ToTypename for DummyTypeName { - fn to_typename() -> bevy_mod_scripting_lua::tealr::Type { - T::to_typename() - } -} - -#[macro_export] -macro_rules! impl_from_lua_with_clone { - ($v:ty) => { - impl<'lua> bevy_mod_scripting_lua::tealr::mlu::mlua::FromLua<'lua> for $v { - #[inline] - fn from_lua( - value: bevy_mod_scripting_lua::tealr::mlu::mlua::Value<'lua>, - _: &'lua bevy_mod_scripting_lua::tealr::mlu::mlua::Lua, - ) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<$v> { - match value { - bevy_mod_scripting_lua::tealr::mlu::mlua::Value::UserData(ud) => { - Ok(ud.borrow::<$v>()?.clone()) - } - _ => Err( - bevy_mod_scripting_lua::tealr::mlu::mlua::Error::FromLuaConversionError { - from: value.type_name(), - to: "userdata", - message: None, - }, - ), - } - } - } - }; -} - -/// Implements :tealr::TypeName, tealr::TypeBody and mlua::Userdata based on non-generic single token type name implementing TealData -#[macro_export] -macro_rules! impl_tealr_type { - ($v:ty) => { - impl bevy_mod_scripting_lua::tealr::ToTypename for $v { - fn to_typename() -> bevy_mod_scripting_lua::tealr::Type { - bevy_mod_scripting_lua::tealr::Type::new_single(stringify!($v), bevy_mod_scripting_lua::tealr::KindOfType::External) - } - } - - impl bevy_mod_scripting_lua::tealr::mlu::mlua::UserData for $v { - fn add_fields<'lua, F: bevy_mod_scripting_lua::tealr::mlu::mlua::prelude::LuaUserDataFields<'lua, Self>>(fields: &mut F) { - let mut wrapper = ::bevy_mod_scripting_lua::tealr::mlu::UserDataWrapper::from_user_data_fields(fields); - ::add_fields(&mut wrapper) - } - - fn add_methods<'lua, M: bevy_mod_scripting_lua::tealr::mlu::mlua::prelude::LuaUserDataMethods<'lua, Self>>( - methods: &mut M, - ) { - let mut x = ::bevy_mod_scripting_lua::tealr::mlu::UserDataWrapper::from_user_data_methods(methods); - ::add_methods(&mut x); - } - } - - impl bevy_mod_scripting_lua::tealr::TypeBody for $v { - fn get_type_body() -> bevy_mod_scripting_lua::tealr::TypeGenerator { - let mut gen = ::bevy_mod_scripting_lua::tealr::RecordGenerator::new::(false); - gen.is_user_data = true; - ::add_fields(&mut gen); - ::add_methods(&mut gen); - <_ as ::std::convert::From<_>>::from(gen) - } - } - }; -} - -/// like create_bevy_mod_scripting_lua::tealr_union but translates to `any` in the lua declaration file, -/// a fill in to allow multiple userdata types -#[macro_export] -macro_rules! impl_tealr_any_union { - ($visibility:vis $(Derives($($derives:ident), +))? enum $type_name:ident = $($sub_types_ident:ident: $sub_types_type:ty) | +) => { - #[derive($($($derives ,)*)*)] - #[allow(non_camel_case_types)] - $visibility enum $type_name { - $($sub_types_ident($sub_types_type) ,)* - } - impl<'lua> ::bevy_mod_scripting_lua::tealr::mlu::mlua::IntoLua<'lua> for $type_name { - fn into_lua(self, lua: &'lua ::bevy_mod_scripting_lua::tealr::mlu::mlua::Lua) -> ::std::result::Result<::bevy_mod_scripting_lua::tealr::mlu::mlua::Value<'lua>, ::bevy_mod_scripting_lua::tealr::mlu::mlua::Error> { - match self { - $($type_name::$sub_types_ident(x) => x.into_lua(lua),)* - } - } - } - impl<'lua> ::bevy_mod_scripting_lua::tealr::mlu::mlua::FromLua<'lua> for $type_name { - fn from_lua(value: ::bevy_mod_scripting_lua::tealr::mlu::mlua::Value<'lua>, lua: &'lua ::bevy_mod_scripting_lua::tealr::mlu::mlua::Lua) -> ::std::result::Result { - $(match $sub_types_ident::from_lua(value.clone(),lua) { - Ok(x) => return Ok($type_name::$sub_types_ident(x)), - Err(::bevy_mod_scripting_lua::tealr::mlu::mlua::Error::FromLuaConversionError{from:_,to:_,message:_}) => {} - Err(x) => return Err(x) - };)* - Err(::bevy_mod_scripting_lua::tealr::mlu::mlua::Error::FromLuaConversionError{ - to: stringify!( $($sub_types_ident)|* ), - from: value.type_name(), - message: None - }) - } - } - impl ::bevy_mod_scripting_lua::tealr::ToTypename for $type_name { - fn to_typename() -> bevy_mod_scripting_lua::tealr::Type { - bevy_mod_scripting_lua::tealr::Type::new_single("any", bevy_mod_scripting_lua::tealr::KindOfType::Builtin) - } - } - }; -} - -#[macro_export] -macro_rules! impl_tealr_generic{ - { - $vis:vis struct $name:ident - } => { - #[derive(Default,Clone,Debug)] - $vis struct $name; - - impl $crate::lua::ValueLuaType for $name {} - - impl ::bevy_mod_scripting_lua::tealr::mlu::TealData for $name { - - } - - impl ::bevy::reflect::TypePath for $name { - fn short_type_path() -> &'static str{ - panic!("This should never be called, I am a dummy implementation") - } - - fn type_path() -> &'static str{ - panic!("This should never be called, I am a dummy implementation") - } - } - - impl ::bevy::reflect::Reflect for $name { - - fn into_any(self: Box) -> Box { - panic!("This should never be called, I am a dummy implementation"); - } - - fn as_any(&self) -> &dyn std::any::Any { - panic!("This should never be called, I am a dummy implementation"); - } - - fn as_any_mut(&mut self) -> &mut dyn std::any::Any { - panic!("This should never be called, I am a dummy implementation"); - } - - fn as_reflect(&self) -> &dyn ::bevy::reflect::Reflect { - panic!("This should never be called, I am a dummy implementation"); - } - - fn as_reflect_mut(&mut self) -> &mut dyn ::bevy::reflect::Reflect { - panic!("This should never be called, I am a dummy implementation"); - } - - fn apply(&mut self, _: &dyn ::bevy::reflect::Reflect) { - panic!("This should never be called, I am a dummy implementation"); - } - - fn set(&mut self, _: Box) -> Result<(), Box> { - panic!("This should never be called, I am a dummy implementation"); - } - - fn reflect_ref(&self) -> bevy::reflect::ReflectRef { - panic!("This should never be called, I am a dummy implementation"); - } - - fn reflect_mut(&mut self) -> bevy::reflect::ReflectMut { - panic!("This should never be called, I am a dummy implementation"); - } - - fn clone_value(&self) -> Box { - panic!("This should never be called, I am a dummy implementation"); - } - - fn into_reflect(self: Box) -> Box { - panic!("This should never be called, I am a dummy implementation"); - } - - fn reflect_owned(self: Box) -> ::bevy::reflect::ReflectOwned { - panic!("This should never be called, I am a dummy implementation"); - } - - fn get_represented_type_info(&self) -> std::option::Option<&'static bevy::reflect::TypeInfo> { - panic!("This should never be called, I am a dummy implementation"); - } - } - - impl ::bevy::reflect::FromReflect for $name { - fn from_reflect(_: &(dyn bevy::prelude::Reflect + 'static)) -> std::option::Option { - panic!("This should never be called, I am a dummy implementation"); - } - } - - $crate::impl_tealr_type!($name); - $crate::impl_from_lua_with_clone!($name); - } -} - -// /// Implements UserData for type which implements TealData, can handle generics after the type name: -// /// ```rust,ignore -// /// impl_user_data!(MyType<'a,T : Debug>); -// /// ``` -// macro_rules! impl_user_data { -// ($v:ident $(< $( $lt:tt $( : $clt:tt $(+ $dlt:tt $(<'a>)? )* )? ),+ >)? ) => { -// impl $(< $( $lt $( : $clt $(+ $dlt $(<'a>)?)* )? ),+ >)? ::bevy_mod_scripting_lua::tealr::mlu::mlua::UserData for $v $(< $( $lt ),+ >)? { -// fn add_methods<'lua, M: ::bevy_mod_scripting_lua::tealr::mlu::mlua::UserDataMethods<'lua, Self>>(methods: &mut M) { -// let mut x = ::bevy_mod_scripting_lua::tealr::mlu::UserDataWrapper::from_user_data_methods(methods); -// ::add_methods(&mut x); -// } -// fn add_fields<'lua, F: ::bevy_mod_scripting_lua::tealr::mlu::mlua::UserDataFields<'lua, Self>>(fields: &mut F) { -// let mut wrapper = ::bevy_mod_scripting_lua::tealr::mlu::UserDataWrapper::from_user_data_fields(fields); -// ::add_fields(&mut wrapper) -// } -// } - -// } -// } - -// pub(crate) use impl_user_data; diff --git a/crates/bevy_script_api/src/providers/bevy_core.rs b/crates/bevy_script_api/src/providers/bevy_core.rs deleted file mode 100644 index ed8492c8..00000000 --- a/crates/bevy_script_api/src/providers/bevy_core.rs +++ /dev/null @@ -1,87 +0,0 @@ -// @generated by cargo bevy-api-gen generate, modify the templates not this file -#![allow(clippy::all)] -#![allow(unused, deprecated, dead_code)] -#![cfg_attr(rustfmt, rustfmt_skip)] -use super::bevy_ecs::*; -use super::bevy_reflect::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::core::prelude::Name", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::core::prelude::Name; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &name::Name) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct Name {} -#[derive(Default)] -pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { - Ok(()) - } -} -pub struct BevyCoreAPIProvider; -impl bevy_mod_scripting_core::hosts::APIProvider for BevyCoreAPIProvider { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - fn attach_api( - &mut self, - ctx: &mut Self::APITarget, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context"); - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx) - .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other( - e.to_string(), - )) - } - fn get_doc_fragment(&self) -> Option { - Some( - bevy_mod_scripting_lua::docs::LuaDocFragment::new( - "BevyCoreAPI", - |tw| { - tw.document_global_instance::() - .expect("Something went wrong documenting globals") - .process_type::() - }, - ), - ) - } - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn register_with_app(&self, app: &mut bevy::app::App) { - app.register_foreign_lua_type::(); - } -} diff --git a/crates/bevy_script_api/src/providers/bevy_ecs.rs b/crates/bevy_script_api/src/providers/bevy_ecs.rs deleted file mode 100644 index 718cfb2e..00000000 --- a/crates/bevy_script_api/src/providers/bevy_ecs.rs +++ /dev/null @@ -1,382 +0,0 @@ -// @generated by cargo bevy-api-gen generate, modify the templates not this file -#![allow(clippy::all)] -#![allow(unused, deprecated, dead_code)] -#![cfg_attr(rustfmt, rustfmt_skip)] -use super::bevy_reflect::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::ecs::entity::Entity", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &entity::Entity) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::entity::Entity; - -"#, - r#" -/// Creates a new entity ID with the specified `index` and a generation of 1. -/// # 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. - - #[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. -/// 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. - - #[lua(kind = "Method")] - fn to_bits(self) -> u64; - -"#, - r#" -/// 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. -/// # Panics -/// This method will likely panic if given `u64` values that did not come from [`Entity::to_bits`]. - - #[lua(kind = "Function", output(proxy))] - fn from_bits(bits: u64) -> bevy::ecs::entity::Entity; - -"#, - r#" -/// 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. - - #[lua(kind = "Method")] - 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(kind = "Method")] - fn generation(self) -> u32; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Entity {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::ecs::component::ComponentId", - functions[r#" -/// Creates a new [`ComponentId`]. -/// The `index` is a unique value associated with each type of component in a given world. -/// Usually, this value is taken from a counter incremented for each type of component registered with the world. - - #[lua(kind = "Function", output(proxy))] - fn new(index: usize) -> bevy::ecs::component::ComponentId; - -"#, - r#" -/// Returns the index of the current component. - - #[lua(kind = "Method")] - fn index(self) -> usize; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &component::ComponentId) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::component::ComponentId; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct ComponentId(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::ecs::component::Tick", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::component::Tick; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -/// Creates a new [`Tick`] wrapping the given value. - - #[lua(kind = "Function", output(proxy))] - fn new(tick: u32) -> bevy::ecs::component::Tick; - -"#, - r#" -/// Gets the value of this change tick. - - #[lua(kind = "Method")] - fn get(self) -> u32; - -"#, - r#" -/// Sets the value of this change tick. - - #[lua(kind = "MutatingMethod")] - fn set(&mut self, tick: u32) -> (); - -"#, - r#" -/// Returns `true` if this `Tick` occurred since the system's `last_run`. -/// `this_run` is the current tick of the system, used as a reference to help deal with wraparound. - - #[lua(kind = "Method")] - fn is_newer_than( - self, - #[proxy] - last_run: bevy::ecs::component::Tick, - #[proxy] - this_run: bevy::ecs::component::Tick, - ) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &component::Tick) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Tick {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::ecs::component::ComponentTicks", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::component::ComponentTicks; - -"#, - r#" -/// Returns `true` if the component or resource was added after the system last ran. - - #[lua(kind = "Method")] - fn is_added( - &self, - #[proxy] - last_run: bevy::ecs::component::Tick, - #[proxy] - this_run: bevy::ecs::component::Tick, - ) -> bool; - -"#, - r#" -/// Returns `true` if the component or resource was added or mutably dereferenced after the system last ran. - - #[lua(kind = "Method")] - fn is_changed( - &self, - #[proxy] - last_run: bevy::ecs::component::Tick, - #[proxy] - this_run: bevy::ecs::component::Tick, - ) -> bool; - -"#, - r#" -/// Returns the tick recording the time this component or resource was most recently changed. - - #[lua(kind = "Method", output(proxy))] - fn last_changed_tick(&self) -> bevy::ecs::component::Tick; - -"#, - r#" -/// Returns the tick recording the time this component or resource was added. - - #[lua(kind = "Method", output(proxy))] - fn added_tick(&self) -> bevy::ecs::component::Tick; - -"#, - r#" -/// Manually sets the change tick. -/// This is normally done automatically via the [`DerefMut`](std::ops::DerefMut) implementation -/// on [`Mut`](crate::change_detection::Mut), [`ResMut`](crate::change_detection::ResMut), etc. -/// However, components and resources that make use of interior mutability might require manual updates. -/// # Example -/// ```no_run -/// # use bevy_ecs::{world::World, component::ComponentTicks}; -/// let world: World = unimplemented!(); -/// let component_ticks: ComponentTicks = unimplemented!(); -/// component_ticks.set_changed(world.read_change_tick()); -/// ``` - - #[lua(kind = "MutatingMethod")] - fn set_changed(&mut self, #[proxy] change_tick: bevy::ecs::component::Tick) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct ComponentTicks {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::ecs::entity::EntityHash", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::entity::EntityHash; - -"#] -)] -pub struct EntityHash {} -#[derive(Default)] -pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { - instances - .add_instance( - "Entity", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "ComponentId", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Tick", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - Ok(()) - } -} -pub struct BevyEcsAPIProvider; -impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - fn attach_api( - &mut self, - ctx: &mut Self::APITarget, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context"); - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx) - .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other( - e.to_string(), - )) - } - fn get_doc_fragment(&self) -> Option { - Some( - bevy_mod_scripting_lua::docs::LuaDocFragment::new( - "BevyEcsAPI", - |tw| { - tw.document_global_instance::() - .expect("Something went wrong documenting globals") - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaComponentId, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::() - }, - ), - ) - } - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn register_with_app(&self, app: &mut bevy::app::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::(); - } -} diff --git a/crates/bevy_script_api/src/providers/bevy_hierarchy.rs b/crates/bevy_script_api/src/providers/bevy_hierarchy.rs deleted file mode 100644 index 837439d3..00000000 --- a/crates/bevy_script_api/src/providers/bevy_hierarchy.rs +++ /dev/null @@ -1,116 +0,0 @@ -// @generated by cargo bevy-api-gen generate, modify the templates not this file -#![allow(clippy::all)] -#![allow(unused, deprecated, dead_code)] -#![cfg_attr(rustfmt, rustfmt_skip)] -use super::bevy_ecs::*; -use super::bevy_reflect::*; -use super::bevy_core::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(), - remote = "bevy::hierarchy::prelude::Children", - functions[r#" -/// Swaps the child at `a_index` with the child at `b_index`. - - #[lua(kind = "MutatingMethod")] - fn swap(&mut self, a_index: usize, b_index: usize) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Children(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(), - remote = "bevy::hierarchy::prelude::Parent", - functions[r#" -/// Gets the [`Entity`] ID of the parent. - - #[lua(kind = "Method", output(proxy))] - fn get(&self) -> bevy::ecs::entity::Entity; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &components::parent::Parent) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Parent(); -#[derive(Default)] -pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { - Ok(()) - } -} -pub struct BevyHierarchyAPIProvider; -impl bevy_mod_scripting_core::hosts::APIProvider for BevyHierarchyAPIProvider { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - fn attach_api( - &mut self, - ctx: &mut Self::APITarget, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context"); - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx) - .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other( - e.to_string(), - )) - } - fn get_doc_fragment(&self) -> Option { - Some( - bevy_mod_scripting_lua::docs::LuaDocFragment::new( - "BevyHierarchyAPI", - |tw| { - tw.document_global_instance::() - .expect("Something went wrong documenting globals") - .process_type::() - .process_type::() - }, - ), - ) - } - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn register_with_app(&self, app: &mut bevy::app::App) { - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - } -} diff --git a/crates/bevy_script_api/src/providers/bevy_input.rs b/crates/bevy_script_api/src/providers/bevy_input.rs deleted file mode 100644 index bc84022f..00000000 --- a/crates/bevy_script_api/src/providers/bevy_input.rs +++ /dev/null @@ -1,1537 +0,0 @@ -// @generated by cargo bevy-api-gen generate, modify the templates not this file -#![allow(clippy::all)] -#![allow(unused, deprecated, dead_code)] -#![cfg_attr(rustfmt, rustfmt_skip)] -use super::bevy_ecs::*; -use super::bevy_reflect::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::Gamepad", - functions[r#" -/// Creates a new [`Gamepad`]. - - #[lua(kind = "Function", output(proxy))] - fn new(id: usize) -> bevy::input::gamepad::Gamepad; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::Gamepad) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::Gamepad; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Gamepad { - id: usize, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadAxis", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadAxis; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadAxis) -> bool; - -"#, - r#" -/// Creates a new [`GamepadAxis`]. -/// # Examples -/// ``` -/// # use bevy_input::gamepad::{GamepadAxis, GamepadAxisType, Gamepad}; -/// # -/// let gamepad_axis = GamepadAxis::new( -/// Gamepad::new(1), -/// GamepadAxisType::LeftStickX, -/// ); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - axis_type: bevy::input::gamepad::GamepadAxisType, - ) -> bevy::input::gamepad::GamepadAxis; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GamepadAxis { - #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] - axis_type: bevy::input::gamepad::GamepadAxisType, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadAxisType", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadAxisType) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadAxisType; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GamepadAxisType {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadButton", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadButton) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButton; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -/// Creates a new [`GamepadButton`]. -/// # Examples -/// ``` -/// # use bevy_input::gamepad::{GamepadButton, GamepadButtonType, Gamepad}; -/// # -/// let gamepad_button = GamepadButton::new( -/// Gamepad::new(1), -/// GamepadButtonType::South, -/// ); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - button_type: bevy::input::gamepad::GamepadButtonType, - ) -> bevy::input::gamepad::GamepadButton; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GamepadButton { - #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] - button_type: bevy::input::gamepad::GamepadButtonType, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadButtonType", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadButtonType) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonType; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GamepadButtonType {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::keyboard::KeyCode", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::KeyCode; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &keyboard::KeyCode) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct KeyCode {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::mouse::MouseButton", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &mouse::MouseButton) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseButton; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct MouseButton {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::touch::TouchInput", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &touch::TouchInput) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touch::TouchInput; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct TouchInput { - #[lua(output(proxy))] - phase: bevy::input::touch::TouchPhase, - #[lua(output(proxy))] - position: bevy::math::Vec2, - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - force: ReflectedValue, - id: u64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::keyboard::Key", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &keyboard::Key) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::Key; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Key {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::keyboard::KeyboardInput", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &keyboard::KeyboardInput) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::KeyboardInput; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct KeyboardInput { - #[lua(output(proxy))] - key_code: bevy::input::keyboard::KeyCode, - #[lua(output(proxy))] - logical_key: bevy::input::keyboard::Key, - #[lua(output(proxy))] - state: bevy::input::ButtonState, - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::keyboard::NativeKey", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::NativeKey; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &keyboard::NativeKey) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct NativeKey {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::keyboard::NativeKeyCode", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::NativeKeyCode; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &keyboard::NativeKeyCode) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct NativeKeyCode {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::mouse::MouseButtonInput", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseButtonInput; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &mouse::MouseButtonInput) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct MouseButtonInput { - #[lua(output(proxy))] - button: bevy::input::mouse::MouseButton, - #[lua(output(proxy))] - state: bevy::input::ButtonState, - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::mouse::MouseMotion", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseMotion; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &mouse::MouseMotion) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct MouseMotion { - #[lua(output(proxy))] - delta: bevy::math::Vec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::mouse::MouseScrollUnit", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &mouse::MouseScrollUnit) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseScrollUnit; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct MouseScrollUnit {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::mouse::MouseWheel", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseWheel; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &mouse::MouseWheel) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct MouseWheel { - #[lua(output(proxy))] - unit: bevy::input::mouse::MouseScrollUnit, - x: f32, - y: f32, - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::touch::ForceTouch", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touch::ForceTouch; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &touch::ForceTouch) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct ForceTouch {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::touch::TouchPhase", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &touch::TouchPhase) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touch::TouchPhase; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct TouchPhase {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::touchpad::TouchpadMagnify", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &touchpad::TouchpadMagnify) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touchpad::TouchpadMagnify; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct TouchpadMagnify(f32); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::touchpad::TouchpadRotate", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &touchpad::TouchpadRotate) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touchpad::TouchpadRotate; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct TouchpadRotate(f32); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::AxisSettings", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::AxisSettings) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::AxisSettings; - -"#, - r#" -/// Get the value above which inputs will be rounded up to 1.0. - - #[lua(kind = "Method")] - fn livezone_upperbound(&self) -> f32; - -"#, - r#" -/// Try to set the value above which inputs will be rounded up to 1.0. -/// If the value passed is negative or less than `deadzone_upperbound`, -/// the value will not be changed. -/// Returns the new value of `livezone_upperbound`. - - #[lua(kind = "MutatingMethod")] - fn set_livezone_upperbound(&mut self, value: f32) -> f32; - -"#, - r#" -/// Get the value below which positive inputs will be rounded down to 0.0. - - #[lua(kind = "Method")] - fn deadzone_upperbound(&self) -> f32; - -"#, - r#" -/// Try to set the value below which positive inputs will be rounded down to 0.0. -/// If the value passed is negative or greater than `livezone_upperbound`, -/// the value will not be changed. -/// Returns the new value of `deadzone_upperbound`. - - #[lua(kind = "MutatingMethod")] - fn set_deadzone_upperbound(&mut self, value: f32) -> f32; - -"#, - r#" -/// Get the value below which negative inputs will be rounded down to -1.0. - - #[lua(kind = "Method")] - fn livezone_lowerbound(&self) -> f32; - -"#, - r#" -/// Try to set the value below which negative inputs will be rounded down to -1.0. -/// If the value passed is positive or greater than `deadzone_lowerbound`, -/// the value will not be changed. -/// Returns the new value of `livezone_lowerbound`. - - #[lua(kind = "MutatingMethod")] - fn set_livezone_lowerbound(&mut self, value: f32) -> f32; - -"#, - r#" -/// Get the value above which inputs will be rounded up to 0.0. - - #[lua(kind = "Method")] - fn deadzone_lowerbound(&self) -> f32; - -"#, - r#" -/// Try to set the value above which inputs will be rounded up to 0.0. -/// If the value passed is less than -1.0 or less than `livezone_lowerbound`, -/// the value will not be changed. -/// Returns the new value of `deadzone_lowerbound`. - - #[lua(kind = "MutatingMethod")] - fn set_deadzone_lowerbound(&mut self, value: f32) -> f32; - -"#, - r#" -/// Get the minimum value by which input must change before the change is registered. - - #[lua(kind = "Method")] - fn threshold(&self) -> f32; - -"#, - r#" -/// Try to set the minimum value by which input must change before the changes will be applied. -/// If the value passed is not within [0.0..=2.0], the value will not be changed. -/// Returns the new value of threshold. - - #[lua(kind = "MutatingMethod")] - fn set_threshold(&mut self, value: f32) -> f32; - -"#, - r#" -/// Clamps the `raw_value` according to the `AxisSettings`. - - #[lua(kind = "Method")] - fn clamp(&self, new_value: f32) -> f32; - -"#, - r#" -/// Filters the `new_value` based on the `old_value`, according to the [`AxisSettings`]. -/// Returns the clamped `new_value` if the change exceeds the settings threshold, -/// and `None` otherwise. - - #[lua(kind = "Method")] - fn filter( - &self, - new_value: f32, - old_value: std::option::Option, - ) -> std::option::Option; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct AxisSettings {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::ButtonAxisSettings", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::ButtonAxisSettings; - -"#, - r#" -/// Filters the `new_value` based on the `old_value`, according to the [`ButtonAxisSettings`]. -/// Returns the clamped `new_value`, according to the [`ButtonAxisSettings`], if the change -/// exceeds the settings threshold, and `None` otherwise. - - #[lua(kind = "Method")] - fn filter( - &self, - new_value: f32, - old_value: std::option::Option, - ) -> std::option::Option; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct ButtonAxisSettings { - high: f32, - low: f32, - threshold: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::ButtonSettings", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::ButtonSettings; - -"#, - r#" -/// Returns `true` if the button is pressed. -/// A button is considered pressed if the `value` passed is greater than or equal to the press threshold. - - #[lua(kind = "Method")] - fn is_pressed(&self, value: f32) -> bool; - -"#, - r#" -/// Returns `true` if the button is released. -/// A button is considered released if the `value` passed is lower than or equal to the release threshold. - - #[lua(kind = "Method")] - fn is_released(&self, value: f32) -> bool; - -"#, - r#" -/// Get the button input threshold above which the button is considered pressed. - - #[lua(kind = "Method")] - fn press_threshold(&self) -> f32; - -"#, - r#" -/// Try to set the button input threshold above which the button is considered pressed. -/// If the value passed is outside the range [release threshold..=1.0], the value will not be changed. -/// Returns the new value of the press threshold. - - #[lua(kind = "MutatingMethod")] - fn set_press_threshold(&mut self, value: f32) -> f32; - -"#, - r#" -/// Get the button input threshold below which the button is considered released. - - #[lua(kind = "Method")] - fn release_threshold(&self) -> f32; - -"#, - r#" -/// Try to set the button input threshold below which the button is considered released. If the -/// value passed is outside the range [0.0..=press threshold], the value will not be changed. -/// Returns the new value of the release threshold. - - #[lua(kind = "MutatingMethod")] - fn set_release_threshold(&mut self, value: f32) -> f32; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct ButtonSettings {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadAxisChangedEvent", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadAxisChangedEvent) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadAxisChangedEvent; - -"#, - r#" -/// Creates a [`GamepadAxisChangedEvent`]. - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - axis_type: bevy::input::gamepad::GamepadAxisType, - value: f32, - ) -> bevy::input::gamepad::GamepadAxisChangedEvent; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GamepadAxisChangedEvent { - #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] - axis_type: bevy::input::gamepad::GamepadAxisType, - value: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadButtonChangedEvent", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonChangedEvent; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadButtonChangedEvent) -> bool; - -"#, - r#" -/// Creates a [`GamepadButtonChangedEvent`]. - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - button_type: bevy::input::gamepad::GamepadButtonType, - value: f32, - ) -> bevy::input::gamepad::GamepadButtonChangedEvent; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GamepadButtonChangedEvent { - #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] - button_type: bevy::input::gamepad::GamepadButtonType, - value: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadButtonInput", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadButtonInput) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonInput; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GamepadButtonInput { - #[lua(output(proxy))] - button: bevy::input::gamepad::GamepadButton, - #[lua(output(proxy))] - state: bevy::input::ButtonState, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadConnection", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadConnection; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadConnection) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GamepadConnection {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadConnectionEvent", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadConnectionEvent) -> bool; - -"#, - r#" -/// Creates a [`GamepadConnectionEvent`]. - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - connection: bevy::input::gamepad::GamepadConnection, - ) -> bevy::input::gamepad::GamepadConnectionEvent; - -"#, - r#" -/// Is the gamepad connected? - - #[lua(kind = "Method")] - fn connected(&self) -> bool; - -"#, - r#" -/// Is the gamepad disconnected? - - #[lua(kind = "Method")] - fn disconnected(&self) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadConnectionEvent; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GamepadConnectionEvent { - #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] - connection: bevy::input::gamepad::GamepadConnection, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadEvent", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadEvent) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadEvent; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GamepadEvent {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(), - remote = "bevy::input::gamepad::GamepadSettings", - functions[r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GamepadSettings { - #[lua(output(proxy))] - default_button_settings: bevy::input::gamepad::ButtonSettings, - #[lua(output(proxy))] - default_axis_settings: bevy::input::gamepad::AxisSettings, - #[lua(output(proxy))] - default_button_axis_settings: bevy::input::gamepad::ButtonAxisSettings, - button_settings: ReflectedValue, - axis_settings: ReflectedValue, - button_axis_settings: ReflectedValue, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::ButtonState", - functions[r#" -/// Is this button pressed? - - #[lua(kind = "Method")] - fn is_pressed(&self) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &ButtonState) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::ButtonState; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct ButtonState {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadInfo", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadInfo) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadInfo; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GamepadInfo { - name: std::string::String, -} -#[derive(Default)] -pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { - instances - .add_instance( - "Gamepad", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "GamepadAxis", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "GamepadButton", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadButton, - >::new, - )?; - instances - .add_instance( - "GamepadAxisChangedEvent", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadAxisChangedEvent, - >::new, - )?; - instances - .add_instance( - "GamepadButtonChangedEvent", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadButtonChangedEvent, - >::new, - )?; - instances - .add_instance( - "GamepadConnectionEvent", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadConnectionEvent, - >::new, - )?; - Ok(()) - } -} -pub struct BevyInputAPIProvider; -impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - fn attach_api( - &mut self, - ctx: &mut Self::APITarget, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context"); - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx) - .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other( - e.to_string(), - )) - } - fn get_doc_fragment(&self) -> Option { - Some( - bevy_mod_scripting_lua::docs::LuaDocFragment::new( - "BevyInputAPI", - |tw| { - tw.document_global_instance::() - .expect("Something went wrong documenting globals") - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadAxis, - >, - >() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadButton, - >, - >() - .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::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadAxisChangedEvent, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadButtonChangedEvent, - >, - >() - .process_type::() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadConnectionEvent, - >, - >() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - }, - ), - ) - } - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn register_with_app(&self, app: &mut bevy::app::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::(); - 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::< - bevy::input::gamepad::GamepadButtonChangedEvent, - >(); - 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::(); - } -} diff --git a/crates/bevy_script_api/src/providers/bevy_reflect.rs b/crates/bevy_script_api/src/providers/bevy_reflect.rs deleted file mode 100644 index 747729b8..00000000 --- a/crates/bevy_script_api/src/providers/bevy_reflect.rs +++ /dev/null @@ -1,24756 +0,0 @@ -// @generated by cargo bevy-api-gen generate, modify the templates not this file -#![allow(clippy::all)] -#![allow(unused, deprecated, dead_code)] -#![cfg_attr(rustfmt, rustfmt_skip)] -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::utils::Duration", - functions[r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u32) -> bevy::utils::Duration; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u32) -> bevy::utils::Duration; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_utils::Duration) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::utils::Duration; - -"#, - r#" -/// Creates a new `Duration` from the specified number of whole seconds and -/// additional nanoseconds. -/// If the number of nanoseconds is greater than 1 billion (the number of -/// nanoseconds in a second), then it will carry over into the seconds provided. -/// # Panics -/// This constructor will panic if the carry from the nanoseconds overflows -/// the seconds counter. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let five_seconds = Duration::new(5, 0); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn new(secs: u64, nanos: u32) -> bevy::utils::Duration; - -"#, - r#" -/// Creates a new `Duration` from the specified number of whole seconds. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let duration = Duration::from_secs(5); -/// assert_eq!(5, duration.as_secs()); -/// assert_eq!(0, duration.subsec_nanos()); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_secs(secs: u64) -> bevy::utils::Duration; - -"#, - r#" -/// Creates a new `Duration` from the specified number of milliseconds. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let duration = Duration::from_millis(2569); -/// assert_eq!(2, duration.as_secs()); -/// assert_eq!(569_000_000, duration.subsec_nanos()); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_millis(millis: u64) -> bevy::utils::Duration; - -"#, - r#" -/// Creates a new `Duration` from the specified number of microseconds. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let duration = Duration::from_micros(1_000_002); -/// assert_eq!(1, duration.as_secs()); -/// assert_eq!(2000, duration.subsec_nanos()); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_micros(micros: u64) -> bevy::utils::Duration; - -"#, - r#" -/// Creates a new `Duration` from the specified number of nanoseconds. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let duration = Duration::from_nanos(1_000_000_123); -/// assert_eq!(1, duration.as_secs()); -/// assert_eq!(123, duration.subsec_nanos()); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_nanos(nanos: u64) -> bevy::utils::Duration; - -"#, - r#" -/// Returns true if this `Duration` spans no time. -/// # Examples -/// ``` -/// use std::time::Duration; -/// assert!(Duration::ZERO.is_zero()); -/// assert!(Duration::new(0, 0).is_zero()); -/// assert!(Duration::from_nanos(0).is_zero()); -/// assert!(Duration::from_secs(0).is_zero()); -/// assert!(!Duration::new(1, 1).is_zero()); -/// assert!(!Duration::from_nanos(1).is_zero()); -/// assert!(!Duration::from_secs(1).is_zero()); -/// ``` - - #[lua(kind = "Method")] - fn is_zero(&self) -> bool; - -"#, - r#" -/// Returns the number of _whole_ seconds contained by this `Duration`. -/// The returned value does not include the fractional (nanosecond) part of the -/// duration, which can be obtained using [`subsec_nanos`]. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let duration = Duration::new(5, 730023852); -/// assert_eq!(duration.as_secs(), 5); -/// ``` -/// To determine the total number of seconds represented by the `Duration` -/// including the fractional part, use [`as_secs_f64`] or [`as_secs_f32`] -/// [`as_secs_f64`]: Duration::as_secs_f64 -/// [`as_secs_f32`]: Duration::as_secs_f32 -/// [`subsec_nanos`]: Duration::subsec_nanos - - #[lua(kind = "Method")] - fn as_secs(&self) -> u64; - -"#, - r#" -/// Returns the fractional part of this `Duration`, in whole milliseconds. -/// This method does **not** return the length of the duration when -/// represented by milliseconds. The returned number always represents a -/// fractional portion of a second (i.e., it is less than one thousand). -/// # Examples -/// ``` -/// use std::time::Duration; -/// let duration = Duration::from_millis(5432); -/// assert_eq!(duration.as_secs(), 5); -/// assert_eq!(duration.subsec_millis(), 432); -/// ``` - - #[lua(kind = "Method")] - fn subsec_millis(&self) -> u32; - -"#, - r#" -/// Returns the fractional part of this `Duration`, in whole microseconds. -/// This method does **not** return the length of the duration when -/// represented by microseconds. The returned number always represents a -/// fractional portion of a second (i.e., it is less than one million). -/// # Examples -/// ``` -/// use std::time::Duration; -/// let duration = Duration::from_micros(1_234_567); -/// assert_eq!(duration.as_secs(), 1); -/// assert_eq!(duration.subsec_micros(), 234_567); -/// ``` - - #[lua(kind = "Method")] - fn subsec_micros(&self) -> u32; - -"#, - r#" -/// Returns the fractional part of this `Duration`, in nanoseconds. -/// This method does **not** return the length of the duration when -/// represented by nanoseconds. The returned number always represents a -/// fractional portion of a second (i.e., it is less than one billion). -/// # Examples -/// ``` -/// use std::time::Duration; -/// let duration = Duration::from_millis(5010); -/// assert_eq!(duration.as_secs(), 5); -/// assert_eq!(duration.subsec_nanos(), 10_000_000); -/// ``` - - #[lua(kind = "Method")] - fn subsec_nanos(&self) -> u32; - -"#, - r#" -/// Returns the total number of whole milliseconds contained by this `Duration`. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let duration = Duration::new(5, 730023852); -/// assert_eq!(duration.as_millis(), 5730); -/// ``` - - #[lua(kind = "Method")] - fn as_millis(&self) -> u128; - -"#, - r#" -/// Returns the total number of whole microseconds contained by this `Duration`. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let duration = Duration::new(5, 730023852); -/// assert_eq!(duration.as_micros(), 5730023); -/// ``` - - #[lua(kind = "Method")] - fn as_micros(&self) -> u128; - -"#, - r#" -/// Returns the total number of nanoseconds contained by this `Duration`. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let duration = Duration::new(5, 730023852); -/// assert_eq!(duration.as_nanos(), 5730023852); -/// ``` - - #[lua(kind = "Method")] - fn as_nanos(&self) -> u128; - -"#, - r#" -/// Saturating `Duration` addition. Computes `self + other`, returning [`Duration::MAX`] -/// if overflow occurred. -/// # Examples -/// ``` -/// #![feature(duration_constants)] -/// use std::time::Duration; -/// assert_eq!(Duration::new(0, 0).saturating_add(Duration::new(0, 1)), Duration::new(0, 1)); -/// assert_eq!(Duration::new(1, 0).saturating_add(Duration::new(u64::MAX, 0)), Duration::MAX); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_add( - self, - #[proxy] - rhs: bevy::utils::Duration, - ) -> bevy::utils::Duration; - -"#, - r#" -/// Saturating `Duration` subtraction. Computes `self - other`, returning [`Duration::ZERO`] -/// if the result would be negative or if overflow occurred. -/// # Examples -/// ``` -/// use std::time::Duration; -/// assert_eq!(Duration::new(0, 1).saturating_sub(Duration::new(0, 0)), Duration::new(0, 1)); -/// assert_eq!(Duration::new(0, 0).saturating_sub(Duration::new(0, 1)), Duration::ZERO); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub( - self, - #[proxy] - rhs: bevy::utils::Duration, - ) -> bevy::utils::Duration; - -"#, - r#" -/// Saturating `Duration` multiplication. Computes `self * other`, returning -/// [`Duration::MAX`] if overflow occurred. -/// # Examples -/// ``` -/// #![feature(duration_constants)] -/// use std::time::Duration; -/// assert_eq!(Duration::new(0, 500_000_001).saturating_mul(2), Duration::new(1, 2)); -/// assert_eq!(Duration::new(u64::MAX - 1, 0).saturating_mul(2), Duration::MAX); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, rhs: u32) -> bevy::utils::Duration; - -"#, - r#" -/// Returns the number of seconds contained by this `Duration` as `f64`. -/// The returned value does include the fractional (nanosecond) part of the duration. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let dur = Duration::new(2, 700_000_000); -/// assert_eq!(dur.as_secs_f64(), 2.7); -/// ``` - - #[lua(kind = "Method")] - fn as_secs_f64(&self) -> f64; - -"#, - r#" -/// Returns the number of seconds contained by this `Duration` as `f32`. -/// The returned value does include the fractional (nanosecond) part of the duration. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let dur = Duration::new(2, 700_000_000); -/// assert_eq!(dur.as_secs_f32(), 2.7); -/// ``` - - #[lua(kind = "Method")] - fn as_secs_f32(&self) -> f32; - -"#, - r#" -/// Creates a new `Duration` from the specified number of seconds represented -/// as `f64`. -/// # Panics -/// This constructor will panic if `secs` is negative, overflows `Duration` or not finite. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let res = Duration::from_secs_f64(0.0); -/// assert_eq!(res, Duration::new(0, 0)); -/// let res = Duration::from_secs_f64(1e-20); -/// assert_eq!(res, Duration::new(0, 0)); -/// let res = Duration::from_secs_f64(4.2e-7); -/// assert_eq!(res, Duration::new(0, 420)); -/// let res = Duration::from_secs_f64(2.7); -/// assert_eq!(res, Duration::new(2, 700_000_000)); -/// let res = Duration::from_secs_f64(3e10); -/// assert_eq!(res, Duration::new(30_000_000_000, 0)); -/// // subnormal float -/// let res = Duration::from_secs_f64(f64::from_bits(1)); -/// assert_eq!(res, Duration::new(0, 0)); -/// // conversion uses rounding -/// let res = Duration::from_secs_f64(0.999e-9); -/// assert_eq!(res, Duration::new(0, 1)); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_secs_f64(secs: f64) -> bevy::utils::Duration; - -"#, - r#" -/// Creates a new `Duration` from the specified number of seconds represented -/// as `f32`. -/// # Panics -/// This constructor will panic if `secs` is negative, overflows `Duration` or not finite. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let res = Duration::from_secs_f32(0.0); -/// assert_eq!(res, Duration::new(0, 0)); -/// let res = Duration::from_secs_f32(1e-20); -/// assert_eq!(res, Duration::new(0, 0)); -/// let res = Duration::from_secs_f32(4.2e-7); -/// assert_eq!(res, Duration::new(0, 420)); -/// let res = Duration::from_secs_f32(2.7); -/// assert_eq!(res, Duration::new(2, 700_000_048)); -/// let res = Duration::from_secs_f32(3e10); -/// assert_eq!(res, Duration::new(30_000_001_024, 0)); -/// // subnormal float -/// let res = Duration::from_secs_f32(f32::from_bits(1)); -/// assert_eq!(res, Duration::new(0, 0)); -/// // conversion uses rounding -/// let res = Duration::from_secs_f32(0.999e-9); -/// assert_eq!(res, Duration::new(0, 1)); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_secs_f32(secs: f32) -> bevy::utils::Duration; - -"#, - r#" -/// Multiplies `Duration` by `f64`. -/// # Panics -/// This method will panic if result is negative, overflows `Duration` or not finite. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let dur = Duration::new(2, 700_000_000); -/// assert_eq!(dur.mul_f64(3.14), Duration::new(8, 478_000_000)); -/// assert_eq!(dur.mul_f64(3.14e5), Duration::new(847_800, 0)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn mul_f64(self, rhs: f64) -> bevy::utils::Duration; - -"#, - r#" -/// Multiplies `Duration` by `f32`. -/// # Panics -/// This method will panic if result is negative, overflows `Duration` or not finite. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let dur = Duration::new(2, 700_000_000); -/// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_641)); -/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847800, 0)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn mul_f32(self, rhs: f32) -> bevy::utils::Duration; - -"#, - r#" -/// Divide `Duration` by `f64`. -/// # Panics -/// This method will panic if result is negative, overflows `Duration` or not finite. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let dur = Duration::new(2, 700_000_000); -/// assert_eq!(dur.div_f64(3.14), Duration::new(0, 859_872_611)); -/// assert_eq!(dur.div_f64(3.14e5), Duration::new(0, 8_599)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn div_f64(self, rhs: f64) -> bevy::utils::Duration; - -"#, - r#" -/// Divide `Duration` by `f32`. -/// # Panics -/// This method will panic if result is negative, overflows `Duration` or not finite. -/// # Examples -/// ``` -/// use std::time::Duration; -/// let dur = Duration::new(2, 700_000_000); -/// // note that due to rounding errors result is slightly -/// // different from 0.859_872_611 -/// assert_eq!(dur.div_f32(3.14), Duration::new(0, 859_872_580)); -/// assert_eq!(dur.div_f32(3.14e5), Duration::new(0, 8_599)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn div_f32(self, rhs: f32) -> bevy::utils::Duration; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Duration {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::utils::Instant", - functions[r#" -/// # Panics -/// This function may panic if the resulting point in time cannot be represented by the -/// underlying data structure. See [`Instant::checked_add`] for a version without panic. - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_utils::Instant) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::utils::Instant; - -"#, - r#" -/// Returns an instant corresponding to "now". -/// # Examples -/// ``` -/// use std::time::Instant; -/// let now = Instant::now(); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn now() -> bevy::utils::Instant; - -"#, - r#" -/// Returns the amount of time elapsed from another instant to this one, -/// or zero duration if that instant is later than this one. -/// # Panics -/// Previous rust versions panicked when `earlier` was later than `self`. Currently this -/// method saturates. Future versions may reintroduce the panic in some circumstances. -/// See [Monotonicity]. -/// [Monotonicity]: Instant#monotonicity -/// # Examples -/// ```no_run -/// use std::time::{Duration, Instant}; -/// use std::thread::sleep; -/// let now = Instant::now(); -/// sleep(Duration::new(1, 0)); -/// let new_now = Instant::now(); -/// println!("{:?}", new_now.duration_since(now)); -/// println!("{:?}", now.duration_since(new_now)); // 0ns -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn duration_since( - &self, - #[proxy] - earlier: bevy::utils::Instant, - ) -> bevy::utils::Duration; - -"#, - r#" -/// Returns the amount of time elapsed from another instant to this one, -/// or zero duration if that instant is later than this one. -/// # Examples -/// ```no_run -/// use std::time::{Duration, Instant}; -/// use std::thread::sleep; -/// let now = Instant::now(); -/// sleep(Duration::new(1, 0)); -/// let new_now = Instant::now(); -/// println!("{:?}", new_now.saturating_duration_since(now)); -/// println!("{:?}", now.saturating_duration_since(new_now)); // 0ns -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_duration_since( - &self, - #[proxy] - earlier: bevy::utils::Instant, - ) -> bevy::utils::Duration; - -"#, - r#" -/// Returns the amount of time elapsed since this instant. -/// # Panics -/// Previous rust versions panicked when the current time was earlier than self. Currently this -/// method returns a Duration of zero in that case. Future versions may reintroduce the panic. -/// See [Monotonicity]. -/// [Monotonicity]: Instant#monotonicity -/// # Examples -/// ```no_run -/// use std::thread::sleep; -/// use std::time::{Duration, Instant}; -/// let instant = Instant::now(); -/// let three_secs = Duration::from_secs(3); -/// sleep(three_secs); -/// assert!(instant.elapsed() >= three_secs); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn elapsed(&self) -> bevy::utils::Duration; - -"#, - r#" -/// Returns the amount of time elapsed from another instant to this one, -/// or zero duration if that instant is later than this one. -/// # Panics -/// Previous rust versions panicked when `other` was later than `self`. Currently this -/// method saturates. Future versions may reintroduce the panic in some circumstances. -/// See [Monotonicity]. -/// [Monotonicity]: Instant#monotonicity - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] other: bevy::utils::Instant) -> bevy::utils::Duration; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Instant(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroI128", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroI128; - -"#, - r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: i128) -> std::num::NonZeroI128; - -"#, - r#" -/// Returns the value as a primitive type. - - #[lua(kind = "Method")] - fn get(self) -> i128; - -"#, - r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI128::new(-1i128).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; - -"#, - r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI128::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Computes the absolute value of self. -///See [`i128::abs`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI128::new(1)?; -///let neg = NonZeroI128::new(-1)?; -/// assert_eq!(pos, pos.abs()); -/// assert_eq!(pos, neg.abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> std::num::NonZeroI128; - -"#, - r#" -/// Saturating absolute value, see -///[`i128::saturating_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI128::new(1)?; -///let neg = NonZeroI128::new(-1)?; -///let min = NonZeroI128::new(i128::MIN)?; -///let min_plus = NonZeroI128::new(i128::MIN + 1)?; -///let max = NonZeroI128::new(i128::MAX)?; -/// assert_eq!(pos, pos.saturating_abs()); -/// assert_eq!(pos, neg.saturating_abs()); -/// assert_eq!(max, min.saturating_abs()); -/// assert_eq!(max, min_plus.saturating_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_abs(self) -> std::num::NonZeroI128; - -"#, - r#" -/// Wrapping absolute value, see -///[`i128::wrapping_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI128::new(1)?; -///let neg = NonZeroI128::new(-1)?; -///let min = NonZeroI128::new(i128::MIN)?; -///# let max = NonZeroI128::new(i128::MAX)?; -/// assert_eq!(pos, pos.wrapping_abs()); -/// assert_eq!(pos, neg.wrapping_abs()); -/// assert_eq!(min, min.wrapping_abs()); -/// assert_eq!(max, (-max).wrapping_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_abs(self) -> std::num::NonZeroI128; - -"#, - r#" -/// Computes the absolute value of self -/// without any wrapping or panicking. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -///# use std::num::NonZeroU128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let u_pos = NonZeroU128::new(1)?; -///let i_pos = NonZeroI128::new(1)?; -///let i_neg = NonZeroI128::new(-1)?; -///let i_min = NonZeroI128::new(i128::MIN)?; -///let u_max = NonZeroU128::new(u128::MAX / 2 + 1)?; -/// assert_eq!(u_pos, i_pos.unsigned_abs()); -/// assert_eq!(u_pos, i_neg.unsigned_abs()); -/// assert_eq!(u_max, i_min.unsigned_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn unsigned_abs(self) -> std::num::NonZeroU128; - -"#, - r#" -/// Returns `true` if `self` is positive and `false` if the -/// number is negative. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI128::new(5)?; -///let neg_five = NonZeroI128::new(-5)?; -/// assert!(pos_five.is_positive()); -/// assert!(!neg_five.is_positive()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_positive(self) -> bool; - -"#, - r#" -/// Returns `true` if `self` is negative and `false` if the -/// number is positive. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI128::new(5)?; -///let neg_five = NonZeroI128::new(-5)?; -/// assert!(neg_five.is_negative()); -/// assert!(!pos_five.is_negative()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_negative(self) -> bool; - -"#, - r#" -/// Saturating negation. Computes `-self`, -///returning [`NonZeroI128::MAX`] -///if `self == NonZeroI128::MIN` -/// instead of overflowing. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI128::new(5)?; -///let neg_five = NonZeroI128::new(-5)?; -///let min = NonZeroI128::new(i128::MIN)?; -///let min_plus_one = NonZeroI128::new(i128::MIN + 1)?; -///let max = NonZeroI128::new(i128::MAX)?; -/// assert_eq!(pos_five.saturating_neg(), neg_five); -/// assert_eq!(min.saturating_neg(), max); -/// assert_eq!(max.saturating_neg(), min_plus_one); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_neg(self) -> std::num::NonZeroI128; - -"#, - r#" -/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary -/// of the type. -///See [`i128::wrapping_neg`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI128::new(5)?; -///let neg_five = NonZeroI128::new(-5)?; -///let min = NonZeroI128::new(i128::MIN)?; -/// assert_eq!(pos_five.wrapping_neg(), neg_five); -/// assert_eq!(min.wrapping_neg(), min); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_neg(self) -> std::num::NonZeroI128; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroI128::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroI128::new(2)?; -///let four = NonZeroI128::new(4)?; -///let max = NonZeroI128::new(i128::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroI128, - ) -> std::num::NonZeroI128; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroI128::MIN`] or [`NonZeroI128::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroI128::new(3)?; -///let twenty_seven = NonZeroI128::new(27)?; -///let max = NonZeroI128::new(i128::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI128; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroI128) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> std::num::NonZeroI128; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct NonZeroI128(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroI16", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroI16) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroI16; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: i16) -> std::num::NonZeroI16; - -"#, - r#" -/// Returns the value as a primitive type. - - #[lua(kind = "Method")] - fn get(self) -> i16; - -"#, - r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI16::new(-1i16).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; - -"#, - r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI16::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Computes the absolute value of self. -///See [`i16::abs`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI16::new(1)?; -///let neg = NonZeroI16::new(-1)?; -/// assert_eq!(pos, pos.abs()); -/// assert_eq!(pos, neg.abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> std::num::NonZeroI16; - -"#, - r#" -/// Saturating absolute value, see -///[`i16::saturating_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI16::new(1)?; -///let neg = NonZeroI16::new(-1)?; -///let min = NonZeroI16::new(i16::MIN)?; -///let min_plus = NonZeroI16::new(i16::MIN + 1)?; -///let max = NonZeroI16::new(i16::MAX)?; -/// assert_eq!(pos, pos.saturating_abs()); -/// assert_eq!(pos, neg.saturating_abs()); -/// assert_eq!(max, min.saturating_abs()); -/// assert_eq!(max, min_plus.saturating_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_abs(self) -> std::num::NonZeroI16; - -"#, - r#" -/// Wrapping absolute value, see -///[`i16::wrapping_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI16::new(1)?; -///let neg = NonZeroI16::new(-1)?; -///let min = NonZeroI16::new(i16::MIN)?; -///# let max = NonZeroI16::new(i16::MAX)?; -/// assert_eq!(pos, pos.wrapping_abs()); -/// assert_eq!(pos, neg.wrapping_abs()); -/// assert_eq!(min, min.wrapping_abs()); -/// assert_eq!(max, (-max).wrapping_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_abs(self) -> std::num::NonZeroI16; - -"#, - r#" -/// Computes the absolute value of self -/// without any wrapping or panicking. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -///# use std::num::NonZeroU16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let u_pos = NonZeroU16::new(1)?; -///let i_pos = NonZeroI16::new(1)?; -///let i_neg = NonZeroI16::new(-1)?; -///let i_min = NonZeroI16::new(i16::MIN)?; -///let u_max = NonZeroU16::new(u16::MAX / 2 + 1)?; -/// assert_eq!(u_pos, i_pos.unsigned_abs()); -/// assert_eq!(u_pos, i_neg.unsigned_abs()); -/// assert_eq!(u_max, i_min.unsigned_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn unsigned_abs(self) -> std::num::NonZeroU16; - -"#, - r#" -/// Returns `true` if `self` is positive and `false` if the -/// number is negative. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI16::new(5)?; -///let neg_five = NonZeroI16::new(-5)?; -/// assert!(pos_five.is_positive()); -/// assert!(!neg_five.is_positive()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_positive(self) -> bool; - -"#, - r#" -/// Returns `true` if `self` is negative and `false` if the -/// number is positive. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI16::new(5)?; -///let neg_five = NonZeroI16::new(-5)?; -/// assert!(neg_five.is_negative()); -/// assert!(!pos_five.is_negative()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_negative(self) -> bool; - -"#, - r#" -/// Saturating negation. Computes `-self`, -///returning [`NonZeroI16::MAX`] -///if `self == NonZeroI16::MIN` -/// instead of overflowing. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI16::new(5)?; -///let neg_five = NonZeroI16::new(-5)?; -///let min = NonZeroI16::new(i16::MIN)?; -///let min_plus_one = NonZeroI16::new(i16::MIN + 1)?; -///let max = NonZeroI16::new(i16::MAX)?; -/// assert_eq!(pos_five.saturating_neg(), neg_five); -/// assert_eq!(min.saturating_neg(), max); -/// assert_eq!(max.saturating_neg(), min_plus_one); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_neg(self) -> std::num::NonZeroI16; - -"#, - r#" -/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary -/// of the type. -///See [`i16::wrapping_neg`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI16::new(5)?; -///let neg_five = NonZeroI16::new(-5)?; -///let min = NonZeroI16::new(i16::MIN)?; -/// assert_eq!(pos_five.wrapping_neg(), neg_five); -/// assert_eq!(min.wrapping_neg(), min); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_neg(self) -> std::num::NonZeroI16; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroI16::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroI16::new(2)?; -///let four = NonZeroI16::new(4)?; -///let max = NonZeroI16::new(i16::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroI16, - ) -> std::num::NonZeroI16; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroI16::MIN`] or [`NonZeroI16::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroI16::new(3)?; -///let twenty_seven = NonZeroI16::new(27)?; -///let max = NonZeroI16::new(i16::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI16; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> std::num::NonZeroI16; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct NonZeroI16(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroI32", - functions[r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> std::num::NonZeroI32; - -"#, - r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: i32) -> std::num::NonZeroI32; - -"#, - r#" -/// Returns the value as a primitive type. - - #[lua(kind = "Method")] - fn get(self) -> i32; - -"#, - r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI32::new(-1i32).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; - -"#, - r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI32::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Computes the absolute value of self. -///See [`i32::abs`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI32::new(1)?; -///let neg = NonZeroI32::new(-1)?; -/// assert_eq!(pos, pos.abs()); -/// assert_eq!(pos, neg.abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> std::num::NonZeroI32; - -"#, - r#" -/// Saturating absolute value, see -///[`i32::saturating_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI32::new(1)?; -///let neg = NonZeroI32::new(-1)?; -///let min = NonZeroI32::new(i32::MIN)?; -///let min_plus = NonZeroI32::new(i32::MIN + 1)?; -///let max = NonZeroI32::new(i32::MAX)?; -/// assert_eq!(pos, pos.saturating_abs()); -/// assert_eq!(pos, neg.saturating_abs()); -/// assert_eq!(max, min.saturating_abs()); -/// assert_eq!(max, min_plus.saturating_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_abs(self) -> std::num::NonZeroI32; - -"#, - r#" -/// Wrapping absolute value, see -///[`i32::wrapping_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI32::new(1)?; -///let neg = NonZeroI32::new(-1)?; -///let min = NonZeroI32::new(i32::MIN)?; -///# let max = NonZeroI32::new(i32::MAX)?; -/// assert_eq!(pos, pos.wrapping_abs()); -/// assert_eq!(pos, neg.wrapping_abs()); -/// assert_eq!(min, min.wrapping_abs()); -/// assert_eq!(max, (-max).wrapping_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_abs(self) -> std::num::NonZeroI32; - -"#, - r#" -/// Computes the absolute value of self -/// without any wrapping or panicking. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -///# use std::num::NonZeroU32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let u_pos = NonZeroU32::new(1)?; -///let i_pos = NonZeroI32::new(1)?; -///let i_neg = NonZeroI32::new(-1)?; -///let i_min = NonZeroI32::new(i32::MIN)?; -///let u_max = NonZeroU32::new(u32::MAX / 2 + 1)?; -/// assert_eq!(u_pos, i_pos.unsigned_abs()); -/// assert_eq!(u_pos, i_neg.unsigned_abs()); -/// assert_eq!(u_max, i_min.unsigned_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn unsigned_abs(self) -> std::num::NonZeroU32; - -"#, - r#" -/// Returns `true` if `self` is positive and `false` if the -/// number is negative. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI32::new(5)?; -///let neg_five = NonZeroI32::new(-5)?; -/// assert!(pos_five.is_positive()); -/// assert!(!neg_five.is_positive()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_positive(self) -> bool; - -"#, - r#" -/// Returns `true` if `self` is negative and `false` if the -/// number is positive. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI32::new(5)?; -///let neg_five = NonZeroI32::new(-5)?; -/// assert!(neg_five.is_negative()); -/// assert!(!pos_five.is_negative()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_negative(self) -> bool; - -"#, - r#" -/// Saturating negation. Computes `-self`, -///returning [`NonZeroI32::MAX`] -///if `self == NonZeroI32::MIN` -/// instead of overflowing. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI32::new(5)?; -///let neg_five = NonZeroI32::new(-5)?; -///let min = NonZeroI32::new(i32::MIN)?; -///let min_plus_one = NonZeroI32::new(i32::MIN + 1)?; -///let max = NonZeroI32::new(i32::MAX)?; -/// assert_eq!(pos_five.saturating_neg(), neg_five); -/// assert_eq!(min.saturating_neg(), max); -/// assert_eq!(max.saturating_neg(), min_plus_one); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_neg(self) -> std::num::NonZeroI32; - -"#, - r#" -/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary -/// of the type. -///See [`i32::wrapping_neg`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI32::new(5)?; -///let neg_five = NonZeroI32::new(-5)?; -///let min = NonZeroI32::new(i32::MIN)?; -/// assert_eq!(pos_five.wrapping_neg(), neg_five); -/// assert_eq!(min.wrapping_neg(), min); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_neg(self) -> std::num::NonZeroI32; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroI32::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroI32::new(2)?; -///let four = NonZeroI32::new(4)?; -///let max = NonZeroI32::new(i32::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroI32, - ) -> std::num::NonZeroI32; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroI32::MIN`] or [`NonZeroI32::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroI32::new(3)?; -///let twenty_seven = NonZeroI32::new(27)?; -///let max = NonZeroI32::new(i32::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI32; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroI32; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroI32) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct NonZeroI32(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroI64", - functions[r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: i64) -> std::num::NonZeroI64; - -"#, - r#" -/// Returns the value as a primitive type. - - #[lua(kind = "Method")] - fn get(self) -> i64; - -"#, - r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI64::new(-1i64).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; - -"#, - r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI64::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Computes the absolute value of self. -///See [`i64::abs`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI64::new(1)?; -///let neg = NonZeroI64::new(-1)?; -/// assert_eq!(pos, pos.abs()); -/// assert_eq!(pos, neg.abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> std::num::NonZeroI64; - -"#, - r#" -/// Saturating absolute value, see -///[`i64::saturating_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI64::new(1)?; -///let neg = NonZeroI64::new(-1)?; -///let min = NonZeroI64::new(i64::MIN)?; -///let min_plus = NonZeroI64::new(i64::MIN + 1)?; -///let max = NonZeroI64::new(i64::MAX)?; -/// assert_eq!(pos, pos.saturating_abs()); -/// assert_eq!(pos, neg.saturating_abs()); -/// assert_eq!(max, min.saturating_abs()); -/// assert_eq!(max, min_plus.saturating_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_abs(self) -> std::num::NonZeroI64; - -"#, - r#" -/// Wrapping absolute value, see -///[`i64::wrapping_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI64::new(1)?; -///let neg = NonZeroI64::new(-1)?; -///let min = NonZeroI64::new(i64::MIN)?; -///# let max = NonZeroI64::new(i64::MAX)?; -/// assert_eq!(pos, pos.wrapping_abs()); -/// assert_eq!(pos, neg.wrapping_abs()); -/// assert_eq!(min, min.wrapping_abs()); -/// assert_eq!(max, (-max).wrapping_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_abs(self) -> std::num::NonZeroI64; - -"#, - r#" -/// Computes the absolute value of self -/// without any wrapping or panicking. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -///# use std::num::NonZeroU64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let u_pos = NonZeroU64::new(1)?; -///let i_pos = NonZeroI64::new(1)?; -///let i_neg = NonZeroI64::new(-1)?; -///let i_min = NonZeroI64::new(i64::MIN)?; -///let u_max = NonZeroU64::new(u64::MAX / 2 + 1)?; -/// assert_eq!(u_pos, i_pos.unsigned_abs()); -/// assert_eq!(u_pos, i_neg.unsigned_abs()); -/// assert_eq!(u_max, i_min.unsigned_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn unsigned_abs(self) -> std::num::NonZeroU64; - -"#, - r#" -/// Returns `true` if `self` is positive and `false` if the -/// number is negative. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI64::new(5)?; -///let neg_five = NonZeroI64::new(-5)?; -/// assert!(pos_five.is_positive()); -/// assert!(!neg_five.is_positive()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_positive(self) -> bool; - -"#, - r#" -/// Returns `true` if `self` is negative and `false` if the -/// number is positive. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI64::new(5)?; -///let neg_five = NonZeroI64::new(-5)?; -/// assert!(neg_five.is_negative()); -/// assert!(!pos_five.is_negative()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_negative(self) -> bool; - -"#, - r#" -/// Saturating negation. Computes `-self`, -///returning [`NonZeroI64::MAX`] -///if `self == NonZeroI64::MIN` -/// instead of overflowing. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI64::new(5)?; -///let neg_five = NonZeroI64::new(-5)?; -///let min = NonZeroI64::new(i64::MIN)?; -///let min_plus_one = NonZeroI64::new(i64::MIN + 1)?; -///let max = NonZeroI64::new(i64::MAX)?; -/// assert_eq!(pos_five.saturating_neg(), neg_five); -/// assert_eq!(min.saturating_neg(), max); -/// assert_eq!(max.saturating_neg(), min_plus_one); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_neg(self) -> std::num::NonZeroI64; - -"#, - r#" -/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary -/// of the type. -///See [`i64::wrapping_neg`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI64::new(5)?; -///let neg_five = NonZeroI64::new(-5)?; -///let min = NonZeroI64::new(i64::MIN)?; -/// assert_eq!(pos_five.wrapping_neg(), neg_five); -/// assert_eq!(min.wrapping_neg(), min); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_neg(self) -> std::num::NonZeroI64; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroI64::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroI64::new(2)?; -///let four = NonZeroI64::new(4)?; -///let max = NonZeroI64::new(i64::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroI64, - ) -> std::num::NonZeroI64; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroI64::MIN`] or [`NonZeroI64::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroI64::new(3)?; -///let twenty_seven = NonZeroI64::new(27)?; -///let max = NonZeroI64::new(i64::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI64; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> std::num::NonZeroI64; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroI64) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroI64; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct NonZeroI64(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroI8", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> std::num::NonZeroI8; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroI8) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroI8; - -"#, - r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: i8) -> std::num::NonZeroI8; - -"#, - r#" -/// Returns the value as a primitive type. - - #[lua(kind = "Method")] - fn get(self) -> i8; - -"#, - r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI8::new(-1i8).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; - -"#, - r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI8::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Computes the absolute value of self. -///See [`i8::abs`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI8::new(1)?; -///let neg = NonZeroI8::new(-1)?; -/// assert_eq!(pos, pos.abs()); -/// assert_eq!(pos, neg.abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> std::num::NonZeroI8; - -"#, - r#" -/// Saturating absolute value, see -///[`i8::saturating_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI8::new(1)?; -///let neg = NonZeroI8::new(-1)?; -///let min = NonZeroI8::new(i8::MIN)?; -///let min_plus = NonZeroI8::new(i8::MIN + 1)?; -///let max = NonZeroI8::new(i8::MAX)?; -/// assert_eq!(pos, pos.saturating_abs()); -/// assert_eq!(pos, neg.saturating_abs()); -/// assert_eq!(max, min.saturating_abs()); -/// assert_eq!(max, min_plus.saturating_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_abs(self) -> std::num::NonZeroI8; - -"#, - r#" -/// Wrapping absolute value, see -///[`i8::wrapping_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI8::new(1)?; -///let neg = NonZeroI8::new(-1)?; -///let min = NonZeroI8::new(i8::MIN)?; -///# let max = NonZeroI8::new(i8::MAX)?; -/// assert_eq!(pos, pos.wrapping_abs()); -/// assert_eq!(pos, neg.wrapping_abs()); -/// assert_eq!(min, min.wrapping_abs()); -/// assert_eq!(max, (-max).wrapping_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_abs(self) -> std::num::NonZeroI8; - -"#, - r#" -/// Computes the absolute value of self -/// without any wrapping or panicking. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -///# use std::num::NonZeroU8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let u_pos = NonZeroU8::new(1)?; -///let i_pos = NonZeroI8::new(1)?; -///let i_neg = NonZeroI8::new(-1)?; -///let i_min = NonZeroI8::new(i8::MIN)?; -///let u_max = NonZeroU8::new(u8::MAX / 2 + 1)?; -/// assert_eq!(u_pos, i_pos.unsigned_abs()); -/// assert_eq!(u_pos, i_neg.unsigned_abs()); -/// assert_eq!(u_max, i_min.unsigned_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn unsigned_abs(self) -> std::num::NonZeroU8; - -"#, - r#" -/// Returns `true` if `self` is positive and `false` if the -/// number is negative. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI8::new(5)?; -///let neg_five = NonZeroI8::new(-5)?; -/// assert!(pos_five.is_positive()); -/// assert!(!neg_five.is_positive()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_positive(self) -> bool; - -"#, - r#" -/// Returns `true` if `self` is negative and `false` if the -/// number is positive. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI8::new(5)?; -///let neg_five = NonZeroI8::new(-5)?; -/// assert!(neg_five.is_negative()); -/// assert!(!pos_five.is_negative()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_negative(self) -> bool; - -"#, - r#" -/// Saturating negation. Computes `-self`, -///returning [`NonZeroI8::MAX`] -///if `self == NonZeroI8::MIN` -/// instead of overflowing. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI8::new(5)?; -///let neg_five = NonZeroI8::new(-5)?; -///let min = NonZeroI8::new(i8::MIN)?; -///let min_plus_one = NonZeroI8::new(i8::MIN + 1)?; -///let max = NonZeroI8::new(i8::MAX)?; -/// assert_eq!(pos_five.saturating_neg(), neg_five); -/// assert_eq!(min.saturating_neg(), max); -/// assert_eq!(max.saturating_neg(), min_plus_one); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_neg(self) -> std::num::NonZeroI8; - -"#, - r#" -/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary -/// of the type. -///See [`i8::wrapping_neg`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI8::new(5)?; -///let neg_five = NonZeroI8::new(-5)?; -///let min = NonZeroI8::new(i8::MIN)?; -/// assert_eq!(pos_five.wrapping_neg(), neg_five); -/// assert_eq!(min.wrapping_neg(), min); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_neg(self) -> std::num::NonZeroI8; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroI8::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroI8::new(2)?; -///let four = NonZeroI8::new(4)?; -///let max = NonZeroI8::new(i8::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] other: std::num::NonZeroI8) -> std::num::NonZeroI8; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroI8::MIN`] or [`NonZeroI8::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroI8::new(3)?; -///let twenty_seven = NonZeroI8::new(27)?; -///let max = NonZeroI8::new(i8::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI8; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct NonZeroI8(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroU128", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroU128; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroU128) -> bool; - -"#, - r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: u128) -> std::num::NonZeroU128; - -"#, - r#" -/// Returns the value as a primitive type. - - #[lua(kind = "Method")] - fn get(self) -> u128; - -"#, - r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU128::new(u128::MAX).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; - -"#, - r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU128::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Adds an unsigned integer to a non-zero value. -///Return [`NonZeroU128::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let one = NonZeroU128::new(1)?; -///let two = NonZeroU128::new(2)?; -///let max = NonZeroU128::new(u128::MAX)?; -/// assert_eq!(two, one.saturating_add(1)); -/// assert_eq!(max, max.saturating_add(1)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, other: u128) -> std::num::NonZeroU128; - -"#, - r#" -/// Returns the base 2 logarithm of the number, rounded down. -/// This is the same operation as -///[`u128::ilog2`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU128; -///assert_eq!(NonZeroU128::new(7).unwrap().ilog2(), 2); -///assert_eq!(NonZeroU128::new(8).unwrap().ilog2(), 3); -///assert_eq!(NonZeroU128::new(9).unwrap().ilog2(), 3); -/// ``` - - #[lua(kind = "Method")] - fn ilog2(self) -> u32; - -"#, - r#" -/// Returns the base 10 logarithm of the number, rounded down. -/// This is the same operation as -///[`u128::ilog10`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU128; -///assert_eq!(NonZeroU128::new(99).unwrap().ilog10(), 1); -///assert_eq!(NonZeroU128::new(100).unwrap().ilog10(), 2); -///assert_eq!(NonZeroU128::new(101).unwrap().ilog10(), 2); -/// ``` - - #[lua(kind = "Method")] - fn ilog10(self) -> u32; - -"#, - r#" -/// Returns `true` if and only if `self == (1 << k)` for some `k`. -/// On many architectures, this function can perform better than `is_power_of_two()` -/// on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let eight = std::num::NonZeroU128::new(8).unwrap(); -/// assert!(eight.is_power_of_two()); -///let ten = std::num::NonZeroU128::new(10).unwrap(); -/// assert!(!ten.is_power_of_two()); -/// ``` - - #[lua(kind = "Method")] - fn is_power_of_two(self) -> bool; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroU128::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroU128::new(2)?; -///let four = NonZeroU128::new(4)?; -///let max = NonZeroU128::new(u128::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroU128, - ) -> std::num::NonZeroU128; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroU128::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroU128::new(3)?; -///let twenty_seven = NonZeroU128::new(27)?; -///let max = NonZeroU128::new(u128::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU128; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct NonZeroU128(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroU16", - functions[r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: u16) -> std::num::NonZeroU16; - -"#, - r#" -/// Returns the value as a primitive type. - - #[lua(kind = "Method")] - fn get(self) -> u16; - -"#, - r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU16::new(u16::MAX).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; - -"#, - r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU16::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Adds an unsigned integer to a non-zero value. -///Return [`NonZeroU16::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let one = NonZeroU16::new(1)?; -///let two = NonZeroU16::new(2)?; -///let max = NonZeroU16::new(u16::MAX)?; -/// assert_eq!(two, one.saturating_add(1)); -/// assert_eq!(max, max.saturating_add(1)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, other: u16) -> std::num::NonZeroU16; - -"#, - r#" -/// Returns the base 2 logarithm of the number, rounded down. -/// This is the same operation as -///[`u16::ilog2`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU16; -///assert_eq!(NonZeroU16::new(7).unwrap().ilog2(), 2); -///assert_eq!(NonZeroU16::new(8).unwrap().ilog2(), 3); -///assert_eq!(NonZeroU16::new(9).unwrap().ilog2(), 3); -/// ``` - - #[lua(kind = "Method")] - fn ilog2(self) -> u32; - -"#, - r#" -/// Returns the base 10 logarithm of the number, rounded down. -/// This is the same operation as -///[`u16::ilog10`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU16; -///assert_eq!(NonZeroU16::new(99).unwrap().ilog10(), 1); -///assert_eq!(NonZeroU16::new(100).unwrap().ilog10(), 2); -///assert_eq!(NonZeroU16::new(101).unwrap().ilog10(), 2); -/// ``` - - #[lua(kind = "Method")] - fn ilog10(self) -> u32; - -"#, - r#" -/// Returns `true` if and only if `self == (1 << k)` for some `k`. -/// On many architectures, this function can perform better than `is_power_of_two()` -/// on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let eight = std::num::NonZeroU16::new(8).unwrap(); -/// assert!(eight.is_power_of_two()); -///let ten = std::num::NonZeroU16::new(10).unwrap(); -/// assert!(!ten.is_power_of_two()); -/// ``` - - #[lua(kind = "Method")] - fn is_power_of_two(self) -> bool; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroU16::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroU16::new(2)?; -///let four = NonZeroU16::new(4)?; -///let max = NonZeroU16::new(u16::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroU16, - ) -> std::num::NonZeroU16; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroU16::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroU16::new(3)?; -///let twenty_seven = NonZeroU16::new(27)?; -///let max = NonZeroU16::new(u16::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU16; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroU16) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroU16; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct NonZeroU16(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroU32", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroU32) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: u32) -> std::num::NonZeroU32; - -"#, - r#" -/// Returns the value as a primitive type. - - #[lua(kind = "Method")] - fn get(self) -> u32; - -"#, - r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU32::new(u32::MAX).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; - -"#, - r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU32::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Adds an unsigned integer to a non-zero value. -///Return [`NonZeroU32::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let one = NonZeroU32::new(1)?; -///let two = NonZeroU32::new(2)?; -///let max = NonZeroU32::new(u32::MAX)?; -/// assert_eq!(two, one.saturating_add(1)); -/// assert_eq!(max, max.saturating_add(1)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, other: u32) -> std::num::NonZeroU32; - -"#, - r#" -/// Returns the base 2 logarithm of the number, rounded down. -/// This is the same operation as -///[`u32::ilog2`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU32; -///assert_eq!(NonZeroU32::new(7).unwrap().ilog2(), 2); -///assert_eq!(NonZeroU32::new(8).unwrap().ilog2(), 3); -///assert_eq!(NonZeroU32::new(9).unwrap().ilog2(), 3); -/// ``` - - #[lua(kind = "Method")] - fn ilog2(self) -> u32; - -"#, - r#" -/// Returns the base 10 logarithm of the number, rounded down. -/// This is the same operation as -///[`u32::ilog10`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU32; -///assert_eq!(NonZeroU32::new(99).unwrap().ilog10(), 1); -///assert_eq!(NonZeroU32::new(100).unwrap().ilog10(), 2); -///assert_eq!(NonZeroU32::new(101).unwrap().ilog10(), 2); -/// ``` - - #[lua(kind = "Method")] - fn ilog10(self) -> u32; - -"#, - r#" -/// Returns `true` if and only if `self == (1 << k)` for some `k`. -/// On many architectures, this function can perform better than `is_power_of_two()` -/// on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let eight = std::num::NonZeroU32::new(8).unwrap(); -/// assert!(eight.is_power_of_two()); -///let ten = std::num::NonZeroU32::new(10).unwrap(); -/// assert!(!ten.is_power_of_two()); -/// ``` - - #[lua(kind = "Method")] - fn is_power_of_two(self) -> bool; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroU32::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroU32::new(2)?; -///let four = NonZeroU32::new(4)?; -///let max = NonZeroU32::new(u32::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroU32, - ) -> std::num::NonZeroU32; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroU32::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroU32::new(3)?; -///let twenty_seven = NonZeroU32::new(27)?; -///let max = NonZeroU32::new(u32::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU32; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroU32; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct NonZeroU32(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroU64", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroU64) -> bool; - -"#, - r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: u64) -> std::num::NonZeroU64; - -"#, - r#" -/// Returns the value as a primitive type. - - #[lua(kind = "Method")] - fn get(self) -> u64; - -"#, - r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU64::new(u64::MAX).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; - -"#, - r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU64::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Adds an unsigned integer to a non-zero value. -///Return [`NonZeroU64::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let one = NonZeroU64::new(1)?; -///let two = NonZeroU64::new(2)?; -///let max = NonZeroU64::new(u64::MAX)?; -/// assert_eq!(two, one.saturating_add(1)); -/// assert_eq!(max, max.saturating_add(1)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, other: u64) -> std::num::NonZeroU64; - -"#, - r#" -/// Returns the base 2 logarithm of the number, rounded down. -/// This is the same operation as -///[`u64::ilog2`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU64; -///assert_eq!(NonZeroU64::new(7).unwrap().ilog2(), 2); -///assert_eq!(NonZeroU64::new(8).unwrap().ilog2(), 3); -///assert_eq!(NonZeroU64::new(9).unwrap().ilog2(), 3); -/// ``` - - #[lua(kind = "Method")] - fn ilog2(self) -> u32; - -"#, - r#" -/// Returns the base 10 logarithm of the number, rounded down. -/// This is the same operation as -///[`u64::ilog10`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU64; -///assert_eq!(NonZeroU64::new(99).unwrap().ilog10(), 1); -///assert_eq!(NonZeroU64::new(100).unwrap().ilog10(), 2); -///assert_eq!(NonZeroU64::new(101).unwrap().ilog10(), 2); -/// ``` - - #[lua(kind = "Method")] - fn ilog10(self) -> u32; - -"#, - r#" -/// Returns `true` if and only if `self == (1 << k)` for some `k`. -/// On many architectures, this function can perform better than `is_power_of_two()` -/// on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let eight = std::num::NonZeroU64::new(8).unwrap(); -/// assert!(eight.is_power_of_two()); -///let ten = std::num::NonZeroU64::new(10).unwrap(); -/// assert!(!ten.is_power_of_two()); -/// ``` - - #[lua(kind = "Method")] - fn is_power_of_two(self) -> bool; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroU64::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroU64::new(2)?; -///let four = NonZeroU64::new(4)?; -///let max = NonZeroU64::new(u64::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroU64, - ) -> std::num::NonZeroU64; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroU64::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroU64::new(3)?; -///let twenty_seven = NonZeroU64::new(27)?; -///let max = NonZeroU64::new(u64::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU64; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroU64; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct NonZeroU64(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroU8", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroU8; - -"#, - r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: u8) -> std::num::NonZeroU8; - -"#, - r#" -/// Returns the value as a primitive type. - - #[lua(kind = "Method")] - fn get(self) -> u8; - -"#, - r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU8::new(u8::MAX).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; - -"#, - r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU8::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Adds an unsigned integer to a non-zero value. -///Return [`NonZeroU8::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let one = NonZeroU8::new(1)?; -///let two = NonZeroU8::new(2)?; -///let max = NonZeroU8::new(u8::MAX)?; -/// assert_eq!(two, one.saturating_add(1)); -/// assert_eq!(max, max.saturating_add(1)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, other: u8) -> std::num::NonZeroU8; - -"#, - r#" -/// Returns the base 2 logarithm of the number, rounded down. -/// This is the same operation as -///[`u8::ilog2`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU8; -///assert_eq!(NonZeroU8::new(7).unwrap().ilog2(), 2); -///assert_eq!(NonZeroU8::new(8).unwrap().ilog2(), 3); -///assert_eq!(NonZeroU8::new(9).unwrap().ilog2(), 3); -/// ``` - - #[lua(kind = "Method")] - fn ilog2(self) -> u32; - -"#, - r#" -/// Returns the base 10 logarithm of the number, rounded down. -/// This is the same operation as -///[`u8::ilog10`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU8; -///assert_eq!(NonZeroU8::new(99).unwrap().ilog10(), 1); -///assert_eq!(NonZeroU8::new(100).unwrap().ilog10(), 2); -///assert_eq!(NonZeroU8::new(101).unwrap().ilog10(), 2); -/// ``` - - #[lua(kind = "Method")] - fn ilog10(self) -> u32; - -"#, - r#" -/// Returns `true` if and only if `self == (1 << k)` for some `k`. -/// On many architectures, this function can perform better than `is_power_of_two()` -/// on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let eight = std::num::NonZeroU8::new(8).unwrap(); -/// assert!(eight.is_power_of_two()); -///let ten = std::num::NonZeroU8::new(10).unwrap(); -/// assert!(!ten.is_power_of_two()); -/// ``` - - #[lua(kind = "Method")] - fn is_power_of_two(self) -> bool; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroU8::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroU8::new(2)?; -///let four = NonZeroU8::new(4)?; -///let max = NonZeroU8::new(u8::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] other: std::num::NonZeroU8) -> std::num::NonZeroU8; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroU8::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroU8::new(3)?; -///let twenty_seven = NonZeroU8::new(27)?; -///let max = NonZeroU8::new(u8::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU8; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroU8) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct NonZeroU8(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroUsize", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: usize) -> std::num::NonZeroUsize; - -"#, - r#" -/// Returns the value as a primitive type. - - #[lua(kind = "Method")] - fn get(self) -> usize; - -"#, - r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroUsize::new(usize::MAX).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; - -"#, - r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroUsize::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Adds an unsigned integer to a non-zero value. -///Return [`NonZeroUsize::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroUsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let one = NonZeroUsize::new(1)?; -///let two = NonZeroUsize::new(2)?; -///let max = NonZeroUsize::new(usize::MAX)?; -/// assert_eq!(two, one.saturating_add(1)); -/// assert_eq!(max, max.saturating_add(1)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, other: usize) -> std::num::NonZeroUsize; - -"#, - r#" -/// Returns the base 2 logarithm of the number, rounded down. -/// This is the same operation as -///[`usize::ilog2`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroUsize; -///assert_eq!(NonZeroUsize::new(7).unwrap().ilog2(), 2); -///assert_eq!(NonZeroUsize::new(8).unwrap().ilog2(), 3); -///assert_eq!(NonZeroUsize::new(9).unwrap().ilog2(), 3); -/// ``` - - #[lua(kind = "Method")] - fn ilog2(self) -> u32; - -"#, - r#" -/// Returns the base 10 logarithm of the number, rounded down. -/// This is the same operation as -///[`usize::ilog10`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroUsize; -///assert_eq!(NonZeroUsize::new(99).unwrap().ilog10(), 1); -///assert_eq!(NonZeroUsize::new(100).unwrap().ilog10(), 2); -///assert_eq!(NonZeroUsize::new(101).unwrap().ilog10(), 2); -/// ``` - - #[lua(kind = "Method")] - fn ilog10(self) -> u32; - -"#, - r#" -/// Returns `true` if and only if `self == (1 << k)` for some `k`. -/// On many architectures, this function can perform better than `is_power_of_two()` -/// on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let eight = std::num::NonZeroUsize::new(8).unwrap(); -/// assert!(eight.is_power_of_two()); -///let ten = std::num::NonZeroUsize::new(10).unwrap(); -/// assert!(!ten.is_power_of_two()); -/// ``` - - #[lua(kind = "Method")] - fn is_power_of_two(self) -> bool; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroUsize::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroUsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroUsize::new(2)?; -///let four = NonZeroUsize::new(4)?; -///let max = NonZeroUsize::new(usize::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroUsize, - ) -> std::num::NonZeroUsize; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroUsize::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroUsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroUsize::new(3)?; -///let twenty_seven = NonZeroUsize::new(27)?; -///let max = NonZeroUsize::new(usize::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroUsize; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroUsize) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroUsize; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct NonZeroUsize(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::path::PathBuf", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::path::PathBuf) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::path::PathBuf; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "MutatingMethod", - )] - fn clone_from(&mut self, #[proxy] source: &std::path::PathBuf) -> (); - -"#, - r#" -/// Allocates an empty `PathBuf`. -/// # Examples -/// ``` -/// use std::path::PathBuf; -/// let path = PathBuf::new(); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn new() -> std::path::PathBuf; - -"#, - r#" -/// Creates a new `PathBuf` with a given capacity used to create the -/// internal [`OsString`]. See [`with_capacity`] defined on [`OsString`]. -/// # Examples -/// ``` -/// use std::path::PathBuf; -/// let mut path = PathBuf::with_capacity(10); -/// let capacity = path.capacity(); -/// // This push is done without reallocating -/// path.push(r"C:\"); -/// assert_eq!(capacity, path.capacity()); -/// ``` -/// [`with_capacity`]: OsString::with_capacity - - #[lua(kind = "Function", output(proxy))] - fn with_capacity(capacity: usize) -> std::path::PathBuf; - -"#, - r#" -/// Truncates `self` to [`self.parent`]. -/// Returns `false` and does nothing if [`self.parent`] is [`None`]. -/// Otherwise, returns `true`. -/// [`self.parent`]: Path::parent -/// # Examples -/// ``` -/// use std::path::{Path, PathBuf}; -/// let mut p = PathBuf::from("/spirited/away.rs"); -/// p.pop(); -/// assert_eq!(Path::new("/spirited"), p); -/// p.pop(); -/// assert_eq!(Path::new("/"), p); -/// ``` - - #[lua(kind = "MutatingMethod")] - fn pop(&mut self) -> bool; - -"#, - r#" -/// Invokes [`capacity`] on the underlying instance of [`OsString`]. -/// [`capacity`]: OsString::capacity - - #[lua(kind = "Method")] - fn capacity(&self) -> usize; - -"#, - r#" -/// Invokes [`clear`] on the underlying instance of [`OsString`]. -/// [`clear`]: OsString::clear - - #[lua(kind = "MutatingMethod")] - fn clear(&mut self) -> (); - -"#, - r#" -/// Invokes [`reserve`] on the underlying instance of [`OsString`]. -/// [`reserve`]: OsString::reserve - - #[lua(kind = "MutatingMethod")] - fn reserve(&mut self, additional: usize) -> (); - -"#, - r#" -/// Invokes [`reserve_exact`] on the underlying instance of [`OsString`]. -/// [`reserve_exact`]: OsString::reserve_exact - - #[lua(kind = "MutatingMethod")] - fn reserve_exact(&mut self, additional: usize) -> (); - -"#, - r#" -/// Invokes [`shrink_to_fit`] on the underlying instance of [`OsString`]. -/// [`shrink_to_fit`]: OsString::shrink_to_fit - - #[lua(kind = "MutatingMethod")] - fn shrink_to_fit(&mut self) -> (); - -"#, - r#" -/// Invokes [`shrink_to`] on the underlying instance of [`OsString`]. -/// [`shrink_to`]: OsString::shrink_to - - #[lua(kind = "MutatingMethod")] - fn shrink_to(&mut self, min_capacity: usize) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct PathBuf {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::ops::RangeFull", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::ops::RangeFull; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::ops::RangeFull) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct RangeFull {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Quat", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Quat; - -"#, - r#" -/// Subtracts the `rhs` quaternion from `self`. -/// The difference is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; - -"#, - 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) -> bevy::math::Quat; - -"#, - r#" -/// Creates a rotation quaternion from an array. -/// # 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_array(a: [f32; 4]) -> bevy::math::Quat; - -"#, - 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::Vec4) -> bevy::math::Quat; - -"#, - 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::Vec3, angle: f32) -> bevy::math::Quat; - -"#, - 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::Vec3) -> bevy::math::Quat; - -"#, - r#" -/// Creates a quaternion from the `angle` (in radians) around the x axis. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_x(angle: f32) -> bevy::math::Quat; - -"#, - r#" -/// Creates a quaternion from the `angle` (in radians) around the y axis. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_y(angle: f32) -> bevy::math::Quat; - -"#, - r#" -/// Creates a quaternion from the `angle` (in radians) around the z axis. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_z(angle: f32) -> bevy::math::Quat; - -"#, - 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, - ) -> bevy::math::Quat; - -"#, - r#" -/// Creates a quaternion from a 3x3 rotation matrix. - - #[lua(kind = "Function", output(proxy))] - fn from_mat3(#[proxy] mat: &glam::Mat3) -> bevy::math::Quat; - -"#, - r#" -/// Creates a quaternion from a 3x3 SIMD aligned rotation matrix. - - #[lua(kind = "Function", output(proxy))] - fn from_mat3a(#[proxy] mat: &glam::Mat3A) -> bevy::math::Quat; - -"#, - r#" -/// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. - - #[lua(kind = "Function", output(proxy))] - fn from_mat4(#[proxy] mat: &glam::Mat4) -> bevy::math::Quat; - -"#, - 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::Vec3, - #[proxy] - to: bevy::math::Vec3, - ) -> bevy::math::Quat; - -"#, - 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::Vec3, - #[proxy] - to: bevy::math::Vec3, - ) -> bevy::math::Quat; - -"#, - 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::Vec2, - #[proxy] - to: bevy::math::Vec2, - ) -> bevy::math::Quat; - -"#, - r#" -/// Returns the rotation axis scaled by the rotation in radians. - - #[lua(kind = "Method", output(proxy))] - fn to_scaled_axis(self) -> bevy::math::Vec3; - -"#, - r#" -/// Returns the rotation angles for the given euler rotation sequence. - - #[lua(kind = "Method")] - fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f32, f32, f32); - -"#, - r#" -/// `[x, y, z, w]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [f32; 4]; - -"#, - r#" -/// Returns the vector part of the quaternion. - - #[lua(kind = "Method", output(proxy))] - fn xyz(self) -> bevy::math::Vec3; - -"#, - r#" -/// Returns the quaternion conjugate of `self`. For a unit quaternion the -/// conjugate is also the inverse. - - #[lua(kind = "Method", output(proxy))] - fn conjugate(self) -> bevy::math::Quat; - -"#, - 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(kind = "Method", output(proxy))] - fn inverse(self) -> bevy::math::Quat; - -"#, - 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(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::Quat) -> f32; - -"#, - r#" -/// Computes the length of `self`. - - #[lua(kind = "Method")] - 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(kind = "Method")] - fn length_squared(self) -> f32; - -"#, - r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::Quat; - -"#, - 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(kind = "Method")] - fn is_finite(self) -> bool; - -"#, - r#" - - #[lua(kind = "Method")] - fn is_nan(self) -> bool; - -"#, - r#" -/// Returns whether `self` of length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - - #[lua(kind = "Method")] - fn is_normalized(self) -> bool; - -"#, - r#" - - #[lua(kind = "Method")] - 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(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::Quat) -> 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(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Quat, 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(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] end: bevy::math::Quat, s: f32) -> bevy::math::Quat; - -"#, - 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(kind = "Method", output(proxy))] - fn slerp(self, #[proxy] end: bevy::math::Quat, s: f32) -> bevy::math::Quat; - -"#, - 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(kind = "Method", output(proxy))] - fn mul_vec3(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn mul_quat(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; - -"#, - r#" -/// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. - - #[lua(kind = "Function", output(proxy))] - fn from_affine3(#[proxy] a: &glam::Affine3A) -> bevy::math::Quat; - -"#, - r#" -/// Multiplies a quaternion and a 3D vector, returning the rotated vector. - - #[lua(kind = "Method", output(proxy))] - fn mul_vec3a(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_dquat(self) -> bevy::math::DQuat; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_f64(self) -> bevy::math::DQuat; - -"#, - r#" -/// Adds two quaternions. -/// The sum is not guaranteed to be normalized. -/// Note that addition is not the same as combining the rotations represented by the -/// two quaternions! That corresponds to multiplication. - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; - -"#, - r#" -/// Multiplies a quaternion by a scalar value. -/// The product is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Quat; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Quat; - -"#, - r#" -/// Divides a quaternion by a scalar value. -/// The quotient is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Quat; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - 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( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Quat) -> bool; - -"#, - 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( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; - -"#, - r#" -/// Rotates the [`Direction3d`] using a [`Quat`]. - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul( - self, - #[proxy] - direction: bevy::math::primitives::Direction3d, - ) -> bevy::math::primitives::Direction3d; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct Quat(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Vec3", - functions[r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f32) -> bevy::math::Vec3; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: f32) -> bevy::math::Vec3; - -"#, - 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::BVec3, - #[proxy] - if_true: bevy::math::Vec3, - #[proxy] - if_false: bevy::math::Vec3, - ) -> bevy::math::Vec3; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f32; 3]) -> bevy::math::Vec3; - -"#, - r#" -/// `[x, y, z]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [f32; 3]; - -"#, - r#" -/// Creates a 4D vector from `self` and the given `w` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, w: f32) -> bevy::math::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(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::Vec2; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::Vec3) -> f32; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" -/// Computes the cross product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::Vec3, - #[proxy] - max: bevy::math::Vec3, - ) -> bevy::math::Vec3; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> f32; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::Vec3; - -"#, - r#" -/// Returns a vector with signs of `rhs` and the magnitudes of `self`. - - #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - 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(kind = "Method")] - 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(kind = "Method")] - fn is_finite(self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec3; - -"#, - r#" -/// Computes the length of `self`. - - #[lua(kind = "Method")] - fn length(self) -> f32; - -"#, - r#" -/// Computes the squared length of `self`. -/// This is faster than `length()` as it avoids a square root operation. - - #[lua(kind = "Method")] - fn length_squared(self) -> f32; - -"#, - r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - - #[lua(kind = "Method")] - fn length_recip(self) -> f32; - -"#, - r#" -/// Computes the Euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::Vec3) -> f32; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::Vec3) -> f32; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// [Euclidean division]: f32::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::Vec3; - -"#, - r#" -/// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::Vec3; - -"#, - r#" -/// Returns a vector containing the largest integer less than or equal to a number for each -/// element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::Vec3; - -"#, - r#" -/// Returns a vector containing the smallest integer greater than or equal to a number for -/// each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::Vec3; - -"#, - r#" -/// Returns a vector containing the integer part each element of `self`. This means numbers are -/// always truncated towards zero. - - #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::Vec3; - -"#, - r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of -/// `self`. - - #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::Vec3; - -"#, - r#" -/// Returns a vector containing each element of `self` raised to the power of `n`. - - #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f32) -> bevy::math::Vec3; - -"#, - r#" -/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::Vec3, s: f32) -> bevy::math::Vec3; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec3, 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(kind = "Method", output(proxy))] - fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3; - -"#, - r#" -/// Returns a vector with a length no more than `max` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f32) -> bevy::math::Vec3; - -"#, - r#" -/// Returns a vector with a length no less than `min` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f32) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::Vec3, - #[proxy] - b: bevy::math::Vec3, - ) -> bevy::math::Vec3; - -"#, - 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(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::Vec3) -> 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(kind = "Method", output(proxy))] - fn any_orthogonal_vector(&self) -> bevy::math::Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn any_orthonormal_vector(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f32) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f32) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::Vec3) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct Vec3 { - x: f32, - y: f32, - z: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::IVec2", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::IVec2) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i32) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i32) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: i32) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i32) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::IVec2; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: i32, y: i32) -> bevy::math::IVec2; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: i32) -> bevy::math::IVec2; - -"#, - 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::BVec2, - #[proxy] - if_true: bevy::math::IVec2, - #[proxy] - if_false: bevy::math::IVec2, - ) -> bevy::math::IVec2; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i32; 2]) -> bevy::math::IVec2; - -"#, - r#" -/// `[x, y]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [i32; 2]; - -"#, - r#" -/// Creates a 3D vector from `self` and the given `z` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, z: i32) -> bevy::math::IVec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::IVec2) -> i32; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::IVec2, - #[proxy] - max: bevy::math::IVec2, - ) -> bevy::math::IVec2; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> i32; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::IVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::IVec2; - -"#, - 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(kind = "Method")] - fn is_negative_bitmask(self) -> u32; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> i32; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::IVec2) -> i32; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. -/// [Euclidean division]: i32::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" -/// Returns a vector that is equal to `self` rotated by 90 degrees. - - #[lua(kind = "Method", output(proxy))] - fn perp(self) -> bevy::math::IVec2; - -"#, - r#" -/// The perpendicular dot product of `self` and `rhs`. -/// Also known as the wedge product, 2D cross product, and determinant. - - #[lua(kind = "Method")] - fn perp_dot(self, #[proxy] rhs: bevy::math::IVec2) -> 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(kind = "Method", output(proxy))] - fn rotate(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec2(&self) -> bevy::math::Vec2; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec2(&self) -> bevy::math::DVec2; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec2(&self) -> bevy::math::UVec2; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i32) -> bevy::math::IVec2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct IVec2 { - x: i32, - y: i32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::IVec3", - functions[r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: i32, y: i32, z: i32) -> bevy::math::IVec3; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: i32) -> bevy::math::IVec3; - -"#, - 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::BVec3, - #[proxy] - if_true: bevy::math::IVec3, - #[proxy] - if_false: bevy::math::IVec3, - ) -> bevy::math::IVec3; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i32; 3]) -> bevy::math::IVec3; - -"#, - r#" -/// `[x, y, z]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [i32; 3]; - -"#, - r#" -/// Creates a 4D vector from `self` and the given `w` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, w: i32) -> bevy::math::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(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::IVec2; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::IVec3) -> i32; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" -/// Computes the cross product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::IVec3, - #[proxy] - max: bevy::math::IVec3, - ) -> bevy::math::IVec3; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> i32; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::IVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::IVec3; - -"#, - 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(kind = "Method")] - fn is_negative_bitmask(self) -> u32; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> i32; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::IVec3) -> i32; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. -/// [Euclidean division]: i32::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3a(&self) -> bevy::math::Vec3A; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i32) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: i32) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i32) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::IVec3) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i32) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i32) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct IVec3 { - x: i32, - y: i32, - z: i32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::IVec4", - functions[r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i32) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::IVec4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: i32) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i32) -> bevy::math::IVec4; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: i32, y: i32, z: i32, w: i32) -> bevy::math::IVec4; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: i32) -> bevy::math::IVec4; - -"#, - 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::BVec4, - #[proxy] - if_true: bevy::math::IVec4, - #[proxy] - if_false: bevy::math::IVec4, - ) -> bevy::math::IVec4; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i32; 4]) -> bevy::math::IVec4; - -"#, - r#" -/// `[x, y, z, w]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [i32; 4]; - -"#, - r#" -/// Creates a 3D 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(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::IVec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::IVec4) -> i32; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::IVec4, - #[proxy] - max: bevy::math::IVec4, - ) -> bevy::math::IVec4; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> i32; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::IVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::IVec4; - -"#, - 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(kind = "Method")] - fn is_negative_bitmask(self) -> u32; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> i32; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::IVec4) -> i32; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. -/// [Euclidean division]: i32::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec4(&self) -> bevy::math::Vec4; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec4(&self) -> bevy::math::DVec4; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec4(&self) -> bevy::math::UVec4; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i32) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i32) -> bevy::math::IVec4; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct IVec4 { - x: i32, - y: i32, - z: i32, - w: i32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::I64Vec2", - functions[r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i64) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i64) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: i64) -> bevy::math::I64Vec2; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: i64, y: i64) -> bevy::math::I64Vec2; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: i64) -> bevy::math::I64Vec2; - -"#, - 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::BVec2, - #[proxy] - if_true: bevy::math::I64Vec2, - #[proxy] - if_false: bevy::math::I64Vec2, - ) -> bevy::math::I64Vec2; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i64; 2]) -> bevy::math::I64Vec2; - -"#, - r#" -/// `[x, y]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [i64; 2]; - -"#, - r#" -/// Creates a 3D vector from `self` and the given `z` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, z: i64) -> bevy::math::I64Vec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" -/// Component-wise clamping of values, similar to [`i64::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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::I64Vec2, - #[proxy] - max: bevy::math::I64Vec2, - ) -> bevy::math::I64Vec2; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> i64; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - fn max_element(self) -> i64; - -"#, - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::I64Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::I64Vec2; - -"#, - 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(kind = "Method")] - fn is_negative_bitmask(self) -> u32; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> i64; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. -/// [Euclidean division]: i64::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" -/// Returns a vector that is equal to `self` rotated by 90 degrees. - - #[lua(kind = "Method", output(proxy))] - fn perp(self) -> bevy::math::I64Vec2; - -"#, - r#" -/// The perpendicular dot product of `self` and `rhs`. -/// Also known as the wedge product, 2D cross product, and determinant. - - #[lua(kind = "Method")] - fn perp_dot(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; - -"#, - 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(kind = "Method", output(proxy))] - fn rotate(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec2(&self) -> bevy::math::Vec2; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec2(&self) -> bevy::math::DVec2; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec2(&self) -> bevy::math::IVec2; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec2(&self) -> bevy::math::UVec2; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::I64Vec2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i64) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct I64Vec2 { - x: i64, - y: i64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::I64Vec3", - functions[r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i64) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i64) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: i64) -> bevy::math::I64Vec3; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: i64, y: i64, z: i64) -> bevy::math::I64Vec3; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: i64) -> bevy::math::I64Vec3; - -"#, - 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::BVec3, - #[proxy] - if_true: bevy::math::I64Vec3, - #[proxy] - if_false: bevy::math::I64Vec3, - ) -> bevy::math::I64Vec3; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i64; 3]) -> bevy::math::I64Vec3; - -"#, - r#" -/// `[x, y, z]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [i64; 3]; - -"#, - r#" -/// Creates a 4D vector from `self` and the given `w` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, w: i64) -> bevy::math::I64Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::I64Vec2; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::I64Vec3) -> i64; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Computes the cross product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Component-wise clamping of values, similar to [`i64::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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::I64Vec3, - #[proxy] - max: bevy::math::I64Vec3, - ) -> bevy::math::I64Vec3; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> i64; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - fn max_element(self) -> i64; - -"#, - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::I64Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::I64Vec3; - -"#, - 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(kind = "Method")] - fn is_negative_bitmask(self) -> u32; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> i64; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec3) -> i64; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. -/// [Euclidean division]: i64::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3a(&self) -> bevy::math::Vec3A; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i64) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::I64Vec3) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct I64Vec3 { - x: i64, - y: i64, - z: i64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::I64Vec4", - functions[r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i64) -> bevy::math::I64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i64) -> bevy::math::I64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::I64Vec4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i64) -> bevy::math::I64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::I64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: i64) -> bevy::math::I64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::I64Vec4; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: i64, y: i64, z: i64, w: i64) -> bevy::math::I64Vec4; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: i64) -> bevy::math::I64Vec4; - -"#, - 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::BVec4, - #[proxy] - if_true: bevy::math::I64Vec4, - #[proxy] - if_false: bevy::math::I64Vec4, - ) -> bevy::math::I64Vec4; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i64; 4]) -> bevy::math::I64Vec4; - -"#, - r#" -/// `[x, y, z, w]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [i64; 4]; - -"#, - r#" -/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. -/// Truncation to [`I64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. - - #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::I64Vec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::I64Vec4) -> i64; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" -/// Component-wise clamping of values, similar to [`i64::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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::I64Vec4, - #[proxy] - max: bevy::math::I64Vec4, - ) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> i64; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - fn max_element(self) -> i64; - -"#, - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::I64Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::I64Vec4; - -"#, - 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(kind = "Method")] - fn is_negative_bitmask(self) -> u32; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> i64; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec4) -> i64; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. -/// [Euclidean division]: i64::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec4(&self) -> bevy::math::Vec4; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec4(&self) -> bevy::math::DVec4; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec4(&self) -> bevy::math::IVec4; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec4(&self) -> bevy::math::UVec4; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct I64Vec4 { - x: i64, - y: i64, - z: i64, - w: i64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::UVec2", - functions[r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: u32, y: u32) -> bevy::math::UVec2; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: u32) -> bevy::math::UVec2; - -"#, - 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::BVec2, - #[proxy] - if_true: bevy::math::UVec2, - #[proxy] - if_false: bevy::math::UVec2, - ) -> bevy::math::UVec2; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [u32; 2]) -> bevy::math::UVec2; - -"#, - r#" -/// `[x, y]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [u32; 2]; - -"#, - r#" -/// Creates a 3D vector from `self` and the given `z` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, z: u32) -> bevy::math::UVec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::UVec2) -> u32; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::UVec2, - #[proxy] - max: bevy::math::UVec2, - ) -> bevy::math::UVec2; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> u32; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> u32; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec2(&self) -> bevy::math::Vec2; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec2(&self) -> bevy::math::DVec2; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec2(&self) -> bevy::math::IVec2; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u32) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u32) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u32) -> bevy::math::UVec2; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::UVec2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u32) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u32) -> bevy::math::UVec2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct UVec2 { - x: u32, - y: u32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::UVec3", - functions[r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: u32, y: u32, z: u32) -> bevy::math::UVec3; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: u32) -> bevy::math::UVec3; - -"#, - 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::BVec3, - #[proxy] - if_true: bevy::math::UVec3, - #[proxy] - if_false: bevy::math::UVec3, - ) -> bevy::math::UVec3; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [u32; 3]) -> bevy::math::UVec3; - -"#, - r#" -/// `[x, y, z]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [u32; 3]; - -"#, - r#" -/// Creates a 4D vector from `self` and the given `w` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, w: u32) -> bevy::math::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(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::UVec2; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::UVec3) -> u32; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" -/// Computes the cross product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::UVec3, - #[proxy] - max: bevy::math::UVec3, - ) -> bevy::math::UVec3; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> u32; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> u32; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3a(&self) -> bevy::math::Vec3A; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u32) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::UVec3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u32) -> bevy::math::UVec3; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u32) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u32) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u32) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::UVec3; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct UVec3 { - x: u32, - y: u32, - z: u32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::UVec4", - functions[r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u32) -> bevy::math::UVec4; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: u32, y: u32, z: u32, w: u32) -> bevy::math::UVec4; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: u32) -> bevy::math::UVec4; - -"#, - 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::BVec4, - #[proxy] - if_true: bevy::math::UVec4, - #[proxy] - if_false: bevy::math::UVec4, - ) -> bevy::math::UVec4; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [u32; 4]) -> bevy::math::UVec4; - -"#, - r#" -/// `[x, y, z, w]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [u32; 4]; - -"#, - r#" -/// Creates a 3D 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(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::UVec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::UVec4) -> u32; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::UVec4, - #[proxy] - max: bevy::math::UVec4, - ) -> bevy::math::UVec4; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> u32; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> u32; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec4(&self) -> bevy::math::Vec4; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec4(&self) -> bevy::math::DVec4; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec4(&self) -> bevy::math::IVec4; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::UVec4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u32) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u32) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u32) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u32) -> bevy::math::UVec4; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct UVec4 { - x: u32, - y: u32, - z: u32, - w: u32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::U64Vec2", - functions[r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u64) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u64) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::U64Vec2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u64) -> bevy::math::U64Vec2; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: u64, y: u64) -> bevy::math::U64Vec2; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: u64) -> bevy::math::U64Vec2; - -"#, - 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::BVec2, - #[proxy] - if_true: bevy::math::U64Vec2, - #[proxy] - if_false: bevy::math::U64Vec2, - ) -> bevy::math::U64Vec2; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [u64; 2]) -> bevy::math::U64Vec2; - -"#, - r#" -/// `[x, y]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [u64; 2]; - -"#, - r#" -/// Creates a 3D vector from `self` and the given `z` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, z: u64) -> bevy::math::U64Vec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::U64Vec2) -> u64; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" -/// Component-wise clamping of values, similar to [`u64::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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::U64Vec2, - #[proxy] - max: bevy::math::U64Vec2, - ) -> bevy::math::U64Vec2; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> u64; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - fn max_element(self) -> u64; - -"#, - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> u64; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec2(&self) -> bevy::math::Vec2; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec2(&self) -> bevy::math::DVec2; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec2(&self) -> bevy::math::IVec2; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec2(&self) -> bevy::math::UVec2; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct U64Vec2 { - x: u64, - y: u64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::U64Vec3", - functions[r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: u64, y: u64, z: u64) -> bevy::math::U64Vec3; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: u64) -> bevy::math::U64Vec3; - -"#, - 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::BVec3, - #[proxy] - if_true: bevy::math::U64Vec3, - #[proxy] - if_false: bevy::math::U64Vec3, - ) -> bevy::math::U64Vec3; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [u64; 3]) -> bevy::math::U64Vec3; - -"#, - r#" -/// `[x, y, z]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [u64; 3]; - -"#, - r#" -/// Creates a 4D vector from `self` and the given `w` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, w: u64) -> bevy::math::U64Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::U64Vec2; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::U64Vec3) -> u64; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" -/// Computes the cross product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" -/// Component-wise clamping of values, similar to [`u64::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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::U64Vec3, - #[proxy] - max: bevy::math::U64Vec3, - ) -> bevy::math::U64Vec3; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> u64; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - fn max_element(self) -> u64; - -"#, - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> u64; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3a(&self) -> bevy::math::Vec3A; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u64) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u64) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u64) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::U64Vec3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct U64Vec3 { - x: u64, - y: u64, - z: u64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::U64Vec4", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u64) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u64) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: u64, y: u64, z: u64, w: u64) -> bevy::math::U64Vec4; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: u64) -> bevy::math::U64Vec4; - -"#, - 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::BVec4, - #[proxy] - if_true: bevy::math::U64Vec4, - #[proxy] - if_false: bevy::math::U64Vec4, - ) -> bevy::math::U64Vec4; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [u64; 4]) -> bevy::math::U64Vec4; - -"#, - r#" -/// `[x, y, z, w]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [u64; 4]; - -"#, - r#" -/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. -/// Truncation to [`U64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. - - #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::U64Vec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::U64Vec4) -> u64; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Component-wise clamping of values, similar to [`u64::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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::U64Vec4, - #[proxy] - max: bevy::math::U64Vec4, - ) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> u64; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - fn max_element(self) -> u64; - -"#, - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> u64; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec4(&self) -> bevy::math::Vec4; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec4(&self) -> bevy::math::DVec4; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec4(&self) -> bevy::math::IVec4; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec4(&self) -> bevy::math::UVec4; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::U64Vec4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u64) -> bevy::math::U64Vec4; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct U64Vec4 { - x: u64, - y: u64, - z: u64, - w: u64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Vec2", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::Vec2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f32) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f32) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f32) -> bevy::math::Vec2; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: f32, y: f32) -> bevy::math::Vec2; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: f32) -> bevy::math::Vec2; - -"#, - 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::BVec2, - #[proxy] - if_true: bevy::math::Vec2, - #[proxy] - if_false: bevy::math::Vec2, - ) -> bevy::math::Vec2; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f32; 2]) -> bevy::math::Vec2; - -"#, - r#" -/// `[x, y]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [f32; 2]; - -"#, - r#" -/// Creates a 3D vector from `self` and the given `z` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, z: f32) -> bevy::math::Vec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::Vec2) -> f32; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::Vec2, - #[proxy] - max: bevy::math::Vec2, - ) -> bevy::math::Vec2; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> f32; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::Vec2; - -"#, - r#" -/// Returns a vector with signs of `rhs` and the magnitudes of `self`. - - #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - 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(kind = "Method")] - 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(kind = "Method")] - fn is_finite(self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec2; - -"#, - r#" -/// Computes the length of `self`. - - #[lua(kind = "Method")] - fn length(self) -> f32; - -"#, - r#" -/// Computes the squared length of `self`. -/// This is faster than `length()` as it avoids a square root operation. - - #[lua(kind = "Method")] - fn length_squared(self) -> f32; - -"#, - r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - - #[lua(kind = "Method")] - fn length_recip(self) -> f32; - -"#, - r#" -/// Computes the Euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::Vec2) -> f32; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::Vec2) -> f32; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// [Euclidean division]: f32::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::Vec2; - -"#, - r#" -/// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::Vec2; - -"#, - r#" -/// Returns a vector containing the largest integer less than or equal to a number for each -/// element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::Vec2; - -"#, - r#" -/// Returns a vector containing the smallest integer greater than or equal to a number for -/// each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::Vec2; - -"#, - r#" -/// Returns a vector containing the integer part each element of `self`. This means numbers are -/// always truncated towards zero. - - #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::Vec2; - -"#, - r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of -/// `self`. - - #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::Vec2; - -"#, - r#" -/// Returns a vector containing each element of `self` raised to the power of `n`. - - #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f32) -> bevy::math::Vec2; - -"#, - r#" -/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::Vec2, s: f32) -> bevy::math::Vec2; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec2, 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(kind = "Method", output(proxy))] - fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec2; - -"#, - r#" -/// Returns a vector with a length no more than `max` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f32) -> bevy::math::Vec2; - -"#, - r#" -/// Returns a vector with a length no less than `min` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f32) -> bevy::math::Vec2; - -"#, - 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(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::Vec2, - #[proxy] - b: bevy::math::Vec2, - ) -> bevy::math::Vec2; - -"#, - 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) -> bevy::math::Vec2; - -"#, - r#" -/// Returns the angle (in radians) of this vector in the range `[-Ï€, +Ï€]`. -/// The input does not need to be a unit vector however it must be non-zero. - - #[lua(kind = "Method")] - fn to_angle(self) -> f32; - -"#, - 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(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::Vec2) -> f32; - -"#, - r#" -/// Returns a vector that is equal to `self` rotated by 90 degrees. - - #[lua(kind = "Method", output(proxy))] - fn perp(self) -> bevy::math::Vec2; - -"#, - r#" -/// The perpendicular dot product of `self` and `rhs`. -/// Also known as the wedge product, 2D cross product, and determinant. - - #[lua(kind = "Method")] - fn perp_dot(self, #[proxy] rhs: bevy::math::Vec2) -> 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(kind = "Method", output(proxy))] - fn rotate(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec2(&self) -> bevy::math::DVec2; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec2(&self) -> bevy::math::IVec2; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec2(&self) -> bevy::math::UVec2; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct Vec2 { - x: f32, - y: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Vec3A", - functions[r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Vec3A; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3A; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: f32) -> bevy::math::Vec3A; - -"#, - 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::BVec3A, - #[proxy] - if_true: bevy::math::Vec3A, - #[proxy] - if_false: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f32; 3]) -> bevy::math::Vec3A; - -"#, - r#" -/// `[x, y, z]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [f32; 3]; - -"#, - r#" -/// Creates a 4D vector from `self` and the given `w` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, w: f32) -> bevy::math::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(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::Vec2; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" -/// Computes the cross product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::Vec3A, - #[proxy] - max: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> f32; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns a vector with signs of `rhs` and the magnitudes of `self`. - - #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method")] - 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(kind = "Method")] - fn is_finite(self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec3A; - -"#, - r#" -/// Computes the length of `self`. - - #[lua(kind = "Method")] - fn length(self) -> f32; - -"#, - r#" -/// Computes the squared length of `self`. -/// This is faster than `length()` as it avoids a square root operation. - - #[lua(kind = "Method")] - fn length_squared(self) -> f32; - -"#, - r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - - #[lua(kind = "Method")] - fn length_recip(self) -> f32; - -"#, - r#" -/// Computes the Euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// [Euclidean division]: f32::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn project_onto_normalized( - self, - #[proxy] - rhs: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from_normalized( - self, - #[proxy] - rhs: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns a vector containing the largest integer less than or equal to a number for each -/// element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns a vector containing the smallest integer greater than or equal to a number for -/// each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns a vector containing the integer part each element of `self`. This means numbers are -/// always truncated towards zero. - - #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of -/// `self`. - - #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns a vector containing each element of `self` raised to the power of `n`. - - #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f32) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::Vec3A, s: f32) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec3A, 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(kind = "Method", output(proxy))] - fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns a vector with a length no more than `max` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f32) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns a vector with a length no less than `min` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f32) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::Vec3A, - #[proxy] - b: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::Vec3A) -> 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(kind = "Method", output(proxy))] - fn any_orthogonal_vector(&self) -> bevy::math::Vec3A; - -"#, - 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(kind = "Method", output(proxy))] - fn any_orthonormal_vector(&self) -> bevy::math::Vec3A; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Vec3A) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f32) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f32) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f32) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Vec3A; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct Vec3A(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Vec4", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Vec4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Vec4; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: f32, y: f32, z: f32, w: f32) -> bevy::math::Vec4; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: f32) -> bevy::math::Vec4; - -"#, - 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::BVec4A, - #[proxy] - if_true: bevy::math::Vec4, - #[proxy] - if_false: bevy::math::Vec4, - ) -> bevy::math::Vec4; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f32; 4]) -> bevy::math::Vec4; - -"#, - r#" -/// `[x, y, z, w]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [f32; 4]; - -"#, - r#" -/// Creates a 3D 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(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::Vec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::Vec4) -> f32; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::Vec4, - #[proxy] - max: bevy::math::Vec4, - ) -> bevy::math::Vec4; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> f32; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::Vec4; - -"#, - r#" -/// Returns a vector with signs of `rhs` and the magnitudes of `self`. - - #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - 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(kind = "Method")] - 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(kind = "Method")] - fn is_finite(self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec4A; - -"#, - r#" -/// Computes the length of `self`. - - #[lua(kind = "Method")] - fn length(self) -> f32; - -"#, - r#" -/// Computes the squared length of `self`. -/// This is faster than `length()` as it avoids a square root operation. - - #[lua(kind = "Method")] - fn length_squared(self) -> f32; - -"#, - r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - - #[lua(kind = "Method")] - fn length_recip(self) -> f32; - -"#, - r#" -/// Computes the Euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::Vec4) -> f32; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::Vec4) -> f32; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// [Euclidean division]: f32::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::Vec4; - -"#, - r#" -/// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::Vec4; - -"#, - r#" -/// Returns a vector containing the largest integer less than or equal to a number for each -/// element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::Vec4; - -"#, - r#" -/// Returns a vector containing the smallest integer greater than or equal to a number for -/// each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::Vec4; - -"#, - r#" -/// Returns a vector containing the integer part each element of `self`. This means numbers are -/// always truncated towards zero. - - #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::Vec4; - -"#, - r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of -/// `self`. - - #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::Vec4; - -"#, - r#" -/// Returns a vector containing each element of `self` raised to the power of `n`. - - #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f32) -> bevy::math::Vec4; - -"#, - r#" -/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::Vec4, s: f32) -> bevy::math::Vec4; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec4, 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(kind = "Method", output(proxy))] - fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec4; - -"#, - r#" -/// Returns a vector with a length no more than `max` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f32) -> bevy::math::Vec4; - -"#, - r#" -/// Returns a vector with a length no less than `min` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f32) -> bevy::math::Vec4; - -"#, - 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(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::Vec4, - #[proxy] - b: bevy::math::Vec4, - ) -> bevy::math::Vec4; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec4(&self) -> bevy::math::DVec4; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec4(&self) -> bevy::math::IVec4; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec4(&self) -> bevy::math::UVec4; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f32) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f32) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f32) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct Vec4(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::BVec2", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::BVec2) -> bool; - -"#, - r#" -/// Creates a new vector mask. - - #[lua(kind = "Function", output(proxy))] - fn new(x: bool, y: bool) -> bevy::math::BVec2; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: bool) -> bevy::math::BVec2; - -"#, - 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(kind = "Method")] - fn bitmask(self) -> u32; - -"#, - r#" -/// Returns true if any of the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn any(self) -> bool; - -"#, - r#" -/// Returns true if all the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn all(self) -> bool; - -"#, - r#" -/// Tests the value at `index`. -/// Panics if `index` is greater than 1. - - #[lua(kind = "Method")] - fn test(&self, index: usize) -> bool; - -"#, - r#" -/// Sets the element at `index`. -/// Panics if `index` is greater than 1. - - #[lua(kind = "MutatingMethod")] - fn set(&mut self, index: usize, value: bool) -> (); - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct BVec2 { - x: bool, - y: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::BVec3", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::BVec3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec3; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -/// Creates a new vector mask. - - #[lua(kind = "Function", output(proxy))] - fn new(x: bool, y: bool, z: bool) -> bevy::math::BVec3; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: bool) -> bevy::math::BVec3; - -"#, - 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(kind = "Method")] - fn bitmask(self) -> u32; - -"#, - r#" -/// Returns true if any of the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn any(self) -> bool; - -"#, - r#" -/// Returns true if all the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn all(self) -> bool; - -"#, - r#" -/// Tests the value at `index`. -/// Panics if `index` is greater than 2. - - #[lua(kind = "Method")] - fn test(&self, index: usize) -> bool; - -"#, - r#" -/// Sets the element at `index`. -/// Panics if `index` is greater than 2. - - #[lua(kind = "MutatingMethod")] - fn set(&mut self, index: usize, value: bool) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct BVec3 { - x: bool, - y: bool, - z: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::BVec4", - functions[r#" -/// Creates a new vector mask. - - #[lua(kind = "Function", output(proxy))] - fn new(x: bool, y: bool, z: bool, w: bool) -> bevy::math::BVec4; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: bool) -> bevy::math::BVec4; - -"#, - 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(kind = "Method")] - fn bitmask(self) -> u32; - -"#, - r#" -/// Returns true if any of the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn any(self) -> bool; - -"#, - r#" -/// Returns true if all the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn all(self) -> bool; - -"#, - r#" -/// Tests the value at `index`. -/// Panics if `index` is greater than 3. - - #[lua(kind = "Method")] - fn test(&self, index: usize) -> bool; - -"#, - r#" -/// Sets the element at `index`. -/// Panics if `index` is greater than 3. - - #[lua(kind = "MutatingMethod")] - fn set(&mut self, index: usize, value: bool) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::BVec4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec4; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct BVec4 { - x: bool, - y: bool, - z: bool, - w: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DVec2", - functions[r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f64) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::DVec2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f64) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: f64, y: f64) -> bevy::math::DVec2; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: f64) -> bevy::math::DVec2; - -"#, - 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::BVec2, - #[proxy] - if_true: bevy::math::DVec2, - #[proxy] - if_false: bevy::math::DVec2, - ) -> bevy::math::DVec2; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f64; 2]) -> bevy::math::DVec2; - -"#, - r#" -/// `[x, y]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [f64; 2]; - -"#, - r#" -/// Creates a 3D vector from `self` and the given `z` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, z: f64) -> bevy::math::DVec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::DVec2) -> f64; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::DVec2, - #[proxy] - max: bevy::math::DVec2, - ) -> bevy::math::DVec2; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> f64; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::DVec2; - -"#, - r#" -/// Returns a vector with signs of `rhs` and the magnitudes of `self`. - - #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - 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(kind = "Method")] - 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(kind = "Method")] - fn is_finite(self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec2; - -"#, - r#" -/// Computes the length of `self`. - - #[lua(kind = "Method")] - fn length(self) -> f64; - -"#, - r#" -/// Computes the squared length of `self`. -/// This is faster than `length()` as it avoids a square root operation. - - #[lua(kind = "Method")] - fn length_squared(self) -> f64; - -"#, - r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - - #[lua(kind = "Method")] - fn length_recip(self) -> f64; - -"#, - r#" -/// Computes the Euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::DVec2) -> f64; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::DVec2) -> f64; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// [Euclidean division]: f64::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::DVec2; - -"#, - r#" -/// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn project_onto_normalized( - self, - #[proxy] - rhs: bevy::math::DVec2, - ) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from_normalized( - self, - #[proxy] - rhs: bevy::math::DVec2, - ) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::DVec2; - -"#, - r#" -/// Returns a vector containing the largest integer less than or equal to a number for each -/// element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::DVec2; - -"#, - r#" -/// Returns a vector containing the smallest integer greater than or equal to a number for -/// each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::DVec2; - -"#, - r#" -/// Returns a vector containing the integer part each element of `self`. This means numbers are -/// always truncated towards zero. - - #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::DVec2; - -"#, - r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of -/// `self`. - - #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::DVec2; - -"#, - r#" -/// Returns a vector containing each element of `self` raised to the power of `n`. - - #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f64) -> bevy::math::DVec2; - -"#, - r#" -/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::DVec2, s: f64) -> bevy::math::DVec2; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec2, 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(kind = "Method", output(proxy))] - fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec2; - -"#, - r#" -/// Returns a vector with a length no more than `max` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f64) -> bevy::math::DVec2; - -"#, - r#" -/// Returns a vector with a length no less than `min` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f64) -> bevy::math::DVec2; - -"#, - 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(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::DVec2, - #[proxy] - b: bevy::math::DVec2, - ) -> bevy::math::DVec2; - -"#, - 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) -> bevy::math::DVec2; - -"#, - r#" -/// Returns the angle (in radians) of this vector in the range `[-Ï€, +Ï€]`. -/// The input does not need to be a unit vector however it must be non-zero. - - #[lua(kind = "Method")] - fn to_angle(self) -> f64; - -"#, - 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(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::DVec2) -> f64; - -"#, - r#" -/// Returns a vector that is equal to `self` rotated by 90 degrees. - - #[lua(kind = "Method", output(proxy))] - fn perp(self) -> bevy::math::DVec2; - -"#, - r#" -/// The perpendicular dot product of `self` and `rhs`. -/// Also known as the wedge product, 2D cross product, and determinant. - - #[lua(kind = "Method")] - fn perp_dot(self, #[proxy] rhs: bevy::math::DVec2) -> 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(kind = "Method", output(proxy))] - fn rotate(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec2(&self) -> bevy::math::Vec2; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec2(&self) -> bevy::math::IVec2; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec2(&self) -> bevy::math::UVec2; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f64) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f64) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct DVec2 { - x: f64, - y: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DVec3", - functions[r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f64) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::DVec3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f64) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f64) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f64) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DVec3; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: f64, y: f64, z: f64) -> bevy::math::DVec3; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: f64) -> bevy::math::DVec3; - -"#, - 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::BVec3, - #[proxy] - if_true: bevy::math::DVec3, - #[proxy] - if_false: bevy::math::DVec3, - ) -> bevy::math::DVec3; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f64; 3]) -> bevy::math::DVec3; - -"#, - r#" -/// `[x, y, z]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [f64; 3]; - -"#, - r#" -/// Creates a 4D vector from `self` and the given `w` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, w: f64) -> bevy::math::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(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::DVec2; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::DVec3) -> f64; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" -/// Computes the cross product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::DVec3, - #[proxy] - max: bevy::math::DVec3, - ) -> bevy::math::DVec3; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> f64; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::DVec3; - -"#, - r#" -/// Returns a vector with signs of `rhs` and the magnitudes of `self`. - - #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - 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(kind = "Method")] - 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(kind = "Method")] - fn is_finite(self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec3; - -"#, - r#" -/// Computes the length of `self`. - - #[lua(kind = "Method")] - fn length(self) -> f64; - -"#, - r#" -/// Computes the squared length of `self`. -/// This is faster than `length()` as it avoids a square root operation. - - #[lua(kind = "Method")] - fn length_squared(self) -> f64; - -"#, - r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - - #[lua(kind = "Method")] - fn length_recip(self) -> f64; - -"#, - r#" -/// Computes the Euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::DVec3) -> f64; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::DVec3) -> f64; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// [Euclidean division]: f64::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::DVec3; - -"#, - r#" -/// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn project_onto_normalized( - self, - #[proxy] - rhs: bevy::math::DVec3, - ) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from_normalized( - self, - #[proxy] - rhs: bevy::math::DVec3, - ) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::DVec3; - -"#, - r#" -/// Returns a vector containing the largest integer less than or equal to a number for each -/// element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::DVec3; - -"#, - r#" -/// Returns a vector containing the smallest integer greater than or equal to a number for -/// each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::DVec3; - -"#, - r#" -/// Returns a vector containing the integer part each element of `self`. This means numbers are -/// always truncated towards zero. - - #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::DVec3; - -"#, - r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of -/// `self`. - - #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::DVec3; - -"#, - r#" -/// Returns a vector containing each element of `self` raised to the power of `n`. - - #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f64) -> bevy::math::DVec3; - -"#, - r#" -/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::DVec3, s: f64) -> bevy::math::DVec3; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec3, 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(kind = "Method", output(proxy))] - fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec3; - -"#, - r#" -/// Returns a vector with a length no more than `max` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f64) -> bevy::math::DVec3; - -"#, - r#" -/// Returns a vector with a length no less than `min` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f64) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::DVec3, - #[proxy] - b: bevy::math::DVec3, - ) -> bevy::math::DVec3; - -"#, - 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(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::DVec3) -> 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(kind = "Method", output(proxy))] - fn any_orthogonal_vector(&self) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn any_orthonormal_vector(&self) -> bevy::math::DVec3; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3a(&self) -> bevy::math::Vec3A; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct DVec3 { - x: f64, - y: f64, - z: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DVec4", - functions[r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: f64, y: f64, z: f64, w: f64) -> bevy::math::DVec4; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: f64) -> bevy::math::DVec4; - -"#, - 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::BVec4, - #[proxy] - if_true: bevy::math::DVec4, - #[proxy] - if_false: bevy::math::DVec4, - ) -> bevy::math::DVec4; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f64; 4]) -> bevy::math::DVec4; - -"#, - r#" -/// `[x, y, z, w]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [f64; 4]; - -"#, - r#" -/// Creates a 3D 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(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::DVec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::DVec4) -> f64; - -"#, - r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::DVec4, - #[proxy] - max: bevy::math::DVec4, - ) -> bevy::math::DVec4; - -"#, - r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - - #[lua(kind = "Method")] - fn min_element(self) -> f64; - -"#, - r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::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(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::DVec4; - -"#, - r#" -/// Returns a vector with signs of `rhs` and the magnitudes of `self`. - - #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - 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(kind = "Method")] - 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(kind = "Method")] - fn is_finite(self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec4; - -"#, - r#" -/// Computes the length of `self`. - - #[lua(kind = "Method")] - fn length(self) -> f64; - -"#, - r#" -/// Computes the squared length of `self`. -/// This is faster than `length()` as it avoids a square root operation. - - #[lua(kind = "Method")] - fn length_squared(self) -> f64; - -"#, - r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - - #[lua(kind = "Method")] - fn length_recip(self) -> f64; - -"#, - r#" -/// Computes the Euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::DVec4) -> f64; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::DVec4) -> f64; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// [Euclidean division]: f64::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::DVec4; - -"#, - r#" -/// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn project_onto_normalized( - self, - #[proxy] - rhs: bevy::math::DVec4, - ) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn reject_from_normalized( - self, - #[proxy] - rhs: bevy::math::DVec4, - ) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::DVec4; - -"#, - r#" -/// Returns a vector containing the largest integer less than or equal to a number for each -/// element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::DVec4; - -"#, - r#" -/// Returns a vector containing the smallest integer greater than or equal to a number for -/// each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::DVec4; - -"#, - r#" -/// Returns a vector containing the integer part each element of `self`. This means numbers are -/// always truncated towards zero. - - #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::DVec4; - -"#, - r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of -/// `self`. - - #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::DVec4; - -"#, - r#" -/// Returns a vector containing each element of `self` raised to the power of `n`. - - #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f64) -> bevy::math::DVec4; - -"#, - r#" -/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::DVec4, s: f64) -> bevy::math::DVec4; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec4, 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(kind = "Method", output(proxy))] - fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec4; - -"#, - r#" -/// Returns a vector with a length no more than `max` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f64) -> bevy::math::DVec4; - -"#, - r#" -/// Returns a vector with a length no less than `min` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f64) -> bevy::math::DVec4; - -"#, - 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(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::DVec4, - #[proxy] - b: bevy::math::DVec4, - ) -> bevy::math::DVec4; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec4(&self) -> bevy::math::Vec4; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec4(&self) -> bevy::math::IVec4; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec4(&self) -> bevy::math::UVec4; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f64) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f64) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f64) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::DVec4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f64) -> bevy::math::DVec4; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -pub struct DVec4 { - x: f64, - y: f64, - z: f64, - w: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Mat2", - functions[r#" -/// Creates a 2x2 matrix from two column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::Vec2, - #[proxy] - y_axis: bevy::math::Vec2, - ) -> bevy::math::Mat2; - -"#, - r#" -/// Creates a `[f32; 4]` array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f32; 4]; - -"#, - r#" -/// Creates a `[[f32; 2]; 2]` 2D array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f32; 2]; 2]; - -"#, - 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::Vec2) -> bevy::math::Mat2; - -"#, - 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::Vec2, - angle: f32, - ) -> bevy::math::Mat2; - -"#, - r#" -/// Creates a 2x2 matrix containing a rotation of `angle` (in radians). - - #[lua(kind = "Function", output(proxy))] - fn from_angle(angle: f32) -> bevy::math::Mat2; - -"#, - 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::Mat3) -> bevy::math::Mat2; - -"#, - 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::Mat3A) -> bevy::math::Mat2; - -"#, - r#" -/// Returns the matrix column for the given `index`. -/// # Panics -/// Panics if `index` is greater than 1. - - #[lua(kind = "Method", output(proxy))] - fn col(&self, index: usize) -> bevy::math::Vec2; - -"#, - r#" -/// Returns the matrix row for the given `index`. -/// # Panics -/// Panics if `index` is greater than 1. - - #[lua(kind = "Method", output(proxy))] - fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - fn is_nan(&self) -> bool; - -"#, - r#" -/// Returns the transpose of `self`. - - #[lua(kind = "Method", output(proxy))] - fn transpose(&self) -> bevy::math::Mat2; - -"#, - r#" -/// Returns the determinant of `self`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::Mat2; - -"#, - r#" -/// Transforms a 2D vector. - - #[lua(kind = "Method", output(proxy))] - fn mul_vec2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" -/// Multiplies two 2x2 matrices. - - #[lua(kind = "Method", output(proxy))] - fn mul_mat2(&self, #[proxy] rhs: &glam::Mat2) -> bevy::math::Mat2; - -"#, - r#" -/// Adds two 2x2 matrices. - - #[lua(kind = "Method", output(proxy))] - fn add_mat2(&self, #[proxy] rhs: &glam::Mat2) -> bevy::math::Mat2; - -"#, - r#" -/// Subtracts two 2x2 matrices. - - #[lua(kind = "Method", output(proxy))] - fn sub_mat2(&self, #[proxy] rhs: &glam::Mat2) -> bevy::math::Mat2; - -"#, - r#" -/// Multiplies a 2x2 matrix by a scalar. - - #[lua(kind = "Method", output(proxy))] - fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat2; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat2, max_abs_diff: f32) -> bool; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_dmat2(&self) -> bevy::math::DMat2; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Mat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Mat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Mat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Mat2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaVec2::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) -} -"#] -)] -pub struct Mat2(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Mat3", - functions[r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Mat3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; - -"#, - r#" -/// Creates a 3x3 matrix from three column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::Vec3, - #[proxy] - y_axis: bevy::math::Vec3, - #[proxy] - z_axis: bevy::math::Vec3, - ) -> bevy::math::Mat3; - -"#, - r#" -/// Creates a `[f32; 9]` array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f32; 9]; - -"#, - r#" -/// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f32; 3]; 3]; - -"#, - 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::Vec3) -> bevy::math::Mat3; - -"#, - 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::Mat4) -> bevy::math::Mat3; - -"#, - 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::Quat) -> bevy::math::Mat3; - -"#, - 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::Vec3, angle: f32) -> bevy::math::Mat3; - -"#, - 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, - ) -> bevy::math::Mat3; - -"#, - 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) -> bevy::math::Mat3; - -"#, - 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) -> bevy::math::Mat3; - -"#, - 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) -> bevy::math::Mat3; - -"#, - 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::Vec2) -> bevy::math::Mat3; - -"#, - 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) -> bevy::math::Mat3; - -"#, - 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::Vec2, - angle: f32, - #[proxy] - translation: bevy::math::Vec2, - ) -> bevy::math::Mat3; - -"#, - 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::Vec2) -> bevy::math::Mat3; - -"#, - 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::Mat2) -> bevy::math::Mat3; - -"#, - r#" -/// Returns the matrix column for the given `index`. -/// # Panics -/// Panics if `index` is greater than 2. - - #[lua(kind = "Method", output(proxy))] - fn col(&self, index: usize) -> bevy::math::Vec3; - -"#, - r#" -/// Returns the matrix row for the given `index`. -/// # Panics -/// Panics if `index` is greater than 2. - - #[lua(kind = "Method", output(proxy))] - fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - fn is_nan(&self) -> bool; - -"#, - r#" -/// Returns the transpose of `self`. - - #[lua(kind = "Method", output(proxy))] - fn transpose(&self) -> bevy::math::Mat3; - -"#, - r#" -/// Returns the determinant of `self`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::Mat3; - -"#, - 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(kind = "Method", output(proxy))] - fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" -/// Transforms a 3D vector. - - #[lua(kind = "Method", output(proxy))] - fn mul_vec3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" -/// Transforms a [`Vec3A`]. - - #[lua(kind = "Method", output(proxy))] - fn mul_vec3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" -/// Multiplies two 3x3 matrices. - - #[lua(kind = "Method", output(proxy))] - fn mul_mat3(&self, #[proxy] rhs: &glam::Mat3) -> bevy::math::Mat3; - -"#, - r#" -/// Adds two 3x3 matrices. - - #[lua(kind = "Method", output(proxy))] - fn add_mat3(&self, #[proxy] rhs: &glam::Mat3) -> bevy::math::Mat3; - -"#, - r#" -/// Subtracts two 3x3 matrices. - - #[lua(kind = "Method", output(proxy))] - fn sub_mat3(&self, #[proxy] rhs: &glam::Mat3) -> bevy::math::Mat3; - -"#, - r#" -/// Multiplies a 3x3 matrix by a scalar. - - #[lua(kind = "Method", output(proxy))] - fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat3; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat3, max_abs_diff: f32) -> bool; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_dmat3(&self) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaVec3::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) -} -"#] -)] -pub struct Mat3 { - #[lua(output(proxy))] - x_axis: bevy::math::Vec3, - #[lua(output(proxy))] - y_axis: bevy::math::Vec3, - #[lua(output(proxy))] - z_axis: bevy::math::Vec3, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Mat3A", - functions[r#" -/// Creates a 3x3 matrix from three column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::Vec3A, - #[proxy] - y_axis: bevy::math::Vec3A, - #[proxy] - z_axis: bevy::math::Vec3A, - ) -> bevy::math::Mat3A; - -"#, - r#" -/// Creates a `[f32; 9]` array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f32; 9]; - -"#, - r#" -/// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f32; 3]; 3]; - -"#, - 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::Vec3) -> bevy::math::Mat3A; - -"#, - 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::Mat4) -> bevy::math::Mat3A; - -"#, - 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::Quat) -> bevy::math::Mat3A; - -"#, - 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::Vec3, angle: f32) -> bevy::math::Mat3A; - -"#, - 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, - ) -> bevy::math::Mat3A; - -"#, - 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) -> bevy::math::Mat3A; - -"#, - 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) -> bevy::math::Mat3A; - -"#, - 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) -> bevy::math::Mat3A; - -"#, - 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::Vec2) -> bevy::math::Mat3A; - -"#, - 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) -> bevy::math::Mat3A; - -"#, - 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::Vec2, - angle: f32, - #[proxy] - translation: bevy::math::Vec2, - ) -> bevy::math::Mat3A; - -"#, - 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::Vec2) -> bevy::math::Mat3A; - -"#, - 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::Mat2) -> bevy::math::Mat3A; - -"#, - r#" -/// Returns the matrix column for the given `index`. -/// # Panics -/// Panics if `index` is greater than 2. - - #[lua(kind = "Method", output(proxy))] - fn col(&self, index: usize) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns the matrix row for the given `index`. -/// # Panics -/// Panics if `index` is greater than 2. - - #[lua(kind = "Method", output(proxy))] - fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - fn is_nan(&self) -> bool; - -"#, - r#" -/// Returns the transpose of `self`. - - #[lua(kind = "Method", output(proxy))] - fn transpose(&self) -> bevy::math::Mat3A; - -"#, - r#" -/// Returns the determinant of `self`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::Mat3A; - -"#, - 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(kind = "Method", output(proxy))] - fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" -/// Transforms a 3D vector. - - #[lua(kind = "Method", output(proxy))] - fn mul_vec3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" -/// Transforms a [`Vec3A`]. - - #[lua(kind = "Method", output(proxy))] - fn mul_vec3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" -/// Multiplies two 3x3 matrices. - - #[lua(kind = "Method", output(proxy))] - fn mul_mat3(&self, #[proxy] rhs: &glam::Mat3A) -> bevy::math::Mat3A; - -"#, - r#" -/// Adds two 3x3 matrices. - - #[lua(kind = "Method", output(proxy))] - fn add_mat3(&self, #[proxy] rhs: &glam::Mat3A) -> bevy::math::Mat3A; - -"#, - r#" -/// Subtracts two 3x3 matrices. - - #[lua(kind = "Method", output(proxy))] - fn sub_mat3(&self, #[proxy] rhs: &glam::Mat3A) -> bevy::math::Mat3A; - -"#, - r#" -/// Multiplies a 3x3 matrix by a scalar. - - #[lua(kind = "Method", output(proxy))] - fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat3A; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat3A, max_abs_diff: f32) -> bool; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_dmat3(&self) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Mat3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Mat3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Mat3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Mat3A) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaVec3A::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) -} -"#] -)] -pub struct Mat3A { - #[lua(output(proxy))] - x_axis: bevy::math::Vec3A, - #[lua(output(proxy))] - y_axis: bevy::math::Vec3A, - #[lua(output(proxy))] - z_axis: bevy::math::Vec3A, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Mat4", - functions[r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" -/// Creates a 4x4 matrix from four column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::Vec4, - #[proxy] - y_axis: bevy::math::Vec4, - #[proxy] - z_axis: bevy::math::Vec4, - #[proxy] - w_axis: bevy::math::Vec4, - ) -> bevy::math::Mat4; - -"#, - r#" -/// Creates a `[f32; 16]` array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f32; 16]; - -"#, - r#" -/// Creates a `[[f32; 4]; 4]` 4D array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f32; 4]; 4]; - -"#, - 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::Vec4) -> bevy::math::Mat4; - -"#, - 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::Vec3, - #[proxy] - rotation: bevy::math::Quat, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Mat4; - -"#, - 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::Quat, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Mat4; - -"#, - 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::Quat) -> bevy::math::Mat4; - -"#, - 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::Mat3) -> bevy::math::Mat4; - -"#, - 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::Mat3A) -> bevy::math::Mat4; - -"#, - 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::Vec3) -> bevy::math::Mat4; - -"#, - 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::Vec3, angle: f32) -> bevy::math::Mat4; - -"#, - 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, - ) -> bevy::math::Mat4; - -"#, - 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) -> bevy::math::Mat4; - -"#, - 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) -> bevy::math::Mat4; - -"#, - 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) -> bevy::math::Mat4; - -"#, - 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::Vec3) -> bevy::math::Mat4; - -"#, - r#" -/// Returns the matrix column for the given `index`. -/// # Panics -/// Panics if `index` is greater than 3. - - #[lua(kind = "Method", output(proxy))] - fn col(&self, index: usize) -> bevy::math::Vec4; - -"#, - r#" -/// Returns the matrix row for the given `index`. -/// # Panics -/// Panics if `index` is greater than 3. - - #[lua(kind = "Method", output(proxy))] - fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - fn is_nan(&self) -> bool; - -"#, - r#" -/// Returns the transpose of `self`. - - #[lua(kind = "Method", output(proxy))] - fn transpose(&self) -> bevy::math::Mat4; - -"#, - r#" -/// Returns the determinant of `self`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::Mat4; - -"#, - 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::Vec3, - #[proxy] - dir: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Mat4; - -"#, - 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::Vec3, - #[proxy] - dir: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Mat4; - -"#, - 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::Vec3, - #[proxy] - center: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Mat4; - -"#, - 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::Vec3, - #[proxy] - center: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Mat4; - -"#, - 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, - ) -> bevy::math::Mat4; - -"#, - 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, - ) -> bevy::math::Mat4; - -"#, - 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, - ) -> bevy::math::Mat4; - -"#, - 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, - ) -> bevy::math::Mat4; - -"#, - 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, - ) -> bevy::math::Mat4; - -"#, - 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, - ) -> bevy::math::Mat4; - -"#, - 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, - ) -> bevy::math::Mat4; - -"#, - 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, - ) -> bevy::math::Mat4; - -"#, - 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, - ) -> bevy::math::Mat4; - -"#, - 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, - ) -> bevy::math::Mat4; - -"#, - 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(kind = "Method", output(proxy))] - fn project_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_vector3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_point3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_vector3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" -/// Transforms a 4D vector. - - #[lua(kind = "Method", output(proxy))] - fn mul_vec4(&self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" -/// Multiplies two 4x4 matrices. - - #[lua(kind = "Method", output(proxy))] - fn mul_mat4(&self, #[proxy] rhs: &glam::Mat4) -> bevy::math::Mat4; - -"#, - r#" -/// Adds two 4x4 matrices. - - #[lua(kind = "Method", output(proxy))] - fn add_mat4(&self, #[proxy] rhs: &glam::Mat4) -> bevy::math::Mat4; - -"#, - r#" -/// Subtracts two 4x4 matrices. - - #[lua(kind = "Method", output(proxy))] - fn sub_mat4(&self, #[proxy] rhs: &glam::Mat4) -> bevy::math::Mat4; - -"#, - r#" -/// Multiplies a 4x4 matrix by a scalar. - - #[lua(kind = "Method", output(proxy))] - fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat4; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat4, max_abs_diff: f32) -> bool; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_dmat4(&self) -> bevy::math::DMat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Mat4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Mat4; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaVec4::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) -} -"#] -)] -pub struct Mat4 { - #[lua(output(proxy))] - x_axis: bevy::math::Vec4, - #[lua(output(proxy))] - y_axis: bevy::math::Vec4, - #[lua(output(proxy))] - z_axis: bevy::math::Vec4, - #[lua(output(proxy))] - w_axis: bevy::math::Vec4, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DMat2", - functions[r#" -/// Creates a 2x2 matrix from two column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::DVec2, - #[proxy] - y_axis: bevy::math::DVec2, - ) -> bevy::math::DMat2; - -"#, - r#" -/// Creates a `[f64; 4]` array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f64; 4]; - -"#, - r#" -/// Creates a `[[f64; 2]; 2]` 2D array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f64; 2]; 2]; - -"#, - 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::DVec2) -> bevy::math::DMat2; - -"#, - 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::DVec2, - angle: f64, - ) -> bevy::math::DMat2; - -"#, - r#" -/// Creates a 2x2 matrix containing a rotation of `angle` (in radians). - - #[lua(kind = "Function", output(proxy))] - fn from_angle(angle: f64) -> bevy::math::DMat2; - -"#, - 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::DMat3) -> bevy::math::DMat2; - -"#, - r#" -/// Returns the matrix column for the given `index`. -/// # Panics -/// Panics if `index` is greater than 1. - - #[lua(kind = "Method", output(proxy))] - fn col(&self, index: usize) -> bevy::math::DVec2; - -"#, - r#" -/// Returns the matrix row for the given `index`. -/// # Panics -/// Panics if `index` is greater than 1. - - #[lua(kind = "Method", output(proxy))] - fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - fn is_nan(&self) -> bool; - -"#, - r#" -/// Returns the transpose of `self`. - - #[lua(kind = "Method", output(proxy))] - fn transpose(&self) -> bevy::math::DMat2; - -"#, - r#" -/// Returns the determinant of `self`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::DMat2; - -"#, - r#" -/// Transforms a 2D vector. - - #[lua(kind = "Method", output(proxy))] - fn mul_vec2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" -/// Multiplies two 2x2 matrices. - - #[lua(kind = "Method", output(proxy))] - fn mul_mat2(&self, #[proxy] rhs: &glam::DMat2) -> bevy::math::DMat2; - -"#, - r#" -/// Adds two 2x2 matrices. - - #[lua(kind = "Method", output(proxy))] - fn add_mat2(&self, #[proxy] rhs: &glam::DMat2) -> bevy::math::DMat2; - -"#, - r#" -/// Subtracts two 2x2 matrices. - - #[lua(kind = "Method", output(proxy))] - fn sub_mat2(&self, #[proxy] rhs: &glam::DMat2) -> bevy::math::DMat2; - -"#, - r#" -/// Multiplies a 2x2 matrix by a scalar. - - #[lua(kind = "Method", output(proxy))] - fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat2; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DMat2, max_abs_diff: f64) -> bool; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_mat2(&self) -> bevy::math::Mat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DMat2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DMat2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DMat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DMat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaDVec2::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) -} -"#] -)] -pub struct DMat2 { - #[lua(output(proxy))] - x_axis: bevy::math::DVec2, - #[lua(output(proxy))] - y_axis: bevy::math::DVec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DMat3", - functions[r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DMat3) -> bool; - -"#, - r#" -/// Creates a 3x3 matrix from three column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::DVec3, - #[proxy] - y_axis: bevy::math::DVec3, - #[proxy] - z_axis: bevy::math::DVec3, - ) -> bevy::math::DMat3; - -"#, - r#" -/// Creates a `[f64; 9]` array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f64; 9]; - -"#, - r#" -/// Creates a `[[f64; 3]; 3]` 3D array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f64; 3]; 3]; - -"#, - 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::DVec3) -> bevy::math::DMat3; - -"#, - 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::DMat4) -> bevy::math::DMat3; - -"#, - 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::DQuat) -> bevy::math::DMat3; - -"#, - 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::DVec3, - angle: f64, - ) -> bevy::math::DMat3; - -"#, - 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, - ) -> bevy::math::DMat3; - -"#, - 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) -> bevy::math::DMat3; - -"#, - 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) -> bevy::math::DMat3; - -"#, - 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) -> bevy::math::DMat3; - -"#, - 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::DVec2) -> bevy::math::DMat3; - -"#, - 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) -> bevy::math::DMat3; - -"#, - 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::DVec2, - angle: f64, - #[proxy] - translation: bevy::math::DVec2, - ) -> bevy::math::DMat3; - -"#, - 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::DVec2) -> bevy::math::DMat3; - -"#, - 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::DMat2) -> bevy::math::DMat3; - -"#, - r#" -/// Returns the matrix column for the given `index`. -/// # Panics -/// Panics if `index` is greater than 2. - - #[lua(kind = "Method", output(proxy))] - fn col(&self, index: usize) -> bevy::math::DVec3; - -"#, - r#" -/// Returns the matrix row for the given `index`. -/// # Panics -/// Panics if `index` is greater than 2. - - #[lua(kind = "Method", output(proxy))] - fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - fn is_nan(&self) -> bool; - -"#, - r#" -/// Returns the transpose of `self`. - - #[lua(kind = "Method", output(proxy))] - fn transpose(&self) -> bevy::math::DMat3; - -"#, - r#" -/// Returns the determinant of `self`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::DMat3; - -"#, - 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(kind = "Method", output(proxy))] - fn transform_point2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_vector2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" -/// Transforms a 3D vector. - - #[lua(kind = "Method", output(proxy))] - fn mul_vec3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" -/// Multiplies two 3x3 matrices. - - #[lua(kind = "Method", output(proxy))] - fn mul_mat3(&self, #[proxy] rhs: &glam::DMat3) -> bevy::math::DMat3; - -"#, - r#" -/// Adds two 3x3 matrices. - - #[lua(kind = "Method", output(proxy))] - fn add_mat3(&self, #[proxy] rhs: &glam::DMat3) -> bevy::math::DMat3; - -"#, - r#" -/// Subtracts two 3x3 matrices. - - #[lua(kind = "Method", output(proxy))] - fn sub_mat3(&self, #[proxy] rhs: &glam::DMat3) -> bevy::math::DMat3; - -"#, - r#" -/// Multiplies a 3x3 matrix by a scalar. - - #[lua(kind = "Method", output(proxy))] - fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat3; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DMat3, max_abs_diff: f64) -> bool; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_mat3(&self) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaDVec3::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) -} -"#] -)] -pub struct DMat3 { - #[lua(output(proxy))] - x_axis: bevy::math::DVec3, - #[lua(output(proxy))] - y_axis: bevy::math::DVec3, - #[lua(output(proxy))] - z_axis: bevy::math::DVec3, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DMat4", - functions[r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DMat4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DMat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DMat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DMat4; - -"#, - r#" -/// Creates a 4x4 matrix from four column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::DVec4, - #[proxy] - y_axis: bevy::math::DVec4, - #[proxy] - z_axis: bevy::math::DVec4, - #[proxy] - w_axis: bevy::math::DVec4, - ) -> bevy::math::DMat4; - -"#, - r#" -/// Creates a `[f64; 16]` array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f64; 16]; - -"#, - r#" -/// Creates a `[[f64; 4]; 4]` 4D array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f64; 4]; 4]; - -"#, - 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::DVec4) -> bevy::math::DMat4; - -"#, - 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::DVec3, - #[proxy] - rotation: bevy::math::DQuat, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DMat4; - -"#, - 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::DQuat, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DMat4; - -"#, - 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::DQuat) -> bevy::math::DMat4; - -"#, - 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::DMat3) -> bevy::math::DMat4; - -"#, - 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::DVec3) -> bevy::math::DMat4; - -"#, - 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::DVec3, - angle: f64, - ) -> bevy::math::DMat4; - -"#, - 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, - ) -> bevy::math::DMat4; - -"#, - 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) -> bevy::math::DMat4; - -"#, - 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) -> bevy::math::DMat4; - -"#, - 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) -> bevy::math::DMat4; - -"#, - 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::DVec3) -> bevy::math::DMat4; - -"#, - r#" -/// Returns the matrix column for the given `index`. -/// # Panics -/// Panics if `index` is greater than 3. - - #[lua(kind = "Method", output(proxy))] - fn col(&self, index: usize) -> bevy::math::DVec4; - -"#, - r#" -/// Returns the matrix row for the given `index`. -/// # Panics -/// Panics if `index` is greater than 3. - - #[lua(kind = "Method", output(proxy))] - fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - fn is_nan(&self) -> bool; - -"#, - r#" -/// Returns the transpose of `self`. - - #[lua(kind = "Method", output(proxy))] - fn transpose(&self) -> bevy::math::DMat4; - -"#, - r#" -/// Returns the determinant of `self`. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::DMat4; - -"#, - 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::DVec3, - #[proxy] - dir: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DMat4; - -"#, - 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::DVec3, - #[proxy] - dir: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DMat4; - -"#, - 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::DVec3, - #[proxy] - center: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DMat4; - -"#, - 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::DVec3, - #[proxy] - center: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DMat4; - -"#, - 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, - ) -> bevy::math::DMat4; - -"#, - 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, - ) -> bevy::math::DMat4; - -"#, - 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, - ) -> bevy::math::DMat4; - -"#, - 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, - ) -> bevy::math::DMat4; - -"#, - 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, - ) -> bevy::math::DMat4; - -"#, - 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, - ) -> bevy::math::DMat4; - -"#, - 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, - ) -> bevy::math::DMat4; - -"#, - 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, - ) -> bevy::math::DMat4; - -"#, - 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, - ) -> bevy::math::DMat4; - -"#, - 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, - ) -> bevy::math::DMat4; - -"#, - 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(kind = "Method", output(proxy))] - fn project_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_vector3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" -/// Transforms a 4D vector. - - #[lua(kind = "Method", output(proxy))] - fn mul_vec4(&self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" -/// Multiplies two 4x4 matrices. - - #[lua(kind = "Method", output(proxy))] - fn mul_mat4(&self, #[proxy] rhs: &glam::DMat4) -> bevy::math::DMat4; - -"#, - r#" -/// Adds two 4x4 matrices. - - #[lua(kind = "Method", output(proxy))] - fn add_mat4(&self, #[proxy] rhs: &glam::DMat4) -> bevy::math::DMat4; - -"#, - r#" -/// Subtracts two 4x4 matrices. - - #[lua(kind = "Method", output(proxy))] - fn sub_mat4(&self, #[proxy] rhs: &glam::DMat4) -> bevy::math::DMat4; - -"#, - r#" -/// Multiplies a 4x4 matrix by a scalar. - - #[lua(kind = "Method", output(proxy))] - fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat4; - -"#, - 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(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DMat4, max_abs_diff: f64) -> bool; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_mat4(&self) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DMat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaDVec4::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) -} -"#] -)] -pub struct DMat4 { - #[lua(output(proxy))] - x_axis: bevy::math::DVec4, - #[lua(output(proxy))] - y_axis: bevy::math::DVec4, - #[lua(output(proxy))] - z_axis: bevy::math::DVec4, - #[lua(output(proxy))] - w_axis: bevy::math::DVec4, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Affine2", - functions[r#" -/// Creates an affine transform from three column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::Vec2, - #[proxy] - y_axis: bevy::math::Vec2, - #[proxy] - z_axis: bevy::math::Vec2, - ) -> bevy::math::Affine2; - -"#, - r#" -/// Creates a `[f32; 6]` array storing data in column major order. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f32; 6]; - -"#, - r#" -/// Creates a `[[f32; 2]; 3]` 2D array storing data in -/// column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f32; 2]; 3]; - -"#, - 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::Vec2) -> bevy::math::Affine2; - -"#, - r#" -/// Creates an affine transform from the given rotation `angle`. - - #[lua(kind = "Function", output(proxy))] - fn from_angle(angle: f32) -> bevy::math::Affine2; - -"#, - r#" -/// Creates an affine transformation from the given 2D `translation`. - - #[lua(kind = "Function", output(proxy))] - fn from_translation(#[proxy] translation: bevy::math::Vec2) -> bevy::math::Affine2; - -"#, - 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::Mat2) -> bevy::math::Affine2; - -"#, - 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::Mat2, - #[proxy] - translation: bevy::math::Vec2, - ) -> bevy::math::Affine2; - -"#, - 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::Vec2, - angle: f32, - #[proxy] - translation: bevy::math::Vec2, - ) -> bevy::math::Affine2; - -"#, - 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::Vec2, - ) -> bevy::math::Affine2; - -"#, - r#" -/// The given `Mat3` must be an affine transform, - - #[lua(kind = "Function", output(proxy))] - fn from_mat3(#[proxy] m: bevy::math::Mat3) -> bevy::math::Affine2; - -"#, - r#" -/// The given [`Mat3A`] must be an affine transform, - - #[lua(kind = "Function", output(proxy))] - fn from_mat3a(#[proxy] m: bevy::math::Mat3A) -> bevy::math::Affine2; - -"#, - r#" -/// Transforms the given 2D point, applying shear, scale, rotation and translation. - - #[lua(kind = "Method", output(proxy))] - fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - 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(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Affine2, 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(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::Affine2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Affine2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Affine2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Affine2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct Affine2 { - #[lua(output(proxy))] - matrix2: bevy::math::Mat2, - #[lua(output(proxy))] - translation: bevy::math::Vec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Affine3A", - functions[r#" -/// Creates an affine transform from three column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::Vec3A, - #[proxy] - y_axis: bevy::math::Vec3A, - #[proxy] - z_axis: bevy::math::Vec3A, - #[proxy] - w_axis: bevy::math::Vec3A, - ) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates a `[f32; 12]` array storing data in column major order. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f32; 12]; - -"#, - r#" -/// Creates a `[[f32; 3]; 4]` 3D array storing data in -/// column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f32; 3]; 4]; - -"#, - 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::Vec3) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates an affine transform from the given `rotation` quaternion. - - #[lua(kind = "Function", output(proxy))] - fn from_quat(#[proxy] rotation: bevy::math::Quat) -> bevy::math::Affine3A; - -"#, - 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::Vec3, - angle: f32, - ) -> bevy::math::Affine3A; - -"#, - 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) -> bevy::math::Affine3A; - -"#, - 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) -> bevy::math::Affine3A; - -"#, - 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) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates an affine transformation from the given 3D `translation`. - - #[lua(kind = "Function", output(proxy))] - fn from_translation(#[proxy] translation: bevy::math::Vec3) -> bevy::math::Affine3A; - -"#, - 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::Mat3) -> bevy::math::Affine3A; - -"#, - 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::Mat3, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - 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::Vec3, - #[proxy] - rotation: bevy::math::Quat, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - 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::Quat, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - 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::Mat4) -> bevy::math::Affine3A; - -"#, - 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::Vec3, - #[proxy] - dir: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - 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::Vec3, - #[proxy] - dir: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - 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::Vec3, - #[proxy] - center: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - 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::Vec3, - #[proxy] - center: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - r#" -/// Transforms the given 3D points, applying shear, scale, rotation and translation. - - #[lua(kind = "Method", output(proxy))] - fn transform_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_vector3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" -/// Transforms the given [`Vec3A`], applying shear, scale, rotation and translation. - - #[lua(kind = "Method", output(proxy))] - fn transform_point3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" -/// Transforms the given [`Vec3A`], applying shear, scale and rotation (but NOT -/// translation). -/// To also apply translation, use [`Self::transform_point3a()`] instead. - - #[lua(kind = "Method", output(proxy))] - fn transform_vector3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - 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(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Affine3A, 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(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::Affine3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Affine3A; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Affine3A; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Affine3A) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct Affine3A { - #[lua(output(proxy))] - matrix3: bevy::math::Mat3A, - #[lua(output(proxy))] - translation: bevy::math::Vec3A, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DAffine2", - functions[r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DAffine2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DAffine2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DAffine2) -> bool; - -"#, - r#" -/// Creates an affine transform from three column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::DVec2, - #[proxy] - y_axis: bevy::math::DVec2, - #[proxy] - z_axis: bevy::math::DVec2, - ) -> bevy::math::DAffine2; - -"#, - r#" -/// Creates a `[f64; 6]` array storing data in column major order. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f64; 6]; - -"#, - r#" -/// Creates a `[[f64; 2]; 3]` 2D array storing data in -/// column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f64; 2]; 3]; - -"#, - 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::DVec2) -> bevy::math::DAffine2; - -"#, - r#" -/// Creates an affine transform from the given rotation `angle`. - - #[lua(kind = "Function", output(proxy))] - fn from_angle(angle: f64) -> bevy::math::DAffine2; - -"#, - r#" -/// Creates an affine transformation from the given 2D `translation`. - - #[lua(kind = "Function", output(proxy))] - fn from_translation(#[proxy] translation: bevy::math::DVec2) -> bevy::math::DAffine2; - -"#, - 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::DMat2) -> bevy::math::DAffine2; - -"#, - 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::DMat2, - #[proxy] - translation: bevy::math::DVec2, - ) -> bevy::math::DAffine2; - -"#, - 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::DVec2, - angle: f64, - #[proxy] - translation: bevy::math::DVec2, - ) -> bevy::math::DAffine2; - -"#, - 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::DVec2, - ) -> bevy::math::DAffine2; - -"#, - r#" -/// The given `DMat3` must be an affine transform, - - #[lua(kind = "Function", output(proxy))] - fn from_mat3(#[proxy] m: bevy::math::DMat3) -> bevy::math::DAffine2; - -"#, - r#" -/// Transforms the given 2D point, applying shear, scale, rotation and translation. - - #[lua(kind = "Method", output(proxy))] - fn transform_point2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_vector2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - 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(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DAffine2, 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(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::DAffine2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct DAffine2 { - #[lua(output(proxy))] - matrix2: bevy::math::DMat2, - #[lua(output(proxy))] - translation: bevy::math::DVec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DAffine3", - functions[r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DAffine3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DAffine3) -> bool; - -"#, - r#" -/// Creates an affine transform from three column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::DVec3, - #[proxy] - y_axis: bevy::math::DVec3, - #[proxy] - z_axis: bevy::math::DVec3, - #[proxy] - w_axis: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates a `[f64; 12]` array storing data in column major order. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f64; 12]; - -"#, - r#" -/// Creates a `[[f64; 3]; 4]` 3D array storing data in -/// column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f64; 3]; 4]; - -"#, - 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::DVec3) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates an affine transform from the given `rotation` quaternion. - - #[lua(kind = "Function", output(proxy))] - fn from_quat(#[proxy] rotation: bevy::math::DQuat) -> bevy::math::DAffine3; - -"#, - 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::DVec3, - angle: f64, - ) -> bevy::math::DAffine3; - -"#, - 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) -> bevy::math::DAffine3; - -"#, - 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) -> bevy::math::DAffine3; - -"#, - 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) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates an affine transformation from the given 3D `translation`. - - #[lua(kind = "Function", output(proxy))] - fn from_translation(#[proxy] translation: bevy::math::DVec3) -> bevy::math::DAffine3; - -"#, - 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::DMat3) -> bevy::math::DAffine3; - -"#, - 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::DMat3, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - 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::DVec3, - #[proxy] - rotation: bevy::math::DQuat, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - 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::DQuat, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - 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::DMat4) -> bevy::math::DAffine3; - -"#, - 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::DVec3, - #[proxy] - dir: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - 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::DVec3, - #[proxy] - dir: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - 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::DVec3, - #[proxy] - center: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - 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::DVec3, - #[proxy] - center: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - r#" -/// Transforms the given 3D points, applying shear, scale, rotation and translation. - - #[lua(kind = "Method", output(proxy))] - fn transform_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn transform_vector3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - 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(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DAffine3, 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(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::DAffine3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DAffine3; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct DAffine3 { - #[lua(output(proxy))] - matrix3: bevy::math::DMat3, - #[lua(output(proxy))] - translation: bevy::math::DVec3, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DQuat", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DQuat) -> bool; - -"#, - r#" -/// Divides a quaternion by a scalar value. -/// The quotient is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f64) -> bevy::math::DQuat; - -"#, - r#" -/// Subtracts the `rhs` quaternion from `self`. -/// The difference is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; - -"#, - r#" -/// Adds two quaternions. -/// The sum is not guaranteed to be normalized. -/// Note that addition is not the same as combining the rotations represented by the -/// two quaternions! That corresponds to multiplication. - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; - -"#, - 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( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; - -"#, - r#" -/// Multiplies a quaternion by a scalar value. -/// The product is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DQuat; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DQuat; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DQuat; - -"#, - 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) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a rotation quaternion from an array. -/// # 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_array(a: [f64; 4]) -> bevy::math::DQuat; - -"#, - 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::DVec4) -> bevy::math::DQuat; - -"#, - 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::DVec3, - angle: f64, - ) -> bevy::math::DQuat; - -"#, - 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::DVec3) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from the `angle` (in radians) around the x axis. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_x(angle: f64) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from the `angle` (in radians) around the y axis. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_y(angle: f64) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from the `angle` (in radians) around the z axis. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_z(angle: f64) -> bevy::math::DQuat; - -"#, - 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, - ) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from a 3x3 rotation matrix. - - #[lua(kind = "Function", output(proxy))] - fn from_mat3(#[proxy] mat: &glam::DMat3) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. - - #[lua(kind = "Function", output(proxy))] - fn from_mat4(#[proxy] mat: &glam::DMat4) -> bevy::math::DQuat; - -"#, - 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::DVec3, - #[proxy] - to: bevy::math::DVec3, - ) -> bevy::math::DQuat; - -"#, - 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::DVec3, - #[proxy] - to: bevy::math::DVec3, - ) -> bevy::math::DQuat; - -"#, - 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::DVec2, - #[proxy] - to: bevy::math::DVec2, - ) -> bevy::math::DQuat; - -"#, - r#" -/// Returns the rotation axis scaled by the rotation in radians. - - #[lua(kind = "Method", output(proxy))] - fn to_scaled_axis(self) -> bevy::math::DVec3; - -"#, - r#" -/// Returns the rotation angles for the given euler rotation sequence. - - #[lua(kind = "Method")] - fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f64, f64, f64); - -"#, - r#" -/// `[x, y, z, w]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [f64; 4]; - -"#, - r#" -/// Returns the vector part of the quaternion. - - #[lua(kind = "Method", output(proxy))] - fn xyz(self) -> bevy::math::DVec3; - -"#, - r#" -/// Returns the quaternion conjugate of `self`. For a unit quaternion the -/// conjugate is also the inverse. - - #[lua(kind = "Method", output(proxy))] - fn conjugate(self) -> bevy::math::DQuat; - -"#, - 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(kind = "Method", output(proxy))] - fn inverse(self) -> bevy::math::DQuat; - -"#, - 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(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::DQuat) -> f64; - -"#, - r#" -/// Computes the length of `self`. - - #[lua(kind = "Method")] - 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(kind = "Method")] - fn length_squared(self) -> f64; - -"#, - r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - - #[lua(kind = "Method")] - 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(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::DQuat; - -"#, - 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(kind = "Method")] - fn is_finite(self) -> bool; - -"#, - r#" - - #[lua(kind = "Method")] - fn is_nan(self) -> bool; - -"#, - r#" -/// Returns whether `self` of length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - - #[lua(kind = "Method")] - fn is_normalized(self) -> bool; - -"#, - r#" - - #[lua(kind = "Method")] - 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(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::DQuat) -> 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(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DQuat, 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(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; - -"#, - 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(kind = "Method", output(proxy))] - fn slerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; - -"#, - 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(kind = "Method", output(proxy))] - fn mul_vec3(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] - fn mul_quat(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. - - #[lua(kind = "Function", output(proxy))] - fn from_affine3(#[proxy] a: &glam::DAffine3) -> bevy::math::DQuat; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_quat(self) -> bevy::math::Quat; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_f32(self) -> bevy::math::Quat; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct DQuat { - x: f64, - y: f64, - z: f64, - w: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::EulerRot", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::EulerRot) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::EulerRot; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct EulerRot {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::BVec3A", - functions[r#" -/// Creates a new vector mask. - - #[lua(kind = "Function", output(proxy))] - fn new(x: bool, y: bool, z: bool) -> bevy::math::BVec3A; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: bool) -> bevy::math::BVec3A; - -"#, - 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(kind = "Method")] - fn bitmask(self) -> u32; - -"#, - r#" -/// Returns true if any of the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn any(self) -> bool; - -"#, - r#" -/// Returns true if all the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn all(self) -> bool; - -"#, - r#" -/// Tests the value at `index`. -/// Panics if `index` is greater than 2. - - #[lua(kind = "Method")] - fn test(&self, index: usize) -> bool; - -"#, - r#" -/// Sets the element at `index`. -/// Panics if `index` is greater than 2. - - #[lua(kind = "MutatingMethod")] - fn set(&mut self, index: usize, value: bool) -> (); - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec3A; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::BVec3A) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct BVec3A(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::BVec4A", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::BVec4A) -> bool; - -"#, - r#" -/// Creates a new vector mask. - - #[lua(kind = "Function", output(proxy))] - fn new(x: bool, y: bool, z: bool, w: bool) -> bevy::math::BVec4A; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: bool) -> bevy::math::BVec4A; - -"#, - 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(kind = "Method")] - fn bitmask(self) -> u32; - -"#, - r#" -/// Returns true if any of the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn any(self) -> bool; - -"#, - r#" -/// Returns true if all the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn all(self) -> bool; - -"#, - r#" -/// Tests the value at `index`. -/// Panics if `index` is greater than 3. - - #[lua(kind = "Method")] - fn test(&self, index: usize) -> bool; - -"#, - r#" -/// Sets the element at `index`. -/// Panics if `index` is greater than 3. - - #[lua(kind = "MutatingMethod")] - fn set(&mut self, index: usize, value: bool) -> (); - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec4A; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct BVec4A(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Direction2d", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction2d) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Direction2d; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::primitives::Direction2d; - -"#, - r#" -/// Create a [`Direction2d`] from a [`Vec2`] that is already normalized. -/// # Warning -/// `value` must be normalized, i.e it's length must be `1.0`. - - #[lua(kind = "Function", output(proxy))] - fn new_unchecked( - #[proxy] - value: bevy::math::Vec2, - ) -> bevy::math::primitives::Direction2d; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Direction2d(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Circle", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Circle) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Circle; - -"#, - r#" -/// Create a new [`Circle`] from a `radius` - - #[lua(kind = "Function", output(proxy))] - fn new(radius: f32) -> bevy::math::primitives::Circle; - -"#, - r#" -/// Get the diameter of the circle - - #[lua(kind = "Method")] - fn diameter(&self) -> f32; - -"#, - r#" -/// Get the area of the circle - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" -/// Get the perimeter or circumference of the circle - - #[lua(kind = "Method")] - fn perimeter(&self) -> f32; - -"#, - r#" -/// Finds the point on the circle that is closest to the given `point`. -/// If the point is outside the circle, the returned point will be on the perimeter of the circle. -/// Otherwise, it will be inside the circle and returned as is. - - #[lua(kind = "Method", output(proxy))] - fn closest_point(&self, #[proxy] point: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Circle { - radius: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Ellipse", - functions[r#" -/// Create a new `Ellipse` from half of its width and height. -/// This corresponds to the two perpendicular radii defining the ellipse. - - #[lua(kind = "Function", output(proxy))] - fn new(half_width: f32, half_height: f32) -> bevy::math::primitives::Ellipse; - -"#, - r#" -/// Create a new `Ellipse` from a given full size. -/// `size.x` is the diameter along the X axis, and `size.y` is the diameter along the Y axis. - - #[lua(kind = "Function", output(proxy))] - fn from_size(#[proxy] size: bevy::math::Vec2) -> bevy::math::primitives::Ellipse; - -"#, - r#" -/// Returns the length of the semi-major axis. This corresponds to the longest radius of the ellipse. - - #[lua(kind = "Method")] - fn semi_major(self) -> f32; - -"#, - r#" -/// Returns the length of the semi-minor axis. This corresponds to the shortest radius of the ellipse. - - #[lua(kind = "Method")] - fn semi_minor(self) -> f32; - -"#, - r#" -/// Get the area of the ellipse - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Ellipse; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Ellipse) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Ellipse { - #[lua(output(proxy))] - half_size: bevy::math::Vec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Plane2d", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Plane2d; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Plane2d) -> bool; - -"#, - r#" -/// Create a new `Plane2d` from a normal -/// # Panics -/// Panics if the given `normal` is zero (or very close to zero), or non-finite. - - #[lua(kind = "Function", output(proxy))] - fn new(#[proxy] normal: bevy::math::Vec2) -> bevy::math::primitives::Plane2d; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Plane2d { - #[lua(output(proxy))] - normal: bevy::math::primitives::Direction2d, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Line2d", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Line2d; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Line2d) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Line2d { - #[lua(output(proxy))] - direction: bevy::math::primitives::Direction2d, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Segment2d", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Segment2d) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Segment2d; - -"#, - r#" -/// Create a new `Segment2d` from a direction and full length of the segment - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - direction: bevy::math::primitives::Direction2d, - length: f32, - ) -> bevy::math::primitives::Segment2d; - -"#, - r#" -/// Get the position of the first point on the line segment - - #[lua(kind = "Method", output(proxy))] - fn point1(&self) -> bevy::math::Vec2; - -"#, - r#" -/// Get the position of the second point on the line segment - - #[lua(kind = "Method", output(proxy))] - fn point2(&self) -> bevy::math::Vec2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Segment2d { - #[lua(output(proxy))] - direction: bevy::math::primitives::Direction2d, - half_length: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Triangle2d", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Triangle2d; - -"#, - r#" -/// Create a new `Triangle2d` from points `a`, `b`, and `c` - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - a: bevy::math::Vec2, - #[proxy] - b: bevy::math::Vec2, - #[proxy] - c: bevy::math::Vec2, - ) -> bevy::math::primitives::Triangle2d; - -"#, - r#" -/// Get the area of the triangle - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" -/// Get the perimeter of the triangle - - #[lua(kind = "Method")] - fn perimeter(&self) -> f32; - -"#, - r#" -/// Reverse the [`WindingOrder`] of the triangle -/// by swapping the second and third vertices - - #[lua(kind = "MutatingMethod")] - fn reverse(&mut self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Triangle2d) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Triangle2d { - vertices: ReflectedValue, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Rectangle", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Rectangle; - -"#, - r#" -/// Create a new `Rectangle` from a full width and height - - #[lua(kind = "Function", output(proxy))] - fn new(width: f32, height: f32) -> bevy::math::primitives::Rectangle; - -"#, - r#" -/// Create a new `Rectangle` from a given full size - - #[lua(kind = "Function", output(proxy))] - fn from_size(#[proxy] size: bevy::math::Vec2) -> bevy::math::primitives::Rectangle; - -"#, - r#" -/// Create a new `Rectangle` from two corner points - - #[lua(kind = "Function", output(proxy))] - fn from_corners( - #[proxy] - point1: bevy::math::Vec2, - #[proxy] - point2: bevy::math::Vec2, - ) -> bevy::math::primitives::Rectangle; - -"#, - r#" -/// Get the size of the rectangle - - #[lua(kind = "Method", output(proxy))] - fn size(&self) -> bevy::math::Vec2; - -"#, - r#" -/// Get the area of the rectangle - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" -/// Get the perimeter of the rectangle - - #[lua(kind = "Method")] - fn perimeter(&self) -> f32; - -"#, - r#" -/// Finds the point on the rectangle that is closest to the given `point`. -/// If the point is outside the rectangle, the returned point will be on the perimeter of the rectangle. -/// Otherwise, it will be inside the rectangle and returned as is. - - #[lua(kind = "Method", output(proxy))] - fn closest_point(&self, #[proxy] point: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Rectangle) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Rectangle { - #[lua(output(proxy))] - half_size: bevy::math::Vec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::RegularPolygon", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::RegularPolygon; - -"#, - r#" -/// Create a new `RegularPolygon` -/// from the radius of the circumcircle and a number of sides -/// # Panics -/// Panics if `circumradius` is non-positive - - #[lua(kind = "Function", output(proxy))] - fn new(circumradius: f32, sides: usize) -> bevy::math::primitives::RegularPolygon; - -"#, - r#" -/// Get the radius of the circumcircle on which all vertices -/// of the regular polygon lie - - #[lua(kind = "Method")] - fn circumradius(&self) -> f32; - -"#, - r#" -/// Get the inradius or apothem of the regular polygon. -/// This is the radius of the largest circle that can -/// be drawn within the polygon - - #[lua(kind = "Method")] - fn inradius(&self) -> f32; - -"#, - r#" -/// Get the length of one side of the regular polygon - - #[lua(kind = "Method")] - fn side_length(&self) -> f32; - -"#, - r#" -/// Get the area of the regular polygon - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" -/// Get the perimeter of the regular polygon. -/// This is the sum of its sides - - #[lua(kind = "Method")] - fn perimeter(&self) -> f32; - -"#, - r#" -/// Get the internal angle of the regular polygon in degrees. -/// This is the angle formed by two adjacent sides with points -/// within the angle being in the interior of the polygon - - #[lua(kind = "Method")] - fn internal_angle_degrees(&self) -> f32; - -"#, - r#" -/// Get the internal angle of the regular polygon in radians. -/// This is the angle formed by two adjacent sides with points -/// within the angle being in the interior of the polygon - - #[lua(kind = "Method")] - fn internal_angle_radians(&self) -> f32; - -"#, - r#" -/// Get the external angle of the regular polygon in degrees. -/// This is the angle formed by two adjacent sides with points -/// within the angle being in the exterior of the polygon - - #[lua(kind = "Method")] - fn external_angle_degrees(&self) -> f32; - -"#, - r#" -/// Get the external angle of the regular polygon in radians. -/// This is the angle formed by two adjacent sides with points -/// within the angle being in the exterior of the polygon - - #[lua(kind = "Method")] - fn external_angle_radians(&self) -> f32; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::RegularPolygon) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct RegularPolygon { - #[lua(output(proxy))] - circumcircle: bevy::math::primitives::Circle, - sides: usize, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Capsule2d", - functions[r#" -/// Create a new `Capsule2d` from a radius and length - - #[lua(kind = "Function", output(proxy))] - fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule2d; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule2d) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Capsule2d; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Capsule2d { - radius: f32, - half_length: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Direction3d", - functions[r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::primitives::Direction3d; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Direction3d; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction3d) -> bool; - -"#, - r#" -/// Create a [`Direction3d`] from a [`Vec3`] that is already normalized. -/// # Warning -/// `value` must be normalized, i.e it's length must be `1.0`. - - #[lua(kind = "Function", output(proxy))] - fn new_unchecked( - #[proxy] - value: bevy::math::Vec3, - ) -> bevy::math::primitives::Direction3d; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Vec3; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Direction3d(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Sphere", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Sphere; - -"#, - r#" -/// Create a new [`Sphere`] from a `radius` - - #[lua(kind = "Function", output(proxy))] - fn new(radius: f32) -> bevy::math::primitives::Sphere; - -"#, - r#" -/// Get the diameter of the sphere - - #[lua(kind = "Method")] - fn diameter(&self) -> f32; - -"#, - r#" -/// Get the surface area of the sphere - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" -/// Get the volume of the sphere - - #[lua(kind = "Method")] - fn volume(&self) -> f32; - -"#, - r#" -/// Finds the point on the sphere that is closest to the given `point`. -/// If the point is outside the sphere, the returned point will be on the surface of the sphere. -/// Otherwise, it will be inside the sphere and returned as is. - - #[lua(kind = "Method", output(proxy))] - fn closest_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Sphere) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Sphere { - radius: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Plane3d", - functions[r#" -/// Create a new `Plane3d` from a normal -/// # Panics -/// Panics if the given `normal` is zero (or very close to zero), or non-finite. - - #[lua(kind = "Function", output(proxy))] - fn new(#[proxy] normal: bevy::math::Vec3) -> bevy::math::primitives::Plane3d; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Plane3d) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Plane3d; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Plane3d { - #[lua(output(proxy))] - normal: bevy::math::primitives::Direction3d, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Line3d", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Line3d; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Line3d) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Line3d { - #[lua(output(proxy))] - direction: bevy::math::primitives::Direction3d, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Segment3d", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Segment3d; - -"#, - r#" -/// Create a new `Segment3d` from a direction and full length of the segment - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - direction: bevy::math::primitives::Direction3d, - length: f32, - ) -> bevy::math::primitives::Segment3d; - -"#, - r#" -/// Get the position of the first point on the line segment - - #[lua(kind = "Method", output(proxy))] - fn point1(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Get the position of the second point on the line segment - - #[lua(kind = "Method", output(proxy))] - fn point2(&self) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Segment3d) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Segment3d { - #[lua(output(proxy))] - direction: bevy::math::primitives::Direction3d, - half_length: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Cuboid", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Cuboid) -> bool; - -"#, - r#" -/// Create a new `Cuboid` from a full x, y, and z length - - #[lua(kind = "Function", output(proxy))] - fn new( - x_length: f32, - y_length: f32, - z_length: f32, - ) -> bevy::math::primitives::Cuboid; - -"#, - r#" -/// Create a new `Cuboid` from a given full size - - #[lua(kind = "Function", output(proxy))] - fn from_size(#[proxy] size: bevy::math::Vec3) -> bevy::math::primitives::Cuboid; - -"#, - r#" -/// Create a new `Cuboid` from two corner points - - #[lua(kind = "Function", output(proxy))] - fn from_corners( - #[proxy] - point1: bevy::math::Vec3, - #[proxy] - point2: bevy::math::Vec3, - ) -> bevy::math::primitives::Cuboid; - -"#, - r#" -/// Get the size of the cuboid - - #[lua(kind = "Method", output(proxy))] - fn size(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Get the surface area of the cuboid - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" -/// Get the volume of the cuboid - - #[lua(kind = "Method")] - fn volume(&self) -> f32; - -"#, - r#" -/// Finds the point on the cuboid that is closest to the given `point`. -/// If the point is outside the cuboid, the returned point will be on the surface of the cuboid. -/// Otherwise, it will be inside the cuboid and returned as is. - - #[lua(kind = "Method", output(proxy))] - fn closest_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Cuboid; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Cuboid { - #[lua(output(proxy))] - half_size: bevy::math::Vec3, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Cylinder", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Cylinder; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Cylinder) -> bool; - -"#, - r#" -/// Create a new `Cylinder` from a radius and full height - - #[lua(kind = "Function", output(proxy))] - fn new(radius: f32, height: f32) -> bevy::math::primitives::Cylinder; - -"#, - r#" -/// Get the base of the cylinder as a [`Circle`] - - #[lua(kind = "Method", output(proxy))] - fn base(&self) -> bevy::math::primitives::Circle; - -"#, - r#" -/// Get the surface area of the side of the cylinder, -/// also known as the lateral area - - #[lua(kind = "Method")] - fn lateral_area(&self) -> f32; - -"#, - r#" -/// Get the surface area of one base of the cylinder - - #[lua(kind = "Method")] - fn base_area(&self) -> f32; - -"#, - r#" -/// Get the total surface area of the cylinder - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" -/// Get the volume of the cylinder - - #[lua(kind = "Method")] - fn volume(&self) -> f32; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Cylinder { - radius: f32, - half_height: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Capsule3d", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule3d) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Capsule3d; - -"#, - r#" -/// Create a new `Capsule3d` from a radius and length - - #[lua(kind = "Function", output(proxy))] - fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule3d; - -"#, - r#" -/// Get the part connecting the hemispherical ends -/// of the capsule as a [`Cylinder`] - - #[lua(kind = "Method", output(proxy))] - fn to_cylinder(&self) -> bevy::math::primitives::Cylinder; - -"#, - r#" -/// Get the surface area of the capsule - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" -/// Get the volume of the capsule - - #[lua(kind = "Method")] - fn volume(&self) -> f32; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Capsule3d { - radius: f32, - half_length: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Cone", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Cone) -> bool; - -"#, - r#" -/// Get the base of the cone as a [`Circle`] - - #[lua(kind = "Method", output(proxy))] - fn base(&self) -> bevy::math::primitives::Circle; - -"#, - r#" -/// Get the slant height of the cone, the length of the line segment -/// connecting a point on the base to the apex - - #[lua(kind = "Method")] - fn slant_height(&self) -> f32; - -"#, - r#" -/// Get the surface area of the side of the cone, -/// also known as the lateral area - - #[lua(kind = "Method")] - fn lateral_area(&self) -> f32; - -"#, - r#" -/// Get the surface area of the base of the cone - - #[lua(kind = "Method")] - fn base_area(&self) -> f32; - -"#, - r#" -/// Get the total surface area of the cone - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" -/// Get the volume of the cone - - #[lua(kind = "Method")] - fn volume(&self) -> f32; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Cone; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Cone { - radius: f32, - height: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::ConicalFrustum", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::ConicalFrustum; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::ConicalFrustum) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct ConicalFrustum { - radius_top: f32, - radius_bottom: f32, - height: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Torus", - functions[r#" -/// Create a new `Torus` from an inner and outer radius. -/// The inner radius is the radius of the hole, and the outer radius -/// is the radius of the entire object - - #[lua(kind = "Function", output(proxy))] - fn new(inner_radius: f32, outer_radius: f32) -> bevy::math::primitives::Torus; - -"#, - r#" -/// Get the inner radius of the torus. -/// For a ring torus, this corresponds to the radius of the hole, -/// or `major_radius - minor_radius` - - #[lua(kind = "Method")] - fn inner_radius(&self) -> f32; - -"#, - r#" -/// Get the outer radius of the torus. -/// This corresponds to the overall radius of the entire object, -/// or `major_radius + minor_radius` - - #[lua(kind = "Method")] - fn outer_radius(&self) -> f32; - -"#, - r#" -/// Get the surface area of the torus. Note that this only produces -/// the expected result when the torus has a ring and isn't self-intersecting - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" -/// Get the volume of the torus. Note that this only produces -/// the expected result when the torus has a ring and isn't self-intersecting - - #[lua(kind = "Method")] - fn volume(&self) -> f32; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Torus; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Torus) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Torus { - minor_radius: f32, - major_radius: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::IRect", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::IRect; - -"#, - 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 -/// ``` -/// # use bevy_math::IRect; -/// let r = IRect::new(0, 4, 10, 6); // w=10 h=2 -/// let r = IRect::new(2, 3, 5, -1); // w=3 h=4 -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn new(x0: i32, y0: i32, x1: i32, y1: i32) -> bevy::math::IRect; - -"#, - 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 -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// // Unit rect from [0,0] to [1,1] -/// let r = IRect::from_corners(IVec2::ZERO, IVec2::ONE); // w=1 h=1 -/// // Same; the points do not need to be ordered -/// let r = IRect::from_corners(IVec2::ONE, IVec2::ZERO); // w=1 h=1 -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_corners( - #[proxy] - p0: bevy::math::IVec2, - #[proxy] - p1: bevy::math::IVec2, - ) -> bevy::math::IRect; - -"#, - r#" -/// Create a new rectangle from its center and size. -/// # Rounding Behaviour -/// If the size contains odd numbers they will be rounded down to the nearest whole number. -/// # Panics -/// This method panics if any of the components of the size is negative. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::from_center_size(IVec2::ZERO, IVec2::new(3, 2)); // w=2 h=2 -/// assert_eq!(r.min, IVec2::splat(-1)); -/// assert_eq!(r.max, IVec2::splat(1)); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_center_size( - #[proxy] - origin: bevy::math::IVec2, - #[proxy] - size: bevy::math::IVec2, - ) -> bevy::math::IRect; - -"#, - 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 -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::from_center_half_size(IVec2::ZERO, IVec2::ONE); // w=2 h=2 -/// assert_eq!(r.min, IVec2::splat(-1)); -/// assert_eq!(r.max, IVec2::splat(1)); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_center_half_size( - #[proxy] - origin: bevy::math::IVec2, - #[proxy] - half_size: bevy::math::IVec2, - ) -> bevy::math::IRect; - -"#, - r#" -/// Check if the rectangle is empty. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::from_corners(IVec2::ZERO, IVec2::new(0, 1)); // w=0 h=1 -/// assert!(r.is_empty()); -/// ``` - - #[lua(kind = "Method")] - fn is_empty(&self) -> bool; - -"#, - r#" -/// Rectangle width (max.x - min.x). -/// # Examples -/// ``` -/// # use bevy_math::IRect; -/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// assert_eq!(r.width(), 5); -/// ``` - - #[lua(kind = "Method")] - fn width(&self) -> i32; - -"#, - r#" -/// Rectangle height (max.y - min.y). -/// # Examples -/// ``` -/// # use bevy_math::IRect; -/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// assert_eq!(r.height(), 1); -/// ``` - - #[lua(kind = "Method")] - fn height(&self) -> i32; - -"#, - r#" -/// Rectangle size. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// assert_eq!(r.size(), IVec2::new(5, 1)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn size(&self) -> bevy::math::IVec2; - -"#, - r#" -/// Rectangle half-size. -/// # Rounding Behaviour -/// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::new(0, 0, 4, 3); // w=4 h=3 -/// assert_eq!(r.half_size(), IVec2::new(2, 1)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn half_size(&self) -> bevy::math::IVec2; - -"#, - r#" -/// The center point of the rectangle. -/// # Rounding Behaviour -/// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::new(0, 0, 5, 2); // w=5 h=2 -/// assert_eq!(r.center(), IVec2::new(2, 1)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn center(&self) -> bevy::math::IVec2; - -"#, - r#" -/// Check if a point lies within this rectangle, inclusive of its edges. -/// # Examples -/// ``` -/// # use bevy_math::IRect; -/// let r = IRect::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(kind = "Method")] - fn contains(&self, #[proxy] point: bevy::math::IVec2) -> 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 -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r1 = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// let r2 = IRect::new(1, -1, 3, 3); // w=2 h=4 -/// let r = r1.union(r2); -/// assert_eq!(r.min, IVec2::new(0, -1)); -/// assert_eq!(r.max, IVec2::new(5, 3)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn union(&self, #[proxy] other: bevy::math::IRect) -> bevy::math::IRect; - -"#, - 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 -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// let u = r.union_point(IVec2::new(3, 6)); -/// assert_eq!(u.min, IVec2::ZERO); -/// assert_eq!(u.max, IVec2::new(5, 6)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn union_point(&self, #[proxy] other: bevy::math::IVec2) -> bevy::math::IRect; - -"#, - 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 ([`IRect::is_empty()`] returns `true`), but -/// the actual values of [`IRect::min`] and [`IRect::max`] are implementation-dependent. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r1 = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// let r2 = IRect::new(1, -1, 3, 3); // w=2 h=4 -/// let r = r1.intersect(r2); -/// assert_eq!(r.min, IVec2::new(1, 0)); -/// assert_eq!(r.max, IVec2::new(3, 1)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn intersect(&self, #[proxy] other: bevy::math::IRect) -> bevy::math::IRect; - -"#, - 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 -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// let r2 = r.inset(3); // w=11 h=7 -/// assert_eq!(r2.min, IVec2::splat(-3)); -/// assert_eq!(r2.max, IVec2::new(8, 4)); -/// let r = IRect::new(0, -1, 4, 3); // w=4 h=4 -/// let r2 = r.inset(-1); // w=2 h=2 -/// assert_eq!(r2.min, IVec2::new(1, 0)); -/// assert_eq!(r2.max, IVec2::new(3, 2)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn inset(&self, inset: i32) -> bevy::math::IRect; - -"#, - r#" -/// Returns self as [`Rect`] (f32) - - #[lua(kind = "Method", output(proxy))] - fn as_rect(&self) -> bevy::math::Rect; - -"#, - r#" -/// Returns self as [`URect`] (u32) - - #[lua(kind = "Method", output(proxy))] - fn as_urect(&self) -> bevy::math::URect; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::IRect) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct IRect { - #[lua(output(proxy))] - min: bevy::math::IVec2, - #[lua(output(proxy))] - max: bevy::math::IVec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - 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 -/// ``` -/// # 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) -> bevy::math::Rect; - -"#, - 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 -/// ``` -/// # 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::Vec2, - #[proxy] - p1: bevy::math::Vec2, - ) -> bevy::math::Rect; - -"#, - 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 -/// ``` -/// # 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::Vec2, - #[proxy] - size: bevy::math::Vec2, - ) -> bevy::math::Rect; - -"#, - 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 -/// ``` -/// # 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::Vec2, - #[proxy] - half_size: bevy::math::Vec2, - ) -> bevy::math::Rect; - -"#, - r#" -/// Check if the rectangle is empty. -/// # Examples -/// ``` -/// # 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(kind = "Method")] - fn is_empty(&self) -> bool; - -"#, - r#" -/// Rectangle width (max.x - min.x). -/// # Examples -/// ``` -/// # use bevy_math::Rect; -/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 -/// assert!((r.width() - 5.).abs() <= 1e-5); -/// ``` - - #[lua(kind = "Method")] - fn width(&self) -> f32; - -"#, - r#" -/// Rectangle height (max.y - min.y). -/// # Examples -/// ``` -/// # use bevy_math::Rect; -/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 -/// assert!((r.height() - 1.).abs() <= 1e-5); -/// ``` - - #[lua(kind = "Method")] - fn height(&self) -> f32; - -"#, - r#" -/// Rectangle size. -/// # Examples -/// ``` -/// # 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(kind = "Method", output(proxy))] - fn size(&self) -> bevy::math::Vec2; - -"#, - r#" -/// Rectangle half-size. -/// # Examples -/// ``` -/// # 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(kind = "Method", output(proxy))] - fn half_size(&self) -> bevy::math::Vec2; - -"#, - r#" -/// The center point of the rectangle. -/// # Examples -/// ``` -/// # 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(kind = "Method", output(proxy))] - fn center(&self) -> bevy::math::Vec2; - -"#, - r#" -/// Check if a point lies within this rectangle, inclusive of its edges. -/// # Examples -/// ``` -/// # 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(kind = "Method")] - fn contains(&self, #[proxy] point: bevy::math::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 -/// ``` -/// # 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(kind = "Method", output(proxy))] - fn union(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; - -"#, - 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 -/// ``` -/// # 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(kind = "Method", output(proxy))] - fn union_point(&self, #[proxy] other: bevy::math::Vec2) -> bevy::math::Rect; - -"#, - 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 -/// ``` -/// # 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(kind = "Method", output(proxy))] - fn intersect(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; - -"#, - 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 -/// ``` -/// # 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(kind = "Method", output(proxy))] - fn inset(&self, inset: f32) -> bevy::math::Rect; - -"#, - r#" -/// Build a new rectangle from this one with its coordinates expressed -/// relative to `other` in a normalized ([0..1] x [0..1]) coordinate system. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// let r = Rect::new(2., 3., 4., 6.); -/// let s = Rect::new(0., 0., 10., 10.); -/// let n = r.normalize(s); -/// assert_eq!(n.min.x, 0.2); -/// assert_eq!(n.min.y, 0.3); -/// assert_eq!(n.max.x, 0.4); -/// assert_eq!(n.max.y, 0.6); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn normalize(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; - -"#, - r#" -/// Returns self as [`IRect`] (i32) - - #[lua(kind = "Method", output(proxy))] - fn as_irect(&self) -> bevy::math::IRect; - -"#, - r#" -/// Returns self as [`URect`] (u32) - - #[lua(kind = "Method", output(proxy))] - fn as_urect(&self) -> bevy::math::URect; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::Rect) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Rect; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Rect { - #[lua(output(proxy))] - min: bevy::math::Vec2, - #[lua(output(proxy))] - max: bevy::math::Vec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::URect", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::URect; - -"#, - 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 -/// ``` -/// # use bevy_math::URect; -/// let r = URect::new(0, 4, 10, 6); // w=10 h=2 -/// let r = URect::new(2, 4, 5, 0); // w=3 h=4 -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn new(x0: u32, y0: u32, x1: u32, y1: u32) -> bevy::math::URect; - -"#, - 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 -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// // Unit rect from [0,0] to [1,1] -/// let r = URect::from_corners(UVec2::ZERO, UVec2::ONE); // w=1 h=1 -/// // Same; the points do not need to be ordered -/// let r = URect::from_corners(UVec2::ONE, UVec2::ZERO); // w=1 h=1 -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_corners( - #[proxy] - p0: bevy::math::UVec2, - #[proxy] - p1: bevy::math::UVec2, - ) -> bevy::math::URect; - -"#, - r#" -/// Create a new rectangle from its center and size. -/// # Rounding Behaviour -/// If the size contains odd numbers they will be rounded down to the nearest whole number. -/// # Panics -/// This method panics if any of the components of the size is negative or if `origin - (size / 2)` results in any negatives. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::from_center_size(UVec2::ONE, UVec2::splat(2)); // w=2 h=2 -/// assert_eq!(r.min, UVec2::splat(0)); -/// assert_eq!(r.max, UVec2::splat(2)); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_center_size( - #[proxy] - origin: bevy::math::UVec2, - #[proxy] - size: bevy::math::UVec2, - ) -> bevy::math::URect; - -"#, - 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 or if `origin - half_size` results in any negatives. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::from_center_half_size(UVec2::ONE, UVec2::ONE); // w=2 h=2 -/// assert_eq!(r.min, UVec2::splat(0)); -/// assert_eq!(r.max, UVec2::splat(2)); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_center_half_size( - #[proxy] - origin: bevy::math::UVec2, - #[proxy] - half_size: bevy::math::UVec2, - ) -> bevy::math::URect; - -"#, - r#" -/// Check if the rectangle is empty. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::from_corners(UVec2::ZERO, UVec2::new(0, 1)); // w=0 h=1 -/// assert!(r.is_empty()); -/// ``` - - #[lua(kind = "Method")] - fn is_empty(&self) -> bool; - -"#, - r#" -/// Rectangle width (max.x - min.x). -/// # Examples -/// ``` -/// # use bevy_math::URect; -/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 -/// assert_eq!(r.width(), 5); -/// ``` - - #[lua(kind = "Method")] - fn width(&self) -> u32; - -"#, - r#" -/// Rectangle height (max.y - min.y). -/// # Examples -/// ``` -/// # use bevy_math::URect; -/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 -/// assert_eq!(r.height(), 1); -/// ``` - - #[lua(kind = "Method")] - fn height(&self) -> u32; - -"#, - r#" -/// Rectangle size. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 -/// assert_eq!(r.size(), UVec2::new(5, 1)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn size(&self) -> bevy::math::UVec2; - -"#, - r#" -/// Rectangle half-size. -/// # Rounding Behaviour -/// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::new(0, 0, 4, 2); // w=4 h=2 -/// assert_eq!(r.half_size(), UVec2::new(2, 1)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn half_size(&self) -> bevy::math::UVec2; - -"#, - r#" -/// The center point of the rectangle. -/// # Rounding Behaviour -/// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::new(0, 0, 4, 2); // w=4 h=2 -/// assert_eq!(r.center(), UVec2::new(2, 1)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn center(&self) -> bevy::math::UVec2; - -"#, - r#" -/// Check if a point lies within this rectangle, inclusive of its edges. -/// # Examples -/// ``` -/// # use bevy_math::URect; -/// let r = URect::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(kind = "Method")] - fn contains(&self, #[proxy] point: bevy::math::UVec2) -> 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 -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r1 = URect::new(0, 0, 5, 1); // w=5 h=1 -/// let r2 = URect::new(1, 0, 3, 8); // w=2 h=4 -/// let r = r1.union(r2); -/// assert_eq!(r.min, UVec2::new(0, 0)); -/// assert_eq!(r.max, UVec2::new(5, 8)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn union(&self, #[proxy] other: bevy::math::URect) -> bevy::math::URect; - -"#, - 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 -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 -/// let u = r.union_point(UVec2::new(3, 6)); -/// assert_eq!(u.min, UVec2::ZERO); -/// assert_eq!(u.max, UVec2::new(5, 6)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn union_point(&self, #[proxy] other: bevy::math::UVec2) -> bevy::math::URect; - -"#, - 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 ([`URect::is_empty()`] returns `true`), but -/// the actual values of [`URect::min`] and [`URect::max`] are implementation-dependent. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r1 = URect::new(0, 0, 2, 2); // w=2 h=2 -/// let r2 = URect::new(1, 1, 3, 3); // w=2 h=2 -/// let r = r1.intersect(r2); -/// assert_eq!(r.min, UVec2::new(1, 1)); -/// assert_eq!(r.max, UVec2::new(2, 2)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn intersect(&self, #[proxy] other: bevy::math::URect) -> bevy::math::URect; - -"#, - 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 -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::new(4, 4, 6, 6); // w=2 h=2 -/// let r2 = r.inset(1); // w=4 h=4 -/// assert_eq!(r2.min, UVec2::splat(3)); -/// assert_eq!(r2.max, UVec2::splat(7)); -/// let r = URect::new(4, 4, 8, 8); // w=4 h=4 -/// let r2 = r.inset(-1); // w=2 h=2 -/// assert_eq!(r2.min, UVec2::splat(5)); -/// assert_eq!(r2.max, UVec2::splat(7)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn inset(&self, inset: i32) -> bevy::math::URect; - -"#, - r#" -/// Returns self as [`Rect`] (f32) - - #[lua(kind = "Method", output(proxy))] - fn as_rect(&self) -> bevy::math::Rect; - -"#, - r#" -/// Returns self as [`IRect`] (i32) - - #[lua(kind = "Method", output(proxy))] - fn as_irect(&self) -> bevy::math::IRect; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::URect) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct URect { - #[lua(output(proxy))] - min: bevy::math::UVec2, - #[lua(output(proxy))] - max: bevy::math::UVec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "smol_str::SmolStr", - functions[r#" - - #[lua(kind = "Method")] - fn to_string(&self) -> std::string::String; - -"#, - r#" - - #[lua(kind = "Method")] - fn len(&self) -> usize; - -"#, - r#" - - #[lua(kind = "Method")] - fn is_empty(&self) -> bool; - -"#, - r#" - - #[lua(kind = "Method")] - fn is_heap_allocated(&self) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &smol_str::SmolStr) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> smol_str::SmolStr; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct SmolStr(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroIsize", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroIsize) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: isize) -> std::num::NonZeroIsize; - -"#, - r#" -/// Returns the value as a primitive type. - - #[lua(kind = "Method")] - fn get(self) -> isize; - -"#, - r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroIsize::new(-1isize).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; - -"#, - r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroIsize::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Computes the absolute value of self. -///See [`isize::abs`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroIsize::new(1)?; -///let neg = NonZeroIsize::new(-1)?; -/// assert_eq!(pos, pos.abs()); -/// assert_eq!(pos, neg.abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> std::num::NonZeroIsize; - -"#, - r#" -/// Saturating absolute value, see -///[`isize::saturating_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroIsize::new(1)?; -///let neg = NonZeroIsize::new(-1)?; -///let min = NonZeroIsize::new(isize::MIN)?; -///let min_plus = NonZeroIsize::new(isize::MIN + 1)?; -///let max = NonZeroIsize::new(isize::MAX)?; -/// assert_eq!(pos, pos.saturating_abs()); -/// assert_eq!(pos, neg.saturating_abs()); -/// assert_eq!(max, min.saturating_abs()); -/// assert_eq!(max, min_plus.saturating_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_abs(self) -> std::num::NonZeroIsize; - -"#, - r#" -/// Wrapping absolute value, see -///[`isize::wrapping_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroIsize::new(1)?; -///let neg = NonZeroIsize::new(-1)?; -///let min = NonZeroIsize::new(isize::MIN)?; -///# let max = NonZeroIsize::new(isize::MAX)?; -/// assert_eq!(pos, pos.wrapping_abs()); -/// assert_eq!(pos, neg.wrapping_abs()); -/// assert_eq!(min, min.wrapping_abs()); -/// assert_eq!(max, (-max).wrapping_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_abs(self) -> std::num::NonZeroIsize; - -"#, - r#" -/// Computes the absolute value of self -/// without any wrapping or panicking. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -///# use std::num::NonZeroUsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let u_pos = NonZeroUsize::new(1)?; -///let i_pos = NonZeroIsize::new(1)?; -///let i_neg = NonZeroIsize::new(-1)?; -///let i_min = NonZeroIsize::new(isize::MIN)?; -///let u_max = NonZeroUsize::new(usize::MAX / 2 + 1)?; -/// assert_eq!(u_pos, i_pos.unsigned_abs()); -/// assert_eq!(u_pos, i_neg.unsigned_abs()); -/// assert_eq!(u_max, i_min.unsigned_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn unsigned_abs(self) -> std::num::NonZeroUsize; - -"#, - r#" -/// Returns `true` if `self` is positive and `false` if the -/// number is negative. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroIsize::new(5)?; -///let neg_five = NonZeroIsize::new(-5)?; -/// assert!(pos_five.is_positive()); -/// assert!(!neg_five.is_positive()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_positive(self) -> bool; - -"#, - r#" -/// Returns `true` if `self` is negative and `false` if the -/// number is positive. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroIsize::new(5)?; -///let neg_five = NonZeroIsize::new(-5)?; -/// assert!(neg_five.is_negative()); -/// assert!(!pos_five.is_negative()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_negative(self) -> bool; - -"#, - r#" -/// Saturating negation. Computes `-self`, -///returning [`NonZeroIsize::MAX`] -///if `self == NonZeroIsize::MIN` -/// instead of overflowing. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroIsize::new(5)?; -///let neg_five = NonZeroIsize::new(-5)?; -///let min = NonZeroIsize::new(isize::MIN)?; -///let min_plus_one = NonZeroIsize::new(isize::MIN + 1)?; -///let max = NonZeroIsize::new(isize::MAX)?; -/// assert_eq!(pos_five.saturating_neg(), neg_five); -/// assert_eq!(min.saturating_neg(), max); -/// assert_eq!(max.saturating_neg(), min_plus_one); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_neg(self) -> std::num::NonZeroIsize; - -"#, - r#" -/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary -/// of the type. -///See [`isize::wrapping_neg`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroIsize::new(5)?; -///let neg_five = NonZeroIsize::new(-5)?; -///let min = NonZeroIsize::new(isize::MIN)?; -/// assert_eq!(pos_five.wrapping_neg(), neg_five); -/// assert_eq!(min.wrapping_neg(), min); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_neg(self) -> std::num::NonZeroIsize; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroIsize::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroIsize::new(2)?; -///let four = NonZeroIsize::new(4)?; -///let max = NonZeroIsize::new(isize::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroIsize, - ) -> std::num::NonZeroIsize; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroIsize::MIN`] or [`NonZeroIsize::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroIsize::new(3)?; -///let twenty_seven = NonZeroIsize::new(27)?; -///let max = NonZeroIsize::new(isize::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroIsize; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroIsize; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> std::num::NonZeroIsize; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct NonZeroIsize(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::utils::Uuid", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::utils::Uuid; - -"#, - r#" -/// Returns the version number of the UUID. -/// This represents the algorithm used to generate the value. -/// This method is the future-proof alternative to [`Uuid::get_version`]. -/// # Examples -/// Basic usage: -/// ``` -/// # use uuid::Uuid; -/// # fn main() -> Result<(), uuid::Error> { -/// let my_uuid = Uuid::parse_str("02f09a3f-1624-3b1d-8409-44eff7708208")?; -/// assert_eq!(3, my_uuid.get_version_num()); -/// # Ok(()) -/// # } -/// ``` -/// # References -/// * [Version in RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.3) - - #[lua(kind = "Method")] - fn get_version_num(&self) -> usize; - -"#, - r#" -/// Returns a 128bit value containing the value. -/// The bytes in the UUID will be packed directly into a `u128`. -/// # Examples -/// ``` -/// # use uuid::Uuid; -/// # fn main() -> Result<(), uuid::Error> { -/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; -/// assert_eq!( -/// uuid.as_u128(), -/// 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8, -/// ); -/// # Ok(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn as_u128(&self) -> u128; - -"#, - r#" -/// Returns a 128bit little-endian value containing the value. -/// The bytes in the `u128` will be flipped to convert into big-endian -/// order. This is based on the endianness of the UUID, rather than the -/// target environment so bytes will be flipped on both big and little -/// endian machines. -/// Note that this will produce a different result than -/// [`Uuid::to_fields_le`], because the entire UUID is reversed, rather -/// than reversing the individual fields in-place. -/// # Examples -/// ``` -/// # use uuid::Uuid; -/// # fn main() -> Result<(), uuid::Error> { -/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; -/// assert_eq!( -/// uuid.to_u128_le(), -/// 0xd8d7d6d5d4d3d2d1c2c1b2b1a4a3a2a1, -/// ); -/// # Ok(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn to_u128_le(&self) -> u128; - -"#, - r#" -/// Returns two 64bit values containing the value. -/// The bytes in the UUID will be split into two `u64`. -/// The first u64 represents the 64 most significant bits, -/// the second one represents the 64 least significant. -/// # Examples -/// ``` -/// # use uuid::Uuid; -/// # fn main() -> Result<(), uuid::Error> { -/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; -/// assert_eq!( -/// uuid.as_u64_pair(), -/// (0xa1a2a3a4b1b2c1c2, 0xd1d2d3d4d5d6d7d8), -/// ); -/// # Ok(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn as_u64_pair(&self) -> (u64, u64); - -"#, - r#" -/// Consumes self and returns the underlying byte value of the UUID. -/// # Examples -/// ``` -/// # use uuid::Uuid; -/// let bytes = [ -/// 0xa1, 0xa2, 0xa3, 0xa4, -/// 0xb1, 0xb2, -/// 0xc1, 0xc2, -/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, -/// ]; -/// let uuid = Uuid::from_bytes(bytes); -/// assert_eq!(bytes, uuid.into_bytes()); -/// ``` - - #[lua(kind = "Method")] - fn into_bytes(self) -> [u8; 16]; - -"#, - r#" -/// Returns the bytes of the UUID in little-endian order. -/// The bytes will be flipped to convert into little-endian order. This is -/// based on the endianness of the UUID, rather than the target environment -/// so bytes will be flipped on both big and little endian machines. -/// # Examples -/// ``` -/// use uuid::Uuid; -/// # fn main() -> Result<(), uuid::Error> { -/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; -/// assert_eq!( -/// uuid.to_bytes_le(), -/// ([ -/// 0xa4, 0xa3, 0xa2, 0xa1, 0xb2, 0xb1, 0xc2, 0xc1, 0xd1, 0xd2, -/// 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 -/// ]) -/// ); -/// # Ok(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn to_bytes_le(&self) -> [u8; 16]; - -"#, - r#" -/// Tests if the UUID is nil (all zeros). - - #[lua(kind = "Method")] - fn is_nil(&self) -> bool; - -"#, - r#" -/// Tests if the UUID is max (all ones). - - #[lua(kind = "Method")] - fn is_max(&self) -> bool; - -"#, - r#" -/// A buffer that can be used for `encode_...` calls, that is -/// guaranteed to be long enough for any of the format adapters. -/// # Examples -/// ``` -/// # use uuid::Uuid; -/// let uuid = Uuid::nil(); -/// assert_eq!( -/// uuid.simple().encode_lower(&mut Uuid::encode_buffer()), -/// "00000000000000000000000000000000" -/// ); -/// assert_eq!( -/// uuid.hyphenated() -/// .encode_lower(&mut Uuid::encode_buffer()), -/// "00000000-0000-0000-0000-000000000000" -/// ); -/// assert_eq!( -/// uuid.urn().encode_lower(&mut Uuid::encode_buffer()), -/// "urn:uuid:00000000-0000-0000-0000-000000000000" -/// ); -/// ``` - - #[lua(kind = "Function")] - fn encode_buffer() -> [u8; 45]; - -"#, - r#" -/// The 'nil UUID' (all zeros). -/// The nil UUID is a special form of UUID that is specified to have all -/// 128 bits set to zero. -/// # References -/// * [Nil UUID in RFC4122](https://tools.ietf.org/html/rfc4122.html#section-4.1.7) -/// # Examples -/// Basic usage: -/// ``` -/// # use uuid::Uuid; -/// let uuid = Uuid::nil(); -/// assert_eq!( -/// "00000000-0000-0000-0000-000000000000", -/// uuid.hyphenated().to_string(), -/// ); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn nil() -> bevy::utils::Uuid; - -"#, - r#" -/// The 'max UUID' (all ones). -/// The max UUID is a special form of UUID that is specified to have all -/// 128 bits set to one. -/// # References -/// * [Max UUID in Draft RFC: New UUID Formats, Version 4](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04#section-5.4) -/// # Examples -/// Basic usage: -/// ``` -/// # use uuid::Uuid; -/// let uuid = Uuid::max(); -/// assert_eq!( -/// "ffffffff-ffff-ffff-ffff-ffffffffffff", -/// uuid.hyphenated().to_string(), -/// ); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn max() -> bevy::utils::Uuid; - -"#, - r#" -/// Creates a UUID from a 128bit value. -/// # Examples -/// Basic usage: -/// ``` -/// # use uuid::Uuid; -/// let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128; -/// let uuid = Uuid::from_u128(v); -/// assert_eq!( -/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", -/// uuid.hyphenated().to_string(), -/// ); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_u128(v: u128) -> bevy::utils::Uuid; - -"#, - r#" -/// Creates a UUID from a 128bit value in little-endian order. -/// The entire value will be flipped to convert into big-endian order. -/// This is based on the endianness of the UUID, rather than the target -/// environment so bytes will be flipped on both big and little endian -/// machines. -/// # Examples -/// Basic usage: -/// ``` -/// # use uuid::Uuid; -/// let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128; -/// let uuid = Uuid::from_u128_le(v); -/// assert_eq!( -/// "d8d7d6d5-d4d3-d2d1-c2c1-b2b1a4a3a2a1", -/// uuid.hyphenated().to_string(), -/// ); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_u128_le(v: u128) -> bevy::utils::Uuid; - -"#, - r#" -/// Creates a UUID from two 64bit values. -/// # Examples -/// Basic usage: -/// ``` -/// # use uuid::Uuid; -/// let hi = 0xa1a2a3a4b1b2c1c2u64; -/// let lo = 0xd1d2d3d4d5d6d7d8u64; -/// let uuid = Uuid::from_u64_pair(hi, lo); -/// assert_eq!( -/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", -/// uuid.hyphenated().to_string(), -/// ); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_u64_pair(high_bits: u64, low_bits: u64) -> bevy::utils::Uuid; - -"#, - r#" -/// Creates a UUID using the supplied bytes. -/// # Examples -/// Basic usage: -/// ``` -/// # fn main() -> Result<(), uuid::Error> { -/// # use uuid::Uuid; -/// let bytes = [ -/// 0xa1, 0xa2, 0xa3, 0xa4, -/// 0xb1, 0xb2, -/// 0xc1, 0xc2, -/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, -/// ]; -/// let uuid = Uuid::from_bytes(bytes); -/// assert_eq!( -/// uuid.hyphenated().to_string(), -/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8" -/// ); -/// # Ok(()) -/// # } -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_bytes(bytes: [u8; 16]) -> bevy::utils::Uuid; - -"#, - r#" -/// Creates a UUID using the supplied bytes in little endian order. -/// The individual fields encoded in the buffer will be flipped. -/// # Examples -/// Basic usage: -/// ``` -/// # fn main() -> Result<(), uuid::Error> { -/// # use uuid::Uuid; -/// let bytes = [ -/// 0xa1, 0xa2, 0xa3, 0xa4, -/// 0xb1, 0xb2, -/// 0xc1, 0xc2, -/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, -/// ]; -/// let uuid = Uuid::from_bytes_le(bytes); -/// assert_eq!( -/// "a4a3a2a1-b2b1-c2c1-d1d2-d3d4d5d6d7d8", -/// uuid.hyphenated().to_string(), -/// ); -/// # Ok(()) -/// # } -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_bytes_le(b: [u8; 16]) -> bevy::utils::Uuid; - -"#, - r#" -/// Creates a random UUID. -/// This uses the [`getrandom`] crate to utilise the operating system's RNG -/// as the source of random numbers. If you'd like to use a custom -/// generator, don't use this method: generate random bytes using your -/// custom generator and pass them to the -/// [`uuid::Builder::from_random_bytes`][from_random_bytes] function -/// instead. -/// Note that usage of this method requires the `v4` feature of this crate -/// to be enabled. -/// # Examples -/// Basic usage: -/// ``` -/// # use uuid::{Uuid, Version}; -/// let uuid = Uuid::new_v4(); -/// assert_eq!(Some(Version::Random), uuid.get_version()); -/// ``` -/// # References -/// * [Version 4 UUIDs in RFC4122](https://www.rfc-editor.org/rfc/rfc4122#section-4.4) -/// [`getrandom`]: https://crates.io/crates/getrandom -/// [from_random_bytes]: struct.Builder.html#method.from_random_bytes - - #[lua(kind = "Function", output(proxy))] - fn new_v4() -> bevy::utils::Uuid; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_utils::Uuid) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -pub struct Uuid(); -#[derive(Default)] -pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { - instances - .add_instance( - "Duration", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Instant", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroI128", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroI16", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroI32", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroI64", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroI8", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroU128", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroU16", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroU32", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroU64", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroU8", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroUsize", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "PathBuf", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Quat", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Vec3", - 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( - "I64Vec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "I64Vec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "I64Vec4", - 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( - "U64Vec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "U64Vec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "U64Vec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Vec2", - 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( - "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( - "Mat2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Mat3", - 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( - "DQuat", - 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( - "Direction2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Circle", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Ellipse", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Plane2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Segment2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Triangle2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Rectangle", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "RegularPolygon", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaRegularPolygon, - >::new, - )?; - instances - .add_instance( - "Capsule2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Direction3d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Sphere", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Plane3d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Segment3d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Cuboid", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Cylinder", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Capsule3d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Torus", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "IRect", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Rect", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "URect", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroIsize", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Uuid", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - Ok(()) - } -} -pub struct BevyReflectAPIProvider; -impl bevy_mod_scripting_core::hosts::APIProvider for BevyReflectAPIProvider { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - fn attach_api( - &mut self, - ctx: &mut Self::APITarget, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context"); - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx) - .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other( - e.to_string(), - )) - } - fn get_doc_fragment(&self) -> Option { - Some( - bevy_mod_scripting_lua::docs::LuaDocFragment::new( - "BevyReflectAPI", - |tw| { - tw.document_global_instance::() - .expect("Something went wrong documenting globals") - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaDuration, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI128, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI16, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI32, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI64, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI8, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU128, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU16, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU32, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU64, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU8, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroUsize, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaAffine3A, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaDAffine2, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaDAffine3, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaDirection2d, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaSegment2d, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaTriangle2d, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaRectangle, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaRegularPolygon, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaCapsule2d, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaDirection3d, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaSegment3d, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaCylinder, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaCapsule3d, - >, - >() - .process_type::() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroIsize, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - }, - ), - ) - } - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn register_with_app(&self, app: &mut bevy::app::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::(); - 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::(); - 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::(); - 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::(); - 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::(); - 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::(); - } -} diff --git a/crates/bevy_script_api/src/providers/bevy_time.rs b/crates/bevy_script_api/src/providers/bevy_time.rs deleted file mode 100644 index 38c46a8d..00000000 --- a/crates/bevy_script_api/src/providers/bevy_time.rs +++ /dev/null @@ -1,720 +0,0 @@ -// @generated by cargo bevy-api-gen generate, modify the templates not this file -#![allow(clippy::all)] -#![allow(unused, deprecated, dead_code)] -#![cfg_attr(rustfmt, rustfmt_skip)] -use super::bevy_ecs::*; -use super::bevy_reflect::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::time::prelude::Fixed", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::time::prelude::Fixed; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Fixed {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::time::prelude::Real", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::time::prelude::Real; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Real {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::time::prelude::Timer", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &timer::Timer) -> bool; - -"#, - r#" -/// Creates a new timer with a given duration. -/// See also [`Timer::from_seconds`](Timer::from_seconds). - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - duration: bevy::utils::Duration, - #[proxy] - mode: bevy::time::prelude::TimerMode, - ) -> bevy::time::prelude::Timer; - -"#, - r#" -/// Creates a new timer with a given duration in seconds. -/// # Example -/// ``` -/// # use bevy_time::*; -/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn from_seconds( - duration: f32, - #[proxy] - mode: bevy::time::prelude::TimerMode, - ) -> bevy::time::prelude::Timer; - -"#, - r#" -/// Returns `true` if the timer has reached its duration. -/// For repeating timers, this method behaves identically to [`Timer::just_finished`]. -/// # Examples -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let mut timer_once = Timer::from_seconds(1.0, TimerMode::Once); -/// timer_once.tick(Duration::from_secs_f32(1.5)); -/// assert!(timer_once.finished()); -/// timer_once.tick(Duration::from_secs_f32(0.5)); -/// assert!(timer_once.finished()); -/// let mut timer_repeating = Timer::from_seconds(1.0, TimerMode::Repeating); -/// timer_repeating.tick(Duration::from_secs_f32(1.1)); -/// assert!(timer_repeating.finished()); -/// timer_repeating.tick(Duration::from_secs_f32(0.8)); -/// assert!(!timer_repeating.finished()); -/// timer_repeating.tick(Duration::from_secs_f32(0.6)); -/// assert!(timer_repeating.finished()); -/// ``` - - #[lua(kind = "Method")] - fn finished(&self) -> bool; - -"#, - r#" -/// 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()); -/// ``` - - #[lua(kind = "Method")] - fn just_finished(&self) -> bool; - -"#, - r#" -/// Returns the time elapsed on the timer. Guaranteed to be between 0.0 and `duration`. -/// Will only equal `duration` when the timer is finished and non repeating. -/// See also [`Stopwatch::elapsed`](Stopwatch::elapsed). -/// # Examples -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); -/// timer.tick(Duration::from_secs_f32(0.5)); -/// assert_eq!(timer.elapsed(), Duration::from_secs_f32(0.5)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn elapsed(&self) -> bevy::utils::Duration; - -"#, - r#" -/// Returns the time elapsed on the timer as an `f32`. -/// See also [`Timer::elapsed`](Timer::elapsed). - - #[lua(kind = "Method")] - fn elapsed_secs(&self) -> f32; - -"#, - r#" -/// Sets the elapsed time of the timer without any other considerations. -/// See also [`Stopwatch::set`](Stopwatch::set). -/// # -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); -/// timer.set_elapsed(Duration::from_secs(2)); -/// assert_eq!(timer.elapsed(), Duration::from_secs(2)); -/// // the timer is not finished even if the elapsed time is greater than the duration. -/// assert!(!timer.finished()); -/// ``` - - #[lua(kind = "MutatingMethod")] - fn set_elapsed(&mut self, #[proxy] time: bevy::utils::Duration) -> (); - -"#, - r#" -/// Returns the duration of the timer. -/// # Examples -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let timer = Timer::new(Duration::from_secs(1), TimerMode::Once); -/// assert_eq!(timer.duration(), Duration::from_secs(1)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn duration(&self) -> bevy::utils::Duration; - -"#, - r#" -/// Sets the duration of the timer. -/// # Examples -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let mut timer = Timer::from_seconds(1.5, TimerMode::Once); -/// timer.set_duration(Duration::from_secs(1)); -/// assert_eq!(timer.duration(), Duration::from_secs(1)); -/// ``` - - #[lua(kind = "MutatingMethod")] - fn set_duration(&mut self, #[proxy] duration: bevy::utils::Duration) -> (); - -"#, - r#" -/// Returns the mode of the timer. -/// # Examples -/// ``` -/// # use bevy_time::*; -/// let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating); -/// assert_eq!(timer.mode(), TimerMode::Repeating); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn mode(&self) -> bevy::time::prelude::TimerMode; - -"#, - r#" -/// Sets the mode of the timer. -/// # Examples -/// ``` -/// # use bevy_time::*; -/// let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating); -/// timer.set_mode(TimerMode::Once); -/// assert_eq!(timer.mode(), TimerMode::Once); -/// ``` - - #[lua(kind = "MutatingMethod")] - fn set_mode(&mut self, #[proxy] mode: bevy::time::prelude::TimerMode) -> (); - -"#, - r#" -/// 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); -/// ``` - - #[lua(kind = "MutatingMethod")] - fn pause(&mut self) -> (); - -"#, - r#" -/// 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); -/// ``` - - #[lua(kind = "MutatingMethod")] - fn unpause(&mut self) -> (); - -"#, - r#" -/// 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()); -/// ``` - - #[lua(kind = "Method")] - fn paused(&self) -> bool; - -"#, - r#" -/// 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); -/// ``` - - #[lua(kind = "MutatingMethod")] - fn reset(&mut self) -> (); - -"#, - r#" -/// Returns the fraction 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.fraction(), 0.25); -/// ``` - - #[lua(kind = "Method")] - fn fraction(&self) -> f32; - -"#, - r#" -/// Returns the fraction 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.fraction_remaining(), 0.75); -/// ``` - - #[lua(kind = "Method")] - fn fraction_remaining(&self) -> f32; - -"#, - r#" -/// 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); -/// ``` - - #[lua(kind = "Method")] - fn remaining_secs(&self) -> f32; - -"#, - r#" -/// Returns the remaining time using Duration -/// # 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.remaining(), Duration::from_secs_f32(1.5)); -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn remaining(&self) -> bevy::utils::Duration; - -"#, - r#" -/// 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); -/// ``` - - #[lua(kind = "Method")] - fn times_finished_this_tick(&self) -> u32; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::time::prelude::Timer; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Timer {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::time::prelude::TimerMode", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &timer::TimerMode) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::time::prelude::TimerMode; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct TimerMode {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::time::prelude::Virtual", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::time::prelude::Virtual; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Virtual {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::time::Stopwatch", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::time::Stopwatch; - -"#, - 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() -> bevy::time::Stopwatch; - -"#, - r#" -/// Returns the elapsed time since the last [`reset`](Stopwatch::reset) -/// of the stopwatch. -/// # Examples -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let mut stopwatch = Stopwatch::new(); -/// stopwatch.tick(Duration::from_secs(1)); -/// assert_eq!(stopwatch.elapsed(), Duration::from_secs(1)); -/// ``` -/// # See Also -/// [`elapsed_secs`](Stopwatch::elapsed_secs) - if an `f32` value is desirable instead. -/// [`elapsed_secs_f64`](Stopwatch::elapsed_secs_f64) - if an `f64` is desirable instead. - - #[lua(kind = "Method", output(proxy))] - fn elapsed(&self) -> bevy::utils::Duration; - -"#, - 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(); -/// 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(kind = "Method")] - 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(kind = "Method")] - fn elapsed_secs_f64(&self) -> f64; - -"#, - r#" -/// Sets the elapsed time of the stopwatch. -/// # Examples -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let mut stopwatch = Stopwatch::new(); -/// stopwatch.set_elapsed(Duration::from_secs_f32(1.0)); -/// assert_eq!(stopwatch.elapsed_secs(), 1.0); -/// ``` - - #[lua(kind = "MutatingMethod")] - fn set_elapsed(&mut self, #[proxy] time: bevy::utils::Duration) -> (); - -"#, - 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(kind = "MutatingMethod")] - 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)); -/// stopwatch.unpause(); -/// stopwatch.tick(Duration::from_secs_f32(1.0)); -/// assert!(!stopwatch.paused()); -/// assert_eq!(stopwatch.elapsed_secs(), 1.0); -/// ``` - - #[lua(kind = "MutatingMethod")] - fn unpause(&mut self) -> (); - -"#, - r#" -/// 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()); -/// ``` - - #[lua(kind = "Method")] - 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); -/// ``` - - #[lua(kind = "MutatingMethod")] - fn reset(&mut self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &stopwatch::Stopwatch) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Stopwatch {} -#[derive(Default)] -pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { - instances - .add_instance( - "Timer", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Stopwatch", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - Ok(()) - } -} -pub struct BevyTimeAPIProvider; -impl bevy_mod_scripting_core::hosts::APIProvider for BevyTimeAPIProvider { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - fn attach_api( - &mut self, - ctx: &mut Self::APITarget, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context"); - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx) - .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other( - e.to_string(), - )) - } - fn get_doc_fragment(&self) -> Option { - Some( - bevy_mod_scripting_lua::docs::LuaDocFragment::new( - "BevyTimeAPI", - |tw| { - tw.document_global_instance::() - .expect("Something went wrong documenting globals") - .process_type::() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaStopwatch, - >, - >() - }, - ), - ) - } - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn register_with_app(&self, app: &mut bevy::app::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::(); - } -} diff --git a/crates/bevy_script_api/src/providers/bevy_transform.rs b/crates/bevy_script_api/src/providers/bevy_transform.rs deleted file mode 100644 index 2ab43435..00000000 --- a/crates/bevy_script_api/src/providers/bevy_transform.rs +++ /dev/null @@ -1,731 +0,0 @@ -// @generated by cargo bevy-api-gen generate, modify the templates not this file -#![allow(clippy::all)] -#![allow(unused, deprecated, dead_code)] -#![cfg_attr(rustfmt, rustfmt_skip)] -use super::bevy_ecs::*; -use super::bevy_reflect::*; -use super::bevy_core::*; -use super::bevy_hierarchy::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::transform::components::GlobalTransform", - functions[r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul( - self, - #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &components::global_transform::GlobalTransform) -> bool; - -"#, - r#" - - #[lua(kind = "Function", output(proxy))] - fn from_xyz(x: f32, y: f32, z: f32) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua(kind = "Function", output(proxy))] - fn from_translation( - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua(kind = "Function", output(proxy))] - fn from_rotation( - #[proxy] - rotation: bevy::math::Quat, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua(kind = "Function", output(proxy))] - fn from_scale( - #[proxy] - scale: bevy::math::Vec3, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" -/// Returns the 3d affine transformation matrix as a [`Mat4`]. - - #[lua(kind = "Method", output(proxy))] - fn compute_matrix(&self) -> bevy::math::Mat4; - -"#, - r#" -/// Returns the 3d affine transformation matrix as an [`Affine3A`]. - - #[lua(kind = "Method", output(proxy))] - fn affine(&self) -> bevy::math::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(kind = "Method", 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: -/// ``` -/// # 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. - - #[lua(kind = "Method", output(proxy))] - fn reparented_to( - &self, - #[proxy] - parent: &components::global_transform::GlobalTransform, - ) -> bevy::transform::components::Transform; - -"#, - r#" -///Return the local right vector (X). - - #[lua(kind = "Method", output(proxy))] - fn right(&self) -> bevy::math::Vec3; - -"#, - r#" -///Return the local left vector (-X). - - #[lua(kind = "Method", output(proxy))] - fn left(&self) -> bevy::math::Vec3; - -"#, - r#" -///Return the local up vector (Y). - - #[lua(kind = "Method", output(proxy))] - fn up(&self) -> bevy::math::Vec3; - -"#, - r#" -///Return the local down vector (-Y). - - #[lua(kind = "Method", output(proxy))] - fn down(&self) -> bevy::math::Vec3; - -"#, - r#" -///Return the local back vector (Z). - - #[lua(kind = "Method", output(proxy))] - fn back(&self) -> bevy::math::Vec3; - -"#, - r#" -///Return the local forward vector (-Z). - - #[lua(kind = "Method", output(proxy))] - fn forward(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Get the translation as a [`Vec3`]. - - #[lua(kind = "Method", output(proxy))] - fn translation(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Get the translation as a [`Vec3A`]. - - #[lua(kind = "Method", output(proxy))] - fn translation_vec3a(&self) -> bevy::math::Vec3A; - -"#, - r#" -/// Get an upper bound of the radius from the given `extents`. - - #[lua(kind = "Method")] - fn radius_vec3a(&self, #[proxy] extents: bevy::math::Vec3A) -> f32; - -"#, - r#" -/// Transforms the given `point`, applying shear, scale, rotation and translation. -/// This moves `point` into the local space of this [`GlobalTransform`]. - - #[lua(kind = "Method", output(proxy))] - fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" -/// Multiplies `self` with `transform` component by component, returning the -/// resulting [`GlobalTransform`] - - #[lua(kind = "Method", output(proxy))] - fn mul_transform( - &self, - #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul( - self, - #[proxy] - global_transform: bevy::transform::components::GlobalTransform, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct GlobalTransform(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::transform::components::Transform", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &components::transform::Transform) -> bool; - -"#, - 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) -> bevy::transform::components::Transform; - -"#, - 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::Mat4, - ) -> bevy::transform::components::Transform; - -"#, - 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::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - 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::Quat, - ) -> bevy::transform::components::Transform; - -"#, - 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::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// 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 - - #[lua(kind = "Method", output(proxy))] - fn looking_at( - self, - #[proxy] - target: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// 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 - - #[lua(kind = "Method", output(proxy))] - fn looking_to( - self, - #[proxy] - direction: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// Returns this [`Transform`] with a new translation. - - #[lua(kind = "Method", output(proxy))] - fn with_translation( - self, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// Returns this [`Transform`] with a new rotation. - - #[lua(kind = "Method", output(proxy))] - fn with_rotation( - self, - #[proxy] - rotation: bevy::math::Quat, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// Returns this [`Transform`] with a new scale. - - #[lua(kind = "Method", output(proxy))] - fn with_scale( - self, - #[proxy] - scale: bevy::math::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// Returns the 3d affine transformation matrix from this transforms translation, -/// rotation, and scale. - - #[lua(kind = "Method", output(proxy))] - fn compute_matrix(&self) -> bevy::math::Mat4; - -"#, - r#" -/// Returns the 3d affine transformation matrix from this transforms translation, -/// rotation, and scale. - - #[lua(kind = "Method", output(proxy))] - fn compute_affine(&self) -> bevy::math::Affine3A; - -"#, - r#" -/// 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 - - #[lua(kind = "MutatingMethod")] - fn rotate(&mut self, #[proxy] rotation: bevy::math::Quat) -> (); - -"#, - r#" -/// 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. - - #[lua(kind = "MutatingMethod")] - fn rotate_axis(&mut self, #[proxy] axis: bevy::math::Vec3, angle: f32) -> (); - -"#, - r#" -/// 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. - - #[lua(kind = "MutatingMethod")] - fn rotate_x(&mut self, angle: f32) -> (); - -"#, - r#" -/// 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. - - #[lua(kind = "MutatingMethod")] - fn rotate_y(&mut self, angle: f32) -> (); - -"#, - r#" -/// 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. - - #[lua(kind = "MutatingMethod")] - fn rotate_z(&mut self, angle: f32) -> (); - -"#, - r#" -/// Rotates this [`Transform`] by the given `rotation`. -/// The `rotation` is relative to this [`Transform`]'s current rotation. - - #[lua(kind = "MutatingMethod")] - fn rotate_local(&mut self, #[proxy] rotation: bevy::math::Quat) -> (); - -"#, - r#" -/// Rotates this [`Transform`] around its local `axis` by `angle` (in radians). - - #[lua(kind = "MutatingMethod")] - fn rotate_local_axis(&mut self, #[proxy] axis: bevy::math::Vec3, angle: f32) -> (); - -"#, - r#" -/// Rotates this [`Transform`] around its local `X` axis by `angle` (in radians). - - #[lua(kind = "MutatingMethod")] - fn rotate_local_x(&mut self, angle: f32) -> (); - -"#, - r#" -/// Rotates this [`Transform`] around its local `Y` axis by `angle` (in radians). - - #[lua(kind = "MutatingMethod")] - fn rotate_local_y(&mut self, angle: f32) -> (); - -"#, - r#" -/// Rotates this [`Transform`] around its local `Z` axis by `angle` (in radians). - - #[lua(kind = "MutatingMethod")] - fn rotate_local_z(&mut self, angle: f32) -> (); - -"#, - r#" -/// Translates this [`Transform`] around a `point` in space. -/// If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent. - - #[lua(kind = "MutatingMethod")] - fn translate_around( - &mut self, - #[proxy] - point: bevy::math::Vec3, - #[proxy] - rotation: bevy::math::Quat, - ) -> (); - -"#, - r#" -/// Rotates this [`Transform`] around a `point` in space. -/// If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent. - - #[lua(kind = "MutatingMethod")] - fn rotate_around( - &mut self, - #[proxy] - point: bevy::math::Vec3, - #[proxy] - rotation: bevy::math::Quat, - ) -> (); - -"#, - r#" -/// 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 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(kind = "MutatingMethod")] - fn look_at( - &mut self, - #[proxy] - target: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> (); - -"#, - r#" -/// 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 - - #[lua(kind = "MutatingMethod")] - fn look_to( - &mut self, - #[proxy] - direction: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> (); - -"#, - r#" -/// Multiplies `self` with `transform` component by component, returning the -/// resulting [`Transform`] - - #[lua(kind = "Method", output(proxy))] - fn mul_transform( - &self, - #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// 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. - - #[lua(kind = "Method", output(proxy))] - fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" -/// Returns `true` if, and only if, translation, rotation and scale all are -/// finite. If any of them contains a `NaN`, positive or negative infinity, -/// this will return `false`. - - #[lua(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul( - self, - #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::Transform; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul( - self, - #[proxy] - global_transform: bevy::transform::components::GlobalTransform, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::transform::components::Transform; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Transform { - #[lua(output(proxy))] - translation: bevy::math::Vec3, - #[lua(output(proxy))] - rotation: bevy::math::Quat, - #[lua(output(proxy))] - scale: bevy::math::Vec3, -} -#[derive(Default)] -pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { - instances - .add_instance( - "GlobalTransform", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGlobalTransform, - >::new, - )?; - instances - .add_instance( - "Transform", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - Ok(()) - } -} -pub struct BevyTransformAPIProvider; -impl bevy_mod_scripting_core::hosts::APIProvider for BevyTransformAPIProvider { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - fn attach_api( - &mut self, - ctx: &mut Self::APITarget, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context"); - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx) - .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other( - e.to_string(), - )) - } - fn get_doc_fragment(&self) -> Option { - Some( - bevy_mod_scripting_lua::docs::LuaDocFragment::new( - "BevyTransformAPI", - |tw| { - tw.document_global_instance::() - .expect("Something went wrong documenting globals") - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGlobalTransform, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaTransform, - >, - >() - }, - ), - ) - } - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn register_with_app(&self, app: &mut bevy::app::App) { - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - } -} diff --git a/crates/bevy_script_api/src/providers/bevy_window.rs b/crates/bevy_script_api/src/providers/bevy_window.rs deleted file mode 100644 index 2844d7db..00000000 --- a/crates/bevy_script_api/src/providers/bevy_window.rs +++ /dev/null @@ -1,1674 +0,0 @@ -// @generated by cargo bevy-api-gen generate, modify the templates not this file -#![allow(clippy::all)] -#![allow(unused, deprecated, dead_code)] -#![cfg_attr(rustfmt, rustfmt_skip)] -use super::bevy_ecs::*; -use super::bevy_reflect::*; -use super::bevy_input::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::CursorEntered", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::CursorEntered; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::CursorEntered) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct CursorEntered { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::CursorIcon", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::CursorIcon; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &cursor::CursorIcon) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct CursorIcon {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::CursorLeft", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::CursorLeft; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::CursorLeft) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct CursorLeft { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::CursorMoved", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::CursorMoved; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::CursorMoved) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct CursorMoved { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] - position: bevy::math::Vec2, - delta: ReflectedValue, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::FileDragAndDrop", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::FileDragAndDrop; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::FileDragAndDrop) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct FileDragAndDrop {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::Ime", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::Ime) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::Ime; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Ime {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::MonitorSelection", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::MonitorSelection; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::MonitorSelection) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct MonitorSelection {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::ReceivedCharacter", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::ReceivedCharacter; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::ReceivedCharacter) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct ReceivedCharacter { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] - char: smol_str::SmolStr, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::Window", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::Window; - -"#, - r#" -/// Setting to true will attempt to maximize the window. -/// Setting to false will attempt to un-maximize the window. - - #[lua(kind = "MutatingMethod")] - fn set_maximized(&mut self, maximized: bool) -> (); - -"#, - r#" -/// Setting to true will attempt to minimize the window. -/// Setting to false will attempt to un-minimize the window. - - #[lua(kind = "MutatingMethod")] - fn set_minimized(&mut self, minimized: bool) -> (); - -"#, - r#" -/// The window's client area width in logical pixels. -/// See [`WindowResolution`] for an explanation about logical/physical sizes. - - #[lua(kind = "Method")] - fn width(&self) -> f32; - -"#, - r#" -/// The window's client area height in logical pixels. -/// See [`WindowResolution`] for an explanation about logical/physical sizes. - - #[lua(kind = "Method")] - fn height(&self) -> f32; - -"#, - r#" -/// The window's client area width in physical pixels. -/// See [`WindowResolution`] for an explanation about logical/physical sizes. - - #[lua(kind = "Method")] - fn physical_width(&self) -> u32; - -"#, - r#" -/// The window's client area height in physical pixels. -/// See [`WindowResolution`] for an explanation about logical/physical sizes. - - #[lua(kind = "Method")] - fn physical_height(&self) -> u32; - -"#, - r#" -/// The window's scale factor. -/// Ratio of physical size to logical size, see [`WindowResolution`]. - - #[lua(kind = "Method")] - fn scale_factor(&self) -> f32; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Window { - #[lua(output(proxy))] - cursor: bevy::window::Cursor, - #[lua(output(proxy))] - present_mode: bevy::window::PresentMode, - #[lua(output(proxy))] - mode: bevy::window::WindowMode, - #[lua(output(proxy))] - position: bevy::window::prelude::WindowPosition, - #[lua(output(proxy))] - resolution: bevy::window::WindowResolution, - title: std::string::String, - name: std::option::Option, - #[lua(output(proxy))] - composite_alpha_mode: bevy::window::CompositeAlphaMode, - #[lua(output(proxy))] - resize_constraints: bevy::window::prelude::WindowResizeConstraints, - resizable: bool, - #[lua(output(proxy))] - enabled_buttons: bevy::window::EnabledButtons, - decorations: bool, - transparent: bool, - focused: bool, - #[lua(output(proxy))] - window_level: bevy::window::WindowLevel, - canvas: std::option::Option, - prevent_default_event_handling: bool, - #[lua(output(proxy))] - internal: bevy::window::InternalWindowState, - ime_enabled: bool, - #[lua(output(proxy))] - ime_position: bevy::math::Vec2, - window_theme: ReflectedValue, - visible: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::WindowMoved", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowMoved) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::WindowMoved; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowMoved { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] - position: bevy::math::IVec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::WindowPosition", - functions[r#" -/// Creates a new [`WindowPosition`] at a position. - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - position: bevy::math::IVec2, - ) -> bevy::window::prelude::WindowPosition; - -"#, - r#" -/// Set the position to a specific point. - - #[lua(kind = "MutatingMethod")] - fn set(&mut self, #[proxy] position: bevy::math::IVec2) -> (); - -"#, - r#" -/// Set the window to a specific monitor. - - #[lua(kind = "MutatingMethod")] - fn center( - &mut self, - #[proxy] - monitor: bevy::window::prelude::MonitorSelection, - ) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::WindowPosition; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowPosition) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowPosition {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::WindowResizeConstraints", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowResizeConstraints) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::WindowResizeConstraints; - -"#, - r#" -/// Checks if the constraints are valid. -/// Will output warnings if it isn't. - - #[lua(kind = "Method", output(proxy))] - fn check_constraints(&self) -> bevy::window::prelude::WindowResizeConstraints; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowResizeConstraints { - min_width: f32, - min_height: f32, - max_width: f32, - max_height: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowResized", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowResized; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowResized) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowResized { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - width: f32, - height: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowCreated", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowCreated; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowCreated) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowCreated { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowClosed", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowClosed; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowClosed) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowClosed { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowCloseRequested", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowCloseRequested) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowCloseRequested; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowCloseRequested { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowDestroyed", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowDestroyed; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowDestroyed) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowDestroyed { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::RequestRedraw", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::RequestRedraw; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::RequestRedraw) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct RequestRedraw {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowFocused", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowFocused; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowFocused) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowFocused { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - focused: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowOccluded", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowOccluded; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowOccluded) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowOccluded { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - occluded: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowScaleFactorChanged", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowScaleFactorChanged) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowScaleFactorChanged; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowScaleFactorChanged { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - scale_factor: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowBackendScaleFactorChanged", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowBackendScaleFactorChanged; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowBackendScaleFactorChanged) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowBackendScaleFactorChanged { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - scale_factor: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowThemeChanged", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowThemeChanged) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowThemeChanged; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowThemeChanged { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] - theme: bevy::window::WindowTheme, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::ApplicationLifetime", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::ApplicationLifetime) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::ApplicationLifetime; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct ApplicationLifetime {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::PrimaryWindow", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::PrimaryWindow) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::PrimaryWindow; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct PrimaryWindow {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::Cursor", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::Cursor; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct Cursor { - #[lua(output(proxy))] - icon: bevy::window::prelude::CursorIcon, - visible: bool, - #[lua(output(proxy))] - grab_mode: bevy::window::CursorGrabMode, - hit_test: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::CursorGrabMode", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::CursorGrabMode; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::CursorGrabMode) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct CursorGrabMode {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::CompositeAlphaMode", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::CompositeAlphaMode; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::CompositeAlphaMode) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct CompositeAlphaMode {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowResolution", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowResolution; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowResolution) -> bool; - -"#, - r#" -/// Creates a new [`WindowResolution`]. - - #[lua(kind = "Function", output(proxy))] - fn new(logical_width: f32, logical_height: f32) -> bevy::window::WindowResolution; - -"#, - r#" -/// Builder method for adding a scale factor override to the resolution. - - #[lua(kind = "Method", output(proxy))] - fn with_scale_factor_override( - self, - scale_factor_override: f32, - ) -> bevy::window::WindowResolution; - -"#, - r#" -/// The window's client area width in logical pixels. - - #[lua(kind = "Method")] - fn width(&self) -> f32; - -"#, - r#" -/// The window's client area height in logical pixels. - - #[lua(kind = "Method")] - fn height(&self) -> f32; - -"#, - r#" -/// The window's client area width in physical pixels. - - #[lua(kind = "Method")] - fn physical_width(&self) -> u32; - -"#, - r#" -/// The window's client area height in physical pixels. - - #[lua(kind = "Method")] - fn physical_height(&self) -> u32; - -"#, - r#" -/// The ratio of physical pixels to logical pixels. -/// `physical_pixels = logical_pixels * scale_factor` - - #[lua(kind = "Method")] - fn scale_factor(&self) -> f32; - -"#, - r#" -/// The window scale factor as reported by the window backend. -/// This value is unaffected by [`WindowResolution::scale_factor_override`]. - - #[lua(kind = "Method")] - fn base_scale_factor(&self) -> f32; - -"#, - r#" -/// The scale factor set with [`WindowResolution::set_scale_factor_override`]. -/// This value may be different from the scale factor reported by the window backend. - - #[lua(kind = "Method")] - fn scale_factor_override(&self) -> std::option::Option; - -"#, - r#" -/// Set the window's logical resolution. - - #[lua(kind = "MutatingMethod")] - fn set(&mut self, width: f32, height: f32) -> (); - -"#, - r#" -/// Set the window's physical resolution. -/// This will ignore the scale factor setting, so most of the time you should -/// prefer to use [`WindowResolution::set`]. - - #[lua(kind = "MutatingMethod")] - fn set_physical_resolution(&mut self, width: u32, height: u32) -> (); - -"#, - r#" -/// Set the window's scale factor, this may get overridden by the backend. - - #[lua(kind = "MutatingMethod")] - fn set_scale_factor(&mut self, scale_factor: f32) -> (); - -"#, - r#" -/// Set the window's scale factor, this will be used over what the backend decides. -/// This can change the logical and physical sizes if the resulting physical -/// size is not within the limits. - - #[lua(kind = "MutatingMethod")] - fn set_scale_factor_override( - &mut self, - scale_factor_override: std::option::Option, - ) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowResolution {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowMode", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowMode; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowMode) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowMode {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowLevel", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowLevel; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowLevel) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowLevel {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::PresentMode", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::PresentMode) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::PresentMode; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct PresentMode {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::InternalWindowState", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::InternalWindowState) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::InternalWindowState; - -"#, - r#" -/// Consumes the current maximize request, if it exists. This should only be called by window backends. - - #[lua(kind = "MutatingMethod")] - fn take_maximize_request(&mut self) -> std::option::Option; - -"#, - r#" -/// Consumes the current minimize request, if it exists. This should only be called by window backends. - - #[lua(kind = "MutatingMethod")] - fn take_minimize_request(&mut self) -> std::option::Option; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct InternalWindowState {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowTheme", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowTheme) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowTheme; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowTheme {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::EnabledButtons", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::EnabledButtons) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::EnabledButtons; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct EnabledButtons { - minimize: bool, - maximize: bool, - close: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowRef", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowRef; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct WindowRef {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::NormalizedWindowRef", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::NormalizedWindowRef) -> bool; - -"#, - r#" -/// Fetch the entity of this window reference - - #[lua(kind = "Method", output(proxy))] - fn entity(&self) -> bevy::ecs::entity::Entity; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::NormalizedWindowRef; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -pub struct NormalizedWindowRef(); -#[derive(Default)] -pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { - instances - .add_instance( - "WindowPosition", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaWindowPosition, - >::new, - )?; - instances - .add_instance( - "WindowResolution", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaWindowResolution, - >::new, - )?; - Ok(()) - } -} -pub struct BevyWindowAPIProvider; -impl bevy_mod_scripting_core::hosts::APIProvider for BevyWindowAPIProvider { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - fn attach_api( - &mut self, - ctx: &mut Self::APITarget, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context"); - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx) - .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other( - e.to_string(), - )) - } - fn get_doc_fragment(&self) -> Option { - Some( - bevy_mod_scripting_lua::docs::LuaDocFragment::new( - "BevyWindowAPI", - |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::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaWindowPosition, - >, - >() - .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::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaWindowResolution, - >, - >() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - }, - ), - ) - } - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn register_with_app(&self, app: &mut bevy::app::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::< - bevy::window::prelude::WindowResizeConstraints, - >(); - 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::(); - 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::(); - } -} diff --git a/crates/bevy_script_api/src/providers/mod.rs b/crates/bevy_script_api/src/providers/mod.rs deleted file mode 100644 index 9f965d0c..00000000 --- a/crates/bevy_script_api/src/providers/mod.rs +++ /dev/null @@ -1,72 +0,0 @@ -// @generated by cargo bevy-api-gen collect, modify the templates not this file -#![allow(clippy::all)] -#![allow(unused, deprecated, dead_code)] -#![cfg_attr(rustfmt, rustfmt_skip)] -pub(crate) mod bevy_ecs; -pub(crate) mod bevy_transform; -pub(crate) mod bevy_input; -pub(crate) mod bevy_core; -pub(crate) mod bevy_time; -pub(crate) mod bevy_hierarchy; -pub(crate) mod bevy_window; -pub(crate) mod bevy_reflect; -extern crate self as bevy_script_api; -use bevy_mod_scripting_core::docs::DocFragment; -pub struct LuaBevyAPIProvider; -impl bevy_mod_scripting_core::hosts::APIProvider for LuaBevyAPIProvider { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - fn attach_api( - &mut self, - ctx: &mut Self::APITarget, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - bevy_ecs::BevyEcsAPIProvider.attach_api(ctx)?; - bevy_transform::BevyTransformAPIProvider.attach_api(ctx)?; - bevy_input::BevyInputAPIProvider.attach_api(ctx)?; - bevy_core::BevyCoreAPIProvider.attach_api(ctx)?; - bevy_time::BevyTimeAPIProvider.attach_api(ctx)?; - bevy_hierarchy::BevyHierarchyAPIProvider.attach_api(ctx)?; - bevy_window::BevyWindowAPIProvider.attach_api(ctx)?; - bevy_reflect::BevyReflectAPIProvider.attach_api(ctx)?; - Ok(()) - } - fn get_doc_fragment(&self) -> Option { - [ - bevy_ecs::BevyEcsAPIProvider.get_doc_fragment(), - bevy_transform::BevyTransformAPIProvider.get_doc_fragment(), - bevy_input::BevyInputAPIProvider.get_doc_fragment(), - bevy_core::BevyCoreAPIProvider.get_doc_fragment(), - bevy_time::BevyTimeAPIProvider.get_doc_fragment(), - bevy_hierarchy::BevyHierarchyAPIProvider.get_doc_fragment(), - bevy_window::BevyWindowAPIProvider.get_doc_fragment(), - bevy_reflect::BevyReflectAPIProvider.get_doc_fragment(), - ] - .into_iter() - .filter_map(|a: Option<_>| a) - .fold( - None, - |a, b| match a { - Some(a) => Some(a.merge(b)), - None => Some(b), - }, - ) - } - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn register_with_app(&self, app: &mut bevy::app::App) { - bevy_ecs::BevyEcsAPIProvider.register_with_app(app); - bevy_transform::BevyTransformAPIProvider.register_with_app(app); - bevy_input::BevyInputAPIProvider.register_with_app(app); - bevy_core::BevyCoreAPIProvider.register_with_app(app); - bevy_time::BevyTimeAPIProvider.register_with_app(app); - bevy_hierarchy::BevyHierarchyAPIProvider.register_with_app(app); - bevy_window::BevyWindowAPIProvider.register_with_app(app); - bevy_reflect::BevyReflectAPIProvider.register_with_app(app); - } -} diff --git a/crates/bevy_script_api/src/rhai/bevy/mod.rs b/crates/bevy_script_api/src/rhai/bevy/mod.rs deleted file mode 100644 index 3b0548f2..00000000 --- a/crates/bevy_script_api/src/rhai/bevy/mod.rs +++ /dev/null @@ -1,262 +0,0 @@ -use bevy::prelude::Entity; -use bevy_mod_scripting_core::prelude::*; - -#[allow(deprecated)] -use bevy_mod_scripting_rhai::{ - prelude::*, - rhai::{self, CustomType, INT}, -}; -use rhai::plugin::*; - -use crate::{ - common::bevy::{ScriptTypeRegistration, ScriptWorld}, - ReflectedValue, -}; - -use super::{RegisterForeignRhaiType, ToDynamic}; - -#[allow(deprecated)] -impl CustomType for ScriptTypeRegistration { - fn build(mut builder: rhai::TypeBuilder) { - builder - .with_name("TypeRegistration") - .with_fn("short_name", |self_: &mut Self| { - ImmutableString::from(self_.short_name()) - }) - .with_fn("type_name", |self_: &mut Self| self_.type_name()) - .with_fn("to_string", |self_: &mut Self| self_.to_string()) - .with_fn("to_debug", |self_: &mut Self| format!("{:?}", self_)); - } -} - -#[allow(deprecated)] -impl CustomType for ScriptWorld { - fn build(mut builder: rhai::TypeBuilder) { - builder - .with_name("World") - .with_fn("get_type_by_name", |self_: ScriptWorld, type_name: &str| { - self_ - .get_type_by_name(type_name) - .map(Dynamic::from) - .unwrap_or_default() - }) - .with_fn( - "add_default_component", - |self_: ScriptWorld, entity: Entity, type_registration: ScriptTypeRegistration| { - self_ - .add_default_component(entity, type_registration) - .map_err(|e| { - Box::new(EvalAltResult::ErrorRuntime( - Dynamic::from(e.to_string()), - Position::NONE, - )) - }) - .and_then(|ok| ok.to_dynamic()) - }, - ) - .with_fn( - "get_component", - |self_: ScriptWorld, entity: Entity, comp_type: ScriptTypeRegistration| { - let component = self_.get_component(entity, comp_type).map_err(|e| { - Box::new(EvalAltResult::ErrorRuntime( - e.to_string().into(), - Position::NONE, - )) - })?; - if let Some(c) = component { - c.to_dynamic() - } else { - Ok(Default::default()) - } - }, - ) - .with_fn( - "has_compoennt", - |self_: ScriptWorld, entity: Entity, comp_type: ScriptTypeRegistration| { - self_.has_component(entity, comp_type).map_err(|e| { - Box::new(EvalAltResult::ErrorRuntime( - e.to_string().into(), - Position::NONE, - )) - }) - }, - ) - .with_fn( - "remove_component", - |mut self_: ScriptWorld, entity: Entity, comp_type: ScriptTypeRegistration| { - self_.remove_component(entity, comp_type).map_err(|e| { - Box::new(EvalAltResult::ErrorRuntime( - e.to_string().into(), - Position::NONE, - )) - }) - }, - ) - .with_fn( - "get_resource", - |self_: ScriptWorld, res_type: ScriptTypeRegistration| { - let resource = self_.get_resource(res_type).map_err(|err| { - Box::new(EvalAltResult::ErrorRuntime( - err.to_string().into(), - Position::NONE, - )) - })?; - - if let Some(c) = resource { - c.to_dynamic() - } else { - Ok(Default::default()) - } - }, - ) - .with_fn( - "has_resource", - |self_: &mut ScriptWorld, res_type: ScriptTypeRegistration| { - self_.has_resource(res_type).map_err(|e| { - Box::new(EvalAltResult::ErrorRuntime( - e.to_string().into(), - Position::NONE, - )) - }) - }, - ) - .with_fn( - "remove_resource", - |self_: &mut ScriptWorld, res_type: ScriptTypeRegistration| { - self_.remove_resource(res_type).map_err(|e| { - Box::new(EvalAltResult::ErrorRuntime( - e.to_string().into(), - Position::NONE, - )) - }) - }, - ) - .with_fn("get_parent", |self_: ScriptWorld, entity: Entity| { - if let Some(parent) = self_.get_parent(entity) { - Dynamic::from(parent) - } else { - Dynamic::UNIT - } - }) - .with_fn("get_children", |self_: ScriptWorld, parent: Entity| { - self_ - .get_children(parent) - .into_iter() - .map(Dynamic::from) - .collect::>() - }) - .with_fn( - "push_child", - |self_: &mut ScriptWorld, parent: Entity, child: Entity| { - self_.push_child(parent, child) - }, - ) - .with_fn( - "remove_children", - |self_: &mut ScriptWorld, parent: Entity, children: Vec| { - self_.remove_children( - parent, - &children - .into_iter() - .map(Dynamic::cast::) - .collect::>(), - ) - }, - ) - .with_fn( - "remove_child", - |self_: &mut ScriptWorld, parent: Entity, child: Entity| { - self_.remove_children(parent, &[child]) - }, - ) - .with_fn( - "insert_children", - |self_: &mut ScriptWorld, parent: Entity, index: INT, children: Vec| { - self_.insert_children( - parent, - index.try_into().expect("number too large"), - &children - .into_iter() - .map(Dynamic::cast::) - .collect::>(), - ) - }, - ) - .with_fn( - "insert_child", - |self_: &mut ScriptWorld, parent: Entity, index: INT, child: Entity| { - self_.insert_children( - parent, - index.try_into().expect("number too large"), - &[child], - ) - }, - ) - .with_fn( - "despawn_children_recursive", - |self_: &mut ScriptWorld, entity: Entity| self_.despawn_children_recursive(entity), - ) - .with_fn( - "despawn_recursive", - |self_: &mut ScriptWorld, entity: Entity| self_.despawn_recursive(entity), - ) - .with_fn("spawn", |self_: &mut ScriptWorld| { - let mut w = self_.write(); - w.spawn(()).id() - }) - .with_fn("despawn", |self_: &mut ScriptWorld, entity: Entity| { - let mut w = self_.write(); - - w.despawn(entity) - }) - .with_fn("to_string", |self_: &mut ScriptWorld| self_.to_string()) - .with_fn("to_debug", |self_: &mut ScriptWorld| format!("{:?}", self_)); - } -} - -pub struct RhaiBevyAPIProvider; - -impl APIProvider for RhaiBevyAPIProvider { - type APITarget = Engine; - type ScriptContext = RhaiContext; - type DocTarget = RhaiDocFragment; - - fn attach_api(&mut self, engine: &mut Self::APITarget) -> Result<(), ScriptError> { - engine.build_type::(); - engine.build_type::(); - engine.build_type::(); - Ok(()) - } - - fn setup_script( - &mut self, - script_data: &ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), ScriptError> { - ctx.scope.set_value("entity", script_data.entity); - Ok(()) - } - - fn get_doc_fragment(&self) -> Option { - None - } - - fn register_with_app(&self, app: &mut bevy::prelude::App) { - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - app.register_foreign_rhai_type::(); - } -} diff --git a/crates/bevy_script_api/src/rhai/mod.rs b/crates/bevy_script_api/src/rhai/mod.rs deleted file mode 100644 index d3e50f7d..00000000 --- a/crates/bevy_script_api/src/rhai/mod.rs +++ /dev/null @@ -1,194 +0,0 @@ -use ::std::borrow::Cow; - -use ::bevy::{ - prelude::{App, AppTypeRegistry}, - reflect::{FromType, GetTypeRegistration, Reflect}, -}; -#[allow(deprecated)] -use bevy_mod_scripting_rhai::rhai::{CustomType, Dynamic, EvalAltResult, INT}; - -use crate::{ReflectReference, ReflectedValue, ValueIndex}; - -pub mod bevy; -pub mod std; - -/// A trait allowing the registration of the [`RhaiProxyable`] trait with the type registry for foreign types -/// -/// If you have access to the type you should prefer to use `#[reflect(RhaiProxyable)]` instead. -/// This is exactly equivalent. -pub trait RegisterForeignRhaiType { - fn register_foreign_rhai_type( - &mut self, - ) -> &mut Self; -} - -impl RegisterForeignRhaiType for App { - fn register_foreign_rhai_type( - &mut self, - ) -> &mut Self { - { - let registry = self.world.resource_mut::(); - let mut registry = registry.write(); - - let rhai_data = >::from_type(); - - if let Some(registration) = registry.get_mut(TypeId::of::()) { - registration.insert(rhai_data) - } else { - let mut registration = T::get_type_registration(); - registration.insert(rhai_data); - registry.add_registration(registration); - } - } - - self - } -} - -pub trait RhaiProxyable { - fn ref_to_rhai(self_: ReflectReference) -> Result>; - fn apply_rhai(self_: &mut ReflectReference, new_val: Dynamic) - -> Result<(), Box>; -} - -pub trait FromRhaiProxy: Sized { - fn from_rhai_proxy(self_: Dynamic) -> Result>; -} - -pub trait ToRhaiProxy { - fn to_rhai_proxy(self) -> Result>; -} - -#[derive(Clone)] -pub struct ReflectRhaiProxyable { - ref_to_rhai: fn(ref_: ReflectReference) -> Result>, - apply_rhai: fn(ref_: &mut ReflectReference, new_val: Dynamic) -> Result<(), Box>, -} - -impl ReflectRhaiProxyable { - pub fn ref_to_rhai(&self, ref_: ReflectReference) -> Result> { - (self.ref_to_rhai)(ref_) - } - - pub fn apply_rhai( - &self, - ref_: &mut ReflectReference, - new_val: Dynamic, - ) -> Result<(), Box> { - (self.apply_rhai)(ref_, new_val) - } -} - -impl FromType for ReflectRhaiProxyable { - fn from_type() -> Self { - Self { - ref_to_rhai: T::ref_to_rhai, - apply_rhai: T::apply_rhai, - } - } -} - -pub trait ToDynamic { - fn to_dynamic(self) -> Result>; -} - -impl ToDynamic for ReflectedValue { - fn to_dynamic(self) -> Result> { - Ok(Dynamic::from(self)) - } -} - -impl ToDynamic for ReflectReference { - fn to_dynamic(self) -> Result> { - // clone since it's cheap and we don't want to clone self later - let world = self.world_ptr.clone(); - let world = world.read(); - - let type_data = world.resource::(); - let g = type_data.read(); - - let type_id = self.get(|s| s.type_id())?; - - if let Some(v) = g.get_type_data::(type_id) { - v.ref_to_rhai(self) - } else { - ReflectedValue { ref_: self }.to_dynamic() - } - } -} - -pub trait ApplyRhai { - fn apply_rhai(&mut self, value: Dynamic) -> Result<(), Box>; -} - -impl ApplyRhai for ReflectReference { - fn apply_rhai(&mut self, value: Dynamic) -> Result<(), Box> { - let world_ptr = self.world_ptr.clone(); - - // remove typedata from the world to be able to manipulate world - let proxyable = { - let world = world_ptr.read(); - let type_registry = world.resource::().read(); - type_registry - .get_type_data::(self.get(|s| s.type_id())?) - .cloned() - }; - - if let Some(ud) = proxyable { - return ud.apply_rhai(self, value); - } else if value.is::() { - let b = value.cast::(); - self.apply(&b.into())?; - return Ok(()); - } - - Err(Box::new(EvalAltResult::ErrorRuntime(self.get(|s| - format!("Attempted to assign `{}` = {value:?}. Did you forget to call `app.register_foreign_rhai_type::<{}>`?", - self.path, - s.get_represented_type_info().unwrap().type_path() - ))?.into(),Position::NONE) - )) - } -} - -impl ValueIndex for ReflectReference { - type Output = Result>; - - fn index(&self, index: Dynamic) -> Self::Output { - if index.is::() { - return Ok(self.index(index.as_int().unwrap() as usize)); - } else if index.is::() { - return Ok(self.index(Cow::Owned(index.into_string().unwrap()))); - }; - - Err(Box::new(EvalAltResult::ErrorMismatchDataType( - index.type_name().to_owned(), - "integer or string".to_owned(), - Position::NONE, - ))) - } -} - -use bevy_mod_scripting_rhai::rhai::plugin::*; - -#[allow(deprecated)] -impl CustomType for ReflectedValue { - fn build(mut builder: bevy_mod_scripting_rhai::rhai::TypeBuilder) { - builder - .with_indexer_get_result(|obj: &mut ReflectedValue, index: Dynamic| { - obj.ref_.index(index)?.to_dynamic() - }) - .with_indexer_set_result(|obj: &mut ReflectedValue, index: Dynamic, value: Dynamic| { - obj.ref_.index(index)?.apply_rhai(value) - }) - .with_fn("to_debug", |self_: &mut ReflectedValue| { - format!("{:?}", self_) - }) - .with_fn("to_string", |self_: &mut ReflectedValue| { - self_ - .ref_ - .get(|s| format!("{:?}", &s)) - .map_err::, _>(|e| e.into()) - }); - } -} diff --git a/crates/bevy_script_api/src/rhai/std.rs b/crates/bevy_script_api/src/rhai/std.rs deleted file mode 100644 index a0bb178b..00000000 --- a/crates/bevy_script_api/src/rhai/std.rs +++ /dev/null @@ -1,427 +0,0 @@ -use std::{ - any::type_name, - fmt::{Debug, Display}, - iter::Map, -}; - -use bevy::reflect::{FromReflect, Reflect, TypePath}; -#[allow(deprecated)] -use bevy_mod_scripting_rhai::rhai::{CustomType, Dynamic, Engine, EvalAltResult, Position}; - -use crate::{ - common::std::ScriptVec, error::ReflectionError, ReflectReference, ReflectionPathElement, - ValueIndex, -}; - -use super::{ApplyRhai, FromRhaiProxy, RhaiProxyable, ToDynamic, ToRhaiProxy}; - -impl RhaiProxyable for T { - fn ref_to_rhai(self_: crate::ReflectReference) -> Result> { - self_.get_typed(|self_: &T| Ok(Dynamic::from(self_.clone())))? - } - - fn apply_rhai( - self_: &mut crate::ReflectReference, - new_val: Dynamic, - ) -> Result<(), Box> { - let other = if new_val.is::() { - new_val.cast::() - } else { - return Err(Box::new(EvalAltResult::ErrorMismatchDataType( - stringify!(T).to_owned(), - new_val.type_name().to_string(), - Position::NONE, - ))); - }; - - self_.set_val(other)?; - Ok(()) - } -} - -/// A marker trait signifying this type is to receive an automatic proxy implementation via `Dynamic::from`. -/// This means the proxy for this type is the type itself, and is created by cloning the original reference. -pub trait RhaiCopy {} - -/// Implements RhaiProxyabel for a numeric type via another proxy type by coercing the type -macro_rules! impl_rhai_proxy { - // i.e. impl_rhai_proxy!(String as Into) - ($type:ty as Into) => { - impl_rhai_proxy!($type,$type,self: {self.into()}, s: {s.into()}); - }; - // i.e. impl_rhai_proxy!(u32 as i64) - ($type:ty as $proxy_type:ty) => { - impl_rhai_proxy!($type, $proxy_type,self:{(self as $proxy_type).into()}, s:{(*s as $proxy_type).into()}); - }; - // i.e. impl_rhai_proxy!(ident, u32, i64, (*ident as i64).into()) expression is used in ref_to_rhai - ($type:ty, $proxy_type:ty,$self:ident: {$($proxy_expr:tt)*}, $self_to_rhai:ident : {$($proxy_expr_to_rhai:tt)*} ) => { - impl RhaiProxyable for $type { - fn ref_to_rhai( - self_: crate::ReflectReference, - ) -> Result> { - self_.get_typed(|$self_to_rhai: &$type| Ok($($proxy_expr_to_rhai)*))? - } - - fn apply_rhai( - self_: &mut crate::ReflectReference, - new_val: Dynamic, - ) -> Result<(), Box> { - self_.set_val(Self::from_rhai_proxy(new_val)?)?; - Ok(()) - } - } - - impl FromRhaiProxy for $type { - #[inline(always)] - fn from_rhai_proxy(self_: Dynamic) -> Result> { - if self_.is::<$proxy_type>(){ - Ok(self_.cast::<$proxy_type>() as $type) - } else { - Err(Box::new(EvalAltResult::ErrorMismatchDataType( - stringify!($type).to_owned(), - self_.type_name().to_owned(), - Position::NONE, - ))) - } - - } - } - - impl ToRhaiProxy for $type { - #[inline(always)] - fn to_rhai_proxy($self) -> Result> { - Ok($($proxy_expr)*) - } - } - }; -} -use bevy_mod_scripting_rhai::rhai::{FLOAT, INT}; - -impl_rhai_proxy!(i8 as INT); -impl_rhai_proxy!(i16 as INT); -impl_rhai_proxy!(i32 as INT); -impl_rhai_proxy!(i64 as INT); -impl_rhai_proxy!(i128 as INT); -impl_rhai_proxy!(isize as INT); -impl_rhai_proxy!(u8 as INT); -impl_rhai_proxy!(u16 as INT); -impl_rhai_proxy!(u32 as INT); -impl_rhai_proxy!(u64 as INT); -impl_rhai_proxy!(u128 as INT); -impl_rhai_proxy!(usize as INT); -impl_rhai_proxy!(f32 as FLOAT); -impl_rhai_proxy!(f64 as FLOAT); -impl_rhai_proxy!(bool as bool); -impl_rhai_proxy!(String as Into); - -impl RhaiProxyable - for Option -{ - fn ref_to_rhai(self_: crate::ReflectReference) -> Result> { - self_.get_typed(|s: &Option| match s { - Some(_) => T::ref_to_rhai(self_.sub_ref(ReflectionPathElement::SubReflection { - label: "as_ref", - get: std::sync::Arc::new(|ref_| { - ref_.downcast_ref::>() - .ok_or_else(|| ReflectionError::CannotDowncast { - from: ref_.get_represented_type_info().unwrap().type_path().into(), - to: stringify!(Option).into(), - })? - .as_ref() - .map(|t| t as &dyn Reflect) - .ok_or_else(|| { - ReflectionError::Other( - "Stale reference to Option. Cannot sub reflect.".to_owned(), - ) - }) - }), - get_mut: std::sync::Arc::new(|ref_| { - ref_.downcast_mut::>() - // TODO: there is some weird borrow checker fuckery going on here - // i tried having from: ref_.get_represented_type_info().unwrap().type_path().into() instead of "Reflect" - // and lying this out in an if let expression, but nothing will satisfy the borrow checker here, so leaving this for now - .ok_or_else(|| ReflectionError::CannotDowncast { - from: "Reflect".into(), - to: stringify!(Option).into(), - })? - .as_mut() - .map(|t| t as &mut dyn Reflect) - .ok_or_else(|| { - ReflectionError::Other( - "Stale reference to Option. Cannot sub reflect.".to_owned(), - ) - }) - }), - })), - None => Ok(Dynamic::UNIT), - })? - } - - fn apply_rhai( - self_: &mut crate::ReflectReference, - new_val: Dynamic, - ) -> Result<(), Box> { - if new_val.is::<()>() { - self_.get_mut_typed(|s: &mut Option| { - *s = None; - Ok(()) - })? - } else { - // we need to do this in two passes, first - // ensure that the target type is the 'some' variant to allow a sub reference - - let is_none = self_.get_typed(|s: &Option| s.is_none())?; - - if is_none { - return self_.get_mut_typed(|s: &mut Option| { - *s = Some(T::from_rhai_proxy(new_val)?); - Ok::<_, Box>(()) - })?; - } - - T::apply_rhai( - &mut self_.sub_ref(ReflectionPathElement::SubReflection { - label: "", - get: std::sync::Arc::new(|ref_| { - ref_.downcast_ref::>() - .ok_or_else(|| ReflectionError::CannotDowncast { - from: ref_.get_represented_type_info().unwrap().type_path().into(), - to: stringify!(Option).into(), - })? - .as_ref() - .map(|t| t as &dyn Reflect) - .ok_or_else(|| { - ReflectionError::Other( - "Stale reference to Option. Cannot sub reflect.".to_owned(), - ) - }) - }), - get_mut: std::sync::Arc::new(|ref_| { - if ref_.is::>() { - ref_.downcast_mut::>() - .unwrap() - .as_mut() - .map(|t| t as &mut dyn Reflect) - .ok_or_else(|| { - ReflectionError::Other( - "Stale reference to Option. Cannot sub reflect.".to_owned(), - ) - }) - } else { - Err(ReflectionError::CannotDowncast { - from: ref_.get_represented_type_info().unwrap().type_path().into(), - to: stringify!(Option).into(), - }) - } - }), - }), - new_val, - ) - } - } -} - -impl FromRhaiProxy for Option { - fn from_rhai_proxy(self_: Dynamic) -> Result> { - if self_.is::<()>() { - Ok(None) - } else { - T::from_rhai_proxy(self_).map(Option::Some) - } - } -} - -impl ToRhaiProxy for Option { - fn to_rhai_proxy(self) -> Result> { - match self { - Some(v) => v.to_rhai_proxy(), - None => Ok(Dynamic::UNIT), - } - } -} - -/// Composite trait composing the various traits required for a type `T` to be used as part of a RhaiVec -pub trait RhaiVecElem: FromReflect + TypePath + RhaiProxyable + FromRhaiProxy + Clone {} -impl RhaiVecElem for T {} - -/// A ScriptVec wrapper which implements a custom iterator ontop of ScriptVec's -pub struct RhaiVec(pub ScriptVec); - -impl Clone for RhaiVec { - fn clone(&self) -> Self { - Self(self.0.clone()) - } -} - -impl Debug for RhaiVec { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", self.0) - } -} - -impl Display for RhaiVec { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.0) - } -} - -impl RhaiVec { - pub fn new_ref(self_: crate::ReflectReference) -> Self { - Self(ScriptVec::::new_ref(self_)) - } -} - -impl std::ops::Deref for RhaiVec { - type Target = ScriptVec; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl std::ops::DerefMut for RhaiVec { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - -impl IntoIterator for RhaiVec { - type Item = Result>; - - type IntoIter = - Map< as IntoIterator>::IntoIter, fn(ReflectReference) -> Self::Item>; - - fn into_iter(self) -> Self::IntoIter { - self.0.into_iter().map(|v| v.to_dynamic()) - } -} - -impl RhaiProxyable for Vec { - fn ref_to_rhai(self_: crate::ReflectReference) -> Result> { - Ok(Dynamic::from(RhaiVec::::new_ref(self_))) - } - - fn apply_rhai( - self_: &mut crate::ReflectReference, - new_val: Dynamic, - ) -> Result<(), Box> { - if new_val.is::>() { - let last_target_idx = self_.get_typed(|s: &Vec| s.len())? - 1; - // there is also another case to consider, Vec has a lua representation available as well (table) - // if we receive one of those, we should also apply it - for (idx, entry) in new_val.cast::>().into_iter().enumerate() { - if idx > last_target_idx { - // here we don't need to do anything special just use LuaProxyable impl - T::apply_rhai(&mut self_.index(idx), entry)?; - } else { - // here we don't have anything to apply this to - // use FromLua impl - self_.get_mut_typed(|s: &mut Vec| { - s[idx] = T::from_rhai_proxy(entry)?; - Ok::<_, Box>(()) - })??; - } - } - Ok(()) - } else if new_val.is::>() { - let vec = new_val.cast::>(); - self_.apply(&vec.ref_)?; - Ok(()) - } else { - Err(Box::new(EvalAltResult::ErrorMismatchDataType( - "Array or Vec".to_owned(), - new_val.type_name().to_owned(), - Position::NONE, - ))) - } - } -} - -impl FromRhaiProxy for Vec { - fn from_rhai_proxy(self_: Dynamic) -> Result> { - if self_.is::>() { - let vec = self_.cast::>(); - vec.ref_.get_typed(|s: &Vec| Ok(s.clone()))? - } else if self_.is::>() { - self_ - .cast::>() - .into_iter() - .map(|v| T::from_rhai_proxy(v)) - .collect::, _>>() - } else { - Err(Box::new(EvalAltResult::ErrorMismatchDataType( - "Array or Vec".to_owned(), - self_.type_name().to_owned(), - Position::NONE, - ))) - } - } -} - -impl ToRhaiProxy for Vec { - fn to_rhai_proxy(self) -> Result> { - self.into_iter() - .map(|v| T::to_rhai_proxy(v)) - .collect::, _>>() - .map(Dynamic::from) - } -} - -#[allow(deprecated)] -impl CustomType for RhaiVec { - fn build(mut builder: bevy_mod_scripting_rhai::rhai::TypeBuilder) { - builder - .with_name(type_name::>()) - .with_fn("to_debug", |vec: &mut RhaiVec| format!("{:?}", vec)) - .with_fn("to_string", |vec: &mut RhaiVec| { - vec.ref_ - .get(|s| format!("{:?}", &s)) - .map_err::, _>(|e| e.into()) - }) - .with_result_fn("is_empty", |vec: &mut RhaiVec| { - vec.is_empty().map_err(Into::into) - }) - .with_result_fn("len", |vec: &mut RhaiVec| { - vec.len().map(|v| v as INT).map_err(Into::into) - }) - .with_result_fn("push", |vec: &mut RhaiVec, val: Dynamic| { - vec.push(T::from_rhai_proxy(val)?).map_err(Into::into) - }) - .with_result_fn("pop", |vec: &mut RhaiVec| vec.pop().map_err(Into::into)) - .with_result_fn("clear", |vec: &mut RhaiVec| { - vec.clear().map_err(Into::into) - }) - .with_result_fn("insert", |vec: &mut RhaiVec, idx: INT, val: Dynamic| { - vec.insert(idx as usize, T::from_rhai_proxy(val)?) - .map_err(Into::into) - }) - .with_result_fn("remove", |vec: &mut RhaiVec, idx: INT| { - vec.remove(idx as usize).map_err(Into::into) - }) - .with_result_fn("index$get$", |vec: &mut RhaiVec, idx: INT| { - vec.index(idx as usize).to_dynamic() - }) - .with_result_fn( - "index$set$", - |vec: &mut RhaiVec, idx: INT, value: Dynamic| { - vec.index(idx as usize).apply_rhai(value) - }, - ); - } -} - -/// A trait for making monomorphization of Vec implementations for any T easier. -/// -/// Rhai does not support the idea of generic types, instead every function is a standalone thing, and hence -/// generics must be monomorphized manually (registered for every type you want to use them with). -pub trait RegisterVecType { - fn register_vec_functions(&mut self) -> &mut Self; -} - -impl RegisterVecType for Engine { - fn register_vec_functions(&mut self) -> &mut Self { - self.build_type::>(); - self.register_iterator_result::, _>(); - self - } -} diff --git a/crates/bevy_script_api/src/script_ref.rs b/crates/bevy_script_api/src/script_ref.rs deleted file mode 100644 index bb9e61ba..00000000 --- a/crates/bevy_script_api/src/script_ref.rs +++ /dev/null @@ -1,185 +0,0 @@ -use bevy::prelude::*; -use parking_lot::RwLock; -use std::fmt::Debug; -use std::{borrow::Cow, sync::Weak}; - -use bevy_mod_scripting_core::world::WorldPointer; - -use crate::{ - error::ReflectionError, - sub_reflect::{ReflectBase, ReflectionPath, ReflectionPathElement}, -}; - -/// A reference to a rust type available from some script language. -/// References can be either to rust or script managed values (created either on the bevy or script side). -/// but also to any subfield of those values (All pointed to values must support `reflect`). -/// Each reference holds a reflection path from the root. -/// -/// Automatically converts to the most convenient lua representation. -/// See [`ReflectReference::to_lua`] -#[derive(Clone, Debug)] -pub struct ReflectReference { - /// The reflection path from the root - pub(crate) path: ReflectionPath, - pub(crate) world_ptr: WorldPointer, -} - -/// Safety: copying just copies the path of reflection, any closures inside, and the world pointer. -/// that itself is safe to copy. -unsafe impl Send for ReflectReference {} -/// Safety: all accesses to value are protected by locking the world pointer. -unsafe impl Sync for ReflectReference {} - -impl ReflectReference { - /// Safely creates a new base component reference - pub fn new_component_ref( - comp: ReflectComponent, - entity: Entity, - world_ptr: WorldPointer, - ) -> Self { - Self { - path: ReflectionPath::new(ReflectBase::Component { comp, entity }), - world_ptr, - } - } - - pub fn new_resource_ref(res: ReflectResource, world_ptr: WorldPointer) -> Self { - Self { - path: ReflectionPath::new(ReflectBase::Resource { res }), - world_ptr, - } - } - - /// Creates a reference to a script owned value - pub fn new_script_ref(ptr: Weak>, world_ptr: WorldPointer) -> Self { - Self { - path: ReflectionPath::new(ReflectBase::ScriptOwned { val: ptr }), - world_ptr, - } - } - - /// Creates a new script reference which points to a sub component of the original data, - /// This also updates the pointer - pub(crate) fn sub_ref(&self, elem: ReflectionPathElement) -> ReflectReference { - let path = self.path.new_sub(elem); - - Self { - path, - ..self.clone() - } - } - - /// Retrieves the underlying `dyn Reflect` reference and applies function which can retrieve a value. - /// Panics if the reference is invalid or world is already borrowed mutably. - #[inline(always)] - pub fn get(&self, f: F) -> Result - where - F: FnOnce(&dyn Reflect) -> O, - { - self.path.get(self.world_ptr.clone(), f) - } - - pub fn get_typed(&self, f: F) -> Result - where - F: FnOnce(&T) -> O, - T: Reflect, - { - self.path.get(self.world_ptr.clone(), |reflect| { - (f)(reflect.downcast_ref::().unwrap_or_else(|| { - panic!( - "Expected `{}` found `{}`", - ::std::any::type_name::(), - reflect.get_represented_type_info().unwrap().type_path() - ) - })) - }) - } - - /// Retrieves the underlying `dyn Reflect` reference and applies function which can retrieve a value. - /// If this is a component it is marked as changed. - /// Panics if the reference is invalid or if the world/value is already borrowed or if r is not a mutable pointer. - #[inline(always)] - pub fn get_mut(&mut self, f: F) -> Result - where - F: FnOnce(&mut dyn Reflect) -> O, - { - self.path.get_mut(self.world_ptr.clone(), f) - } - - pub fn get_mut_typed(&mut self, f: F) -> Result - where - F: FnOnce(&mut T) -> O, - T: Reflect, - { - self.path.get_mut(self.world_ptr.clone(), |reflect| { - (f)(reflect.downcast_mut().unwrap()) - }) - } - - /// applies another [`ReflectReference`] to self by carefuly acquiring locks and cloning if necessary. - /// - /// This is semantically equivalent to the [`Reflect::apply`] method. - /// If you know the type of this value use [`Self::apply_luaref_typed`] since it avoids double cloning and allocating - pub fn apply(&mut self, other: &ReflectReference) -> Result<(), ReflectionError> { - // sadly apply already performs a clone for value types, so this incurs - // a double clone in some cases TODO: is there another way ? - // can we avoid the box ? - let cloned = other.get(|s| s.clone_value())?; - - self.get_mut(|s| s.apply(&*cloned)) - } - - /// Unlike apply this method expects the other type to be identical. Does not allocate so is likely to be faster than apply, uses direct assignment. - /// If you have a concrete value use [`Self::set_val`](TypedReflectReference) unstead - pub fn set(&mut self, other: &Self) -> Result<(), ReflectionError> - where - T: Reflect + Clone, - { - let other: T = other.get_typed(|s: &T| s.clone())?; - self.get_mut_typed(|s| *s = other) - } - - /// Version of [`Self::set`](TypedReflectReference) which directly accepts a `T` value - pub fn set_val(&mut self, other: T) -> Result<(), ReflectionError> - where - T: Reflect, - { - self.get_mut_typed(|s| *s = other) - } -} - -/// A version of index for returning values instead of references -pub trait ValueIndex { - type Output; - - fn index(&self, index: Idx) -> Self::Output; -} - -impl ValueIndex for ReflectReference { - type Output = Self; - - fn index(&self, index: usize) -> Self::Output { - self.sub_ref(ReflectionPathElement::IndexAccess(index)) - } -} - -impl ValueIndex> for ReflectReference { - type Output = Self; - - fn index(&self, index: Cow<'static, str>) -> Self::Output { - self.sub_ref(ReflectionPathElement::FieldAccess(index)) - } -} - -/// A value representing a type which has no special UserData implementation, -/// It exposes the much less convenient reflect interface of the underlying type. -#[derive(Clone, Debug)] -pub struct ReflectedValue { - pub(crate) ref_: ReflectReference, -} - -impl From for ReflectReference { - fn from(ref_: ReflectedValue) -> Self { - ref_.ref_ - } -} diff --git a/crates/bevy_script_api/src/sub_reflect.rs b/crates/bevy_script_api/src/sub_reflect.rs deleted file mode 100644 index 9ec23952..00000000 --- a/crates/bevy_script_api/src/sub_reflect.rs +++ /dev/null @@ -1,389 +0,0 @@ -use parking_lot::RwLock; -use std::fmt; -use std::fmt::{Debug, Display}; -use std::sync::Arc; -use std::{borrow::Cow, sync::Weak}; - -use bevy::{ - prelude::{Entity, ReflectComponent, ReflectResource}, - reflect::{Reflect, ReflectMut, ReflectRef}, -}; - -use crate::error::ReflectionError; -use bevy_mod_scripting_core::world::WorldPointer; - -/// The base of a reflect path, i.e. the top-level object or source. -/// Reflections paths are always relative to some reflect base. -/// -/// If the reflection base and reflection path are both valid we can use them to traverse reflect types -#[derive(Clone)] -pub(crate) enum ReflectBase { - /// A bevy component reference - Component { - comp: ReflectComponent, - entity: Entity, - }, - /// A bevy resource reference - Resource { res: ReflectResource }, - - /// A script owned reflect type (for example a vector constructed in lua) - ScriptOwned { val: Weak> }, -} - -/// Safety: we can safely send this value across thread boundaries -/// the pointer variant is always accessed with the -unsafe impl Send for ReflectBase {} -/// Safety: todo!() -unsafe impl Sync for ReflectBase {} - -impl fmt::Debug for ReflectBase { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::Component { entity, .. } => { - f.debug_struct("Component").field("entity", entity).finish() - } - Self::ScriptOwned { .. } => write!(f, "ScriptOwned"), - Self::Resource { .. } => f.debug_struct("Resource").finish(), - } - } -} - -impl fmt::Display for ReflectBase { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - ReflectBase::Component { entity, .. } => { - f.write_str("(Component on ")?; - f.write_str(&entity.index().to_string())?; - f.write_str(")") - } - ReflectBase::Resource { .. } => f.write_str("(Resource)"), - ReflectBase::ScriptOwned { .. } => f.write_str("(ScriptOwned)"), - } - } -} - -pub type Get = dyn Fn(&dyn Reflect) -> Result<&dyn Reflect, ReflectionError>; -pub type GetMut = dyn Fn(&mut dyn Reflect) -> Result<&mut dyn Reflect, ReflectionError>; - -/// Stores a part of the path of reflection + sub reflection from a root reflect reference. -/// Sub reflection allows us to access values unreachable by standard reflection. -#[derive(Clone)] -pub enum ReflectionPathElement { - SubReflection { - label: &'static str, - get: Arc, - get_mut: Arc, - }, - /// Access to a struct field - FieldAccess(Cow<'static, str>), - /// Access to a TupleStruct, Tuple, List or Array element - IndexAccess(usize), // TODO: Map access -} - -impl Debug for ReflectionPathElement { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::SubReflection { label, .. } => f - .debug_struct("SubReflection") - .field("label", label) - .finish(), - Self::FieldAccess(arg0) => f.debug_tuple("FieldAccess").field(arg0).finish(), - Self::IndexAccess(arg0) => f.debug_tuple("IndexAccess").field(arg0).finish(), - } - } -} - -impl Display for ReflectionPathElement { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - ReflectionPathElement::SubReflection { label, .. } => { - f.write_str(".")?; - f.write_str(label)?; - f.write_str("()") - } - ReflectionPathElement::FieldAccess(s) => { - f.write_str(".")?; - f.write_str(s) - } - ReflectionPathElement::IndexAccess(i) => { - f.write_str("[")?; - f.write_str(&i.to_string())?; - f.write_str("]") - } - } - } -} - -impl ReflectionPathElement { - pub(crate) fn sub_ref<'a>( - &self, - base: &'a dyn Reflect, - ) -> Result<&'a dyn Reflect, ReflectionError> { - match self { - ReflectionPathElement::SubReflection { get, .. } => get(base), - ReflectionPathElement::FieldAccess(field) => match base.reflect_ref() { - ReflectRef::Struct(s) => { - s.field(field) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such field".to_owned(), - }) - } - _ => Err(ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such field".to_owned(), - }), - }, - ReflectionPathElement::IndexAccess(index) => match base.reflect_ref() { - ReflectRef::TupleStruct(s) => { - s.field(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectRef::Tuple(s) => { - s.field(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectRef::List(s) => { - s.get(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectRef::Array(s) => { - s.get(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - _ => Err(ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }), - }, - } - } - - pub(crate) fn sub_ref_mut<'a>( - &self, - base: &'a mut dyn Reflect, - ) -> Result<&'a mut dyn Reflect, ReflectionError> { - match self { - ReflectionPathElement::SubReflection { get_mut, .. } => get_mut(base), - ReflectionPathElement::FieldAccess(field) => match base.reflect_mut() { - ReflectMut::Struct(s) => { - s.field_mut(field) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such field".to_owned(), - }) - } - _ => Err(ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such field".to_owned(), - }), - }, - ReflectionPathElement::IndexAccess(index) => match base.reflect_mut() { - ReflectMut::TupleStruct(s) => { - s.field_mut(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectMut::Tuple(s) => { - s.field_mut(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectMut::List(s) => { - s.get_mut(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectMut::Array(s) => { - s.get_mut(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - _ => Err(ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }), - }, - } - } -} - -#[derive(Clone, Debug)] -pub(crate) struct ReflectionPath { - base: ReflectBase, - // most of these will be very short, people don't make many nested hashmaps vecs etc. - accesses: Vec, -} - -impl Display for ReflectionPath { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(&self.base.to_string())?; - for access in &self.accesses { - f.write_str(&access.to_string())? - } - Ok(()) - } -} - -impl ReflectionPath { - pub fn new(base: ReflectBase) -> Self { - Self { - base, - accesses: Vec::default(), - } - } - - /// Creates a new composite sub reflect - pub fn new_sub(&self, elem: ReflectionPathElement) -> Self { - let mut accesses = self.accesses.clone(); - - accesses.push(elem); - - Self { - accesses, - ..self.clone() - } - } - - /// Walks the path with the given reference as the base - fn walk_path<'a>(&self, ref_: &'a dyn Reflect) -> Result<&'a dyn Reflect, ReflectionError> { - let first = self.accesses.first().map(|s| s.sub_ref(ref_)); - - if let Some(first) = first { - if self.accesses.len() > 1 { - self.accesses[1..] - .iter() - .try_fold(first?, |a, access| access.sub_ref(a)) - } else { - first - } - } else { - Ok(ref_) - } - } - - /// Walks the path with the given mutable reference as the base. - fn walk_path_mut<'a>( - &self, - ref_: &'a mut dyn Reflect, - ) -> Result<&'a mut dyn Reflect, ReflectionError> { - if let Some(first) = self.accesses.first() { - if self.accesses.len() > 1 { - return self.accesses[1..] - .iter() - .try_fold(first.sub_ref_mut(ref_)?, |a, access| access.sub_ref_mut(a)); - } else { - first.sub_ref_mut(ref_) - } - } else { - Ok(ref_) - } - } - - pub fn get(&self, world_ptr: WorldPointer, f: F) -> Result - where - F: FnOnce(&dyn Reflect) -> O, - { - match &self.base { - ReflectBase::Component { comp, entity } => { - let g = world_ptr.read(); - - let entity_ref = - g.get_entity(*entity) - .ok_or_else(|| ReflectionError::InvalidBaseReference { - base: self.base.to_string(), - reason: "This entity does not exist".to_owned(), - })?; - - let ref_ = self.walk_path(comp.reflect(entity_ref).ok_or_else(|| { - ReflectionError::InvalidBaseReference { - base: self.base.to_string(), - reason: "Given component does not exist on this entity".to_owned(), - } - })?)?; - Ok(f(ref_)) - } - ReflectBase::Resource { res } => { - let g = world_ptr.read(); - - let ref_ = self.walk_path(res.reflect(&g).ok_or_else(|| { - ReflectionError::InvalidBaseReference { - base: self.base.to_string(), - reason: "Given resource does not exist in this world".to_owned(), - } - })?)?; - Ok(f(ref_)) - } - ReflectBase::ScriptOwned { val } => { - let g = val - .upgrade() - .expect("Trying to access cached value from previous frame"); - - let g = g.try_read().expect("Rust safety violation: attempted to borrow value {self:?} while it was already mutably borrowed"); - Ok(f(self.walk_path(&*g)?)) - } - } - } - - pub fn get_mut(&mut self, world_ptr: WorldPointer, f: F) -> Result - where - F: FnOnce(&mut dyn Reflect) -> O, - { - match &self.base { - ReflectBase::Component { comp, entity } => { - let mut g = world_ptr.write(); - - let mut e = g.entity_mut(*entity); - let ref_ = self.walk_path_mut( - comp.reflect_mut(&mut e) - .ok_or_else(|| ReflectionError::InvalidBaseReference { - base: self.base.to_string(), - reason: "Given component does not exist on this entity".to_owned(), - })? - .into_inner(), - )?; - Ok(f(ref_)) - } - ReflectBase::Resource { res } => { - let mut g = world_ptr.write(); - - let ref_ = self.walk_path_mut( - res.reflect_mut(&mut g) - .ok_or_else(|| ReflectionError::InvalidBaseReference { - base: self.base.to_string(), - reason: "Given resource does not exist in this world".to_owned(), - })? - .into_inner(), - )?; - Ok(f(ref_)) - } - ReflectBase::ScriptOwned { val } => { - let g = val - .upgrade() - .expect("Trying to access cached value from previous frame"); - let mut g = g.try_write().expect("Rust safety violation: attempted to borrow value {self:?} while it was already mutably borrowed"); - Ok(f(self.walk_path_mut(&mut *g)?)) - } - } - } -} diff --git a/crates/bevy_script_api/src/wrappers.rs b/crates/bevy_script_api/src/wrappers.rs deleted file mode 100644 index d2110b27..00000000 --- a/crates/bevy_script_api/src/wrappers.rs +++ /dev/null @@ -1,107 +0,0 @@ -#[macro_export] -macro_rules! ref_only_wrapper_methods { - ($type_:path, $wrapper_name: ident) => { - /// Creates a script reference pointing to the wrapped value. - /// - /// Depending on this value it may be a lua owned or reflect relative reference - pub fn reflect_ref( - &self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - ) -> $crate::script_ref::ReflectReference { - match self { - Self::Owned(val) => $crate::script_ref::ReflectReference::new_script_ref( - ::std::sync::Arc::downgrade(val), - world_ptr, - ), - Self::Ref(ref_) => ref_.clone(), - } - } - - pub fn new(b: $type_) -> Self { - Self::Owned(::std::sync::Arc::new($crate::parking_lot::RwLock::new(b))) - } - - pub fn new_ref(b: $crate::script_ref::ReflectReference) -> Self { - Self::Ref(b) - } - - /// Perform an operation on the base type and optionally retrieve something by value - /// may require a read lock on the world in case this is a reference - pub fn val(&self, accessor: F) -> Result - where - F: FnOnce(&$type_) -> G, - { - match self { - Self::Owned(v) => Ok(accessor(&v.read())), - Self::Ref(v) => v.get(|s| accessor(s.downcast_ref::<$type_>().unwrap())), - } - } - - pub fn val_mut(&mut self, accessor: F) -> Result - where - F: FnOnce(&mut $type_) -> G, - { - match self { - Self::Owned(v) => Ok(accessor(&mut *v.write())), - Self::Ref(v) => v.get_mut(|s| accessor(s.downcast_mut::<$type_>().unwrap())), - } - } - - /// Applies Self to another ReflectReference. - /// may require a write lock on the world - pub fn apply_self_to_base( - &self, - other: &mut $crate::script_ref::ReflectReference, - ) -> Result<(), $crate::error::ReflectionError> { - match self { - Self::Owned(v) => { - other.get_mut(|other| other.apply(&mut *v.write()))?; - Ok(()) - } - Self::Ref(v) => { - // if we are a ReflectReference, we have to be careful with borrows - // to avoid deadlock - // we take advantage of the fact we know the expected type - other.apply(v) - } - } - } - }; -} - -#[macro_export] -macro_rules! define_wrapper { - ($type_:path, $wrapper_name:ident) => { - #[allow(clippy::large_enum_variant)] - #[doc=concat!("A script wrapper for the type `",stringify!($type_),"`")] - #[derive(Clone)] - pub enum $wrapper_name { - Owned(::std::sync::Arc<$crate::parking_lot::RwLock<$type_>>), - Ref($crate::script_ref::ReflectReference), - } - }; -} - -#[macro_export] -macro_rules! make_script_wrapper { - ($type_:path as $wrapper_name:ident with Clone) => { - $crate::define_wrapper!($type_, $wrapper_name); - impl $wrapper_name { - $crate::ref_only_wrapper_methods!($type_, $wrapper_name); - - /// retrieves the underlying value by cloning it - pub fn inner(&self) -> Result<$type_, $crate::error::ReflectionError> - where - $type_: Clone, - { - self.val(|s| s.clone()) - } - } - }; - ($type_:path as $wrapper_name:ident) => { - $crate::define_wrapper!($type_, $wrapper_name); - impl $wrapper_name { - $crate::ref_only_wrapper_methods!($type_, $wrapper_name); - } - }; -} diff --git a/crates/languages/bevy_mod_scripting_lua/src/assets.rs b/crates/languages/bevy_mod_scripting_lua/src/assets.rs index 8c94f4e5..eeae93a0 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/assets.rs @@ -1,156 +1,156 @@ -use bevy::{ - asset::{io::Reader, Asset, AssetLoader, AsyncReadExt}, - reflect::TypePath, - utils::BoxedFuture, -}; -use bevy_mod_scripting_core::asset::CodeAsset; +// use bevy::{ +// asset::{io::Reader, Asset, AssetLoader, AsyncReadExt}, +// reflect::TypePath, +// utils::BoxedFuture, +// }; +// use bevy_mod_scripting_core::asset::CodeAsset; -use anyhow::Error; +// use anyhow::Error; -#[derive(Asset, TypePath, Debug)] -/// A lua code file in bytes -pub struct LuaFile { - pub bytes: Vec, -} +// #[derive(Asset, TypePath, Debug)] +// /// A lua code file in bytes +// pub struct LuaFile { +// pub bytes: Vec, +// } -impl CodeAsset for LuaFile { - fn bytes(&self) -> &[u8] { - self.bytes.as_slice() - } -} +// impl CodeAsset for LuaFile { +// fn bytes(&self) -> &[u8] { +// self.bytes.as_slice() +// } +// } -#[derive(Default)] -/// Asset loader for lua scripts -pub struct LuaLoader; +// #[derive(Default)] +// /// Asset loader for lua scripts +// pub struct LuaLoader; -fn old_lua_load<'a>( - bytes: &'a [u8], - load_context: &'a mut bevy::asset::LoadContext, -) -> BoxedFuture<'a, Result, Error>> { - match load_context.path().extension().map(|s| s.to_str().unwrap()) { - #[cfg(all(feature = "teal", debug_assertions))] - Some("tl") => { - use bevy::asset::io::file::FileAssetReader; - use std::fs; - use std::path::PathBuf; - use std::process::Command; +// fn old_lua_load<'a>( +// bytes: &'a [u8], +// load_context: &'a mut bevy::asset::LoadContext, +// ) -> BoxedFuture<'a, Result, Error>> { +// match load_context.path().extension().map(|s| s.to_str().unwrap()) { +// #[cfg(all(feature = "teal", debug_assertions))] +// Some("tl") => { +// use bevy::asset::io::file::FileAssetReader; +// use std::fs; +// use std::path::PathBuf; +// use std::process::Command; - let scripts_dir = &FileAssetReader::get_base_path() - .join("assets") - .join("scripts"); +// let scripts_dir = &FileAssetReader::get_base_path() +// .join("assets") +// .join("scripts"); - let temp_file_path = &std::env::temp_dir().join("bevy_mod_scripting.temp.lua"); - bevy::prelude::info!("tl file path {}", scripts_dir.to_str().unwrap()); - // optionally put the output in the /build folder - let build_dir_path: Option = - if load_context.path().starts_with("scripts/build/") { - Some( - load_context - .path() - .strip_prefix("scripts/") - .unwrap() - .to_owned(), - ) - } else if load_context.path().starts_with("scripts/") { - Some( - PathBuf::from("build/") - .join(load_context.path().strip_prefix("scripts/").unwrap()), - ) - } else { - None - }; +// let temp_file_path = &std::env::temp_dir().join("bevy_mod_scripting.temp.lua"); +// bevy::prelude::info!("tl file path {}", scripts_dir.to_str().unwrap()); +// // optionally put the output in the /build folder +// let build_dir_path: Option = +// if load_context.path().starts_with("scripts/build/") { +// Some( +// load_context +// .path() +// .strip_prefix("scripts/") +// .unwrap() +// .to_owned(), +// ) +// } else if load_context.path().starts_with("scripts/") { +// Some( +// PathBuf::from("build/") +// .join(load_context.path().strip_prefix("scripts/").unwrap()), +// ) +// } else { +// None +// }; - let full_path = &FileAssetReader::get_base_path() - .join("assets") - .join(load_context.path()); - bevy::log::info!( - "tl check {} : {}", - full_path.to_str().unwrap(), - scripts_dir.to_str().unwrap() - ); - if let Ok(e) = Command::new("tl") - .args(["check", full_path.to_str().unwrap()]) - .current_dir(scripts_dir) - .status() - { - if !e.success() { - return Box::pin(async move { - Err(Error::msg(format!( - "Teal file `{}` has errors", - load_context.path().to_str().unwrap() - ))) - }); - } - } else { - fs::remove_file(temp_file_path).expect("Something went wrong running `tl check`"); - panic!("Something went wrong running `tl check`"); - } +// let full_path = &FileAssetReader::get_base_path() +// .join("assets") +// .join(load_context.path()); +// bevy::log::info!( +// "tl check {} : {}", +// full_path.to_str().unwrap(), +// scripts_dir.to_str().unwrap() +// ); +// if let Ok(e) = Command::new("tl") +// .args(["check", full_path.to_str().unwrap()]) +// .current_dir(scripts_dir) +// .status() +// { +// if !e.success() { +// return Box::pin(async move { +// Err(Error::msg(format!( +// "Teal file `{}` has errors", +// load_context.path().to_str().unwrap() +// ))) +// }); +// } +// } else { +// fs::remove_file(temp_file_path).expect("Something went wrong running `tl check`"); +// panic!("Something went wrong running `tl check`"); +// } - if let Ok(e) = Command::new("tl") - .args([ - "gen", - full_path.to_str().unwrap(), - "-o", - temp_file_path.to_str().unwrap(), - ]) - .current_dir(scripts_dir) - .status() - { - if !e.success() { - return Box::pin(async move { - Err(Error::msg(format!( - "Teal file `{}` could not be compiled!", - load_context.path().to_str().unwrap() - ))) - }); - } - } else { - fs::remove_file(temp_file_path).expect("Something went wrong running `tl gen`"); - panic!("Something went wrong running `tl gen`") - } +// if let Ok(e) = Command::new("tl") +// .args([ +// "gen", +// full_path.to_str().unwrap(), +// "-o", +// temp_file_path.to_str().unwrap(), +// ]) +// .current_dir(scripts_dir) +// .status() +// { +// if !e.success() { +// return Box::pin(async move { +// Err(Error::msg(format!( +// "Teal file `{}` could not be compiled!", +// load_context.path().to_str().unwrap() +// ))) +// }); +// } +// } else { +// fs::remove_file(temp_file_path).expect("Something went wrong running `tl gen`"); +// panic!("Something went wrong running `tl gen`") +// } - if let Some(mut build_dir_path) = build_dir_path { - build_dir_path = scripts_dir.join(build_dir_path); - let _ = fs::create_dir_all(build_dir_path.parent().unwrap()); - let _ = fs::copy(temp_file_path, build_dir_path.with_extension("lua")); - } +// if let Some(mut build_dir_path) = build_dir_path { +// build_dir_path = scripts_dir.join(build_dir_path); +// let _ = fs::create_dir_all(build_dir_path.parent().unwrap()); +// let _ = fs::copy(temp_file_path, build_dir_path.with_extension("lua")); +// } - let lua_code = - fs::read_to_string(temp_file_path).expect("Could not find output lua file"); - fs::remove_file(temp_file_path).unwrap(); +// let lua_code = +// fs::read_to_string(temp_file_path).expect("Could not find output lua file"); +// fs::remove_file(temp_file_path).unwrap(); - Box::pin(async move { Ok(lua_code.as_bytes().into()) }) - } +// Box::pin(async move { Ok(lua_code.as_bytes().into()) }) +// } - _ => Box::pin(async move { Ok(bytes.into()) }), - } -} -impl AssetLoader for LuaLoader { - type Asset = LuaFile; - type Settings = (); - type Error = Error; +// _ => Box::pin(async move { Ok(bytes.into()) }), +// } +// } +// impl AssetLoader for LuaLoader { +// type Asset = LuaFile; +// type Settings = (); +// type Error = Error; - fn load<'a>( - &'a self, - reader: &'a mut Reader, //bytes: &'a [u8], - _settings: &'a (), - load_context: &'a mut bevy::asset::LoadContext, - ) -> bevy::asset::BoxedFuture<'a, Result> { - bevy::prelude::info!("lua loader invoked: {:#}", load_context.asset_path()); - Box::pin(async move { - let mut bytes = Vec::new(); - reader.read_to_end(&mut bytes).await?; - let bytes = old_lua_load(bytes.as_slice(), load_context).await?; - Ok(LuaFile { bytes }) //}) - }) - } +// fn load<'a>( +// &'a self, +// reader: &'a mut Reader, //bytes: &'a [u8], +// _settings: &'a (), +// load_context: &'a mut bevy::asset::LoadContext, +// ) -> bevy::asset::BoxedFuture<'a, Result> { +// bevy::prelude::info!("lua loader invoked: {:#}", load_context.asset_path()); +// Box::pin(async move { +// let mut bytes = Vec::new(); +// reader.read_to_end(&mut bytes).await?; +// let bytes = old_lua_load(bytes.as_slice(), load_context).await?; +// Ok(LuaFile { bytes }) //}) +// }) +// } - #[cfg(feature = "teal")] - fn extensions(&self) -> &[&str] { - &["lua", "tl"] - } - #[cfg(not(feature = "teal"))] - fn extensions(&self) -> &[&str] { - &["lua"] - } -} +// #[cfg(feature = "teal")] +// fn extensions(&self) -> &[&str] { +// &["lua", "tl"] +// } +// #[cfg(not(feature = "teal"))] +// fn extensions(&self) -> &[&str] { +// &["lua"] +// } +// } diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings.rs deleted file mode 100644 index d2b1691a..00000000 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! Lua specific traits and types relevant to binding rust types to Lua types - -// /// Trait for types which can be converted into a value representible in a scripting language from a reference, -// pub trait RefIntoLua: Reflect { -// fn ref_into_script_value(&self, ctxt: ScriptContext) -> ScriptValueType; -// } - -// /// Type data corresponding to the [`RefIntoScriptValue`] trait -// pub struct ReflectRefIntoScriptValue { -// pub ref_into_script_value: fn(&dyn Reflect, ctxt: ScriptContext) -> ScriptValueType, -// } - -// impl Clone for ReflectRefIntoScriptValue { -// fn clone(&self) -> Self { -// Self { -// ref_into_script_value: self.ref_into_script_value, -// } -// } -// } - -// /// Trait for types which be converted from a value representible in a scripting language to a reference to the original type. -// pub trait ScriptValueToRef: Reflect { -// fn script_value_to_ref(script_value: &ScriptValueType, ctxt: ScriptContext) -> &Self; -// } - -// /// Type data corresponding to the [`ScriptValueToRef`] trait -// pub struct ReflectScriptValueToRef { -// pub script_value_to_ref: -// fn(script_value: &ScriptValueType, ctxt: ScriptContext) -> &dyn Reflect, -// } - -// impl Clone for ReflectScriptValueToRef { -// fn clone(&self) -> Self { -// Self { -// script_value_to_ref: self.script_value_to_ref, -// } -// } -// } diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs new file mode 100644 index 00000000..bd4928b4 --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs @@ -0,0 +1,6 @@ +use bevy_mod_scripting_core::bindings::WorldCallbackAccess; + +pub mod traits; + +/// Lua UserData wrapper for [`bevy::ecs::world::World`] +pub struct LuaWorld(pub WorldCallbackAccess); diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/traits.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/traits.rs new file mode 100644 index 00000000..05e56111 --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/traits.rs @@ -0,0 +1,167 @@ +//! Set of traits used to define how types are turned into and from proxies in Lua. +//! Proxies can either be logical "copies" or owned "direct representations" of the instance, or references to one via the [`bevy_mod_scripting_core::bindings::ReflectReference`] construct. + +use bevy::reflect::{FromReflect, TypeRegistry}; +use bevy_mod_scripting_core::{ + allocator::ReflectAllocator, + bindings::{WorldAccessGuard, WorldAccessUnit, WorldAccessWrite}, + error::ReflectionError, + proxy::{Proxied, Proxy, RefMutProxy, RefProxy, Unproxy}, +}; +use tealr::mlu::mlua::{Error, FromLua, IntoLua, Lua, Value}; + +pub struct LuaProxy(pub Proxy); +pub struct LuaRefProxy(pub RefProxy); +pub struct LuaRefMutProxy(pub RefMutProxy); + +macro_rules! impl_lua_proxy { + ($ty:ident as $as:ident => $generic:tt) => { + impl<'w, 'c, $generic: Proxied + FromReflect + 'c> Unproxy<'w, 'c> for $ty<$generic> { + type Output = <$as<$generic> as Unproxy<'w, 'c>>::Output; + + fn collect_accesses( + &self, + guard: &WorldAccessGuard<'w>, + accesses: &mut bevy::utils::smallvec::SmallVec<[WorldAccessWrite<'w>; 1]>, + ) -> Result<(), ReflectionError> { + self.0.collect_accesses(guard, accesses) + } + + unsafe fn unproxy( + &'c mut self, + guard: &WorldAccessGuard<'w>, + accesses: &'c [WorldAccessUnit<'w>], + type_registry: &TypeRegistry, + allocator: &'c ReflectAllocator, + ) -> Result { + self.0.unproxy(guard, accesses, type_registry, allocator) + } + + fn accesses_len(&self) -> usize { + self.0.accesses_len() + } + } + + impl<'lua, $generic: Proxied + FromReflect> IntoLua<'lua> for $ty<$generic> + where + $generic::Proxy: IntoLua<'lua>, + { + fn into_lua(self, lua: &'lua Lua) -> Result, Error> { + self.0 .0.into_lua(lua) + } + } + + impl<'lua, $generic: Proxied + FromReflect> FromLua<'lua> for $ty<$generic> + where + $generic::Proxy: FromLua<'lua>, + { + fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result { + let inner: $generic::Proxy = $generic::Proxy::from_lua(value, lua)?; + let inner: $as<$generic> = $as::<$generic>(inner); + Ok(Self(inner)) + } + } + }; +} + +impl_lua_proxy!(LuaProxy as Proxy => T); +impl_lua_proxy!(LuaRefProxy as RefProxy => T); +impl_lua_proxy!(LuaRefMutProxy as RefMutProxy => T); + +#[cfg(test)] +mod test { + + use std::{cell::UnsafeCell, sync::Arc}; + + use bevy::{ecs::component::Component, reflect::Reflect}; + use bevy_mod_scripting_core::{ + allocator::ReflectAllocation, + bindings::{ReflectBase, ReflectBaseType, ReflectReference}, + }; + use tealr::mlu::mlua::{UserData, UserDataMethods}; + + use super::*; + + #[derive(Reflect, Component)] + struct Test(pub String); + + impl Test { + fn _set(&mut self, value: &Test) { + self.0 = value.0.clone(); + } + } + + impl Proxied for Test { + type Proxy = TestProxy; + } + + #[derive(Debug, Clone)] + struct TestProxy(ReflectReference); + + impl From for ReflectReference { + fn from(value: TestProxy) -> Self { + value.0 + } + } + + impl From for TestProxy { + fn from(value: ReflectReference) -> Self { + TestProxy(value) + } + } + + impl AsRef for TestProxy { + fn as_ref(&self) -> &ReflectReference { + &self.0 + } + } + impl<'lua> FromLua<'lua> for TestProxy { + fn from_lua( + value: Value<'lua>, + _lua: &'lua Lua, + ) -> tealr::mlu::mlua::prelude::LuaResult { + match value { + Value::UserData(ud) => { + if let Ok(s) = ud.borrow::() { + Ok(s.clone()) + } else { + panic!() + } + } + _ => panic!(), + } + } + } + + impl UserData for TestProxy { + fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) { + methods.add_method("set", |_lua, _self_, _val: LuaRefProxy| Ok(())) + } + } + + #[test] + pub fn test_call_set() { + let lua = Lua::new(); + let globals = lua.globals(); + let test = Test("test".to_string()); + let mut allocator = ReflectAllocator::default(); + let allocation_id = + allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(test)))); + let reflect_ref = ReflectReference { + base: ReflectBaseType { + type_id: std::any::TypeId::of::(), + base_id: ReflectBase::Owned(allocation_id), + }, + reflect_path: vec![], + }; + let proxy = TestProxy(reflect_ref); + globals.set("test", proxy).unwrap(); + lua.load( + r#" + test:set(test) + "#, + ) + .exec() + .unwrap(); + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/docs.rs b/crates/languages/bevy_mod_scripting_lua/src/docs.rs index bc0249e7..78504780 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/docs.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/docs.rs @@ -48,14 +48,14 @@ struct Fragment { builder: TypeWalkerBuilder, } -pub struct LuaDocFragment { +pub struct LuaDocumentationFragment { name: &'static str, walker: Vec, } /// A piece of lua documentation, /// Each piece is combined into one large documentation page, and also a single teal declaration file if the `teal` feature is enabled -impl LuaDocFragment { +impl LuaDocumentationFragment { pub fn new(name: &'static str, f: TypeWalkerBuilder) -> Self { Self { name, @@ -64,7 +64,7 @@ impl LuaDocFragment { } } -impl DocFragment for LuaDocFragment { +impl DocumentationFragment for LuaDocumentationFragment { fn name(&self) -> &'static str { self.name } @@ -74,7 +74,7 @@ impl DocFragment for LuaDocFragment { self } - fn gen_docs(self) -> Result<(), ScriptError> { + fn gen_docs(self) -> Result<(), Box> { let script_asset_path = &FileAssetReader::get_base_path() .join("assets") .join("scripts"); @@ -102,71 +102,47 @@ impl DocFragment for LuaDocFragment { }); // generate json file - let json = serde_json::to_string_pretty(&tw) - .map_err(|e| ScriptError::DocGenError(e.to_string()))?; - - // temporary fix for incompatibility in json formats - // json.remove(json.len() - 1); - // json.push_str(",\n\"tealr_version_used\": \"0.9.0-alpha3\",\n\"extra_page\": []\n}"); + let json = serde_json::to_string_pretty(&tw)?; let json_path = script_doc_dir.join(format!("{}.json", docs_name)); - File::create(json_path) - .and_then(|mut file| { - file.write_all(json.as_bytes())?; - file.flush() - }) - .map_err(|e| ScriptError::DocGenError(e.to_string()))?; - + (File::create(json_path).and_then(|mut file| { + file.write_all(json.as_bytes())?; + file.flush() + }))?; // generate doc config files if they don't exist if !script_doc_dir.join("tealr_doc_gen_config.json").exists() { let config_path = script_doc_dir.join("tealr_doc_gen_config.json"); - File::create(config_path) - .and_then(|mut file| file.write_all(DEFAULT_DOC_CONFIG(&docs_name).as_bytes())) - .map_err(|e| ScriptError::DocGenError(e.to_string()))?; + (File::create(config_path) + .and_then(|mut file| file.write_all(DEFAULT_DOC_CONFIG(&docs_name).as_bytes())))? } // generate docs - Command::new("tealr_doc_gen") + (Command::new("tealr_doc_gen") .current_dir(script_doc_dir) .args(["run"]) - .status() - .map_err(|e| ScriptError::DocGenError(e.to_string()))?; + .status())?; #[cfg(feature = "teal")] { // now manage the definition (d.tl) file let definition_directory = script_asset_path.join("types"); - fs::create_dir_all(&definition_directory).map_err(|e| { - ScriptError::DocGenError(format!( - "Could not create `{}` directories: {e}", - &definition_directory.display() - )) - })?; + (fs::create_dir_all(&definition_directory))?; let definition_file_path = script_doc_dir .join(&docs_name) .join("definitions") .join(docs_name + ".d.tl"); let output_definition_file_path = script_asset_path.join("types").join("types.d.tl"); - fs::copy(&definition_file_path, &output_definition_file_path).map_err(|e| { - ScriptError::DocGenError(format!( - "Could not copy definition file from `{}` to `{}`: {e}", - definition_file_path.display(), - output_definition_file_path.display() - )) - })?; + (fs::copy(&definition_file_path, &output_definition_file_path))?; // finally create a tlconfig.lua file if doesn't exist // we do this to avoid problems with varying teal configurations // keep em settings consistent everywhere let tl_config_path = script_asset_path.join("tlconfig.lua"); if !tl_config_path.exists() { - let mut tl_file = File::create(tl_config_path) - .map_err(|e| ScriptError::DocGenError(e.to_string()))?; - tl_file - .write_all(DEFAULT_TEAL_CONFIG.as_bytes()) - .map_err(|e| ScriptError::DocGenError(e.to_string()))?; + let mut tl_file = (File::create(tl_config_path))?; + (tl_file.write_all(DEFAULT_TEAL_CONFIG.as_bytes()))?; } } Ok(()) diff --git a/crates/languages/bevy_mod_scripting_lua/src/lib.rs b/crates/languages/bevy_mod_scripting_lua/src/lib.rs index 2d296163..0deea728 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/lib.rs @@ -1,188 +1,149 @@ -use crate::{ - assets::{LuaFile, LuaLoader}, - docs::LuaDocFragment, -}; -use bevy::{ecs::schedule::ScheduleLabel, prelude::*}; -use bevy_mod_scripting_core::{prelude::*, systems::*}; - -use std::sync::Mutex; -use std::{fmt, marker::PhantomData}; -use tealr::mlu::mlua::{prelude::*, Function}; - pub mod assets; -pub mod bindings; pub mod docs; pub mod util; +use bevy::{ + app::Plugin, + ecs::{entity::Entity, world::World}, +}; +use bevy_mod_scripting_core::{ + bindings::WorldCallbackAccess, + context::{ContextBuilder, ContextInitializer, ContextPreHandlingInitializer}, + error::ScriptError, + event::CallbackLabel, + handler::Args, + script::ScriptId, + ScriptingPlugin, +}; pub use tealr; +pub mod bindings; +use tealr::mlu::mlua::{Function, IntoLuaMulti, Lua}; pub mod prelude { - pub use crate::{ - assets::{LuaFile, LuaLoader}, - docs::{LuaDocFragment, TypeWalkerBuilder}, - tealr::{ - self, - mlu::{ - mlua::{self, prelude::*, Value}, - TealData, - }, + pub use crate::tealr::{ + self, + mlu::{ + mlua::{self, prelude::*, Value}, + TealData, }, - LuaEvent, LuaScriptHost, }; } -pub trait LuaArg: for<'lua> IntoLuaMulti<'lua> + Clone + Sync + Send + 'static {} - -impl IntoLuaMulti<'lua> + Clone + Sync + Send + 'static> LuaArg for T {} +pub trait LuaEventArg: Args + for<'l> IntoLuaMulti<'l> {} +impl IntoLuaMulti<'l>> LuaEventArg for T {} -#[derive(Clone, Event)] -/// A Lua Hook. The result of creating this event will be -/// a call to the lua script with the hook_name and the given arguments -pub struct LuaEvent { - pub hook_name: String, - pub args: A, - pub recipients: Recipients, +pub struct LuaScriptingPlugin IntoLuaMulti<'l>> { + pub scripting_plugin: ScriptingPlugin, } -impl fmt::Debug for LuaEvent { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("LuaEvent") - .field("hook_name", &self.hook_name) - .field("recipients", &self.recipients) - .finish() +impl Default for LuaScriptingPlugin { + fn default() -> Self { + LuaScriptingPlugin { + scripting_plugin: ScriptingPlugin { + context_assigner: None, + runtime_builder: None, + callback_handler: Some(lua_handler::), + context_builder: Some(ContextBuilder:: { + load: lua_context_load, + reload: lua_context_reload, + }), + }, + } } } -impl ScriptEvent for LuaEvent { - fn recipients(&self) -> &crate::Recipients { - &self.recipients +impl Plugin for LuaScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + self.scripting_plugin.build(app); } } -#[derive(Resource)] -/// Lua script host, enables Lua scripting. -pub struct LuaScriptHost { - _ph: PhantomData, +pub fn lua_context_load( + script_id: &ScriptId, + content: &[u8], + initializers: &[ContextInitializer], + pre_handling_initializers: &[ContextPreHandlingInitializer], + world: &mut World, + _: &mut (), +) -> Result { + #[cfg(feature = "unsafe_lua_modules")] + let context = unsafe { Lua::unsafe_new() }; + #[cfg(not(feature = "unsafe_lua_modules"))] + let mut context = Lua::new(); + + with_world(world, &mut context, |context| { + initializers + .iter() + .try_for_each(|init| init(script_id, context))?; + + pre_handling_initializers + .iter() + .try_for_each(|init| init(script_id, Entity::from_raw(0), context))?; + + context.load(content).exec()?; + Ok(()) + })?; + + Ok(context) } -impl Default for LuaScriptHost { - fn default() -> Self { - Self { - _ph: Default::default(), - } - } +pub fn lua_context_reload( + script: &ScriptId, + content: &[u8], + old_ctxt: &mut Lua, + initializers: &[ContextInitializer], + pre_handling_initializers: &[ContextPreHandlingInitializer], + world: &mut World, + _: &mut (), +) -> Result<(), ScriptError> { + *old_ctxt = lua_context_load( + script, + content, + initializers, + pre_handling_initializers, + world, + &mut (), + )?; + Ok(()) } -impl ScriptHost for LuaScriptHost { - type ScriptContext = Mutex; - type APITarget = Mutex; - type ScriptEvent = LuaEvent; - type ScriptAsset = LuaFile; - type DocTarget = LuaDocFragment; - - fn register_with_app_in_set(app: &mut App, schedule: impl ScheduleLabel, set: impl SystemSet) { - app.add_priority_event::() - .init_asset::() - .init_asset_loader::() - .init_resource::>() - .init_resource::>() - .init_resource::>() - .register_type::>() - .register_type::>() - .register_type::>() - // handle script insertions removal first - // then update their contexts later on script asset changes - .add_systems( - schedule, - ( - script_add_synchronizer::, - script_remove_synchronizer::, - script_hot_reload_handler::, - ) - .chain() - .in_set(set), - ); - } - - fn load_script( - &mut self, - script: &[u8], - script_data: &ScriptData, - providers: &mut APIProviders, - ) -> Result { - #[cfg(feature = "unsafe_lua_modules")] - let lua = unsafe { Lua::unsafe_new() }; - #[cfg(not(feature = "unsafe_lua_modules"))] - let lua = Lua::new(); - - // init lua api before loading script - let mut lua = Mutex::new(lua); - providers.attach_all(&mut lua)?; - - lua.get_mut() - .map_err(|e| ScriptError::FailedToLoad { - script: script_data.name.to_owned(), - msg: e.to_string(), - })? - .load(script) - .set_name(script_data.name) - .exec() - .map_err(|e| ScriptError::FailedToLoad { - script: script_data.name.to_owned(), - msg: e.to_string(), - })?; - - Ok(lua) - } - - fn setup_script( - &mut self, - script_data: &ScriptData, - ctx: &mut Self::ScriptContext, - providers: &mut APIProviders, - ) -> Result<(), ScriptError> { - providers.setup_all(script_data, ctx) - } +#[allow(clippy::too_many_arguments)] +pub fn lua_handler IntoLuaMulti<'l>>( + args: A, + entity: bevy::ecs::entity::Entity, + script_id: &ScriptId, + callback_label: &CallbackLabel, + context: &mut Lua, + pre_handling_initializers: &[ContextPreHandlingInitializer], + _: &mut (), + world: &mut bevy::ecs::world::World, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + with_world(world, context, |context| { + pre_handling_initializers + .iter() + .try_for_each(|init| init(script_id, entity, context))?; + + let handler: Function = match context.globals().raw_get(callback_label.as_ref()) { + Ok(handler) => handler, + // not subscribed to this event type + Err(_) => return Ok(()), + }; + + handler.call::<_, ()>(args)?; + Ok(()) + }) +} - fn handle_events<'a>( - &mut self, - world: &mut World, - events: &[Self::ScriptEvent], - ctxs: impl Iterator, &'a mut Self::ScriptContext)>, - _providers: &mut APIProviders, - ) { - ctxs.for_each(|(script_data, ctx)| { - let ctx = ctx.get_mut().expect("Poison error in context"); - - // event order is preserved, but scripts can't rely on any temporal - // guarantees when it comes to other scripts callbacks, - // at least for now. - let globals = ctx.globals(); - for event in events { - // check if this script should handle this event - if !event.recipients().is_recipient(&script_data) { - continue; - } - - let f: Function = match globals.raw_get(event.hook_name.clone()) { - Ok(f) => f, - Err(_) => continue, // not subscribed to this event - }; - - if let Err(error) = f.call::<_, ()>(event.args.clone()) { - let mut state: CachedScriptState = world.remove_resource().unwrap(); - - let (_, mut error_wrt, _) = state.event_state.get_mut(world); - - let error = ScriptError::RuntimeError { - script: script_data.name.to_owned(), - msg: error.to_string(), - }; - - error!("{}", error); - error_wrt.send(ScriptErrorEvent { error }); - world.insert_resource(state); - } - } - }); - } +/// Safely scopes world access for a lua context to the given closure's scope +pub fn with_world Result<(), ScriptError>>( + world: &mut World, + context: &mut Lua, + f: F, +) -> Result<(), ScriptError> { + WorldCallbackAccess::with_callback_access(world, |guard| { + context + .create_any_userdata(guard.clone()) + .and_then(|guard| context.globals().set("world", guard))?; + + f(context) + }) } diff --git a/crates/languages/bevy_mod_scripting_rhai/src/assets.rs b/crates/languages/bevy_mod_scripting_rhai/src/assets.rs deleted file mode 100644 index 4470cf59..00000000 --- a/crates/languages/bevy_mod_scripting_rhai/src/assets.rs +++ /dev/null @@ -1,44 +0,0 @@ -use bevy::{ - asset::{io::Reader, Asset, AssetLoader, AsyncReadExt, LoadContext}, - reflect::TypePath, -}; - -use bevy_mod_scripting_core::prelude::*; - -#[derive(Asset, Debug, TypePath)] -/// A rhai code file in bytes -pub struct RhaiFile { - pub bytes: Vec, -} - -impl CodeAsset for RhaiFile { - fn bytes(&self) -> &[u8] { - self.bytes.as_slice() - } -} - -#[derive(Default)] -/// Asset loader for lua scripts -pub struct RhaiLoader; - -impl AssetLoader for RhaiLoader { - type Asset = RhaiFile; - type Settings = (); - type Error = anyhow::Error; - fn load<'a>( - &'a self, - reader: &'a mut Reader, - _: &'a Self::Settings, - _: &'a mut LoadContext, - ) -> bevy::asset::BoxedFuture<'a, Result> { - Box::pin(async move { - let mut bytes = Vec::new(); - reader.read_to_end(&mut bytes).await?; - Ok(RhaiFile { bytes }) - }) - } - - fn extensions(&self) -> &[&str] { - &["rhai"] - } -} diff --git a/crates/languages/bevy_mod_scripting_rhai/src/docs.rs b/crates/languages/bevy_mod_scripting_rhai/src/docs.rs deleted file mode 100644 index 6fd312fe..00000000 --- a/crates/languages/bevy_mod_scripting_rhai/src/docs.rs +++ /dev/null @@ -1,17 +0,0 @@ -use bevy_mod_scripting_core::prelude::*; - -pub struct RhaiDocFragment; - -impl DocFragment for RhaiDocFragment { - fn merge(self, _o: Self) -> Self { - todo!() - } - - fn gen_docs(self) -> Result<(), ScriptError> { - todo!() - } - - fn name(&self) -> &'static str { - todo!() - } -} diff --git a/crates/languages/bevy_mod_scripting_rhai/src/lib.rs b/crates/languages/bevy_mod_scripting_rhai/src/lib.rs index 9d2020fc..fef8ede4 100644 --- a/crates/languages/bevy_mod_scripting_rhai/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_rhai/src/lib.rs @@ -1,192 +1,350 @@ -use crate::{ - assets::{RhaiFile, RhaiLoader}, - docs::RhaiDocFragment, +use bevy::{ + app::Plugin, + ecs::{entity::Entity, world::World}, }; -use bevy::{ecs::schedule::ScheduleLabel, prelude::*}; -use bevy_mod_scripting_core::{prelude::*, systems::*}; -use rhai::*; -use std::marker::PhantomData; +use bevy_mod_scripting_core::{ + bindings::WorldCallbackAccess, + context::{ContextAssigner, ContextBuilder, ContextInitializer, ContextPreHandlingInitializer}, + error::ScriptError, + event::CallbackLabel, + handler::Args, + script::ScriptId, + ScriptingPlugin, +}; +use rhai::{CallFnOptions, Engine, FnPtr, FuncArgs, Scope, AST}; -pub mod assets; -pub mod docs; pub use rhai; pub mod prelude { - pub use crate::{ - assets::{RhaiFile, RhaiLoader}, - docs::RhaiDocFragment, - RhaiContext, RhaiEvent, RhaiScriptHost, - }; pub use rhai; - pub use rhai::{Engine, FuncArgs}; + pub use rhai::FuncArgs; } -#[derive(Resource)] -pub struct RhaiScriptHost { - pub engine: Engine, - _ph: PhantomData, +pub trait RhaiEventArg: Args + FuncArgs {} +impl RhaiEventArg for T {} + +pub type RhaiRuntime = Engine; + +pub struct RhaiScriptContext { + pub ast: AST, + pub scope: Scope<'static>, } -#[allow(deprecated)] -impl Default for RhaiScriptHost { +pub struct RhaiScriptingPlugin { + pub scripting_plugin: ScriptingPlugin, +} + +impl Default for RhaiScriptingPlugin { fn default() -> Self { - let mut e = Engine::new(); - // prevent shadowing of `state`,`world` and `entity` in variable in scripts - e.on_def_var(|_, info, _| { - Ok(info.name() != "state" && info.name() != "world" && info.name() != "entity") - }); - - Self { - engine: e, - _ph: Default::default(), + RhaiScriptingPlugin { + scripting_plugin: ScriptingPlugin { + runtime_builder: Some(RhaiRuntime::new), + callback_handler: Some(rhai_callback_handler::), + context_assigner: None, + context_builder: Some(ContextBuilder { + load: rhai_context_load, + reload: rhai_context_reload, + }), + }, } } } -pub struct RhaiContext { - pub ast: AST, - pub scope: Scope<'static>, +impl Plugin for RhaiScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + self.scripting_plugin.build(app); + } } -#[derive(Clone, Event)] -/// A Rhai Hook. The result of creating this event will be -/// a call to the lua script with the hook_name and the given arguments -pub struct RhaiEvent { - pub hook_name: String, - pub args: A, - pub recipients: Recipients, +pub fn rhai_context_load( + script: &ScriptId, + content: &[u8], + initializers: &[ContextInitializer], + pre_handling_initializers: &[ContextPreHandlingInitializer], + world: &mut World, + runtime: &mut RhaiRuntime, +) -> Result { + let mut ast = runtime.compile(std::str::from_utf8(content)?)?; + ast.set_source(script.to_string()); + + let mut context = RhaiScriptContext { + ast, + scope: Scope::new(), + }; + with_world(world, &mut context, |mut context| { + initializers + .iter() + .try_for_each(|init| init(script, &mut context))?; + + pre_handling_initializers + .iter() + .try_for_each(|init| init(script, Entity::from_raw(0), &mut context))?; + + runtime.eval_ast_with_scope(&mut context.scope, &context.ast)?; + // do not invoke top level statements after the first time we run the script + context.ast.clear_statements(); + + Ok(()) + })?; + Ok(context) } -impl ScriptEvent for RhaiEvent { - fn recipients(&self) -> &crate::Recipients { - &self.recipients - } +pub fn rhai_context_reload( + script: &ScriptId, + content: &[u8], + context: &mut RhaiScriptContext, + initializers: &[ContextInitializer], + pre_handling_initializers: &[ContextPreHandlingInitializer], + world: &mut World, + runtime: &mut RhaiRuntime, +) -> Result<(), ScriptError> { + *context = rhai_context_load( + script, + content, + initializers, + pre_handling_initializers, + world, + runtime, + )?; + Ok(()) } -impl ScriptHost for RhaiScriptHost { - type ScriptContext = RhaiContext; - type ScriptEvent = RhaiEvent; - type ScriptAsset = RhaiFile; - type APITarget = Engine; - type DocTarget = RhaiDocFragment; - - fn register_with_app_in_set( - app: &mut bevy::prelude::App, - schedule: impl ScheduleLabel, - set: impl SystemSet, - ) { - app.add_priority_event::() - .init_asset::() - .init_asset_loader::() - .init_resource::>() - .init_resource::>() - .init_resource::>() - .register_type::>() - .register_type::>() - .register_type::>() - .add_systems( - schedule, - ( - script_add_synchronizer::, - script_remove_synchronizer::, - script_hot_reload_handler::, - ) - .chain() - .in_set(set), - ) - // setup engine - .add_systems( - Startup, - |mut providers: ResMut>, mut host: ResMut| { - providers - .attach_all(&mut host.engine) - .expect("Error in adding api's for rhai"); - }, - ); - } +#[allow(clippy::too_many_arguments)] +pub fn rhai_callback_handler( + args: A, + entity: Entity, + script_id: &ScriptId, + callback: &CallbackLabel, + context: &mut RhaiScriptContext, + pre_handling_initializers: &[ContextPreHandlingInitializer], + runtime: &mut RhaiRuntime, + world: &mut World, +) -> Result<(), ScriptError> { + with_world(world, context, |context| { + pre_handling_initializers + .iter() + .try_for_each(|init| init(script_id, entity, context))?; - fn setup_script( - &mut self, - script_data: &ScriptData, - ctx: &mut Self::ScriptContext, - providers: &mut APIProviders, - ) -> Result<(), ScriptError> { - providers.setup_all(script_data, ctx) - } + if context + .scope + .get_value::(callback.as_ref()) + .is_none() + { + // not subscribed to this handler + return Ok(()); + }; - fn load_script( - &mut self, - script: &[u8], - script_data: &ScriptData, - _: &mut APIProviders, - ) -> Result { - let mut scope = Scope::new(); - let mut ast = self - .engine - .compile( - std::str::from_utf8(script).map_err(|e| ScriptError::FailedToLoad { - script: script_data.name.to_owned(), - msg: e.to_string(), - })?, - ) - .map_err(|e| ScriptError::SyntaxError { - script: script_data.name.to_owned(), - msg: e.to_string(), - })?; - - ast.set_source(script_data.name); - - // persistent state for scripts - scope.push("state", Map::new()); - - Ok(RhaiContext { ast, scope }) - } + // we want the call to be able to impact the scope + let options = CallFnOptions::new().rewind_scope(false); + runtime.call_fn_with_options( + options, + &mut context.scope, + &context.ast, + callback.as_ref(), + args, + )?; + Ok(()) + }) +} - fn handle_events<'a>( - &mut self, - world: &mut World, - events: &[Self::ScriptEvent], - ctxs: impl Iterator, &'a mut Self::ScriptContext)>, - _providers: &mut APIProviders, - ) { - ctxs.for_each(|(fd, ctx)| { - for event in events.iter() { - // check if this script should handle this event - if !event.recipients().is_recipient(&fd) { - continue; - }; - - match self.engine.call_fn( - &mut ctx.scope, - &ctx.ast, - &event.hook_name, - event.args.clone(), - ) { - Ok(v) => v, - Err(e) => { - let mut state: CachedScriptState = world.remove_resource().unwrap(); - - match *e { - EvalAltResult::ErrorFunctionNotFound(..) => {} - _ => { - let (_, mut error_wrt, _) = state.event_state.get_mut(world); - - let error = ScriptError::RuntimeError { - script: fd.name.to_string(), - msg: e.to_string(), - }; - error!("{}", error); - error_wrt.send(ScriptErrorEvent { error }); - } - } - - world.insert_resource(state); - } - }; - } - - // executing this at the end here means we execute global statements exactly once - // all this method call does is set a variable on the AST to NONE so should not affect performance - ctx.ast.clear_statements(); - }); - } +pub fn with_world Result<(), ScriptError>>( + world: &mut World, + context: &mut RhaiScriptContext, + f: F, +) -> Result<(), ScriptError> { + WorldCallbackAccess::with_callback_access(world, |guard| { + context.scope.push("world", guard.clone()); + f(context) + }) } +// use crate::{ +// assets::{RhaiFile, RhaiLoader}, +// docs::RhaiDocFragment, +// }; +// use bevy::{ecs::schedule::ScheduleLabel, prelude::*}; +// use bevy_mod_scripting_core::{prelude::*, systems::*}; +// use rhai::*; +// use std::marker::PhantomData; + +// pub mod assets; +// pub mod docs; +// pub use rhai; +// pub mod prelude { +// pub use crate::{ +// assets::{RhaiFile, RhaiLoader}, +// docs::RhaiDocFragment, +// RhaiContext, RhaiEvent, RhaiScriptHost, +// }; +// pub use rhai; +// pub use rhai::{RhaiRuntime, FuncArgs}; +// } + +// #[derive(Resource)] +// pub struct RhaiScriptHost { +// pub RhaiRuntime: RhaiRuntime, +// _ph: PhantomData, +// } + +// #[allow(deprecated)] +// impl Default for RhaiScriptHost { +// fn default() -> Self { +// let mut e = RhaiRuntime::new(); +// // prevent shadowing of `state`,`world` and `entity` in variable in scripts +// e.on_def_var(|_, info, _| { +// Ok(info.name() != "state" && info.name() != "world" && info.name() != "entity") +// }); + +// Self { +// RhaiRuntime: e, +// _ph: Default::default(), +// } +// } +// } + +// pub struct RhaiContext { +// pub ast: AST, +// pub scope: Scope<'static>, +// } + +// #[derive(Clone, Event)] +// /// A Rhai Hook. The result of creating this event will be +// /// a call to the lua script with the hook_name and the given arguments +// pub struct RhaiEvent { +// pub hook_name: String, +// pub args: A, +// pub recipients: Recipients, +// } + +// impl ScriptEvent for RhaiEvent { +// fn recipients(&self) -> &crate::Recipients { +// &self.recipients +// } +// } + +// impl ScriptHost for RhaiScriptHost { +// type ScriptContext = RhaiContext; +// type ScriptEvent = RhaiEvent; +// type ScriptAsset = RhaiFile; +// type APITarget = RhaiRuntime; +// type DocTarget = RhaiDocFragment; + +// fn register_with_app_in_set( +// app: &mut bevy::prelude::App, +// schedule: impl ScheduleLabel, +// set: impl SystemSet, +// ) { +// app.add_priority_event::() +// .init_asset::() +// .init_asset_loader::() +// .init_resource::>() +// .init_resource::>() +// .init_resource::>() +// .register_type::>() +// .register_type::>() +// .register_type::>() +// .add_systems( +// schedule, +// ( +// script_add_synchronizer::, +// script_remove_synchronizer::, +// script_hot_reload_handler::, +// ) +// .chain() +// .in_set(set), +// ) +// // setup RhaiRuntime +// .add_systems( +// Startup, +// |mut providers: ResMut>, mut host: ResMut| { +// providers +// .attach_all(&mut host.RhaiRuntime) +// .expect("Error in adding api's for rhai"); +// }, +// ); +// } + +// fn setup_script( +// &mut self, +// script_data: &ScriptData, +// ctx: &mut Self::ScriptContext, +// providers: &mut APIProviders, +// ) -> Result<(), ScriptError> { +// providers.setup_all(script_data, ctx) +// } + +// fn load_script( +// &mut self, +// script: &[u8], +// script_data: &ScriptData, +// _: &mut APIProviders, +// ) -> Result { +// let mut scope = Scope::new(); +// let mut ast = self +// .RhaiRuntime +// .compile( +// std::str::from_utf8(script).map_err(|e| ScriptError::FailedToLoad { +// script: script_data.name.to_owned(), +// msg: e.to_string(), +// })?, +// ) +// .map_err(|e| ScriptError::SyntaxError { +// script: script_data.name.to_owned(), +// msg: e.to_string(), +// })?; + +// ast.set_source(script_data.name); + +// // persistent state for scripts +// scope.push("state", Map::new()); + +// Ok(RhaiContext { ast, scope }) +// } + +// fn handle_events<'a>( +// &mut self, +// world: &mut World, +// events: &[Self::ScriptEvent], +// ctxs: impl Iterator, &'a mut Self::ScriptContext)>, +// _providers: &mut APIProviders, +// ) { +// ctxs.for_each(|(fd, ctx)| { +// for event in events.iter() { +// // check if this script should handle this event +// if !event.recipients().is_recipient(&fd) { +// continue; +// }; + +// match self.RhaiRuntime.call_fn( +// &mut ctx.scope, +// &ctx.ast, +// &event.hook_name, +// event.args.clone(), +// ) { +// Ok(v) => v, +// Err(e) => { +// let mut state: CachedScriptState = world.remove_resource().unwrap(); + +// match *e { +// EvalAltResult::ErrorFunctionNotFound(..) => {} +// _ => { +// let (_, mut error_wrt, _) = state.event_state.get_mut(world); + +// let error = ScriptError::RuntimeError { +// script: fd.name.to_string(), +// msg: e.to_string(), +// }; +// error!("{}", error); +// error_wrt.send(ScriptErrorEvent { error }); +// } +// } + +// world.insert_resource(state); +// } +// }; +// } + +// // executing this at the end here means we execute global statements exactly once +// // all this method call does is set a variable on the AST to NONE so should not affect performance +// ctx.ast.clear_statements(); +// }); +// } +// } diff --git a/crates/languages/bevy_mod_scripting_rune/src/assets.rs b/crates/languages/bevy_mod_scripting_rune/src/assets.rs deleted file mode 100644 index 23be9f0f..00000000 --- a/crates/languages/bevy_mod_scripting_rune/src/assets.rs +++ /dev/null @@ -1,46 +0,0 @@ -use anyhow::Error; -use bevy::{ - asset::{io::Reader, Asset, AssetLoader, AsyncReadExt}, - reflect::TypePath, -}; -use bevy_mod_scripting_core::prelude::*; - -#[derive(Asset, TypePath, Debug)] -/// A loaded rune file in bytes. -pub struct RuneFile { - /// File content in bytes. - pub bytes: Vec, -} - -impl CodeAsset for RuneFile { - fn bytes(&self) -> &[u8] { - self.bytes.as_slice() - } -} - -#[derive(Default)] -/// Enables loading Rune scripts from `.rune` and `.rn` files. -pub struct RuneLoader; - -impl AssetLoader for RuneLoader { - type Asset = RuneFile; - type Settings = (); - type Error = Error; - - fn load<'a>( - &'a self, - reader: &'a mut Reader, - _settings: &'a (), - _load_context: &'a mut bevy::asset::LoadContext, - ) -> bevy::utils::BoxedFuture<'a, Result> { - Box::pin(async move { - let mut bytes = Vec::new(); - reader.read_to_end(&mut bytes).await?; - Ok(RuneFile { bytes }) - }) - } - - fn extensions(&self) -> &[&str] { - &["rune", "rn"] - } -} diff --git a/crates/languages/bevy_mod_scripting_rune/src/docs.rs b/crates/languages/bevy_mod_scripting_rune/src/docs.rs deleted file mode 100644 index bcd7a02e..00000000 --- a/crates/languages/bevy_mod_scripting_rune/src/docs.rs +++ /dev/null @@ -1,17 +0,0 @@ -use bevy_mod_scripting_core::prelude::*; - -pub struct RuneDocFragment; - -impl DocFragment for RuneDocFragment { - fn merge(self, _o: Self) -> Self { - todo!() - } - - fn gen_docs(self) -> Result<(), ScriptError> { - todo!() - } - - fn name(&self) -> &'static str { - todo!() - } -} diff --git a/crates/languages/bevy_mod_scripting_rune/src/lib.rs b/crates/languages/bevy_mod_scripting_rune/src/lib.rs index 20395b31..93e799be 100644 --- a/crates/languages/bevy_mod_scripting_rune/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_rune/src/lib.rs @@ -1,256 +1,291 @@ -use std::{marker::PhantomData, sync::Arc}; +use std::sync::Arc; -use bevy::prelude::*; -use bevy_mod_scripting_core::{ - prelude::*, - systems::{self, CachedScriptState}, -}; -use prelude::{RuneDocFragment, RuneFile, RuneLoader}; +use bevy_mod_scripting_core::ScriptingPlugin; use rune::{ - runtime::{Args, RuntimeContext, VmError, VmResult}, - Context, Diagnostics, Source, Sources, Unit, Vm, + runtime::{Args, RuntimeContext}, + Unit, Vm, }; -mod assets; -mod docs; - -pub mod prelude { - pub use crate::{ - assets::{RuneFile, RuneLoader}, - docs::RuneDocFragment, - RuneArgs, RuneEvent, RuneScriptContext, RuneScriptHost, - }; - pub use rune::{self, runtime::Args, Context}; -} - -/// Super trait adding additional bounds to Rune's `Args` trait. -/// It's gets automatically implemented for any type that implments `Args`, -/// so you should never have to manually implement it. -pub trait RuneArgs: Args + Clone + Send + Sync + 'static {} - -impl RuneArgs for T {} - -/// A Rune script hook. -#[derive(Debug, Clone, Event)] -pub struct RuneEvent { - /// The name of the Rune function to call. - pub hook_name: String, - /// The arguments to supply the function being invoked. If you - /// don't need any arguments, `()` is a good default value. - pub args: A, - /// The target set of scripts that should handle this event. - pub recipients: Recipients, -} - -impl ScriptEvent for RuneEvent { - fn recipients(&self) -> &Recipients { - &self.recipients - } -} - -/// A cached Rune Vm used to execute units. -struct RuneVm(Vm); +pub trait RuneEventArg: Args + Clone + Send + Sync + 'static {} +impl RuneEventArg for T {} -impl Default for RuneVm { - fn default() -> Self { - Self(Vm::new( - Arc::new(RuntimeContext::default()), - Arc::new(Unit::default()), - )) - } -} - -/// Script context for a rune script. pub struct RuneScriptContext { pub unit: Arc, pub runtime_context: Arc, } -#[derive(Resource)] -/// Rune script host. Enables Rune scripting. -pub struct RuneScriptHost { - _ph: PhantomData, +pub type RuneRuntime = Vm; + +pub struct RuneScriptingPlugin { + pub scripting_plugin: ScriptingPlugin, } -impl Default for RuneScriptHost { +impl Default for RuneScriptingPlugin { fn default() -> Self { Self { - _ph: Default::default(), + scripting_plugin: ScriptingPlugin { + runtime_builder: todo!(), + callback_handler: todo!(), + context_builder: todo!(), + context_assigner: todo!(), + }, } } } -impl RuneScriptHost { - /// Helper function to handle errors from a Rune virtual machine. - /// - #[cold] - fn handle_rune_error(world: &mut World, error: VmError, script_data: &ScriptData<'_>) { - let mut state: CachedScriptState = world.remove_resource().unwrap(); - - let (_, mut error_wrt, _) = state.event_state.get_mut(world); - - let error = ScriptError::RuntimeError { - script: script_data.name.to_owned(), - msg: error.to_string(), - }; - - error!("{}", error); - - error_wrt.send(ScriptErrorEvent { error }); - world.insert_resource(state); - } -} - -impl ScriptHost for RuneScriptHost { - type ScriptContext = RuneScriptContext; - - type ScriptEvent = RuneEvent; - - type ScriptAsset = RuneFile; - - type APITarget = Context; - - type DocTarget = RuneDocFragment; - - fn register_with_app_in_set( - app: &mut App, - schedule: impl bevy::ecs::schedule::ScheduleLabel, - set: impl SystemSet, - ) { - app.add_priority_event::() - .init_asset::() - .init_asset_loader::() - .init_resource::>() - .init_resource::>() - .init_resource::>() - .register_type::>() - .register_type::>() - .register_type::>() - // Add a cached Vm as a non-send resource. - .insert_non_send_resource(RuneVm::default()) - // handle script insertions removal first - // then update their contexts later on script asset changes - .add_systems( - schedule, - ( - systems::script_add_synchronizer::, - systems::script_remove_synchronizer::, - systems::script_hot_reload_handler::, - ) - .chain() - .in_set(set), - ); - } - - fn load_script( - &mut self, - script: &[u8], - script_data: &ScriptData, - providers: &mut APIProviders, - ) -> Result { - let mut context = rune_modules::default_context().map_err(ScriptError::new_other)?; - - // Rune requires that we tell it what modules and types we'll be using before - // it compiles a file. - providers.attach_all(&mut context).unwrap(); - - let mut diagnostics = Diagnostics::new(); - - let mut sources = Sources::new(); - sources - .insert( - Source::new( - script_data.name, - std::str::from_utf8(script).expect("Slice is not UTF-8"), - ) - .map_err(|msg| ScriptError::FailedToLoad { - script: script_data.name.into(), - msg: msg.to_string(), - })?, - ) - .map_err(|msg| ScriptError::FailedToLoad { - script: script_data.name.into(), - msg: msg.to_string(), - })?; - - let result = rune::prepare(&mut sources) - .with_context(&context) - .with_diagnostics(&mut diagnostics) - .build(); - - if !diagnostics.is_empty() { - let mut writer = rune::termcolor::Buffer::no_color(); - - diagnostics - .emit(&mut writer, &sources) - .expect("Failed to write diagnostics to buffer"); - - return Err(ScriptError::SyntaxError { - script: script_data.name.into(), - msg: std::str::from_utf8(writer.as_slice()) - .expect("Slice was not UTF-8") - .to_owned(), - }); - } - - let unit = result.expect("Failed to build Rune unit."); - - let runtime_ctx = context - .runtime() - .expect("Failed to create Rune runtime context."); - - Ok(RuneScriptContext { - unit: Arc::new(unit), - runtime_context: Arc::new(runtime_ctx), - }) - } - - fn setup_script( - &mut self, - script_data: &ScriptData, - ctx: &mut Self::ScriptContext, - providers: &mut APIProviders, - ) -> Result<(), ScriptError> { - providers.setup_all(script_data, ctx) - } - - fn handle_events<'a>( - &mut self, - world: &mut World, - events: &[Self::ScriptEvent], - ctxs: impl Iterator, &'a mut Self::ScriptContext)>, - _providers: &mut APIProviders, - ) { - // Grab the cached Vm. - let RuneVm(mut vm) = world.remove_non_send_resource::().unwrap(/* invariant */); - - { - ctxs.for_each(|(script_data, ctx)| { - for event in events { - if !event.recipients().is_recipient(&script_data) { - continue; - } - - // Swap out the old context and old unit with the new ones. - *vm.context_mut() = Arc::clone(&ctx.runtime_context); - *vm.unit_mut() = Arc::clone(&ctx.unit); - - let mut exec = match vm.execute([event.hook_name.as_str()], event.args.clone()) - { - Ok(exec) => exec, - Err(error) => { - Self::handle_rune_error(world, error, &script_data); - continue; - } - }; - - if let VmResult::Err(error) = exec.complete() { - Self::handle_rune_error(world, error, &script_data); - } - } - }); - } - - world.insert_non_send_resource(RuneVm(vm)); - } -} +// use std::{marker::PhantomData, sync::Arc}; + +// use bevy::prelude::*; +// use bevy_mod_scripting_core::{ +// prelude::*, +// systems::{self, CachedScriptState}, +// }; +// use prelude::{RuneDocFragment, RuneFile, RuneLoader}; +// use rune::{ +// runtime::{Args, RuntimeContext, VmError, VmResult}, +// Context, Diagnostics, Source, Sources, Unit, Vm, +// }; + +// mod assets; +// mod docs; + +// pub mod prelude { +// pub use crate::{ +// assets::{RuneFile, RuneLoader}, +// docs::RuneDocFragment, +// RuneArgs, RuneEvent, RuneScriptContext, RuneScriptHost, +// }; +// pub use rune::{self, runtime::Args, Context}; +// } + +// /// Super trait adding additional bounds to Rune's `Args` trait. +// /// It's gets automatically implemented for any type that implments `Args`, +// /// so you should never have to manually implement it. +// pub trait RuneArgs: Args + Clone + Send + Sync + 'static {} + +// impl RuneArgs for T {} + +// /// A Rune script hook. +// #[derive(Debug, Clone, Event)] +// pub struct RuneEvent { +// /// The name of the Rune function to call. +// pub hook_name: String, +// /// The arguments to supply the function being invoked. If you +// /// don't need any arguments, `()` is a good default value. +// pub args: A, +// /// The target set of scripts that should handle this event. +// pub recipients: Recipients, +// } + +// impl ScriptEvent for RuneEvent { +// fn recipients(&self) -> &Recipients { +// &self.recipients +// } +// } + +// /// A cached Rune Vm used to execute units. +// struct RuneVm(Vm); + +// impl Default for RuneVm { +// fn default() -> Self { +// Self(Vm::new( +// Arc::new(RuntimeContext::default()), +// Arc::new(Unit::default()), +// )) +// } +// } + +// /// Script context for a rune script. +// pub struct RuneScriptContext { +// pub unit: Arc, +// pub runtime_context: Arc, +// } + +// #[derive(Resource)] +// /// Rune script host. Enables Rune scripting. +// pub struct RuneScriptHost { +// _ph: PhantomData, +// } + +// impl Default for RuneScriptHost { +// fn default() -> Self { +// Self { +// _ph: Default::default(), +// } +// } +// } + +// impl RuneScriptHost { +// /// Helper function to handle errors from a Rune virtual machine. +// /// +// #[cold] +// fn handle_rune_error(world: &mut World, error: VmError, script_data: &ScriptData<'_>) { +// let mut state: CachedScriptState = world.remove_resource().unwrap(); + +// let (_, mut error_wrt, _) = state.event_state.get_mut(world); + +// let error = ScriptError::RuntimeError { +// script: script_data.name.to_owned(), +// msg: error.to_string(), +// }; + +// error!("{}", error); + +// error_wrt.send(ScriptErrorEvent { error }); +// world.insert_resource(state); +// } +// } + +// impl ScriptHost for RuneScriptHost { +// type ScriptContext = RuneScriptContext; + +// type ScriptEvent = RuneEvent; + +// type ScriptAsset = RuneFile; + +// type APITarget = Context; + +// type DocTarget = RuneDocFragment; + +// fn register_with_app_in_set( +// app: &mut App, +// schedule: impl bevy::ecs::schedule::ScheduleLabel, +// set: impl SystemSet, +// ) { +// app.add_priority_event::() +// .init_asset::() +// .init_asset_loader::() +// .init_resource::>() +// .init_resource::>() +// .init_resource::>() +// .register_type::>() +// .register_type::>() +// .register_type::>() +// // Add a cached Vm as a non-send resource. +// .insert_non_send_resource(RuneVm::default()) +// // handle script insertions removal first +// // then update their contexts later on script asset changes +// .add_systems( +// schedule, +// ( +// systems::script_add_synchronizer::, +// systems::script_remove_synchronizer::, +// systems::script_hot_reload_handler::, +// ) +// .chain() +// .in_set(set), +// ); +// } + +// fn load_script( +// &mut self, +// script: &[u8], +// script_data: &ScriptData, +// providers: &mut APIProviders, +// ) -> Result { +// let mut context = rune_modules::default_context().map_err(ScriptError::new_other)?; + +// // Rune requires that we tell it what modules and types we'll be using before +// // it compiles a file. +// providers.attach_all(&mut context).unwrap(); + +// let mut diagnostics = Diagnostics::new(); + +// let mut sources = Sources::new(); +// sources +// .insert( +// Source::new( +// script_data.name, +// std::str::from_utf8(script).expect("Slice is not UTF-8"), +// ) +// .map_err(|msg| ScriptError::FailedToLoad { +// script: script_data.name.into(), +// msg: msg.to_string(), +// })?, +// ) +// .map_err(|msg| ScriptError::FailedToLoad { +// script: script_data.name.into(), +// msg: msg.to_string(), +// })?; + +// let result = rune::prepare(&mut sources) +// .with_context(&context) +// .with_diagnostics(&mut diagnostics) +// .build(); + +// if !diagnostics.is_empty() { +// let mut writer = rune::termcolor::Buffer::no_color(); + +// diagnostics +// .emit(&mut writer, &sources) +// .expect("Failed to write diagnostics to buffer"); + +// return Err(ScriptError::SyntaxError { +// script: script_data.name.into(), +// msg: std::str::from_utf8(writer.as_slice()) +// .expect("Slice was not UTF-8") +// .to_owned(), +// }); +// } + +// let unit = result.expect("Failed to build Rune unit."); + +// let runtime_ctx = context +// .runtime() +// .expect("Failed to create Rune runtime context."); + +// Ok(RuneScriptContext { +// unit: Arc::new(unit), +// runtime_context: Arc::new(runtime_ctx), +// }) +// } + +// fn setup_script( +// &mut self, +// script_data: &ScriptData, +// ctx: &mut Self::ScriptContext, +// providers: &mut APIProviders, +// ) -> Result<(), ScriptError> { +// providers.setup_all(script_data, ctx) +// } + +// fn handle_events<'a>( +// &mut self, +// world: &mut World, +// events: &[Self::ScriptEvent], +// ctxs: impl Iterator, &'a mut Self::ScriptContext)>, +// _providers: &mut APIProviders, +// ) { +// // Grab the cached Vm. +// let RuneVm(mut vm) = world.remove_non_send_resource::().unwrap(/* invariant */); + +// { +// ctxs.for_each(|(script_data, ctx)| { +// for event in events { +// if !event.recipients().is_recipient(&script_data) { +// continue; +// } + +// // Swap out the old context and old unit with the new ones. +// *vm.context_mut() = Arc::clone(&ctx.runtime_context); +// *vm.unit_mut() = Arc::clone(&ctx.unit); + +// let mut exec = match vm.execute([event.hook_name.as_str()], event.args.clone()) +// { +// Ok(exec) => exec, +// Err(error) => { +// Self::handle_rune_error(world, error, &script_data); +// continue; +// } +// }; + +// if let VmResult::Err(error) = exec.complete() { +// Self::handle_rune_error(world, error, &script_data); +// } +// } +// }); +// } + +// world.insert_non_send_resource(RuneVm(vm)); +// } +// } diff --git a/examples/lua/event_recipients.rs b/examples/lua/event_recipients.rs index 3a8a75e1..2d4272f5 100644 --- a/examples/lua/event_recipients.rs +++ b/examples/lua/event_recipients.rs @@ -1,134 +1,71 @@ -use bevy::prelude::*; +use bevy::{app::AppExit, core::FrameCount, prelude::*}; use bevy_mod_scripting::prelude::*; -use rand::prelude::SliceRandom; -use std::sync::atomic::Ordering::Relaxed; -use std::sync::{atomic::AtomicU32, Mutex}; - -#[derive(Clone)] -pub struct MyLuaArg(usize); - -impl<'lua> IntoLua<'lua> for MyLuaArg { - fn into_lua(self, lua: &'lua Lua) -> mlua::Result> { - self.0.into_lua(lua) - } -} - -#[derive(Default)] -pub struct LuaAPIProvider; - -/// the custom Lua api, world is provided via a global pointer, -/// and callbacks are defined only once at script creation -impl APIProvider for LuaAPIProvider { - type APITarget = Mutex; - type DocTarget = LuaDocFragment; - type ScriptContext = Mutex; - - fn attach_api(&mut self, ctx: &mut Self::APITarget) -> Result<(), ScriptError> { - // callbacks can receive any `ToLuaMulti` arguments, here '()' and - // return any `FromLuaMulti` arguments, here a `usize` - // check the Rlua documentation for more details - - let ctx = ctx.get_mut().unwrap(); - - ctx.globals() - .set( - "print", - ctx.create_function(|_ctx, msg: String| { - info!("{}", msg); - Ok(()) - }) - .map_err(ScriptError::new_other)?, - ) - .map_err(ScriptError::new_other)?; - - Ok(()) - } - - fn setup_script( - &mut self, - script_data: &ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), ScriptError> { - let ctx = ctx.get_mut().unwrap(); - let globals = ctx.globals(); - globals - .set("script_id", script_data.sid) - .map_err(ScriptError::new_other)?; - Ok(()) - } +use bevy_mod_scripting_core::{ + asset::ScriptAsset, script::ScriptComponent, AddContextPreHandlingInitializer, +}; + +fn load_script( + server: Res, + mut commands: Commands, + mut handle: Local>, +) { + let path = "scripts/event_recipients.lua"; + let handle_ = server.load::(path); + *handle = handle_; + + commands.spawn(ScriptComponent::new(vec![ + "scripts/event_recipients.lua".into() + ])); + commands.spawn(ScriptComponent::new(vec![ + "scripts/event_recipients.lua".into() + ])); } -static COUNTER: AtomicU32 = AtomicU32::new(0); - -/// utility for generating random events from a list -fn fire_random_event(w: &mut PriorityEventWriter>, events: &[ScriptEventData]) { - let mut rng = rand::thread_rng(); - let id = COUNTER.fetch_add(1, Relaxed); - let arg = MyLuaArg(id as usize); - let event = events - .choose(&mut rng) - .map(|v| LuaEvent { - hook_name: v.0.to_string(), - args: arg, - recipients: v.1.clone(), - }) - .unwrap(); - - info!( - "\t - event: {},\t recipients: {:?},\t id: {}", - event.hook_name, event.recipients, id - ); - w.send(event, 0); +fn trigger_script_callback(mut writer: EventWriter>) { + writer.send(ScriptCallbackEvent::new_for_all( + OnEventCallback::into_callback_label(), + 1, + )); + + writer.send(ScriptCallbackEvent::new( + OnEventCallback::into_callback_label(), + 2, + Recipients::Entity(Entity::from_raw(1)), + )); } -fn do_update(mut w: PriorityEventWriter>) { - info!("Update, firing:"); - - let all_events = [ - ScriptEventData("on_event", Recipients::All), - ScriptEventData("on_event", Recipients::ScriptID(0)), - ScriptEventData("on_event", Recipients::ScriptID(1)), - ScriptEventData( - "on_event", - Recipients::ScriptName("scripts/event_recipients.lua".to_owned()), - ), - ]; - - // fire random event, for any of the system sets - fire_random_event(&mut w, &all_events); +fn quit_after_few_frames(mut exit: EventWriter, count: Res) { + if count.0 > 5 { + exit.send(AppExit); + } } -#[derive(Clone)] -pub struct ScriptEventData(&'static str, Recipients); - -fn load_our_scripts(server: Res, mut commands: Commands) { - // spawn two identical scripts - // id's will be 0 and 1 - let path = "scripts/event_recipients.lua"; - let handle = server.load::(path); - let scripts = (0..2) - .map(|_| Script::::new(path.to_string(), handle.clone())) - .collect(); - - commands - .spawn(()) - .insert(ScriptCollection:: { scripts }); +pub struct OnEventCallback; +impl IntoCallbackLabel for OnEventCallback { + fn into_callback_label() -> CallbackLabel { + "on_event".into() + } } fn main() -> std::io::Result<()> { let mut app = App::new(); app.add_plugins(DefaultPlugins) - .add_plugins(ScriptingPlugin) - .add_systems(Startup, load_our_scripts) - // randomly fire events for either all scripts, - // the script with id 0 - // or the script with id 1 - .add_systems(Update, do_update) - .add_script_handler::, 0, 0>(PostUpdate) - .add_script_host::>(PostUpdate) - .add_api_provider::>(Box::new(LuaAPIProvider)); - app.run(); + .add_plugins(LuaScriptingPlugin::::default()) + .add_context_pre_handling_initializer(|_, e, ctx: &mut Lua| { + ctx.globals().set("entity", format!("{e:?}")).unwrap(); + Ok(()) + }) + .add_systems(Startup, load_script) + .add_systems( + Update, + ( + trigger_script_callback, + event_handler::.after(trigger_script_callback), + quit_after_few_frames, + ), + ) + .run(); Ok(()) } diff --git a/src/documentation/main.rs b/src/documentation/main.rs index d7802bea..f210b0bc 100644 --- a/src/documentation/main.rs +++ b/src/documentation/main.rs @@ -6,7 +6,7 @@ fn main() { let args: Vec = env::args().collect(); let mut app = App::new(); app.add_plugins(MinimalPlugins) - .add_plugins(ScriptingPlugin) + // .add_plugins(ScriptingPlugin) .add_plugins(AssetPlugin::default()); static INVALID_ARGUMENT_WARNING: &str = "Expected one of: 'lua','rhai' as arguments"; diff --git a/src/lib.rs b/src/lib.rs index 82d53079..a4f7c1bd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ pub mod rhai { #[cfg(feature = "rhai_script_api")] pub mod api { - pub use bevy_script_api::rhai::*; + // pub use bevy_script_api::rhai::*; } } @@ -40,11 +40,11 @@ pub mod prelude { #[cfg(feature = "lua")] pub use bevy_mod_scripting_lua::prelude::*; - #[cfg(feature = "rhai")] - pub use bevy_mod_scripting_rhai::prelude::*; + // #[cfg(feature = "rhai")] + // pub use bevy_mod_scripting_rhai::prelude::*; - #[cfg(feature = "rune")] - pub use bevy_mod_scripting_rune::prelude::*; + // #[cfg(feature = "rune")] + // pub use bevy_mod_scripting_rune::prelude::*; #[cfg(any(feature = "lua_script_api", feature = "rhai_script_api"))] pub use bevy_script_api::prelude::*; From 55f3a6bb2f11c33462a4db068c75c31ec280e72c Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 20 Apr 2024 18:34:03 +0100 Subject: [PATCH 08/17] adjust macro to use new type system --- crates/bevy_mod_scripting_common/src/input.rs | 622 +---------------- .../bevy_mod_scripting_core/src/bindings.rs | 43 +- crates/bevy_mod_scripting_core/src/proxy.rs | 577 +++++++++++----- .../bevy_mod_scripting_lua/Cargo.toml | 2 + .../src/bindings/mod.rs | 7 +- .../src/bindings/providers/mod.rs | 19 + .../src/bindings/{traits.rs => proxy.rs} | 82 ++- .../src/bindings/world.rs | 70 ++ .../bevy_mod_scripting_lua/src/util.rs | 45 ++ .../bevy_mod_scripting_lua_derive/src/arg.rs | 117 ---- .../src/function.rs | 601 ----------------- .../bevy_mod_scripting_lua_derive/src/lib.rs | 625 +++++------------- .../src/signature.rs | 143 ---- .../src/visitor.rs | 386 ----------- 14 files changed, 828 insertions(+), 2511 deletions(-) create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/providers/mod.rs rename crates/languages/bevy_mod_scripting_lua/src/bindings/{traits.rs => proxy.rs} (62%) create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs delete mode 100644 crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs delete mode 100644 crates/languages/bevy_mod_scripting_lua_derive/src/function.rs delete mode 100644 crates/languages/bevy_mod_scripting_lua_derive/src/signature.rs delete mode 100644 crates/languages/bevy_mod_scripting_lua_derive/src/visitor.rs diff --git a/crates/bevy_mod_scripting_common/src/input.rs b/crates/bevy_mod_scripting_common/src/input.rs index 57aaac37..8200dc38 100644 --- a/crates/bevy_mod_scripting_common/src/input.rs +++ b/crates/bevy_mod_scripting_common/src/input.rs @@ -1,548 +1,47 @@ -use darling::{util::Flag, FromDeriveInput, FromMeta}; +use darling::{FromDeriveInput, FromMeta}; use proc_macro2::Ident; -use quote::format_ident; -use std::{ - collections::HashMap, - ops::{Deref, DerefMut}, - str::FromStr, -}; -use strum::{Display, EnumString}; -use syn::{ - punctuated::Punctuated, - spanned::Spanned, - token::{And, Gt, Lt, Mut, PathSep}, - visit_mut::VisitMut, - AngleBracketedGenericArguments, Attribute, Error, Field, Fields, GenericArgument, PatType, - Path, PathArguments, PathSegment, Receiver, TraitItemFn, Type, TypePath, TypeReference, - TypeTuple, Variant, -}; +use std::ops::{Deref, DerefMut}; +use syn::{spanned::Spanned, visit_mut::VisitMut, Attribute, Field, TraitItemFn, Variant}; -use crate::utils::ident_to_type_path; +#[derive(FromMeta)] +pub struct BMSCorePath(pub syn::Path); -/// Flags which detail required functionality or additional derivation requirements -#[derive(Debug, FromMeta, Default)] -pub struct ProxyFlags { - pub clone: Flag, -} - -/// 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 { - Struct { fields: Fields }, -} - -/// 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 std_type_ident: Option, - pub ident: Ident, - pub colon2_token: Option, - pub lt_token: Lt, - pub gt_token: Gt, - 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 std_type_ident: Option, - 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 { - pub and_token: And, - pub mutability: Option, - pub inner: Box, -} - -/// 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_path: Path, - pub proxy_ident: 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 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` - 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), -} - -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_path: &Path, - proxied_to_proxy_ident_map: &HashMap>, - ) -> 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(TypePath { - qself: None, - path: proxied_type_path.clone(), - }), - proxied_type_path, - proxied_to_proxy_ident_map, - )?); - Ok(Self::Reference(Reference { - and_token: *and, - mutability, - inner, - })) - } - None => Self::new_from_contextual_type( - proxy_prefix, - &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_path, - proxied_to_proxy_ident_map, - ), - } - } - - /// 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, - proxied_to_proxy_ident_map: &HashMap>, - ) -> Result { - Self::new_from_type( - proxy_prefix, - proxied_type, - None, - proxied_to_proxy_ident_map, - false, - ) - } - - pub fn new_from_fully_specified_type_proxy_all( - proxy_prefix: &'static str, - proxied_type: &Type, - ) -> Result { - Self::new_from_type(proxy_prefix, proxied_type, None, &Default::default(), true) - } - - /// 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, - proxied_type: &Type, - proxied_type_path: &Path, - proxied_to_proxy_ident_map: &HashMap>, - ) -> Result { - Self::new_from_type( - proxy_prefix, - proxied_type, - 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, - ) - } - - /// 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_path: Path, - proxied_to_proxy_ident_map: &HashMap>, - proxy_prefix_all: bool, - ) -> SimpleType { - 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 - .cloned() - .flatten() - .unwrap_or_else(|| format_ident!("{proxy_prefix}{}", last_segment)); - - SimpleType::ProxyType(ProxyType { - proxied_path, - proxy_ident, - }) - } else { - 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. - /// 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_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_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_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, - 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_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(), - ident: last_segment.ident.clone(), - colon2_token: args.colon2_token, - lt_token: args.lt_token, - gt_token: args.gt_token, - 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_path, - proxied_to_proxy_ident_map, - proxy_prefix_all, - )?); - let right = Box::new(Self::new_from_type( - proxy_prefix, - right, - 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(), - ident: last_segment.ident.clone(), - colon2_token: args.colon2_token, - lt_token: args.lt_token, - gt_token: args.gt_token, - left, - right, - })); - } - } - } - Err(Error::new_spanned( - proxied_type, - "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_path, - proxied_to_proxy_ident_map, - proxy_prefix_all, - )?), - })), - Type::Infer(_) => Ok(SimpleType::Type(proxied_type.clone())), - Type::Tuple(TypeTuple { elems, .. }) if elems.is_empty() => Ok(SimpleType::Unit), - t => Ok(SimpleType::Type(t.clone())), - } - } - - /// 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()) - } - - /// 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, - } - } - - /// 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, - } +impl Default for BMSCorePath { + fn default() -> Self { + Self(syn::parse_quote!(bevy_mod_scripting::core)) } } -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 { - 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), - } - } - 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, _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, _is_child_of_reference: bool) -> T { - self.visit_simple_type(&reference.inner, true) - } - 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 { - /// 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, - } - } -} - -impl VisitSimpleType for TypeConstructorVisitor { - 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, _: bool) -> 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, false), - )]), - gt_token: unit_path.gt_token, - }), - } - .into(), - }) - } - - 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, - 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), - ]), - gt_token: duo_path.gt_token, - }), - } - .into(), - }) - } - - 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 { - Type::Path(TypePath { - qself: None, - path: proxy_type.proxied_path.clone(), - }) - } - } +#[derive(FromMeta)] +pub struct BMSLuaPath(pub syn::Path); - fn visit_type(&mut self, _type: &Type, _: bool) -> Type { - _type.clone() - } - - fn visit_reference(&mut self, reference: &Reference, _: bool) -> Type { - if self.strip_outer_ref { - 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, true)), - }) - } +impl Default for BMSLuaPath { + fn default() -> Self { + Self(syn::parse_quote!(bevy_mod_scripting::lua)) } } #[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 + /// The name of the type for which we are generating a proxy (target type) pub ident: syn::Ident, + /// The visibility of the target type + pub vis: syn::Visibility, + /// The generics on the target type + pub generics: syn::Generics, pub attrs: Vec, + /// The path to the type for which we are generating a proxy if it's a foreign type pub remote: Option, + + /// The path to the bevy_mod_scripting_core crate + #[darling(default)] + pub bms_core_path: BMSCorePath, + /// The path to the bevy_mod_scripting_lua crate + #[darling(default)] + pub bms_lua_path: BMSLuaPath, + /// 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")] @@ -551,10 +50,6 @@ pub struct ProxyInput { /// 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 - #[darling(default)] - pub derive: ProxyFlags, - /// A list of multi-lang function definitions to be generated on the proxy type #[darling(default)] pub functions: TraitItemFnsWrapper, @@ -610,66 +105,3 @@ 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_path: syn::Ident::new("T", proc_macro2::Span::call_site()).into(), - 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_path: syn::Ident::new("T", proc_macro2::Span::call_site()).into(), - 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/crates/bevy_mod_scripting_core/src/bindings.rs b/crates/bevy_mod_scripting_core/src/bindings.rs index 2dbd3c06..b4121382 100644 --- a/crates/bevy_mod_scripting_core/src/bindings.rs +++ b/crates/bevy_mod_scripting_core/src/bindings.rs @@ -8,6 +8,7 @@ use lockable::LockableHashMap; use std::{ any::TypeId, + fmt::Debug, marker::PhantomData, sync::{Arc, Weak}, time::Duration, @@ -44,6 +45,15 @@ pub struct ReflectAccessId { id: usize, } +impl From for ReflectAccessId { + fn from(value: ComponentId) -> Self { + Self { + kind: ReflectAccessKind::ComponentOrResource, + id: value.index(), + } + } +} + impl ReflectAccessId { pub fn new_component_or_resource_id(id: ComponentId) -> Self { Self { @@ -59,7 +69,7 @@ impl ReflectAccessId { } } } -/// While [`WorldAccessGuard`] prevents aliasing at runtime and also makes sure world exists as long as the guard itself, +/// While [`WorldAccessGuard`] prevents aliasing at runtime and also makes sure world exists at least as long as the guard itself, /// borrows sadly do not persist the script-host boundary :(. That is to be expected, but instead we can make an abstraction which removes the lifetime parameter, making the outer type 'static, /// while making sure the lifetime is still satisfied! #[derive(Clone)] @@ -382,7 +392,7 @@ impl<'w> WorldAccessWrite<'w> { /// An accessor to a `dyn Reflect` struct, stores a base ID of the type and a reflection path /// safe to build but to reflect on the value inside you need to ensure aliasing rules are upheld -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ReflectReference { pub base: ReflectBaseType, // TODO: experiment with Fixed capacity vec, boxed array etc, compromise between heap allocation and runtime cost @@ -611,7 +621,7 @@ impl ReflectReference { } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct ReflectBaseType { pub type_id: TypeId, pub base_id: ReflectBase, @@ -635,7 +645,7 @@ impl ReflectBaseType { } /// The Id of the kind of reflection base being pointed to -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum ReflectBase { Component(Entity, ComponentId), Resource(ComponentId), @@ -696,7 +706,7 @@ impl ReflectBase { } /// An element in the reflection path, the base reference included -#[derive(Clone)] +#[derive(Clone, PartialEq, Eq, Debug)] pub enum ReflectionPathElem { /// A standard reflection path, i.e. `.field_name[vec_index]`, pre-parsed since we construct once potentially use many times Reflection(ParsedPath), @@ -704,15 +714,6 @@ pub enum ReflectionPathElem { DeferredReflection(DeferredReflection), } -impl std::fmt::Debug for ReflectionPathElem { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Reflection(arg0) => f.debug_tuple("Reflection").field(arg0).finish(), - Self::DeferredReflection(_) => f.write_str("DeferredReflection"), - } - } -} - impl<'a> ReflectPath<'a> for &'a ReflectionPathElem { fn reflect_element<'r>( self, @@ -746,6 +747,20 @@ pub struct DeferredReflection { >, } +impl Debug for DeferredReflection { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str("DeferredReflection") + } +} + +impl PartialEq for DeferredReflection { + fn eq(&self, other: &Self) -> bool { + Arc::ptr_eq(&self.get, &other.get) && Arc::ptr_eq(&self.get_mut, &other.get_mut) + } +} + +impl Eq for DeferredReflection {} + #[cfg(test)] mod test { diff --git a/crates/bevy_mod_scripting_core/src/proxy.rs b/crates/bevy_mod_scripting_core/src/proxy.rs index e8f9f55e..7e39b437 100644 --- a/crates/bevy_mod_scripting_core/src/proxy.rs +++ b/crates/bevy_mod_scripting_core/src/proxy.rs @@ -1,6 +1,9 @@ //! Set of traits used to define how types are turned into and from proxies in Lua. //! Proxies can either be logical "copies" or owned "direct representations" of the instance, or references to one via the [`bevy_mod_scripting_core::bindings::ReflectReference`] construct. -use std::num::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; +use std::{ + marker::PhantomData, + num::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}, +}; use bevy::{ reflect::{FromReflect, Reflect, TypeRegistry}, @@ -12,20 +15,18 @@ use crate::{ prelude::{ReflectAllocator, ReflectionError}, }; -pub trait Proxied: Sized { - type Proxy: Clone - + AsRef - + Into - + From - + std::fmt::Debug; -} - -pub struct Proxy(pub T::Proxy); - -pub struct RefProxy(pub T::Proxy); +/// Inverse to [`Unproxy`], packages up a type into a proxy type. +pub trait Proxy { + type Input; -pub struct RefMutProxy(pub T::Proxy); + fn proxy(input: Self::Input) -> Self; +} +/// A mechanism for converting proxy types into their represented types. +/// Note this can be implemented by 'meta-proxy' types which themselves aren't proxies, but wrap other proxies and provide a specific unproxying mechanism. +/// `RefProxy` and `RefMutProxy` are such 'meta-proxy' types. +/// +/// the [`Unproxy::Output`] type parameter is the type that this `proxy` will be converted to after unwrapping. pub trait Unproxy<'w, 'c> { type Output: 'c; @@ -41,21 +42,102 @@ pub trait Unproxy<'w, 'c> { 0 } + /// Unproxies a proxy type into the represented type without world access + /// This will fail on proxies which require world access to unproxy (for example those whose proxies are glorified [`ReflectReference`]'s ) + fn unproxy(&'c mut self) -> Result { + Err(ReflectionError::InsufficientAccess { + base: std::any::type_name::().to_owned(), + reason: "Attempted to unproxy a type that requires world access without providing it" + .to_owned(), + }) + } + + /// Unproxies a proxy type into the represented type with world access /// # Safety - /// - The caller must not use the accesses in the accesses list after the unproxy call to create a mutable reference, as this call might borrow mutably from the same access - unsafe fn unproxy( + /// - The caller must not use the accesses in the accesses list after the unproxy call at all, as implementors assume they have unique access to the accesses. + unsafe fn unproxy_with_world( &'c mut self, - guard: &WorldAccessGuard<'w>, - accesses: &'c [WorldAccessUnit<'w>], - type_registry: &TypeRegistry, - allocator: &'c ReflectAllocator, - ) -> Result; + _guard: &WorldAccessGuard<'w>, + _accesses: &'c [WorldAccessUnit<'w>], + _type_registry: &TypeRegistry, + _allocator: &'c ReflectAllocator, + ) -> Result { + self.unproxy() + } +} + +/// A wrapper type which when unproxied will return a `T` value. +/// Requires the type to be constructible from a reference to the proxy type. +#[derive(Debug, PartialEq, Eq)] +pub struct ValProxy(pub P, PhantomData); + +impl ValProxy { + pub fn new(v: P) -> Self { + Self(v, PhantomData) + } +} + +/// A wrapper type which when unproxied will return a `T` value. +/// Assumes that the proxy type contains a [`ReflectReference`] via [`AsRef`] +#[derive(PartialEq, Eq, Debug)] +pub struct ReflectValProxy(pub P, PhantomData); + +impl ReflectValProxy { + pub fn new(v: P) -> Self { + Self(v, PhantomData) + } } -impl<'w, 'c, T: Proxied + FromReflect> Unproxy<'w, 'c> for Proxy { +/// A proxy type which when unproxied will return a reference to a `T` value. +/// Assumes that the proxy type contains a [`ReflectReference`] via [`AsRef`] +pub struct ReflectRefProxy(pub P, PhantomData); + +impl ReflectRefProxy { + pub fn new(v: P) -> Self { + Self(v, PhantomData) + } +} + +/// A proxy type which when unproxied will return a mutable reference to a `T` value. +/// Assumes that the proxy type contains a [`ReflectReference`] via [`AsRef`] +pub struct ReflectRefMutProxy(pub P, PhantomData); + +impl ReflectRefMutProxy { + pub fn new(v: P) -> Self { + Self(v, PhantomData) + } +} + +impl<'w, 'c, T: 'c, P: 'c> Unproxy<'w, 'c> for ValProxy +where + T: From<&'c P>, +{ + type Output = T; + + fn unproxy(&'c mut self) -> Result { + Ok(T::from(&self.0)) + } +} + +impl Proxy for ValProxy +where + T: Into

, +{ + type Input = T; + + fn proxy(input: Self::Input) -> Self { + ValProxy::new(input.into()) + } +} + +impl<'w, 'c, T, P> Unproxy<'w, 'c> for ReflectValProxy +where + P: AsRef, + T: FromReflect, +{ type Output = T; - unsafe fn unproxy( + unsafe fn unproxy_with_world( &'c mut self, guard: &WorldAccessGuard<'w>, _accesses: &'c [WorldAccessUnit<'w>], @@ -86,7 +168,11 @@ impl<'w, 'c, T: Proxied + FromReflect> Unproxy<'w, 'c> for Proxy { } } -impl<'w, 'c, T: Proxied + Reflect + 'w> Unproxy<'w, 'c> for RefProxy { +impl<'w, 'c, T, P> Unproxy<'w, 'c> for ReflectRefProxy +where + P: AsRef, + T: Reflect, +{ type Output = &'c T; fn collect_accesses( @@ -106,7 +192,7 @@ impl<'w, 'c, T: Proxied + Reflect + 'w> Unproxy<'w, 'c> for RefProxy { Ok(()) } - unsafe fn unproxy( + unsafe fn unproxy_with_world( &'c mut self, guard: &WorldAccessGuard<'w>, accesses: &'c [WorldAccessUnit<'w>], @@ -141,7 +227,11 @@ impl<'w, 'c, T: Proxied + Reflect + 'w> Unproxy<'w, 'c> for RefProxy { } } -impl<'w, 'c, T: Proxied + Reflect + 'w> Unproxy<'w, 'c> for RefMutProxy { +impl<'w, 'c, T, P> Unproxy<'w, 'c> for ReflectRefMutProxy +where + P: AsRef, + T: Reflect, +{ type Output = &'c mut T; fn collect_accesses( @@ -161,7 +251,7 @@ impl<'w, 'c, T: Proxied + Reflect + 'w> Unproxy<'w, 'c> for RefMutProxy { Ok(()) } - unsafe fn unproxy( + unsafe fn unproxy_with_world( &'c mut self, guard: &WorldAccessGuard<'w>, accesses: &'c [WorldAccessUnit<'w>], @@ -221,7 +311,16 @@ impl<'w, 'c, T: Unproxy<'w, 'c>> Unproxy<'w, 'c> for Vec { self.iter().map(|item| item.accesses_len()).sum() } - unsafe fn unproxy( + fn unproxy(&'c mut self) -> Result { + let mut out = Vec::with_capacity(self.len()); + for item in self { + let unproxied = item.unproxy()?; + out.push(unproxied); + } + Ok(out) + } + + unsafe fn unproxy_with_world( &'c mut self, guard: &WorldAccessGuard<'w>, accesses: &'c [WorldAccessUnit<'w>], @@ -232,7 +331,7 @@ impl<'w, 'c, T: Unproxy<'w, 'c>> Unproxy<'w, 'c> for Vec { let mut offset = 0; for item in self { let width = item.accesses_len(); - let unproxied = item.unproxy( + let unproxied = item.unproxy_with_world( guard, &accesses[offset..offset + width], type_registry, @@ -245,51 +344,103 @@ impl<'w, 'c, T: Unproxy<'w, 'c>> Unproxy<'w, 'c> for Vec { } } -impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for &T -where - T::Output: Copy, -{ +impl Proxy for Vec { + type Input = Vec; + + fn proxy(input: Self::Input) -> Self { + input.into_iter().map(T::proxy).collect() + } +} + +impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for &T { type Output = &'c T; - unsafe fn unproxy( - &'c mut self, - _guard: &WorldAccessGuard<'w>, - _accesses: &'c [WorldAccessUnit<'w>], - _type_registry: &TypeRegistry, - _allocator: &'c ReflectAllocator, - ) -> Result { + fn unproxy(&'c mut self) -> Result { Ok(self) } } -impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for &mut T -where - T::Output: Copy, -{ +impl<'a, T: Proxy> Proxy for &'a T { + type Input = &'a T; + + fn proxy(input: Self::Input) -> Self { + input + } +} + +impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for &mut T { type Output = &'c mut T; - unsafe fn unproxy( + fn unproxy(&'c mut self) -> Result { + Ok(self) + } +} + +impl<'a, T: Proxy> Proxy for &'a mut T { + type Input = &'a mut T; + + fn proxy(input: Self::Input) -> Self { + input + } +} + +impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for Option { + type Output = Option; + + fn unproxy(&'c mut self) -> Result { + if let Some(s) = self { + let inner = s.unproxy()?; + Ok(Some(inner)) + } else { + Ok(None) + } + } + + unsafe fn unproxy_with_world( &'c mut self, - _guard: &WorldAccessGuard<'w>, - _accesses: &'c [WorldAccessUnit<'w>], - _type_registry: &TypeRegistry, - _allocator: &'c ReflectAllocator, + guard: &WorldAccessGuard<'w>, + accesses: &'c [WorldAccessUnit<'w>], + type_registry: &TypeRegistry, + allocator: &'c ReflectAllocator, ) -> Result { - Ok(*self) + if let Some(s) = self { + let inner = s.unproxy_with_world(guard, accesses, type_registry, allocator)?; + Ok(Some(inner)) + } else { + Ok(None) + } + } + + fn collect_accesses( + &self, + guard: &WorldAccessGuard<'w>, + accesses: &mut SmallVec<[WorldAccessWrite<'w>; 1]>, + ) -> Result<(), ReflectionError> { + self.as_ref() + .map(|s| s.collect_accesses(guard, accesses)) + .unwrap_or_else(|| Ok(())) + } + + fn accesses_len(&self) -> usize { + self.as_ref().map_or(0, |s| s.accesses_len()) + } +} + +impl Proxy for Option { + type Input = Option; + + fn proxy(input: Self::Input) -> Self { + input.map(T::proxy) } } -macro_rules! impl_by_move { +macro_rules! impl_unproxy_by_move { ($($ty:ty),*) => { $(impl<'w, 'c> Unproxy<'w, 'c> for $ty { type Output = $ty; - unsafe fn unproxy( - &'c mut self, - _guard: &WorldAccessGuard<'w>, - _accesses: &'c [WorldAccessUnit<'w>], - _type_registry: &TypeRegistry, - _allocator: &'c ReflectAllocator, + fn unproxy( + &'c mut self ) -> Result { Ok(*self) } @@ -297,8 +448,36 @@ macro_rules! impl_by_move { }; } -impl_by_move!(usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64, bool); -impl_by_move!( +macro_rules! impl_proxy_by_move { + ($($ty:ident),*) => { + $( + impl Proxy for $ty { + type Input = Self; + + fn proxy(input: Self::Input) -> Self { + input + } + } + )* + } +} + +impl_proxy_by_move!( + usize, + u8, + u16, + u32, + u64, + u128, + isize, + i8, + i16, + i32, + i64, + i128, + f32, + f64, + bool, NonZeroUsize, NonZeroU8, NonZeroU16, @@ -307,62 +486,97 @@ impl_by_move!( NonZeroU128 ); -macro_rules! impl_by_clone { +impl_unproxy_by_move!( + usize, + u8, + u16, + u32, + u64, + u128, + isize, + i8, + i16, + i32, + i64, + i128, + f32, + f64, + bool, + NonZeroUsize, + NonZeroU8, + NonZeroU16, + NonZeroU32, + NonZeroU64, + NonZeroU128 +); + +macro_rules! impl_unproxy_by_clone { ($($ty:ty),*) => { $(impl<'w, 'c> Unproxy<'w, 'c> for $ty { type Output = $ty; - unsafe fn unproxy( - &'c mut self, - _guard: &WorldAccessGuard<'w>, - _accesses: &'c [WorldAccessUnit<'w>], - _type_registry: &TypeRegistry, - _allocator: &'c ReflectAllocator, - ) -> Result { + fn unproxy(&'c mut self) -> Result { Ok(self.clone()) } })* }; } -impl_by_clone!(String); +impl_unproxy_by_clone!(String); +impl_proxy_by_move!(String); -macro_rules! impl_tuple_unproxy { +macro_rules! impl_tuple_unproxy_proxy { ($(($ty:ident, $idx:tt)),*) => { + impl <$($ty : Proxy,)*> Proxy for ($($ty,)*) + { + type Input = ($($ty::Input,)*); + + #[allow(clippy::unused_unit)] + fn proxy(_input: Self::Input) -> Self { + ($($ty::proxy(_input.$idx),)*) + } + } + impl<'w, 'c, $($ty: Unproxy<'w, 'c>),*> Unproxy<'w, 'c> for ($($ty,)*) { type Output = ($($ty::Output,)*); fn collect_accesses( &self, - guard: &WorldAccessGuard<'w>, - accesses: &mut SmallVec<[WorldAccessWrite<'w>; 1]>, + _guard: &WorldAccessGuard<'w>, + _accesses: &mut SmallVec<[WorldAccessWrite<'w>; 1]>, ) -> Result<(), ReflectionError> { - $(self.$idx.collect_accesses(guard, accesses)?;)* + $(self.$idx.collect_accesses(_guard, _accesses)?;)* Ok(()) } fn accesses_len(&self) -> usize { - let mut len = 0; - $(len += self.$idx.accesses_len();)* - len + let mut _len = 0; + $(_len += self.$idx.accesses_len();)* + _len + } + + fn unproxy(&'c mut self) -> Result { + Ok(($( + self.$idx.unproxy()? + ,)*)) } #[allow(unused_assignments)] - unsafe fn unproxy( + unsafe fn unproxy_with_world( &'c mut self, - guard: &WorldAccessGuard<'w>, - accesses: &'c [WorldAccessUnit<'w>], - type_registry: &TypeRegistry, - allocator: &'c ReflectAllocator, + _guard: &WorldAccessGuard<'w>, + _accesses: &'c [WorldAccessUnit<'w>], + _type_registry: &TypeRegistry, + _allocator: &'c ReflectAllocator, ) -> Result { - let mut offset = 0; + let mut _offset = 0; Ok(($( { let width = self.$idx.accesses_len(); - let elem = self.$idx.unproxy(guard, &accesses[offset..offset+width], type_registry, allocator)?; + let elem = self.$idx.unproxy_with_world(_guard, &_accesses[_offset.._offset+width], _type_registry, _allocator)?; - offset += width; + _offset += width; elem } ,)*)) @@ -372,40 +586,41 @@ macro_rules! impl_tuple_unproxy { }; } +impl_tuple_unproxy_proxy!(); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0)); +impl_tuple_unproxy_proxy!((A, 0)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12), (N, 13)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12), (N, 13)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12), (N, 13), (O, 14)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12), (N, 13), (O, 14)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12), (N, 13), (O, 14), (P, 15)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12), (N, 13), (O, 14), (P, 15)); #[rustfmt::skip] -impl_tuple_unproxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12), (N, 13), (O, 14), (P, 15), (Q, 16)); +impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6), (H, 7), (I, 8), (J, 9), (K, 10), (L, 11), (M, 12), (N, 13), (O, 14), (P, 15), (Q, 16)); #[cfg(test)] mod test { @@ -420,22 +635,27 @@ mod test { use super::*; - #[derive(Reflect, Component)] + #[derive(Reflect, Component, PartialEq, Eq, Debug, Clone)] struct Test(pub &'static str); - impl Proxied for Test { - type Proxy = TestProxy; - } + #[derive(Debug, Clone, PartialEq, Eq)] + struct ValTestProxy(Test); - #[derive(Debug, Clone)] - struct TestProxy(ReflectReference); + impl From for ValTestProxy { + fn from(value: Test) -> Self { + Self(value) + } + } - impl From for ReflectReference { - fn from(value: TestProxy) -> Self { - value.0 + impl<'a> From<&'a ValTestProxy> for Test { + fn from(value: &'a ValTestProxy) -> Self { + value.0.clone() } } + #[derive(Debug, Clone, PartialEq, Eq)] + struct TestProxy(ReflectReference); + impl From for TestProxy { fn from(value: ReflectReference) -> Self { TestProxy(value) @@ -448,14 +668,81 @@ mod test { } } + macro_rules! assert_proxy_invertible { + ($original:expr, $($proxy_ty:tt)*) => { + let mut world = World::new(); + let mut accesses = SmallVec::new(); + let world = WorldAccessGuard::new(&mut world); + let type_registry = TypeRegistry::default(); + let allocator = ReflectAllocator::default(); + + let mut proxy = $($proxy_ty)*::proxy($original); + proxy.collect_accesses(&world, &mut accesses).unwrap(); + + let unproxied = unsafe { + proxy + .unproxy_with_world(&world, &mut accesses, &type_registry, &allocator) + .unwrap() + }; + assert_eq!( + unproxied, $original, + "Proxy and unproxy does not yield original type, expected {:?}, got {:?}", + $original, unproxied + ); + + let unproxied_without_world = proxy.unproxy().unwrap(); + assert_eq!( + unproxied_without_world, $original, + "Proxy and unproxy does not yield original type, expected {:?}, got {:?}", + $original, unproxied_without_world + ); + }; + } + + #[test] + pub fn test_non_reflect_val_proxy() { + assert_proxy_invertible!(Test("test"), ValProxy::); + } + + #[test] + pub fn test_complex_types_proxy_is_inverse_of_unproxy() { + assert_proxy_invertible!(Vec::::default(), Vec::); + assert_proxy_invertible!(Some(Test("test")), Option::>); + assert_proxy_invertible!(None::, Option::>); + assert_proxy_invertible!( + Some(Some(Test("test"))), + Option::>> + ); + assert_proxy_invertible!( + vec![Some(Test("test")), None, Some(Test("test"))], + Vec::>> + ); + assert_proxy_invertible!(vec![&1, &2, &3], Vec::<&usize>); + assert_proxy_invertible!(vec![&(1, 2)], Vec::<&(usize, usize)>); + assert_proxy_invertible!(vec![vec![1, 2], vec![1, 2, 3]], Vec::>); + assert_proxy_invertible!( + vec![vec![(1, 2), (3, 4)], vec![(1, 2), (3, 4)]], + Vec::> + ); + assert_proxy_invertible!(Some(1), Option::); + assert_proxy_invertible!(Some(Some(1)), Option::>); + assert_proxy_invertible!(None::, Option::); + assert_proxy_invertible!(None::>, Option::>); + assert_proxy_invertible!(vec![Some(1), None, Some(2)], Vec::>); + assert_proxy_invertible!( + vec![Some(vec![1, 2, 3]), None, Some(vec![1, 4])], + Vec::>> + ); + } + #[test] - pub fn test_proxy() { + pub fn test_val_proxy() { let mut allocator = ReflectAllocator::default(); let alloc_id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(Test( "test", ))))); - let mut proxy = Proxy::(TestProxy(ReflectReference { + let mut proxy = ReflectValProxy::::new(TestProxy(ReflectReference { base: ReflectBaseType { type_id: std::any::TypeId::of::(), base_id: ReflectBase::Owned(alloc_id), @@ -470,7 +757,7 @@ mod test { proxy.collect_accesses(&world, &mut accesses).unwrap(); let unproxied = unsafe { proxy - .unproxy(&world, &accesses, &type_registry, &allocator) + .unproxy_with_world(&world, &accesses, &type_registry, &allocator) .unwrap() }; assert_eq!(unproxied.0, "test"); @@ -483,7 +770,7 @@ mod test { "test", ))))); - let mut proxy = RefProxy::(TestProxy(ReflectReference { + let mut proxy = ReflectRefProxy::::new(TestProxy(ReflectReference { base: ReflectBaseType { type_id: std::any::TypeId::of::(), base_id: ReflectBase::Owned(alloc_id), @@ -498,7 +785,7 @@ mod test { proxy.collect_accesses(&world, &mut accesses).unwrap(); let unproxied = unsafe { proxy - .unproxy(&world, &accesses, &type_registry, &allocator) + .unproxy_with_world(&world, &accesses, &type_registry, &allocator) .unwrap() }; assert_eq!(unproxied.0, "test"); @@ -511,7 +798,7 @@ mod test { "test", ))))); - let mut proxy = RefMutProxy::(TestProxy(ReflectReference { + let mut proxy = ReflectRefMutProxy::::new(TestProxy(ReflectReference { base: ReflectBaseType { type_id: std::any::TypeId::of::(), base_id: ReflectBase::Owned(alloc_id), @@ -526,7 +813,7 @@ mod test { proxy.collect_accesses(&world, &mut accesses).unwrap(); let unproxied = unsafe { proxy - .unproxy(&world, &accesses, &type_registry, &allocator) + .unproxy_with_world(&world, &accesses, &type_registry, &allocator) .unwrap() }; assert_eq!(unproxied.0, "test"); @@ -539,51 +826,15 @@ mod test { "test", ))))); - let mut proxy = vec![RefMutProxy::(TestProxy(ReflectReference { - base: ReflectBaseType { - type_id: std::any::TypeId::of::(), - base_id: ReflectBase::Owned(alloc_id), + let mut proxy = vec![Some(ReflectRefMutProxy::::new(TestProxy( + ReflectReference { + base: ReflectBaseType { + type_id: std::any::TypeId::of::(), + base_id: ReflectBase::Owned(alloc_id), + }, + reflect_path: vec![], }, - reflect_path: vec![], - }))]; - let mut world = World::new(); - let mut accesses = SmallVec::new(); - let world = WorldAccessGuard::new(&mut world); - let type_registry = TypeRegistry::default(); - - proxy.collect_accesses(&world, &mut accesses).unwrap(); - let unproxied = unsafe { - proxy - .unproxy(&world, &accesses, &type_registry, &allocator) - .unwrap() - }; - assert_eq!(unproxied[0].0, "test"); - } - - #[test] - pub fn test_vec_usize_ref() { - let allocator = ReflectAllocator::default(); - - let mut proxy = vec![&1]; - let mut world = World::new(); - let mut accesses = SmallVec::new(); - let world = WorldAccessGuard::new(&mut world); - let type_registry = TypeRegistry::default(); - - proxy.collect_accesses(&world, &mut accesses).unwrap(); - let unproxied = unsafe { - proxy - .unproxy(&world, &accesses, &type_registry, &allocator) - .unwrap() - }; - assert_eq!(unproxied[0], &42); - } - - #[test] - pub fn test_tuple_refs() { - let allocator = ReflectAllocator::default(); - - let mut proxy = (vec![&1], vec![&2, &4], vec![&3]); + )))]; let mut world = World::new(); let mut accesses = SmallVec::new(); let world = WorldAccessGuard::new(&mut world); @@ -592,10 +843,10 @@ mod test { proxy.collect_accesses(&world, &mut accesses).unwrap(); let unproxied = unsafe { proxy - .unproxy(&world, &accesses, &type_registry, &allocator) + .unproxy_with_world(&world, &accesses, &type_registry, &allocator) .unwrap() }; - assert_eq!(unproxied, (vec![&1], vec![&2, &4], vec![&3])); + assert_eq!(unproxied[0].as_ref().unwrap().0, "test"); } #[test] @@ -616,8 +867,8 @@ mod test { // mutable access to the same allocation let proxy = vec![ - RefMutProxy::(TestProxy(reflect_ref.clone())), - RefMutProxy::(TestProxy(reflect_ref)), + ReflectRefMutProxy::::new(TestProxy(reflect_ref.clone())), + ReflectRefMutProxy::::new(TestProxy(reflect_ref)), ]; let mut world = World::new(); diff --git a/crates/languages/bevy_mod_scripting_lua/Cargo.toml b/crates/languages/bevy_mod_scripting_lua/Cargo.toml index 11768079..86517184 100644 --- a/crates/languages/bevy_mod_scripting_lua/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_lua/Cargo.toml @@ -41,11 +41,13 @@ path = "src/lib.rs" [dependencies] bevy = { workspace = true, default-features = false } bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_lua_derive = { path = "../bevy_mod_scripting_lua_derive", version = "0.6.0" } tealr = { version = "0.9", features = [ "mlua_vendored", "mlua_send", "mlua_macros", ] } + parking_lot = "0.12.1" serde_json = "1.0.81" anyhow = "1.0.75" diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs index bd4928b4..798828bd 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs @@ -1,6 +1,5 @@ use bevy_mod_scripting_core::bindings::WorldCallbackAccess; -pub mod traits; - -/// Lua UserData wrapper for [`bevy::ecs::world::World`] -pub struct LuaWorld(pub WorldCallbackAccess); +pub mod providers; +pub mod proxy; +pub mod world; diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/mod.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/mod.rs new file mode 100644 index 00000000..6dcdc78e --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/mod.rs @@ -0,0 +1,19 @@ +use bevy_mod_scripting_lua_derive::LuaProxy; +use tealr::mlu::mlua::{Lua, UserData}; + +#[derive(LuaProxy)] +#[proxy(bms_lua_path = "crate", bms_core_path = "bevy_mod_scripting_core")] +#[proxy(functions[r#" +fn hello2(asd: usize, asd2: usize) -> (); + +"#])] +pub struct Vec3 { + pub x: f32, + pub y: f32, + pub z: f32, +} + +impl Vec3 { + pub fn hello() {} + pub fn hello2(asd: usize, asd2: usize) {} +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/traits.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs similarity index 62% rename from crates/languages/bevy_mod_scripting_lua/src/bindings/traits.rs rename to crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs index 05e56111..e9859c03 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/traits.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs @@ -1,23 +1,33 @@ //! Set of traits used to define how types are turned into and from proxies in Lua. //! Proxies can either be logical "copies" or owned "direct representations" of the instance, or references to one via the [`bevy_mod_scripting_core::bindings::ReflectReference`] construct. -use bevy::reflect::{FromReflect, TypeRegistry}; +use bevy::reflect::{FromReflect, Reflect, TypeRegistry}; use bevy_mod_scripting_core::{ allocator::ReflectAllocator, - bindings::{WorldAccessGuard, WorldAccessUnit, WorldAccessWrite}, + bindings::{ReflectReference, WorldAccessGuard, WorldAccessUnit, WorldAccessWrite}, error::ReflectionError, - proxy::{Proxied, Proxy, RefMutProxy, RefProxy, Unproxy}, + proxy::{ReflectRefMutProxy, ReflectRefProxy, ReflectValProxy, Unproxy, ValProxy}, }; use tealr::mlu::mlua::{Error, FromLua, IntoLua, Lua, Value}; -pub struct LuaProxy(pub Proxy); -pub struct LuaRefProxy(pub RefProxy); -pub struct LuaRefMutProxy(pub RefMutProxy); +/// Local trait alias for the [`Proxied`] trait. +pub trait LuaProxied { + type Proxy; +} + +pub struct LuaNonReflectProxy(pub ValProxy); +pub struct LuaValProxy(pub ReflectValProxy); +pub struct LuaRefProxy(pub ReflectRefProxy); +pub struct LuaRefMutProxy(pub ReflectRefMutProxy); macro_rules! impl_lua_proxy { - ($ty:ident as $as:ident => $generic:tt) => { - impl<'w, 'c, $generic: Proxied + FromReflect + 'c> Unproxy<'w, 'c> for $ty<$generic> { - type Output = <$as<$generic> as Unproxy<'w, 'c>>::Output; + ($ty:ident as $as:ident => $generic:tt : $($bounds:path),* $(| T::Proxy: $($proxy_bounds:tt)*)?) => { + impl<'w, 'c, $generic:'c> Unproxy<'w, 'c> for $ty<$generic> + where + T::Proxy: $($($proxy_bounds)*)?, + T: $($bounds+)*, + { + type Output = <$as<$generic,$generic::Proxy> as Unproxy<'w, 'c>>::Output; fn collect_accesses( &self, @@ -27,14 +37,19 @@ macro_rules! impl_lua_proxy { self.0.collect_accesses(guard, accesses) } - unsafe fn unproxy( + fn unproxy(&'c mut self) -> Result { + self.0.unproxy() + } + + unsafe fn unproxy_with_world( &'c mut self, guard: &WorldAccessGuard<'w>, accesses: &'c [WorldAccessUnit<'w>], type_registry: &TypeRegistry, allocator: &'c ReflectAllocator, ) -> Result { - self.0.unproxy(guard, accesses, type_registry, allocator) + self.0 + .unproxy_with_world(guard, accesses, type_registry, allocator) } fn accesses_len(&self) -> usize { @@ -42,31 +57,32 @@ macro_rules! impl_lua_proxy { } } - impl<'lua, $generic: Proxied + FromReflect> IntoLua<'lua> for $ty<$generic> - where - $generic::Proxy: IntoLua<'lua>, - { - fn into_lua(self, lua: &'lua Lua) -> Result, Error> { - self.0 .0.into_lua(lua) - } - } - - impl<'lua, $generic: Proxied + FromReflect> FromLua<'lua> for $ty<$generic> + impl<'lua, $generic: LuaProxied> FromLua<'lua> for $ty<$generic> where $generic::Proxy: FromLua<'lua>, { fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result { let inner: $generic::Proxy = $generic::Proxy::from_lua(value, lua)?; - let inner: $as<$generic> = $as::<$generic>(inner); + let inner = $as::<$generic,$generic::Proxy>::new(inner); Ok(Self(inner)) } } }; } -impl_lua_proxy!(LuaProxy as Proxy => T); -impl_lua_proxy!(LuaRefProxy as RefProxy => T); -impl_lua_proxy!(LuaRefMutProxy as RefMutProxy => T); +impl<'lua, T: LuaProxied> IntoLua<'lua> for LuaNonReflectProxy +where + T::Proxy: IntoLua<'lua>, +{ + fn into_lua(self, lua: &'lua Lua) -> tealr::mlu::mlua::prelude::LuaResult> { + todo!() + } +} + +impl_lua_proxy!(LuaNonReflectProxy as ValProxy => T : LuaProxied,From<&'c T::Proxy>); +impl_lua_proxy!(LuaValProxy as ReflectValProxy => T : LuaProxied,FromReflect | T::Proxy: AsRef); +impl_lua_proxy!(LuaRefProxy as ReflectRefProxy => T : LuaProxied,Reflect | T::Proxy: AsRef); +impl_lua_proxy!(LuaRefMutProxy as ReflectRefMutProxy => T: LuaProxied,Reflect | T::Proxy: AsRef); #[cfg(test)] mod test { @@ -78,7 +94,10 @@ mod test { allocator::ReflectAllocation, bindings::{ReflectBase, ReflectBaseType, ReflectReference}, }; - use tealr::mlu::mlua::{UserData, UserDataMethods}; + use tealr::{ + mlu::mlua::{UserData, UserDataMethods}, + Name, + }; use super::*; @@ -91,7 +110,7 @@ mod test { } } - impl Proxied for Test { + impl LuaProxied for Test { type Proxy = TestProxy; } @@ -139,6 +158,15 @@ mod test { } } + impl tealr::ToTypename for TestProxy { + fn to_typename() -> tealr::Type { + tealr::Type::Single(tealr::SingleType { + name: tealr::Name("test".into()), + kind: tealr::KindOfType::External, + }) + } + } + #[test] pub fn test_call_set() { let lua = Lua::new(); diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs new file mode 100644 index 00000000..ce3a9c1a --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs @@ -0,0 +1,70 @@ +use bevy_mod_scripting_core::bindings::WorldCallbackAccess; +use tealr::{ + mlu::{mlua::FromLua, FromToLua, TealData}, + ToTypename, Type, +}; + +use crate::{impl_userdata_from_lua, impl_userdata_with_tealdata}; + +use super::proxy::LuaProxied; + +/// Lua UserData wrapper for [`bevy::ecs::world::World`] +#[derive(Clone)] +pub struct LuaWorld(pub WorldCallbackAccess); + +impl_userdata_from_lua!(LuaWorld); +impl_userdata_with_tealdata!(LuaWorld); + +impl LuaProxied for WorldCallbackAccess { + type Proxy = LuaWorld; +} + +impl From<&LuaWorld> for WorldCallbackAccess { + fn from(value: &LuaWorld) -> Self { + value.0.clone() + } +} + +impl TealData for LuaWorld { + fn add_methods<'lua, T: tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { + // methods.add_function("spawn_entity", |_, _, _| Ok(())); + } +} + +impl ToTypename for LuaWorld { + fn to_typename() -> Type { + Type::new_single("World", tealr::KindOfType::External) + } +} + +#[cfg(test)] +mod test { + use std::sync::Arc; + + use bevy::ecs::world::World; + use bevy_mod_scripting_core::{ + bindings::WorldAccessGuard, + proxy::{Unproxy, ValProxy}, + }; + use tealr::mlu::mlua::Lua; + + use super::*; + use crate::bindings::proxy::LuaNonReflectProxy; + use tealr::mlu::mlua::IntoLua; + + #[test] + fn test_world_from_to_lua() { + let mut world = World::new(); + let world_access_guard = Arc::new(WorldAccessGuard::new(&mut world)); + let callback_access = + unsafe { WorldCallbackAccess::new(Arc::downgrade(&world_access_guard)) }; + let proxy = + LuaNonReflectProxy::(ValProxy::new(LuaWorld(callback_access))); + + let lua = Lua::new(); + let lua_val = proxy.into_lua(&lua).unwrap(); + let mut val = LuaNonReflectProxy::::from_lua(lua_val, &lua).unwrap(); + + let val = val.unproxy().unwrap(); + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/util.rs b/crates/languages/bevy_mod_scripting_lua/src/util.rs index bbf7bb52..00357a8d 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/util.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/util.rs @@ -153,3 +153,48 @@ macro_rules! __cfg_feature_any_lua52_lua53_lua54_luajit52 { macro_rules! __cfg_feature_any_lua52_lua53_lua54_luajit52 { ( $( $tok:tt )* ) => {}; } + +#[macro_export] +macro_rules! impl_userdata_from_lua { + ($ty:ident) => { + impl<'lua> FromLua<'lua> for $ty { + fn from_lua( + value: ::tealr::mlu::mlua::Value<'lua>, + lua: &::tealr::mlu::mlua::Lua, + ) -> Result { + match value { + tealr::mlu::mlua::Value::UserData(ud) => Ok(ud.borrow::()?.clone()), + _ => { + return Err(::tealr::mlu::mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: stringify!($ty), + message: None, + }) + } + } + } + } + }; +} + +#[macro_export] +macro_rules! impl_userdata_with_tealdata { + ($ty:ident) => { + impl ::tealr::mlu::mlua::UserData for $ty + where + Self: ::tealr::mlu::TealData, + { + fn add_methods<'lua, T: ::tealr::mlu::mlua::UserDataMethods<'lua, Self>>( + methods: &mut T, + ) { + let mut wrapper = tealr::mlu::UserDataWrapper::from_user_data_methods(methods); + ::add_methods(&mut wrapper); + } + + fn add_fields<'lua, T: ::tealr::mlu::mlua::UserDataFields<'lua, Self>>(fields: &mut T) { + let mut wrapper = tealr::mlu::UserDataWrapper::from_user_data_fields(fields); + ::add_fields(&mut wrapper); + } + } + }; +} diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs deleted file mode 100644 index 9e0cd6d6..00000000 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs +++ /dev/null @@ -1,117 +0,0 @@ -use std::collections::HashMap; - -use bevy_mod_scripting_common::input::{SimpleType, VisitSimpleType}; -use darling::FromAttributes; -use proc_macro2::{Ident, Span}; -use quote::{quote, quote_spanned}; -use syn::{parse_quote, token::Mut}; - -use crate::visitor::{LuaSimpleTypeArgumentUnwrapper, LuaTypeConstructorVisitor}; - -#[derive(Debug, FromAttributes)] -#[darling(attributes(proxy))] -pub struct ArgAttributes { - #[darling(default)] - pub map: HashMap, -} - -/// Struct for holding argument/output information in functions passed via `functions[..]` meta -#[derive(Debug)] -pub struct Arg { - pub attrs: ArgAttributes, - pub mutability: Option, - /// the type of the argument, only suported patterns are allowed - pub name: Ident, - /// variant specific data enumeration - pub 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 - pub is_raw: bool, - pub span: Span, -} - -impl Arg { - pub fn new( - attrs: ArgAttributes, - name: Ident, - mutability: Option, - type_: SimpleType, - is_raw: bool, - ) -> Self { - Self { - attrs, - mutability, - span: name.span(), - name, - type_, - is_raw, - } - } - - /// 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) -> syn::Result> { - let name = &self.name; - if self.is_raw { - // raw parameters DO NOT get unpacked, they get passed directly to the handling method as is - Ok(None) - } else { - // if a proxy parameter is to be passed by value we use inner (which requires Clone to be supported) - Ok(Some( - LuaSimpleTypeArgumentUnwrapper::new(name.clone(), name.span()) - .visit(&self.type_)?, - )) - } - } - - fn arg_signature_generic( - &self, - expecting_receiver: bool, - expecting_ctxt: bool, - ) -> (proc_macro2::TokenStream, proc_macro2::TokenStream) { - assert!(!(expecting_receiver && expecting_ctxt)); - - let _mut = &self.mutability; - let name = &self.name; - let type_ = if expecting_ctxt { - parse_quote!(&bevy_mod_scripting_lua::prelude::Lua) - } else { - LuaTypeConstructorVisitor::new(true, self.type_.contains_proxy_type()) - .visit(&self.type_) - }; - let forced_ref = expecting_receiver.then(|| { - Some(quote_spanned!(self.span=> - & #_mut - )) - }); - - let name_part = quote_spanned!(self.span=> - #_mut #name - ); - let type_part = quote_spanned!(self.span=> - #forced_ref #type_ - ); - (name_part, type_part) - } - - /// Generates the arg signature in an mlua `UserDataFields` or `UserDataMethods` closure for a receiver type argument. - /// generates using an additional outer reference. - pub fn arg_signature_receiver(&self) -> proc_macro2::TokenStream { - let (name, type_) = self.arg_signature_generic(true, false); - quote!(#name : #type_) - } - - /// Generates the arg signature in an mlua `UserDataFields` or `UserDataMethods` closure for a Lua context type argument. - /// generates using an additional outer reference. - pub fn arg_signature_context(&self) -> proc_macro2::TokenStream { - let (name, type_) = self.arg_signature_generic(false, true); - quote!(#name : #type_) - } - - /// Generates the arg signature in an mlua `UserDataFields` or `UserDataMethods` closure for a non-receiver non-context argument. - /// generates the type to match the argument received. - /// The output is split into the name and type parts - pub fn arg_signature(&self) -> (proc_macro2::TokenStream, proc_macro2::TokenStream) { - self.arg_signature_generic(false, false) - } -} diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/function.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/function.rs deleted file mode 100644 index 631f4216..00000000 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/function.rs +++ /dev/null @@ -1,601 +0,0 @@ -use bevy_mod_scripting_common::input::{ - DuoPath, IdentifierRenamingVisitor, Reference, SimpleType, VisitSimpleType, -}; -use darling::{util::Flag, FromAttributes, FromMeta}; -use proc_macro2::{Ident, Span}; -use quote::{format_ident, quote, quote_spanned, ToTokens}; -use strum::{Display, EnumIter, EnumString}; -use syn::{ - punctuated::Punctuated, spanned::Spanned, visit_mut::VisitMut, Block, LitInt, LitStr, Meta, - Path, Token, -}; -use vec1::Vec1; - -use crate::{ - arg::Arg, - signature::Signature, - visitor::{LuaSimpleTypeWrapper, LuaTypeConstructorVisitor}, - PROXY_OUT_ALIAS, RAW_OUT_ALIAS, SELF_ALIAS, -}; - -#[derive(Default, FromMeta, Display, EnumString, EnumIter, PartialEq, Eq, Clone, Copy, Debug)] -#[darling(rename_all = "PascalCase")] -pub enum FunctionKind { - Function, - MetaFunction, - #[default] - Method, - MetaMethod, - MutableFunction, - MutableMetaFunction, - MutatingMethod, - MutatingMetaMethod, - FieldGetterMethod, - FieldSetterMethod, -} - -impl FunctionKind { - pub fn expects_receiver(self) -> bool { - self == FunctionKind::Method - || self == FunctionKind::MetaMethod - || self == FunctionKind::MutatingMethod - || self == FunctionKind::MutatingMetaMethod - || self == FunctionKind::FieldGetterMethod - || self == FunctionKind::FieldSetterMethod - } - - pub fn is_field(self) -> bool { - self == FunctionKind::FieldGetterMethod || self == FunctionKind::FieldSetterMethod - } - - pub fn is_field_getter(self) -> bool { - self == FunctionKind::FieldGetterMethod - } - - /// Returns true if the mlua closure signature accepts a tuple for general 'Arguments' to the function - /// I.e. arguments freely passed to the function by the caller. - pub fn expects_arguments_tuple(self) -> bool { - self != FunctionKind::FieldGetterMethod - } - - pub fn get_tealr_function(self) -> &'static str { - match self { - FunctionKind::Function => "add_function", - FunctionKind::MetaFunction => "add_meta_function", - FunctionKind::Method => "add_method", - FunctionKind::MetaMethod => "add_meta_method", - FunctionKind::MutableFunction => "add_function_mut", - FunctionKind::MutableMetaFunction => "add_meta_function_mut", - FunctionKind::MutatingMethod => "add_method_mut", - FunctionKind::MutatingMetaMethod => "add_meta_method_mut", - FunctionKind::FieldGetterMethod => "add_field_method_get", - FunctionKind::FieldSetterMethod => "add_field_method_set", - } - } - - pub fn is_meta(self) -> bool { - self == FunctionKind::MetaMethod - || self == FunctionKind::MetaFunction - || self == FunctionKind::MutatingMetaMethod - || self == FunctionKind::MutableMetaFunction - } -} - -/// The attributes which can be applied to lua functions using the -/// `lua(..)` meta attribute -#[derive(Debug, FromAttributes)] -#[darling(attributes(lua))] -pub struct FunctionAttributes { - /// Marks the function to be treated as raw meaning a lot of the wrapping and unwrapping is skipped, - /// a 'Lua' ctxt argument is then expected - pub raw: Flag, - - /// Marks the function as a composite with the given ID, at least one another function with the same composite - /// ID must exist resulting in a combined function being generated. The actual function to dispatch to will be decided based on - /// the types of arguments. If the signature is invalid (i.e. doesn't allow us to dispatch) an error will be thrown - #[darling(default)] - pub composite: Option, - - /// If passed provides the name of the metamethod to use for metamethod based functions - /// the name of the function is used to decide what rust function to call in this case - #[darling(default)] - pub metamethod: Option, - - /// The kind of function to generate on the proxy - #[darling(default)] - pub kind: FunctionKind, - - /// Marks this to be ignored, only used for fields as functions are opt-in - pub skip: Flag, - - /// Meta to pass down to the output proxy or in case of fields - /// used as the argument meta for type being get/set - pub output: Option, - - /// If passed will generate statement before calling the method - /// on the type - pub as_trait: Option, - - #[darling(multiple)] - pub doc: Vec, -} - -/// A function which combines the signatures of multiple functions, -/// and dispatches to the one which matches the signature if any -/// Useful for binary operators which can accept many types on both sides -#[derive(Debug)] -pub struct CompositeFunction { - pub id: String, - pub functions: Vec1, -} - -/// A struct corresponding to each function in the functions[...] meta list. -/// -#[derive(Debug)] -pub struct Function { - pub name: Ident, - pub attrs: FunctionAttributes, - pub sig: Signature, - pub default: Option, - pub span: Span, - pub is_unsafe: bool, -} - -impl Function { - pub fn new( - name: Ident, - attrs: FunctionAttributes, - default: Option, - sig: Signature, - span: Span, - is_unsafe: bool, - ) -> darling::Result { - Ok(Self { - name, - attrs, - sig, - default, - span, - is_unsafe, - }) - } - - /// Tries to retrieve the receiver argument from functions. - /// If not expected returns None and Some otherwise. - /// If the function is of the wrong kind or does not have the correct signature an error is thrown - pub fn self_arg(&self) -> syn::Result> { - if self.attrs.kind.expects_receiver() { - self.get_self_arg().map(Option::Some) - } else { - Ok(None) - } - } - - /// Returns an error if self arg is not there and returns it otherwise - pub fn get_self_arg(&self) -> syn::Result<&Arg> { - self.sig.inputs.first().ok_or_else(|| { - syn::Error::new( - self.sig.span, - "Expected receiver as first argument in the signature".to_string(), - ) - }) - } - - /// Tries to retrieve the context argument from raw functions. - /// If the function is not raw or doesn't have a correct signature an error is thrown - pub fn ctxt_arg(&self) -> syn::Result> { - if self.attrs.raw.is_present() { - self.get_ctxt_arg().map(Option::Some) - } else { - Ok(None) - } - } - - /// Returns an error if no context argument is found in the correct place or returns it otherwise - pub fn get_ctxt_arg(&self) -> syn::Result<&Arg> { - let ctxt_idx = if self.attrs.kind.expects_receiver() { - 1 - } else { - 0 - }; - self.sig.inputs.get(ctxt_idx).ok_or_else(|| { - syn::Error::new( - self.sig.span, - format!( - "Expected ctxt argument in the signature as argument number: `{}`", - ctxt_idx + 1 - ), - ) - }) - } - - /// Retrieves the rest of the arguments (after the receiver and context args) - /// If they are expected, otherwise returns None. - /// If arguments are expected but none are present Some(vec![]) is returned - /// If input vec is shorter than expected, i.e. if the receiver should be there but isn't returns an Err - pub fn other_arguments(&self) -> syn::Result>> { - if self.attrs.kind.expects_arguments_tuple() { - self.get_other_arguments().map(Option::Some) - } else { - Ok(None) - } - } - - pub fn get_other_arguments(&self) -> syn::Result> { - let other_args_idx = - self.attrs.kind.expects_receiver() as usize + self.attrs.raw.is_present() as usize; - - if self.sig.inputs.len() < other_args_idx { - return Err(syn::Error::new( - self.sig.span, - format!("Signature too short, expected {other_args_idx} arguments before this one"), - )); - } - - Ok(self.sig.inputs.iter().skip(other_args_idx)) - } - - /// 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 - /// ``` - pub fn generate_mlua_args(&self) -> syn::Result { - let self_arg = self.self_arg()?.map(Arg::arg_signature_receiver); - - let ctxt_arg = self - .ctxt_arg()? - .map(Arg::arg_signature_context) - .unwrap_or_else(|| quote!(_)); - - let other_args = self.other_arguments()?.map(|args| { - let (other_arg_names, other_arg_types) = - args.map(Arg::arg_signature).unzip::<_, _, Vec<_>, Vec<_>>(); - - quote_spanned!(self.sig.span=> - (#(mut #other_arg_names),*) : (#(#other_arg_types),*) - ) - }); - - Ok(vec![Some(ctxt_arg), self_arg, other_args] - .into_iter() - .filter(Option::is_some) - .collect::, Token![,]>>() - .to_token_stream()) - } - - /// 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, - ) -> syn::Result { - Ok(self - .sig - .inputs - .iter() - .map(Arg::unpack_parameter) - .collect::>>()? - .iter() - .zip(self.sig.inputs.iter()) - .filter_map(|(unpacked_param, arg)| { - unpacked_param.as_ref().map(|unpacked_param| { - let name = &arg.name; - quote_spanned! {name.span()=>let mut #name = #unpacked_param;} - }) - }) - .collect::()) - } - - /// Similar to generate_mlua_body_output but for functions, makes some more assumptions and directly generates wrapped/unwrapped output depending on what's necessary - /// Does not require another wrapping step and can be directly put in a result as the final output of an mlua closure - fn generate_mlua_body_output_field( - &self, - raw_output_ident: &Ident, - ) -> syn::Result { - let field_type = if self.attrs.kind.is_field_getter() { - &self.sig.output - } else { - self.get_other_arguments()?.next() - .ok_or_else(|| syn::Error::new(self.sig.span, format!("Setter lua method with no arguments, expected at least one argument in function: `{}`", self.name)))? - }; - // we need to figure out which type of field access this is going to be - let self_name = &self.get_self_arg()?.name; - let ctxt_name = &self.get_ctxt_arg()?.name; - let world_ptr = quote!( - - ::get_world(#ctxt_name)? - ); - - let field_name = { - let str_name = self.name.to_string(); - - if str_name.starts_with('_') && str_name[1..].parse::().is_ok() { - syn::Lit::Int(LitInt::new(&str_name[1..], self.name.span())).to_token_stream() - } else { - self.name.clone().to_token_stream() - } - }; - let field_name_str = syn::Lit::Str(LitStr::new(&self.name.to_string(), self.name.span())); - let proxy_output_type = - LuaTypeConstructorVisitor::new(true, false).visit(&field_type.type_); - - Ok(match &field_type.type_ { - // proxy, need to index into it then wrap the result - // getter - t if t.contains_proxy_type() && self.attrs.kind.is_field_getter() => quote!( - let #raw_output_ident = #proxy_output_type::new_ref(bevy_script_api::script_ref::ValueIndex::index(& #self_name.reflect_ref(#world_ptr), std::borrow::Cow::Borrowed(#field_name_str))); - ), - // setter - t if t.contains_proxy_type() => { - let first_arg_name = &self - .get_other_arguments()? - .next() - .ok_or_else(|| { - syn::Error::new( - self.sig.span, - "Field setter requires a single argument which is missing", - ) - })? - .name; - quote!( - let #raw_output_ident = #first_arg_name.apply_self_to_base(&mut bevy_script_api::script_ref::ValueIndex::index(& #self_name.reflect_ref(#world_ptr), std::borrow::Cow::Borrowed(#field_name_str)))?; - ) - } - - // plain reflection, index into the ReflectReference with the field path - // getter - SimpleType::Type(syn::Type::Path(path)) - if path.path.is_ident("ReflectedValue") && self.attrs.kind.is_field_getter() => - { - quote!( - let #raw_output_ident = bevy_script_api::script_ref::ValueIndex::index(& #self_name.reflect_ref(#world_ptr), std::borrow::Cow::Borrowed(#field_name_str)); - ) - } - // setter - SimpleType::Type(syn::Type::Path(path)) if path.path.is_ident("ReflectedValue") => { - let first_arg_name = &self - .get_other_arguments()? - .next() - .ok_or_else(|| { - syn::Error::new( - self.sig.span, - "Field setter requires a single argument which is missing", - ) - })? - .name; - quote!( - let #raw_output_ident = bevy_script_api::script_ref::ValueIndex::index(& #self_name.reflect_ref(#world_ptr), std::borrow::Cow::Borrowed(#field_name_str)).apply(&#first_arg_name.ref_)?; - ) - } - - // primitive use clone on the value and return it without a wrapper - // getter - _ if self.attrs.kind.is_field_getter() => quote!( - let #raw_output_ident = #self_name.val(|#self_name| #self_name.#field_name.clone())?; - ), - // setter - _ => { - let first_arg_name = &self - .get_other_arguments()? - .next() - .ok_or_else(|| { - syn::Error::new( - self.sig.span, - "Field setter requires a single argument which is missing", - ) - })? - .name; - quote!( - let #raw_output_ident = #self_name.val_mut(|#self_name| #self_name.#field_name = #first_arg_name)?; - ) - } - }) - } - - /// 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_raw_output( - &self, - raw_output_ident: &Ident, - proxied_type_path: &Path, - ) -> syn::Result { - // generate function call on proxied type (operating over unwrapped parameters) - // output will be stored in raw_output_ident with the proxied_type_path - - // the type before we wrap it in a proxy - let raw_output_type = - LuaTypeConstructorVisitor::new(false, false).visit(&self.sig.output.type_); - - match &self.default { - Some(body) => { - let stmts = body.stmts.iter().cloned().map(|mut s| { - IdentifierRenamingVisitor { - target: "self", - replacement: SELF_ALIAS, - } - .visit_stmt_mut(&mut s); - s - }); - - Ok(quote_spanned! {body.span()=> - let #raw_output_ident : #raw_output_type = - (||{ - #(#stmts)* - })(); - }) - } - None => { - let function_name = &self.name; - let param_names = self - .sig - .inputs - .iter() - .map(|arg| &arg.name) - .collect::>(); - - // override this span, as otherwise spans propagate weird - let mut proxied_name = proxied_type_path.clone(); - - proxied_name - .segments - .iter_mut() - .for_each(|v| v.ident.set_span(self.sig.span)); - - let method_path = if let Some(trait_path) = &self.attrs.as_trait { - quote_spanned!(self.sig.span=> - #trait_path::#function_name - ) - } else { - quote_spanned!(self.sig.span=> - #proxied_name::#function_name - ) - }; - - Ok(quote_spanned! {self.sig.span=> - let #raw_output_ident : #raw_output_type = - #method_path(#(#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( - &self, - proxied_output_ident: &Ident, - proxy_output_ident: &Ident, - ) -> syn::Result { - if self.sig.output.is_raw { - return Ok(quote_spanned! {self.sig.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()) - .visit(&self.sig.output.type_)?; - - // the type of the wrapped type (if wrapped) - let proxy_output_type = - LuaTypeConstructorVisitor::new(true, false).visit(&self.sig.output.type_); - - // the statement assigning the proxy output to proxy_output_ident - Ok(quote_spanned! {self.sig.span=> - let #proxy_output_ident : #proxy_output_type = #constructor_wrapped_expression; - }) - } - - pub fn generate_mlua_body( - &self, - proxied_type_path: &Path, - ) -> syn::Result { - let unpacked_parameter_declarations = - self.generate_mlua_body_unwrapped_parameter_assignments()?; - - let raw_output_ident = format_ident!("{RAW_OUT_ALIAS}", span = self.sig.span); - let proxy_output_ident = format_ident!("{PROXY_OUT_ALIAS}", span = self.sig.span); - - let raw_output_stmt = if self.attrs.kind.is_field() { - self.generate_mlua_body_output_field(&raw_output_ident)? - } else { - self.generate_mlua_body_raw_output(&raw_output_ident, proxied_type_path)? - }; - - // for fields the output is expected to be raw anyway so this will just performa no-op - let proxy_output_stmt = - self.generate_mlua_body_proxy_output(&raw_output_ident, &proxy_output_ident)?; - - // determine if we need to wrap the output in an Ok() statement - let last_stm = match &self.sig.output.type_ { - SimpleType::DuoPath(DuoPath { ident, .. }) if *ident == "Result" => { - quote_spanned! {self.sig.span=>#proxy_output_ident} - } - _ => quote_spanned! {self.sig.span=>Ok(#proxy_output_ident)}, - }; - - let conversion_body_stms = quote!( - #raw_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 conversion_body_surrounded_with_dereferening_stms = - self.sig - .inputs - .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.type_, SimpleType::Reference(Reference{ ref inner, .. }) - 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.type_.has_outer_mut_ref() { - format_ident!("val_mut", span = arg_meta.span) - } else { - format_ident!("val", span = arg_meta.span) - }; - - let arg_name = &arg_meta.name; - - quote_spanned! {self.sig.span=>{ - #arg_name.#method_call(|mut #arg_name| {#acc})? - }} - }); - let out = quote!( - #unpacked_parameter_declarations - #conversion_body_surrounded_with_dereferening_stms - ); - - if self.is_unsafe { - Ok(quote_spanned! {self.sig.span=> - unsafe { - #out - } - }) - } else { - Ok(out) - } - } -} diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 439075b9..c1f2fa0e 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -1,26 +1,20 @@ use std::collections::HashMap; -use arg::Arg; use bevy_mod_scripting_common::{input::*, utils::doc_attribute_to_string_lit}; -use syn::{parse_macro_input, DeriveInput, Variant}; +use syn::punctuated::Punctuated; +use syn::{parse_macro_input, parse_quote_spanned, DeriveInput, ExprClosure, FnArg, Variant}; use syn::{ parse_quote, spanned::Spanned, AttrStyle, Attribute, Field, Meta, Path, Token, TraitItemFn, }; -use crate::function::*; -use crate::signature::*; use darling::{FromAttributes, FromDeriveInput}; -use function::FunctionAttributes; use proc_macro::TokenStream; use proc_macro2::*; use quote::*; use vec1::{vec1, Vec1}; -pub(crate) mod arg; -pub(crate) mod function; -pub(crate) mod signature; -pub(crate) mod visitor; const SELF_ALIAS: &str = "_self"; +const CTXT_ALIAS: &str = "lua"; const RAW_OUT_ALIAS: &str = "__proxied_out"; const PROXY_OUT_ALIAS: &str = "__proxy_out"; const PROXY_PREFIX: &str = "Lua"; @@ -30,281 +24,75 @@ const VALID_META_METHODS: [&str; 27] = [ "IPairs", "Iter", "Close", ]; -/// Takes in field with all the required meta and converts it into a -/// TraitItemFn representation -fn convert_field_to_lua_accessor( - idx: usize, - field: &Field, - is_setter: bool, -) -> darling::Result { - let field_name = field - .ident - .clone() - .unwrap_or_else(|| format_ident!("_{}", idx)); - let field_type = &field.ty; - let attrs = &field.attrs; - let mut setter_args: Option = None; - if let Some(attr) = attrs.iter().find(|attr| attr.meta.path().is_ident("lua")) { - attr.parse_nested_meta(|nested| { - if nested.path.is_ident("output") { - nested.parse_nested_meta(|nested| { - setter_args = Some(nested.input.parse()?); - Ok(()) - })? +/// Convert receiver to a standardised form, for example: +/// - instead o a `&self` receiver we have a `_self: LuaRefProxy` +/// - instead of a `&mut self` receiver we have a `_self: LuaRefMutProxy` +/// - instead of a `self` receiver we have a `_self: ValLuaProxy` +fn standardise_receiver<'a>(receiver: &mut FnArg, target_type_ident: &Ident, bms_core_path: &Path) { + let replacement = if let FnArg::Receiver(receiver) = receiver { + let ref_ = &receiver.reference.as_ref().map(|(amp, lifetime)| { + quote_spanned! {receiver.span()=> + #amp #lifetime } - Ok(()) - })?; - } - let setter_arg_attrs = setter_args.map(|tokens| Attribute { - pound_token: Token![#](field.span()), - style: AttrStyle::Outer, - bracket_token: Default::default(), - meta: syn::Meta::List(syn::MetaList { - path: Ident::new("proxy", field.span()).into(), - delimiter: syn::MacroDelimiter::Paren(Default::default()), - tokens, - }), - }); - let trait_item_method: TraitItemFn = if is_setter { - parse_quote! { - #[lua(kind="FieldSetterMethod", raw)] - #(#attrs)* - fn #field_name (&mut self, lua: &Lua, #setter_arg_attrs other: #field_type); - } + }); + + let self_ident = syn::Ident::new(SELF_ALIAS, receiver.span()); + let unproxy_container_name = match (ref_.is_some(), receiver.mutability.is_some()) { + (true, true) => "LuaRefMutProxy", + (true, false) => "LuaRefProxy", + (false, _) => "ValLuProxy", + }; + + Some(syn::FnArg::Typed(parse_quote_spanned! {receiver.span()=> + #self_ident: #bms_core_path::proxy::#unproxy_container_name<#target_type_ident> + })) } else { - parse_quote! { - #[lua(kind="FieldGetterMethod", raw)] - #(#attrs)* - fn #field_name (&self, lua: &Lua) -> #field_type; - } + None }; - - Ok(trait_item_method) + if let Some(replacement) = replacement { + *receiver = replacement; + } } -/// Removes functions from the list and matches them up based on composite ID's into a unified struct -fn extract_composite_functions(functions: &mut Vec) -> Vec { - let indices = functions - .iter() - .enumerate() - .filter_map(|(idx, elem)| { - if elem.attrs.composite.is_some() { - Some(idx) +/// Collect all arguments into a tuple, for example: +/// - `fn foo(a: i32, b: f32)` becomes `(name: (i32, f32))` +fn collect_args_in_tuple<'a, I: Iterator>( + args: I, + name: &Ident, + outer_mut: bool, +) -> FnArg { + let (arg_names, arg_types) = args + .map(|arg| { + if let FnArg::Typed(arg) = arg { + (arg.pat.clone(), arg.ty.clone()) } else { - None + panic!("Function arguments must be typed") } }) - .rev() // reverse order to avoid double shifting things around - .collect::>(); - - let mut composites: HashMap> = HashMap::with_capacity(indices.len()); - for i in indices { - let f = functions.remove(i); - let name = &f.attrs.composite.as_ref().unwrap(); - if composites.contains_key(name.as_str()) { - composites.get_mut(name.as_str()).unwrap().push(f); - } else { - composites.entry((*name).to_owned()).or_insert(vec1![f]); - } - } - - composites - .into_iter() - .map(|(id, functions)| CompositeFunction { id, functions }) - .collect() -} + .unzip::<_, _, Vec<_>, Vec<_>>(); -fn build_function( - proxied_type_path: &Path, - function_def: TraitItemFn, -) -> darling::Result> { - let attrs = FunctionAttributes::from_attributes(&function_def.attrs)?; - // if skipping return no-op - if attrs.skip.is_present() { - return Ok(None); + let outer_mut = if outer_mut { + Some(Token![mut](name.span())) + } else { + None }; - let span = function_def.span(); - - let function_name = function_def.sig.ident.clone(); - let output_attrs = attrs - .output - .clone() - .map(|meta| { - let meta = meta.require_list()?.parse_args::()?; - Ok::<_, syn::Error>(vec![Attribute { - pound_token: Token![#](meta.span()), - style: AttrStyle::Outer, - bracket_token: Default::default(), - meta, - }]) - }) - .transpose()? - .unwrap_or_default(); - - let is_unsafe = function_def.sig.unsafety.is_some(); - - let signature = Signature::new( - proxied_type_path.clone(), - function_def.sig, - attrs.raw.is_present(), - output_attrs, - )?; - Function::new( - function_name.clone(), - attrs, - function_def.default, - signature, - span, - is_unsafe, - ) - .map(Option::Some) + parse_quote!( #outer_mut #name : (#(#arg_types),*) ) } -/// generates either the string function name or the MetaMethod type path depending if it's a valid meta method -fn generate_mlua_function_name(function: &Function) -> syn::Result { - let function_name = &function.name; - let tealr = quote!(bevy_mod_scripting_lua::tealr::mlu::mlua); - if function.attrs.kind.is_meta() { - let metamethod = function.attrs.metamethod.as_ref().ok_or_else(|| { - syn::Error::new( - function.span, - "Missing `metamethod` lua proxy attribute, required for meta functions.", - ) - })?; - // check is valid meta method if not use custom name - if VALID_META_METHODS.contains(&metamethod.to_string().as_str()) { - Ok(quote!(#tealr::MetaMethod::#metamethod)) - } else { - let std_string = metamethod.to_string(); - Ok(quote!(#tealr::MetaMethod::Custom(#std_string.to_string()))) - } - } else { - Ok(function_name.to_string().to_token_stream()) +/// Convert a function definition to a closure, for example: +/// - `fn foo(a: i32, b: f32) -> f32 { a + b }` becomes `|a: i32, b: f32| { a + b} ` +fn convert_function_def_to_closure(f: TraitItemFn) -> ExprClosure { + let span = f.span(); + let sig = f.sig.inputs; + let body = f + .default + .unwrap_or_else(|| panic!("Function {} must have a body", f.sig.ident)); + parse_quote_spanned! {span => + |#sig| #body } } -/// Given a function with correct meta and the name of the proxied type will generate mlua statement -/// which will register the given function within an appropriate mlua container `UserDataMethods` or `UserDataFields` -/// i.e.: -/// ```rust,ignore -/// /// docs -/// fields.#tealr_function(#signature, #closure) -/// // or -/// -/// /// docs -/// methods.#tealr_function(#signature, #closure) -/// ``` -/// depending on if the function is a field accessor or a method/function -fn generate_mlua_registration_code( - container_ident: Ident, - proxied_type_path: &Path, - function: Function, -) -> darling::Result { - let method_documentation_calls = function - .attrs - .doc - .iter() - .map(|tkns| quote_spanned!(function.span=>#container_ident.document_type(#tkns))); - - let tealr_function = format_ident!( - "{}", - function.attrs.kind.get_tealr_function(), - span = function.span - ); - let signature = generate_mlua_function_name(&function)?; - - let args = function.generate_mlua_args()?; - let body = function.generate_mlua_body(proxied_type_path)?; - - Ok(quote_spanned! {body.span()=> - #(#method_documentation_calls);* - #container_ident.#tealr_function(#signature,|#args| { - #body - }); - }) -} - -/// Same as generate_mlua_registration_code but for composite functions -fn generate_mlua_registration_code_composite( - container_ident: Ident, - proxied_type_path: &Path, - functions: CompositeFunction, -) -> darling::Result { - let tealr = quote!(bevy_mod_scripting_lua::tealr::mlu); - let mut method_documentation_calls = Vec::default(); - let first = functions.functions.first(); - // take the first functions for function signature from the composite - let tealr_function = format_ident!( - "{}", - first.attrs.kind.get_tealr_function(), - span = first.span - ); - let signature = generate_mlua_function_name(first)?; - let (main_arg_names, main_arg_types) = first - .get_other_arguments()? - .map(|a| (a.name.clone(), quote!(#tealr::mlua::Value))) - .unzip::<_, _, Vec<_>, Vec<_>>(); - - let dispatchers = - functions - .functions - .iter() - .map(|function| { - // this is much easier, receivers need special treatment on mlua side - // function args are treated equally, we just need a union for lhs and rhs then to convert those args and - // pass dispatch them to the appropriate function - if function.attrs.kind.expects_receiver() || function.attrs.raw.is_present() { - return Err(syn::Error::new( - function.span, - "Composite functions with receivers are not supported, use a function instead", - )); - } - - method_documentation_calls.extend(function.attrs.doc.iter().map( - |tkns| quote_spanned!(function.span=>#container_ident.document_type(#tkns);), - )); - - let (arg_names, arg_types) = function - .sig - .inputs - .iter() - .map(Arg::arg_signature) - .unzip::<_, _, Vec<_>, Vec<_>>(); - let body = function.generate_mlua_body(proxied_type_path)?; - Ok(quote_spanned!(function.span=> - match (#(<#arg_types as #tealr::mlua::FromLua>::from_lua(#main_arg_names.clone(), ctxt)),*) { - (#(Ok(#arg_names)),*) => { - let out = { - #body - }; - return out.and_then(|out| #tealr::mlua::IntoLua::into_lua(out, ctxt)) - }, - _ => (), - }; - )) - }) - .collect::>>()?; - - // let (variant_idents, variant_types) = unique_types.iter().unzip(); - // let composite_id = Ident::new(&functions.id, first.span); - let composite = quote_spanned! {first.span=> - // bevy_script_api::impl_tealr_any_union!(#composite_id = #(#variant_idents: #variant_types),*) - #(#method_documentation_calls)* - #container_ident.#tealr_function(#signature,|ctxt, (#(#main_arg_names),*) : (#(#main_arg_types),*)| { - #(#dispatchers)* - Err(#tealr::mlua::Error::RuntimeError( - format!("Function `{}` has no overloaded version accepting argument types: `{}`", - #signature, - vec![#(#main_arg_names.type_name()),*].join(", ") - ) - ) - ) - }); - }; - Ok(composite) -} - #[proc_macro_derive(LuaProxy, attributes(lua, proxy))] pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let derive_input = parse_macro_input!(input as DeriveInput); @@ -323,37 +111,21 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { .into(); } - let proxied_type_path: syn::Path = meta.remote.unwrap_or(meta.ident.clone().into()); - let proxied_type_str = proxied_type_path.segments.last().unwrap().ident.to_string(); - let proxy_type_ident = format_ident!("{PROXY_PREFIX}{}", &meta.ident); - let tealr = quote!(bevy_mod_scripting_lua::tealr::mlu); - - // optional clone extensions - let opt_with_clone = meta - .derive - .clone - .is_present() - .then_some(quote_spanned! {derive_input.span()=>with Clone}) - .unwrap_or_default(); - - let opt_from_lua_proxy = meta.derive.clone.is_present().then_some( - quote_spanned!{derive_input.span()=> - impl bevy_script_api::lua::FromLuaProxy<'_> for #proxied_type_path { - fn from_lua_proxy<'lua>(lua_value: #tealr::mlua::Value<'lua>, _: &'lua #tealr::mlua::Lua) -> #tealr::mlua::Result { - if let #tealr::mlua::Value::UserData(ud) = lua_value{ - let wrapper = ud.borrow::<#proxy_type_ident>()?; - Ok(std::ops::Deref::deref(&wrapper).inner()?) - } else { - Err(#tealr::mlua::Error::FromLuaConversionError{ - from: "Value", - to: #proxied_type_str, - message: None - }) - } - } - } - } - ).unwrap_or_default(); + let target_type_ident = &meta.ident; + let target_type_path: syn::Path = meta.remote.unwrap_or(meta.ident.clone().into()); + let target_type_str = target_type_path.segments.last().unwrap().ident.to_string(); + let proxy_type_ident = meta.proxy_name.unwrap_or_else(|| { + format_ident!("{PROXY_PREFIX}{}", &meta.ident, span = meta.ident.span()) + }); + + let bms_core = meta.bms_core_path.0; + let bms_lua = meta.bms_lua_path.0; + let tealr = quote_spanned!(bms_lua.span()=> + #bms_lua::tealr + ); + let mlua = quote_spanned!(bms_core.span()=> + #tealr::mlu::mlua + ); // generate type level tealr documentation calls let type_level_document_calls = meta @@ -361,183 +133,114 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { .iter() .filter(|&a| a.meta.path().is_ident("doc")) .map(doc_attribute_to_string_lit) - .map(|tkns| quote_spanned!(derive_input.span()=>methods.document_type(#tkns);)); - - // generate method equivalents for each field, i.e. unify fields and methods as both can be represented as functions - let field_methods: Vec = match meta.data { - darling::ast::Data::::Struct(fields) => { - let mut out: Vec<_> = Default::default(); - let mut errors = darling::Error::accumulator(); - - out.extend( - fields - .iter() - .enumerate() - .filter_map(|(idx, field)| { - errors.handle_in(|| convert_field_to_lua_accessor(idx, field, false)) - }) - .collect::>(), - ); - - out.extend( - fields - .iter() - .enumerate() - .filter_map(|(idx, field)| { - errors.handle_in(|| convert_field_to_lua_accessor(idx, field, true)) - }) - .collect::>(), - ); - - // short circuit if found any errors - if let Err(e) = errors.finish() { - return e.write_errors().into(); - } - - out - } - _ => panic!("Enums or Unions are not supported"), - }; - - let mut errors = darling::Error::accumulator(); - - // generate both tealr documentation and instantiations of functions and field getters/setters - let mut methods = meta - .functions - .0 - .into_iter() - .filter_map(|v| { - errors - .handle_in(|| build_function(&proxied_type_path, v)) - .flatten() - }) - .collect::>(); - - let composites = extract_composite_functions(&mut methods) - .into_iter() - .flat_map(|function| { - errors.handle_in(|| { - generate_mlua_registration_code_composite( - format_ident!("methods", span = function.functions.first().span), - &proxied_type_path, - function, - ) - }) - }) - .collect::>(); - - // for methods, allow composite functions with combined signatures and runtime dispatch based on type + .map(|tkns| { + quote_spanned!(meta.ident.span()=> + methods.document_type(#tkns); + ) + }); - let fields = field_methods - .into_iter() - .flat_map(|v| { - errors - .handle_in(|| build_function(&proxied_type_path, v)) - .flatten() - }) - .collect::>(); - - let methods = methods - .into_iter() - .map(|function| { - errors.handle_in(|| { - generate_mlua_registration_code( - format_ident!("methods", span = function.span), - &proxied_type_path, - function, - ) - }) - }) - .collect::>(); - - let fields = fields - .into_iter() - .map(|function| { - errors.handle_in(|| { - generate_mlua_registration_code( - format_ident!("fields", span = function.span), - &proxied_type_path, - function, - ) + let add_function_stmts = meta.functions.0.into_iter().map(|mut f| { + if let Some(first_arg) = f.sig.inputs.first_mut() { + standardise_receiver(first_arg, target_type_ident, &bms_core) + }; + // collect all args into tuple and add lua context arg + let ctxt_alias = syn::Ident::new(CTXT_ALIAS, f.sig.inputs.span()); + let ctxt_arg = parse_quote_spanned! {f.span()=> + #ctxt_alias: &#mlua::Lua + }; + + let func_name = &f.sig.ident; + let (original_arg_idents, original_arg_types) = f + .sig + .inputs + .iter() + .map(|arg| { + if let FnArg::Typed(arg) = arg { + (arg.pat.clone(), arg.ty.clone()) + } else { + panic!("Function arguments must be typed") + } }) - }) - .collect::>(); - - // stop if any errors so far - if let Err(e) = errors.finish() { - return e.write_errors().into(); - } - - quote_spanned! {derive_input.span()=> - - bevy_script_api::make_script_wrapper!(#proxied_type_path as #proxy_type_ident #opt_with_clone); - bevy_script_api::impl_from_lua_with_clone!(#proxy_type_ident); - bevy_script_api::impl_tealr_type!(#proxy_type_ident); - - #opt_from_lua_proxy - - #[automatically_derived] - #[allow(unused_parens, unused_braces, unused_mut, unused_variables)] - #[allow(clippy::all)] - impl #tealr::TealData for #proxy_type_ident { - fn add_methods<'lua, T: #tealr::TealDataMethods<'lua, Self>>(methods: &mut T) { - #(#type_level_document_calls)* - #(#methods)* - #(#composites)* + .unzip::<_, _, Vec<_>, Vec<_>>(); + + let span = f.span(); + let args_ident = format_ident!("args", span = f.sig.inputs.span()); + f.sig.inputs = Punctuated::from_iter(vec![ + ctxt_arg, + collect_args_in_tuple(f.sig.inputs.iter(), &args_ident, true), + ]); + + let out_type = match &f.sig.output { + syn::ReturnType::Default => quote_spanned! {f.span()=> + () + }, + syn::ReturnType::Type(_, ty) => ty.to_token_stream(), + }; + + // wrap function body in our unwrapping and wrapping logic, ignore pre-existing body + f.default = Some(parse_quote_spanned! {span=> + { + let mut world: #bms_lua::bindings::proxy::LuaNonReflectProxy<#bms_core::bindings::WorldCallbackAccess> = lua.globals().get("world")?; + let mut world = <#bms_lua::bindings::proxy::LuaNonReflectProxy<#bms_core::bindings::WorldCallbackAccess> as #bms_core::proxy::Unproxy>::unproxy(&mut world).map_err(#mlua::Error::external)?; + let mut world = world.read().ok_or_else(|| #mlua::Error::external("World no longer exists"))?; + + // get allocator and type registry + + let cell = world.as_unsafe_world_cell(); + let allocator_resource_id = cell.components().resource_id::<#bms_core::allocator::ReflectAllocator>().expect("Reflect Allocator wasn't initialized"); + let type_registry_resource_id = cell.components().resource_id::().expect("Type Registry wasn't initialized"); + + let allocator_access = world.get_access(allocator_resource_id.into()).expect("Deadlock while accessing allocator"); + let type_registry_access = world.get_access(type_registry_resource_id.into()).expect("Deadlock while accessing type registry"); + + let allocator = world.get_resource::<#bms_core::allocator::ReflectAllocator>(&allocator_access).unwrap().unwrap(); + let type_registry = world.get_resource::(&type_registry_access).unwrap().unwrap(); + let type_registry = type_registry.read(); + let mut world_acceses = Vec::default(); + // Safety: we pinky promise not to touch world_accessses after this point + let (#( #original_arg_idents ),*) = unsafe { <(#(#original_arg_types),*) as #bms_core::proxy::Unproxy>::unproxy_with_world(&mut #args_ident, &world, &mut world_acceses, &type_registry, &allocator).map_err(#mlua::Error::external)? }; + + // call proxy function + let out = #target_type_ident::#func_name(#(#original_arg_idents),*); + // TODO: output proxies + Ok(<#out_type as #bms_core::proxy::Proxy>::proxy(out)) } + }); - fn add_fields<'lua, T: #tealr::TealDataFields<'lua, Self>>(fields: &mut T) { - #(#fields)* - } + let name = f.sig.ident.to_string(); + let closure = convert_function_def_to_closure(f); + quote_spanned! {span=> + methods.add_function(#name, #closure); } + }); - #[allow(clippy::all, unused_variables)] - impl bevy_script_api::lua::LuaProxyable for #proxied_type_path { - fn ref_to_lua<'lua>(self_ : bevy_script_api::script_ref::ReflectReference, lua: &'lua #tealr::mlua::Lua) -> #tealr::mlua::Result<#tealr::mlua::Value<'lua>> { - <#proxy_type_ident as #tealr::mlua::IntoLua>::into_lua(#proxy_type_ident::new_ref(self_),lua) - } + let vis = &meta.vis; + quote_spanned! {meta.ident.span()=> - fn apply_lua<'lua>(self_ : &mut bevy_script_api::script_ref::ReflectReference, lua: &'lua #tealr::mlua::Lua, new_val: #tealr::mlua::Value<'lua>) -> #tealr::mlua::Result<()> { - if let #tealr::mlua::Value::UserData(v) = new_val { - let other = v.borrow::<#proxy_type_ident>()?; - let other = &other; + #vis struct #proxy_type_ident (pub #bms_core::bindings::ReflectReference); - other.apply_self_to_base(self_)?; - Ok(()) - } else { - Err(#tealr::mlua::Error::RuntimeError( - "Error in assigning to custom user data".to_owned(), - )) - } + impl #tealr::mlu::TealData for #proxy_type_ident { + fn add_methods<'lua, M: #tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut M) { + #(#type_level_document_calls)* + #(#add_function_stmts)* } } - #[allow(clippy::all, unused_variables)] - impl bevy_script_api::lua::IntoLuaProxy<'_> for #proxied_type_path { - fn to_lua_proxy<'lua>(self, lua: &'lua #tealr::mlua::Lua) -> #tealr::mlua::Result<#tealr::mlua::Value<'lua>>{ - <#proxy_type_ident as #tealr::mlua::IntoLua>::into_lua(#proxy_type_ident::new(self),lua) + impl #tealr::ToTypename for #proxy_type_ident { + fn to_typename() -> #tealr::Type { + #tealr::Type::Single(#tealr::SingleType { + name: #tealr::Name(#target_type_str.into()), + kind: #tealr::KindOfType::External, + }) } } + } .into() } -#[cfg(test)] -mod test { - - use crate::function::FunctionAttributes; - use darling::FromAttributes; - use syn::TraitItemFn; - - #[test] - fn test_parse_function_attributes_parses() { - let function = " - #[lua(output(proxy))] - fn asd(#[proxy] arg: String, #[proxy(Type=\"LuaType\")] arg2: (String, Type)) -> String; - "; - let trait_fn: TraitItemFn = syn::parse_str(function).unwrap(); - - FunctionAttributes::from_attributes(&trait_fn.attrs).unwrap(); - } -} +// test cases TODO: +// - pub/private wrapper being generated correctly +// - proxy name being generated correctly with custom name +// - proxy name being generated correctly with default name diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/signature.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/signature.rs deleted file mode 100644 index 26aca7fd..00000000 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/signature.rs +++ /dev/null @@ -1,143 +0,0 @@ -use std::collections::HashMap; - -use bevy_mod_scripting_common::input::SimpleType; -use darling::FromAttributes; -use proc_macro2::{Ident, Span}; -use syn::{ - spanned::Spanned, token::Mut, Attribute, FnArg, Pat, PatIdent, PatType, Path, ReturnType, Type, - TypeTuple, -}; - -use crate::{ - arg::{Arg, ArgAttributes}, - PROXY_PREFIX, RAW_OUT_ALIAS, SELF_ALIAS, -}; - -/// Describes the functional signature of a function from the `functions[..]` list -#[derive(Debug)] -pub struct Signature { - pub inputs: Vec, - pub output: Arg, - pub span: Span, -} - -impl Signature { - /// Creates a new signature struct - /// if in_raw_function will set is_raw on all arguments and outputs to true - /// if is_field_setter, output_attrs will be applied to the third argument of the function if it exists (the first non self or ctxt arg) - pub fn new( - proxied_type_path: Path, - sig: syn::Signature, - in_raw_function: bool, - output_attrs: Vec, - ) -> darling::Result { - // convert output to FnArg - let output_arg_name = Ident::new(RAW_OUT_ALIAS, sig.output.span()); - let span = sig.span(); - // if no return type specified use `()` - let output_type = match sig.output { - ReturnType::Default => Type::Tuple(TypeTuple { - paren_token: Default::default(), - elems: Default::default(), - }), - ReturnType::Type(_, ty) => *ty, - }; - - let inputs = sig - .inputs - .into_iter() - .map(|arg| Self::convert_fn_arg(arg, &proxied_type_path, in_raw_function)) - .collect::>>()?; - - // convert to Arg structs - let output = Self::convert_type( - output_type, - &proxied_type_path, - in_raw_function, - output_attrs, - output_arg_name, - None, - )?; - - Ok(Self { - inputs, - output, - span, - }) - } - - /// Convert a function argument into custom Arg struct by converting the type to SimpleType and parsing attributes - fn convert_fn_arg( - arg: FnArg, - proxied_type_path: &Path, - in_raw_function: bool, - ) -> darling::Result { - let type_map = HashMap::from_iter([( - proxied_type_path.segments.last().unwrap().clone().ident, - None, - )]); - - Ok(match arg { - FnArg::Receiver(ref receiver) => { - let type_ = - SimpleType::new_from_fn_arg(PROXY_PREFIX, &arg, proxied_type_path, &type_map)?; - let attrs = ArgAttributes::from_attributes(&receiver.attrs)?; - Arg::new( - attrs, - Ident::new(SELF_ALIAS, receiver.span()), - receiver.mutability, - type_, - in_raw_function, - ) - } - FnArg::Typed(PatType { attrs, pat, ty, .. }) => { - let (mutability, arg_name) = match pat.as_ref() { - Pat::Ident(PatIdent { - mutability, ident, .. - }) => (mutability, ident), - _ => return Err(darling::Error::custom("Unsupported parameter pattern")), - }; - - Self::convert_type( - *ty, - proxied_type_path, - in_raw_function, - attrs, - arg_name.clone(), - *mutability, - )? - } - }) - } - - /// Convert a type corresponding to an argument into an Arg struct by converting it to a Simple type and parsing the given attributes - fn convert_type( - ty: Type, - proxied_type_path: &Path, - in_raw_function: bool, - attrs: Vec, - arg_name: Ident, - mutability: Option, - ) -> darling::Result { - let mut type_map = HashMap::from_iter([( - proxied_type_path.segments.last().unwrap().clone().ident, - None, - )]); - let is_proxy = attrs.iter().any(|a| a.path().is_ident("proxy")); - let attrs = ArgAttributes::from_attributes(&attrs)?; - let type_ = if is_proxy && attrs.map.is_empty() { - SimpleType::new_from_contextual_type_proxy_all(PROXY_PREFIX, &ty, proxied_type_path)? - } else { - type_map.extend(attrs.map.iter().map(|(a, b)| (a.clone(), Some(b.clone())))); - SimpleType::new_from_contextual_type(PROXY_PREFIX, &ty, proxied_type_path, &type_map)? - }; - - Ok(Arg::new( - attrs, - arg_name, - mutability, - type_, - in_raw_function, - )) - } -} diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/visitor.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/visitor.rs deleted file mode 100644 index 2dc8ec2b..00000000 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/visitor.rs +++ /dev/null @@ -1,386 +0,0 @@ -/// 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 quote::*; -use syn::*; - -/// Generates an unwrapping expression which can be used to assign the unwrapped proxy to a variable. -/// the argument `#[proxy] arg: MyType` will generate the following expression: -/// ```rust,ignore -/// arg.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) -> syn::Result { - Ok(quote_spanned!(self.span=> ())) - } - - fn visit_proxy_type( - &mut self, - _: &ProxyType, - is_child_of_reference: bool, - ) -> syn::Result { - let arg_name: &Ident = &self.arg_name; - - if is_child_of_reference { - Ok(quote_spanned!(self.span=> #arg_name)) - } else { - Ok(quote_spanned!(self.span=> #arg_name.inner()?)) - } - } - - fn visit_type(&mut self, _type: &Type, _: bool) -> syn::Result { - let arg_name: &Ident = &self.arg_name; - Ok(quote_spanned!(self.span=> #arg_name)) - } - - fn visit_unit_path( - &mut self, - unit_path: &UnitPath, - _: bool, - ) -> syn::Result { - 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; - Ok(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; - Ok(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) => Err(syn::Error::new_spanned( - &unit_path.ident, - format!("`{}` is not yet supported", unsupported_std_type), - )), - _ => Err(syn::Error::new_spanned( - &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, - ) -> syn::Result { - 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; - Ok(quote_spanned!(self.span=> - #arg_name.map(|mut #arg_name| #inner) - )) - } - Some(StdTypeIdent::Vec) => { - let inner = self.visit_simple_type(&unit_path.inner, false)?; - let arg_name = &self.arg_name; - - Ok(quote_spanned!(self.span=> - #arg_name.into_iter().map(|mut #arg_name| #inner).collect::>() - )) - } - Some(unsupported_std_type) => Err(syn::Error::new_spanned( - &unit_path.ident, - format!("`{}` is not yet supported", unsupported_std_type), - )), - _ => Err(syn::Error::new_spanned( - &unit_path.ident, - "Unsupported type", - )), - } - } - - fn visit_duo_path( - &mut self, - duo_path: &DuoPath, - _: bool, - ) -> syn::Result { - 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; - Ok(quote_spanned!(self.span=> - #arg_name.map(|mut #arg_name| #left).map_err(|#arg_name| #tealr::mlu::mlua::Error::external(#right)) - )) - } - Some(unsupported_std_type) => Err(syn::Error::new_spanned( - &duo_path.ident, - format!("`{}` is not yet supported", unsupported_std_type), - )), - _ => Err(syn::Error::new_spanned(&duo_path.ident, "Unsupported type")), - } - } - - fn visit_unit(&mut self, _: bool) -> syn::Result { - Ok(quote_spanned!(self.span=> - () - )) - } - - fn visit_proxy_type( - &mut self, - proxy_type: &ProxyType, - _: bool, - ) -> syn::Result { - let proxy_ident = &proxy_type.proxy_ident; - let arg_name = &self.arg_name; - Ok(quote_spanned! {self.span=> - #proxy_ident::new(#arg_name) - }) - } - - fn visit_type(&mut self, _type: &Type, _: bool) -> syn::Result { - Ok(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(), - ) - .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(), - ) - .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(|mut 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(), - ) - .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(), - ) - .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(), - ) - .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(), - ) - .unwrap(); - - assert_eq!(output.to_string(), expected.to_string()) - } -} From e078be0fc234b45bc6c689752c8d522d5b4d3ccd Mon Sep 17 00:00:00 2001 From: makspll Date: Sun, 21 Apr 2024 17:20:41 +0100 Subject: [PATCH 09/17] begin migrating codegen --- crates/bevy_api_gen/templates/item.tera | 5 - .../bevy_mod_scripting_core/src/bindings.rs | 21 +- crates/bevy_mod_scripting_core/src/error.rs | 3 + crates/bevy_mod_scripting_core/src/proxy.rs | 160 +- .../src/bindings/providers/bevy_core.rs | 73 + .../src/bindings/providers/bevy_ecs.rs | 364 + .../src/bindings/providers/bevy_hierarchy.rs | 101 + .../src/bindings/providers/bevy_input.rs | 1492 + .../src/bindings/providers/bevy_reflect.rs | 24663 ++++++++++++++++ .../src/bindings/providers/bevy_time.rs | 701 + .../src/bindings/providers/bevy_transform.rs | 716 + .../src/bindings/providers/bevy_window.rs | 1624 + .../src/bindings/providers/mod.rs | 43 +- .../src/bindings/proxy.rs | 52 +- .../src/bindings/world.rs | 9 +- .../bevy_mod_scripting_lua/src/lib.rs | 7 +- .../bevy_mod_scripting_lua/src/util.rs | 2 +- .../bevy_mod_scripting_lua_derive/src/lib.rs | 18 +- makefile | 2 +- 19 files changed, 29965 insertions(+), 91 deletions(-) create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs diff --git a/crates/bevy_api_gen/templates/item.tera b/crates/bevy_api_gen/templates/item.tera index f40dfaac..f1446d51 100644 --- a/crates/bevy_api_gen/templates/item.tera +++ b/crates/bevy_api_gen/templates/item.tera @@ -5,11 +5,6 @@ #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( -derive( - {%- if item.impls_clone -%} - clone, - {%- endif -%} -), remote="{{ item.import_path }}", functions[ {%- filter separated(delimeter=",\n\t\t\t", split_at="---", ignore_first=true) -%} diff --git a/crates/bevy_mod_scripting_core/src/bindings.rs b/crates/bevy_mod_scripting_core/src/bindings.rs index b4121382..f89ffedd 100644 --- a/crates/bevy_mod_scripting_core/src/bindings.rs +++ b/crates/bevy_mod_scripting_core/src/bindings.rs @@ -8,6 +8,7 @@ use lockable::LockableHashMap; use std::{ any::TypeId, + cell::UnsafeCell, fmt::Debug, marker::PhantomData, sync::{Arc, Weak}, @@ -28,7 +29,11 @@ use bevy::{ }, }; -use crate::{allocator::ReflectAllocationId, error::ReflectionError, prelude::ReflectAllocator}; +use crate::{ + allocator::{ReflectAllocation, ReflectAllocationId}, + error::ReflectionError, + prelude::ReflectAllocator, +}; /// Describes kinds of base value we are accessing via reflection #[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] @@ -405,6 +410,20 @@ pub struct ReflectReference { struct UnregisteredType; impl ReflectReference { + pub fn new_allocated( + value: T, + allocator: &mut ReflectAllocator, + ) -> ReflectReference { + let id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(value)))); + ReflectReference { + base: ReflectBaseType { + type_id: TypeId::of::(), + base_id: ReflectBase::Owned(id), + }, + reflect_path: Vec::default(), + } + } + /// Returns `Ok(())` if the given access is sufficient to read the value or an appropriate error otherwise pub fn expect_read_access<'w>( &self, diff --git a/crates/bevy_mod_scripting_core/src/error.rs b/crates/bevy_mod_scripting_core/src/error.rs index c245aed8..07fdac3d 100644 --- a/crates/bevy_mod_scripting_core/src/error.rs +++ b/crates/bevy_mod_scripting_core/src/error.rs @@ -1,3 +1,4 @@ +use bevy::reflect::Reflect; use thiserror::Error; use crate::{allocator::ReflectAllocationId, bindings::ReflectReference}; @@ -89,6 +90,8 @@ pub enum ReflectionError { reference: ReflectReference, to: String, }, + #[error("Failed to build concrete type from &Reflect type: {ref_}")] + FromReflectFailure { ref_: String }, #[error("Could not dereference script allocation with ID: {id}. {reason}")] AllocationError { id: ReflectAllocationId, diff --git a/crates/bevy_mod_scripting_core/src/proxy.rs b/crates/bevy_mod_scripting_core/src/proxy.rs index 7e39b437..aa56119d 100644 --- a/crates/bevy_mod_scripting_core/src/proxy.rs +++ b/crates/bevy_mod_scripting_core/src/proxy.rs @@ -1,8 +1,10 @@ //! Set of traits used to define how types are turned into and from proxies in Lua. //! Proxies can either be logical "copies" or owned "direct representations" of the instance, or references to one via the [`bevy_mod_scripting_core::bindings::ReflectReference`] construct. use std::{ + cell::UnsafeCell, marker::PhantomData, num::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}, + sync::Arc, }; use bevy::{ @@ -11,15 +13,33 @@ use bevy::{ }; use crate::{ - bindings::{ReflectReference, WorldAccessGuard, WorldAccessUnit, WorldAccessWrite}, + allocator::ReflectAllocation, + bindings::{ + ReflectBaseType, ReflectReference, WorldAccessGuard, WorldAccessUnit, WorldAccessWrite, + }, prelude::{ReflectAllocator, ReflectionError}, }; /// Inverse to [`Unproxy`], packages up a type into a proxy type. -pub trait Proxy { +pub trait Proxy<'a>: Sized { type Input; - fn proxy(input: Self::Input) -> Self; + /// Proxies a type without access to the allocator, types which require access to the allocator will throw an error here + fn proxy(input: Self::Input) -> Result { + Err(ReflectionError::InsufficientAccess { + base: std::any::type_name::().to_owned(), + reason: "Attempted to proxy a type that requires an allocator without providing it" + .to_owned(), + }) + } + + /// Proxies a type with access to the allocator + fn proxy_with_allocator( + input: Self::Input, + _allocator: &mut ReflectAllocator, + ) -> Result { + Self::proxy(input) + } } /// A mechanism for converting proxy types into their represented types. @@ -27,8 +47,8 @@ pub trait Proxy { /// `RefProxy` and `RefMutProxy` are such 'meta-proxy' types. /// /// the [`Unproxy::Output`] type parameter is the type that this `proxy` will be converted to after unwrapping. -pub trait Unproxy<'w, 'c> { - type Output: 'c; +pub trait Unproxy<'w, 'o> { + type Output: 'o; fn collect_accesses( &self, @@ -44,7 +64,7 @@ pub trait Unproxy<'w, 'c> { /// Unproxies a proxy type into the represented type without world access /// This will fail on proxies which require world access to unproxy (for example those whose proxies are glorified [`ReflectReference`]'s ) - fn unproxy(&'c mut self) -> Result { + fn unproxy(&'o mut self) -> Result { Err(ReflectionError::InsufficientAccess { base: std::any::type_name::().to_owned(), reason: "Attempted to unproxy a type that requires world access without providing it" @@ -56,11 +76,11 @@ pub trait Unproxy<'w, 'c> { /// # Safety /// - The caller must not use the accesses in the accesses list after the unproxy call at all, as implementors assume they have unique access to the accesses. unsafe fn unproxy_with_world( - &'c mut self, + &'o mut self, _guard: &WorldAccessGuard<'w>, - _accesses: &'c [WorldAccessUnit<'w>], + _accesses: &'o [WorldAccessUnit<'w>], _type_registry: &TypeRegistry, - _allocator: &'c ReflectAllocator, + _allocator: &'o ReflectAllocator, ) -> Result { self.unproxy() } @@ -119,14 +139,31 @@ where } } -impl Proxy for ValProxy +impl Proxy<'_> for ValProxy where T: Into

, { type Input = T; - fn proxy(input: Self::Input) -> Self { - ValProxy::new(input.into()) + fn proxy(input: Self::Input) -> Result { + Ok(ValProxy::new(input.into())) + } +} + +impl Proxy<'_> for ReflectValProxy +where + T: Reflect, + P: From, +{ + type Input = T; + + fn proxy_with_allocator( + input: Self::Input, + allocator: &mut ReflectAllocator, + ) -> Result { + Ok(Self::new( + ReflectReference::new_allocated(input, allocator).into(), + )) } } @@ -168,6 +205,26 @@ where } } +impl<'a, T, P> Proxy<'a> for ReflectRefProxy +where + T: FromReflect, + P: From, +{ + type Input = &'a T; + + fn proxy_with_allocator( + input: Self::Input, + allocator: &mut ReflectAllocator, + ) -> Result { + let inner = T::from_reflect(input).ok_or_else(|| ReflectionError::FromReflectFailure { + ref_: input.reflect_type_path().to_owned(), + })?; + Ok(Self::new( + ReflectReference::new_allocated(inner, allocator).into(), + )) + } +} + impl<'w, 'c, T, P> Unproxy<'w, 'c> for ReflectRefProxy where P: AsRef, @@ -344,12 +401,22 @@ impl<'w, 'c, T: Unproxy<'w, 'c>> Unproxy<'w, 'c> for Vec { } } -impl Proxy for Vec { +impl<'a, T: Proxy<'a>> Proxy<'a> for Vec { type Input = Vec; - fn proxy(input: Self::Input) -> Self { + fn proxy(input: Self::Input) -> Result { input.into_iter().map(T::proxy).collect() } + + fn proxy_with_allocator( + input: Self::Input, + _allocator: &mut ReflectAllocator, + ) -> Result { + input + .into_iter() + .map(|i| T::proxy_with_allocator(i, _allocator)) + .collect() + } } impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for &T { @@ -360,11 +427,18 @@ impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for &T { } } -impl<'a, T: Proxy> Proxy for &'a T { +impl<'a, T: Proxy<'a>> Proxy<'a> for &'a T { type Input = &'a T; - fn proxy(input: Self::Input) -> Self { - input + fn proxy(input: Self::Input) -> Result { + Ok(input) + } + + fn proxy_with_allocator( + input: Self::Input, + _allocator: &mut ReflectAllocator, + ) -> Result { + Ok(input) } } @@ -376,11 +450,18 @@ impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for &mut T { } } -impl<'a, T: Proxy> Proxy for &'a mut T { +impl<'a, T: Proxy<'a>> Proxy<'a> for &'a mut T { type Input = &'a mut T; - fn proxy(input: Self::Input) -> Self { - input + fn proxy(input: Self::Input) -> Result { + Ok(input) + } + + fn proxy_with_allocator( + input: Self::Input, + _allocator: &mut ReflectAllocator, + ) -> Result { + Ok(input) } } @@ -426,11 +507,20 @@ impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for Option { } } -impl Proxy for Option { +impl<'a, T: Proxy<'a>> Proxy<'a> for Option { type Input = Option; - fn proxy(input: Self::Input) -> Self { - input.map(T::proxy) + fn proxy(input: Self::Input) -> Result { + input.map(T::proxy).transpose() + } + + fn proxy_with_allocator( + input: Self::Input, + _allocator: &mut ReflectAllocator, + ) -> Result { + input + .map(|i| T::proxy_with_allocator(i, _allocator)) + .transpose() } } @@ -451,11 +541,11 @@ macro_rules! impl_unproxy_by_move { macro_rules! impl_proxy_by_move { ($($ty:ident),*) => { $( - impl Proxy for $ty { + impl Proxy<'_> for $ty { type Input = Self; - fn proxy(input: Self::Input) -> Self { - input + fn proxy(input: Self::Input) -> Result { + Ok(input) } } )* @@ -527,13 +617,17 @@ impl_proxy_by_move!(String); macro_rules! impl_tuple_unproxy_proxy { ($(($ty:ident, $idx:tt)),*) => { - impl <$($ty : Proxy,)*> Proxy for ($($ty,)*) + impl <'a,$($ty : Proxy<'a>,)*> Proxy<'a> for ($($ty,)*) { type Input = ($($ty::Input,)*); #[allow(clippy::unused_unit)] - fn proxy(_input: Self::Input) -> Self { - ($($ty::proxy(_input.$idx),)*) + fn proxy(_input: Self::Input) -> Result { + Ok(($($ty::proxy(_input.$idx)?,)*)) + } + + fn proxy_with_allocator(_input: Self::Input, _allocator: &mut ReflectAllocator) -> Result { + Ok(($($ty::proxy_with_allocator(_input.$idx, _allocator)?,)*)) } } @@ -674,11 +768,15 @@ mod test { let mut accesses = SmallVec::new(); let world = WorldAccessGuard::new(&mut world); let type_registry = TypeRegistry::default(); - let allocator = ReflectAllocator::default(); + let mut allocator = ReflectAllocator::default(); - let mut proxy = $($proxy_ty)*::proxy($original); + // test allocator version works as well + $($proxy_ty)*::proxy_with_allocator($original, &mut allocator).unwrap(); + // test proxying works + let mut proxy = $($proxy_ty)*::proxy($original).unwrap(); proxy.collect_accesses(&world, &mut accesses).unwrap(); + // test both unproxy methods work let unproxied = unsafe { proxy .unproxy_with_world(&world, &mut accesses, &type_registry, &allocator) diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs new file mode 100644 index 00000000..66488afd --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs @@ -0,0 +1,73 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_ecs::*; +use super::bevy_reflect::*; +extern crate self as bevy_script_api; +use bevy_script_api::{ + lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, +}; +use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::core::prelude::Name", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &name::Name) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::core::prelude::Name; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct Name {} +#[derive(Default)] +pub(crate) struct Globals; +impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { + 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<()> { + Ok(()) + } +} +fn bevy_core_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut bevy_mod_scripting_lua::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyCoreScriptingPlugin; +impl bevy::app::Plugin for BevyCoreScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.register_foreign_lua_type::(); + app.add_context_initializer::<()>(bevy_core_context_initializer); + app.add_documentation_fragment( + bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + "BevyCoreAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + }, + ), + ); + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs new file mode 100644 index 00000000..f1efa51f --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs @@ -0,0 +1,364 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_reflect::*; +extern crate self as bevy_script_api; +use bevy_script_api::{ + lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, +}; +use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::entity::Entity", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::entity::Entity; + +"#, + r#" +/// Creates a new entity ID with the specified `index` and a generation of 1. +/// # 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. + + #[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. +/// 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. + + #[lua(kind = "Method")] + fn to_bits(self) -> u64; + +"#, + r#" +/// 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. +/// # Panics +/// This method will likely panic if given `u64` values that did not come from [`Entity::to_bits`]. + + #[lua(kind = "Function", output(proxy))] + fn from_bits(bits: u64) -> bevy::ecs::entity::Entity; + +"#, + r#" +/// 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. + + #[lua(kind = "Method")] + 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(kind = "Method")] + fn generation(self) -> u32; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &entity::Entity) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Entity {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::component::ComponentId", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::component::ComponentId; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &component::ComponentId) -> bool; + +"#, + r#" +/// Creates a new [`ComponentId`]. +/// The `index` is a unique value associated with each type of component in a given world. +/// Usually, this value is taken from a counter incremented for each type of component registered with the world. + + #[lua(kind = "Function", output(proxy))] + fn new(index: usize) -> bevy::ecs::component::ComponentId; + +"#, + r#" +/// Returns the index of the current component. + + #[lua(kind = "Method")] + fn index(self) -> usize; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ComponentId(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::component::Tick", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &component::Tick) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::component::Tick; + +"#, + r#" +/// Creates a new [`Tick`] wrapping the given value. + + #[lua(kind = "Function", output(proxy))] + fn new(tick: u32) -> bevy::ecs::component::Tick; + +"#, + r#" +/// Gets the value of this change tick. + + #[lua(kind = "Method")] + fn get(self) -> u32; + +"#, + r#" +/// Sets the value of this change tick. + + #[lua(kind = "MutatingMethod")] + fn set(&mut self, tick: u32) -> (); + +"#, + r#" +/// Returns `true` if this `Tick` occurred since the system's `last_run`. +/// `this_run` is the current tick of the system, used as a reference to help deal with wraparound. + + #[lua(kind = "Method")] + fn is_newer_than( + self, + #[proxy] + last_run: bevy::ecs::component::Tick, + #[proxy] + this_run: bevy::ecs::component::Tick, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Tick {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::component::ComponentTicks", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::component::ComponentTicks; + +"#, + r#" +/// Returns `true` if the component or resource was added after the system last ran. + + #[lua(kind = "Method")] + fn is_added( + &self, + #[proxy] + last_run: bevy::ecs::component::Tick, + #[proxy] + this_run: bevy::ecs::component::Tick, + ) -> bool; + +"#, + r#" +/// Returns `true` if the component or resource was added or mutably dereferenced after the system last ran. + + #[lua(kind = "Method")] + fn is_changed( + &self, + #[proxy] + last_run: bevy::ecs::component::Tick, + #[proxy] + this_run: bevy::ecs::component::Tick, + ) -> bool; + +"#, + r#" +/// Returns the tick recording the time this component or resource was most recently changed. + + #[lua(kind = "Method", output(proxy))] + fn last_changed_tick(&self) -> bevy::ecs::component::Tick; + +"#, + r#" +/// Returns the tick recording the time this component or resource was added. + + #[lua(kind = "Method", output(proxy))] + fn added_tick(&self) -> bevy::ecs::component::Tick; + +"#, + r#" +/// Manually sets the change tick. +/// This is normally done automatically via the [`DerefMut`](std::ops::DerefMut) implementation +/// on [`Mut`](crate::change_detection::Mut), [`ResMut`](crate::change_detection::ResMut), etc. +/// However, components and resources that make use of interior mutability might require manual updates. +/// # Example +/// ```no_run +/// # use bevy_ecs::{world::World, component::ComponentTicks}; +/// let world: World = unimplemented!(); +/// let component_ticks: ComponentTicks = unimplemented!(); +/// component_ticks.set_changed(world.read_change_tick()); +/// ``` + + #[lua(kind = "MutatingMethod")] + fn set_changed(&mut self, #[proxy] change_tick: bevy::ecs::component::Tick) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ComponentTicks {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::entity::EntityHash", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::entity::EntityHash; + +"#] +)] +pub struct EntityHash {} +#[derive(Default)] +pub(crate) struct Globals; +impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { + 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<()> { + instances + .add_instance( + "Entity", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "ComponentId", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Tick", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + Ok(()) + } +} +fn bevy_ecs_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut bevy_mod_scripting_lua::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyEcsScriptingPlugin; +impl bevy::app::Plugin for BevyEcsScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::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.add_context_initializer::<()>(bevy_ecs_context_initializer); + app.add_documentation_fragment( + bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + "BevyEcsAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaComponentId, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::() + }, + ), + ); + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs new file mode 100644 index 00000000..39a14866 --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs @@ -0,0 +1,101 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_ecs::*; +use super::bevy_reflect::*; +use super::bevy_core::*; +extern crate self as bevy_script_api; +use bevy_script_api::{ + lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, +}; +use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::hierarchy::prelude::Children", + functions[r#" +/// Swaps the child at `a_index` with the child at `b_index`. + + #[lua(kind = "MutatingMethod")] + fn swap(&mut self, a_index: usize, b_index: usize) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Children(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::hierarchy::prelude::Parent", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &components::parent::Parent) -> bool; + +"#, + r#" +/// Gets the [`Entity`] ID of the parent. + + #[lua(kind = "Method", output(proxy))] + fn get(&self) -> bevy::ecs::entity::Entity; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Parent(); +#[derive(Default)] +pub(crate) struct Globals; +impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { + 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<()> { + Ok(()) + } +} +fn bevy_hierarchy_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut bevy_mod_scripting_lua::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyHierarchyScriptingPlugin; +impl bevy::app::Plugin for BevyHierarchyScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.add_context_initializer::<()>(bevy_hierarchy_context_initializer); + app.add_documentation_fragment( + bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + "BevyHierarchyAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::() + }, + ), + ); + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs new file mode 100644 index 00000000..b1146d8f --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs @@ -0,0 +1,1492 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_ecs::*; +use super::bevy_reflect::*; +extern crate self as bevy_script_api; +use bevy_script_api::{ + lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, +}; +use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::Gamepad", + functions[r#" +/// Creates a new [`Gamepad`]. + + #[lua(kind = "Function", output(proxy))] + fn new(id: usize) -> bevy::input::gamepad::Gamepad; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::Gamepad; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::Gamepad) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Gamepad { + id: usize, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadAxis", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadAxis; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadAxis) -> bool; + +"#, + r#" +/// Creates a new [`GamepadAxis`]. +/// # Examples +/// ``` +/// # use bevy_input::gamepad::{GamepadAxis, GamepadAxisType, Gamepad}; +/// # +/// let gamepad_axis = GamepadAxis::new( +/// Gamepad::new(1), +/// GamepadAxisType::LeftStickX, +/// ); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::input::gamepad::Gamepad, + #[proxy] + axis_type: bevy::input::gamepad::GamepadAxisType, + ) -> bevy::input::gamepad::GamepadAxis; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadAxis { + #[lua(output(proxy))] + gamepad: bevy::input::gamepad::Gamepad, + #[lua(output(proxy))] + axis_type: bevy::input::gamepad::GamepadAxisType, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadAxisType", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadAxisType; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadAxisType) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadAxisType {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadButton", + functions[r#" +/// Creates a new [`GamepadButton`]. +/// # Examples +/// ``` +/// # use bevy_input::gamepad::{GamepadButton, GamepadButtonType, Gamepad}; +/// # +/// let gamepad_button = GamepadButton::new( +/// Gamepad::new(1), +/// GamepadButtonType::South, +/// ); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::input::gamepad::Gamepad, + #[proxy] + button_type: bevy::input::gamepad::GamepadButtonType, + ) -> bevy::input::gamepad::GamepadButton; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadButton) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadButton; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadButton { + #[lua(output(proxy))] + gamepad: bevy::input::gamepad::Gamepad, + #[lua(output(proxy))] + button_type: bevy::input::gamepad::GamepadButtonType, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadButtonType", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadButtonType) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadButtonType; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadButtonType {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::keyboard::KeyCode", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::KeyCode; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &keyboard::KeyCode) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct KeyCode {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::mouse::MouseButton", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::MouseButton; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &mouse::MouseButton) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct MouseButton {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::touch::TouchInput", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touch::TouchInput; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &touch::TouchInput) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct TouchInput { + #[lua(output(proxy))] + phase: bevy::input::touch::TouchPhase, + #[lua(output(proxy))] + position: bevy::math::Vec2, + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, + force: ReflectedValue, + id: u64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::keyboard::Key", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::Key; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &keyboard::Key) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Key {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::keyboard::KeyboardInput", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &keyboard::KeyboardInput) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::KeyboardInput; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct KeyboardInput { + #[lua(output(proxy))] + key_code: bevy::input::keyboard::KeyCode, + #[lua(output(proxy))] + logical_key: bevy::input::keyboard::Key, + #[lua(output(proxy))] + state: bevy::input::ButtonState, + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::keyboard::NativeKey", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &keyboard::NativeKey) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::NativeKey; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct NativeKey {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::keyboard::NativeKeyCode", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &keyboard::NativeKeyCode) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::NativeKeyCode; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct NativeKeyCode {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::mouse::MouseButtonInput", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &mouse::MouseButtonInput) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::MouseButtonInput; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct MouseButtonInput { + #[lua(output(proxy))] + button: bevy::input::mouse::MouseButton, + #[lua(output(proxy))] + state: bevy::input::ButtonState, + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::mouse::MouseMotion", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &mouse::MouseMotion) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::MouseMotion; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct MouseMotion { + #[lua(output(proxy))] + delta: bevy::math::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::mouse::MouseScrollUnit", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &mouse::MouseScrollUnit) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::MouseScrollUnit; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct MouseScrollUnit {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::mouse::MouseWheel", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::MouseWheel; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &mouse::MouseWheel) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct MouseWheel { + #[lua(output(proxy))] + unit: bevy::input::mouse::MouseScrollUnit, + x: f32, + y: f32, + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::touch::ForceTouch", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &touch::ForceTouch) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touch::ForceTouch; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ForceTouch {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::touch::TouchPhase", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &touch::TouchPhase) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touch::TouchPhase; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct TouchPhase {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::touchpad::TouchpadMagnify", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &touchpad::TouchpadMagnify) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touchpad::TouchpadMagnify; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct TouchpadMagnify(f32); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::touchpad::TouchpadRotate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &touchpad::TouchpadRotate) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touchpad::TouchpadRotate; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct TouchpadRotate(f32); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::AxisSettings", + functions[r#" +/// Get the value above which inputs will be rounded up to 1.0. + + #[lua(kind = "Method")] + fn livezone_upperbound(&self) -> f32; + +"#, + r#" +/// Try to set the value above which inputs will be rounded up to 1.0. +/// If the value passed is negative or less than `deadzone_upperbound`, +/// the value will not be changed. +/// Returns the new value of `livezone_upperbound`. + + #[lua(kind = "MutatingMethod")] + fn set_livezone_upperbound(&mut self, value: f32) -> f32; + +"#, + r#" +/// Get the value below which positive inputs will be rounded down to 0.0. + + #[lua(kind = "Method")] + fn deadzone_upperbound(&self) -> f32; + +"#, + r#" +/// Try to set the value below which positive inputs will be rounded down to 0.0. +/// If the value passed is negative or greater than `livezone_upperbound`, +/// the value will not be changed. +/// Returns the new value of `deadzone_upperbound`. + + #[lua(kind = "MutatingMethod")] + fn set_deadzone_upperbound(&mut self, value: f32) -> f32; + +"#, + r#" +/// Get the value below which negative inputs will be rounded down to -1.0. + + #[lua(kind = "Method")] + fn livezone_lowerbound(&self) -> f32; + +"#, + r#" +/// Try to set the value below which negative inputs will be rounded down to -1.0. +/// If the value passed is positive or greater than `deadzone_lowerbound`, +/// the value will not be changed. +/// Returns the new value of `livezone_lowerbound`. + + #[lua(kind = "MutatingMethod")] + fn set_livezone_lowerbound(&mut self, value: f32) -> f32; + +"#, + r#" +/// Get the value above which inputs will be rounded up to 0.0. + + #[lua(kind = "Method")] + fn deadzone_lowerbound(&self) -> f32; + +"#, + r#" +/// Try to set the value above which inputs will be rounded up to 0.0. +/// If the value passed is less than -1.0 or less than `livezone_lowerbound`, +/// the value will not be changed. +/// Returns the new value of `deadzone_lowerbound`. + + #[lua(kind = "MutatingMethod")] + fn set_deadzone_lowerbound(&mut self, value: f32) -> f32; + +"#, + r#" +/// Get the minimum value by which input must change before the change is registered. + + #[lua(kind = "Method")] + fn threshold(&self) -> f32; + +"#, + r#" +/// Try to set the minimum value by which input must change before the changes will be applied. +/// If the value passed is not within [0.0..=2.0], the value will not be changed. +/// Returns the new value of threshold. + + #[lua(kind = "MutatingMethod")] + fn set_threshold(&mut self, value: f32) -> f32; + +"#, + r#" +/// Clamps the `raw_value` according to the `AxisSettings`. + + #[lua(kind = "Method")] + fn clamp(&self, new_value: f32) -> f32; + +"#, + r#" +/// Filters the `new_value` based on the `old_value`, according to the [`AxisSettings`]. +/// Returns the clamped `new_value` if the change exceeds the settings threshold, +/// and `None` otherwise. + + #[lua(kind = "Method")] + fn filter( + &self, + new_value: f32, + old_value: std::option::Option, + ) -> std::option::Option; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::AxisSettings; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::AxisSettings) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AxisSettings {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::ButtonAxisSettings", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::ButtonAxisSettings; + +"#, + r#" +/// Filters the `new_value` based on the `old_value`, according to the [`ButtonAxisSettings`]. +/// Returns the clamped `new_value`, according to the [`ButtonAxisSettings`], if the change +/// exceeds the settings threshold, and `None` otherwise. + + #[lua(kind = "Method")] + fn filter( + &self, + new_value: f32, + old_value: std::option::Option, + ) -> std::option::Option; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ButtonAxisSettings { + high: f32, + low: f32, + threshold: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::ButtonSettings", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::ButtonSettings; + +"#, + r#" +/// Returns `true` if the button is pressed. +/// A button is considered pressed if the `value` passed is greater than or equal to the press threshold. + + #[lua(kind = "Method")] + fn is_pressed(&self, value: f32) -> bool; + +"#, + r#" +/// Returns `true` if the button is released. +/// A button is considered released if the `value` passed is lower than or equal to the release threshold. + + #[lua(kind = "Method")] + fn is_released(&self, value: f32) -> bool; + +"#, + r#" +/// Get the button input threshold above which the button is considered pressed. + + #[lua(kind = "Method")] + fn press_threshold(&self) -> f32; + +"#, + r#" +/// Try to set the button input threshold above which the button is considered pressed. +/// If the value passed is outside the range [release threshold..=1.0], the value will not be changed. +/// Returns the new value of the press threshold. + + #[lua(kind = "MutatingMethod")] + fn set_press_threshold(&mut self, value: f32) -> f32; + +"#, + r#" +/// Get the button input threshold below which the button is considered released. + + #[lua(kind = "Method")] + fn release_threshold(&self) -> f32; + +"#, + r#" +/// Try to set the button input threshold below which the button is considered released. If the +/// value passed is outside the range [0.0..=press threshold], the value will not be changed. +/// Returns the new value of the release threshold. + + #[lua(kind = "MutatingMethod")] + fn set_release_threshold(&mut self, value: f32) -> f32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ButtonSettings {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadAxisChangedEvent", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadAxisChangedEvent; + +"#, + r#" +/// Creates a [`GamepadAxisChangedEvent`]. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::input::gamepad::Gamepad, + #[proxy] + axis_type: bevy::input::gamepad::GamepadAxisType, + value: f32, + ) -> bevy::input::gamepad::GamepadAxisChangedEvent; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadAxisChangedEvent) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadAxisChangedEvent { + #[lua(output(proxy))] + gamepad: bevy::input::gamepad::Gamepad, + #[lua(output(proxy))] + axis_type: bevy::input::gamepad::GamepadAxisType, + value: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadButtonChangedEvent", + functions[r#" +/// Creates a [`GamepadButtonChangedEvent`]. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::input::gamepad::Gamepad, + #[proxy] + button_type: bevy::input::gamepad::GamepadButtonType, + value: f32, + ) -> bevy::input::gamepad::GamepadButtonChangedEvent; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadButtonChangedEvent; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadButtonChangedEvent) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadButtonChangedEvent { + #[lua(output(proxy))] + gamepad: bevy::input::gamepad::Gamepad, + #[lua(output(proxy))] + button_type: bevy::input::gamepad::GamepadButtonType, + value: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadButtonInput", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadButtonInput) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadButtonInput; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadButtonInput { + #[lua(output(proxy))] + button: bevy::input::gamepad::GamepadButton, + #[lua(output(proxy))] + state: bevy::input::ButtonState, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadConnection", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadConnection) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadConnection; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadConnection {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadConnectionEvent", + functions[r#" +/// Creates a [`GamepadConnectionEvent`]. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::input::gamepad::Gamepad, + #[proxy] + connection: bevy::input::gamepad::GamepadConnection, + ) -> bevy::input::gamepad::GamepadConnectionEvent; + +"#, + r#" +/// Is the gamepad connected? + + #[lua(kind = "Method")] + fn connected(&self) -> bool; + +"#, + r#" +/// Is the gamepad disconnected? + + #[lua(kind = "Method")] + fn disconnected(&self) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadConnectionEvent) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadConnectionEvent; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadConnectionEvent { + #[lua(output(proxy))] + gamepad: bevy::input::gamepad::Gamepad, + #[lua(output(proxy))] + connection: bevy::input::gamepad::GamepadConnection, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadEvent", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadEvent) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadEvent; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadEvent {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadSettings", + functions[r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadSettings { + #[lua(output(proxy))] + default_button_settings: bevy::input::gamepad::ButtonSettings, + #[lua(output(proxy))] + default_axis_settings: bevy::input::gamepad::AxisSettings, + #[lua(output(proxy))] + default_button_axis_settings: bevy::input::gamepad::ButtonAxisSettings, + button_settings: ReflectedValue, + axis_settings: ReflectedValue, + button_axis_settings: ReflectedValue, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::ButtonState", + functions[r#" +/// Is this button pressed? + + #[lua(kind = "Method")] + fn is_pressed(&self) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &ButtonState) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::ButtonState; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ButtonState {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadInfo", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadInfo) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadInfo; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadInfo { + name: std::string::String, +} +#[derive(Default)] +pub(crate) struct Globals; +impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { + 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<()> { + instances + .add_instance( + "Gamepad", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "GamepadAxis", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "GamepadButton", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaGamepadButton, + >::new, + )?; + instances + .add_instance( + "GamepadAxisChangedEvent", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaGamepadAxisChangedEvent, + >::new, + )?; + instances + .add_instance( + "GamepadButtonChangedEvent", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaGamepadButtonChangedEvent, + >::new, + )?; + instances + .add_instance( + "GamepadConnectionEvent", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaGamepadConnectionEvent, + >::new, + )?; + Ok(()) + } +} +fn bevy_input_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut bevy_mod_scripting_lua::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyInputScriptingPlugin; +impl bevy::app::Plugin for BevyInputScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::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::(); + 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::< + bevy::input::gamepad::GamepadButtonChangedEvent, + >(); + 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.add_context_initializer::<()>(bevy_input_context_initializer); + app.add_documentation_fragment( + bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + "BevyInputAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaGamepadAxis, + >, + >() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaGamepadButton, + >, + >() + .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::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaGamepadAxisChangedEvent, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaGamepadButtonChangedEvent, + >, + >() + .process_type::() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaGamepadConnectionEvent, + >, + >() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + }, + ), + ); + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs new file mode 100644 index 00000000..d77ba764 --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs @@ -0,0 +1,24663 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +extern crate self as bevy_script_api; +use bevy_script_api::{ + lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, +}; +use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::utils::Duration", + functions[r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u32) -> bevy::utils::Duration; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u32) -> bevy::utils::Duration; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_utils::Duration) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::utils::Duration; + +"#, + r#" +/// Creates a new `Duration` from the specified number of whole seconds and +/// additional nanoseconds. +/// If the number of nanoseconds is greater than 1 billion (the number of +/// nanoseconds in a second), then it will carry over into the seconds provided. +/// # Panics +/// This constructor will panic if the carry from the nanoseconds overflows +/// the seconds counter. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let five_seconds = Duration::new(5, 0); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(secs: u64, nanos: u32) -> bevy::utils::Duration; + +"#, + r#" +/// Creates a new `Duration` from the specified number of whole seconds. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_secs(5); +/// assert_eq!(5, duration.as_secs()); +/// assert_eq!(0, duration.subsec_nanos()); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_secs(secs: u64) -> bevy::utils::Duration; + +"#, + r#" +/// Creates a new `Duration` from the specified number of milliseconds. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_millis(2569); +/// assert_eq!(2, duration.as_secs()); +/// assert_eq!(569_000_000, duration.subsec_nanos()); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_millis(millis: u64) -> bevy::utils::Duration; + +"#, + r#" +/// Creates a new `Duration` from the specified number of microseconds. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_micros(1_000_002); +/// assert_eq!(1, duration.as_secs()); +/// assert_eq!(2000, duration.subsec_nanos()); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_micros(micros: u64) -> bevy::utils::Duration; + +"#, + r#" +/// Creates a new `Duration` from the specified number of nanoseconds. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_nanos(1_000_000_123); +/// assert_eq!(1, duration.as_secs()); +/// assert_eq!(123, duration.subsec_nanos()); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_nanos(nanos: u64) -> bevy::utils::Duration; + +"#, + r#" +/// Returns true if this `Duration` spans no time. +/// # Examples +/// ``` +/// use std::time::Duration; +/// assert!(Duration::ZERO.is_zero()); +/// assert!(Duration::new(0, 0).is_zero()); +/// assert!(Duration::from_nanos(0).is_zero()); +/// assert!(Duration::from_secs(0).is_zero()); +/// assert!(!Duration::new(1, 1).is_zero()); +/// assert!(!Duration::from_nanos(1).is_zero()); +/// assert!(!Duration::from_secs(1).is_zero()); +/// ``` + + #[lua(kind = "Method")] + fn is_zero(&self) -> bool; + +"#, + r#" +/// Returns the number of _whole_ seconds contained by this `Duration`. +/// The returned value does not include the fractional (nanosecond) part of the +/// duration, which can be obtained using [`subsec_nanos`]. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::new(5, 730023852); +/// assert_eq!(duration.as_secs(), 5); +/// ``` +/// To determine the total number of seconds represented by the `Duration` +/// including the fractional part, use [`as_secs_f64`] or [`as_secs_f32`] +/// [`as_secs_f64`]: Duration::as_secs_f64 +/// [`as_secs_f32`]: Duration::as_secs_f32 +/// [`subsec_nanos`]: Duration::subsec_nanos + + #[lua(kind = "Method")] + fn as_secs(&self) -> u64; + +"#, + r#" +/// Returns the fractional part of this `Duration`, in whole milliseconds. +/// This method does **not** return the length of the duration when +/// represented by milliseconds. The returned number always represents a +/// fractional portion of a second (i.e., it is less than one thousand). +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_millis(5432); +/// assert_eq!(duration.as_secs(), 5); +/// assert_eq!(duration.subsec_millis(), 432); +/// ``` + + #[lua(kind = "Method")] + fn subsec_millis(&self) -> u32; + +"#, + r#" +/// Returns the fractional part of this `Duration`, in whole microseconds. +/// This method does **not** return the length of the duration when +/// represented by microseconds. The returned number always represents a +/// fractional portion of a second (i.e., it is less than one million). +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_micros(1_234_567); +/// assert_eq!(duration.as_secs(), 1); +/// assert_eq!(duration.subsec_micros(), 234_567); +/// ``` + + #[lua(kind = "Method")] + fn subsec_micros(&self) -> u32; + +"#, + r#" +/// Returns the fractional part of this `Duration`, in nanoseconds. +/// This method does **not** return the length of the duration when +/// represented by nanoseconds. The returned number always represents a +/// fractional portion of a second (i.e., it is less than one billion). +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_millis(5010); +/// assert_eq!(duration.as_secs(), 5); +/// assert_eq!(duration.subsec_nanos(), 10_000_000); +/// ``` + + #[lua(kind = "Method")] + fn subsec_nanos(&self) -> u32; + +"#, + r#" +/// Returns the total number of whole milliseconds contained by this `Duration`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::new(5, 730023852); +/// assert_eq!(duration.as_millis(), 5730); +/// ``` + + #[lua(kind = "Method")] + fn as_millis(&self) -> u128; + +"#, + r#" +/// Returns the total number of whole microseconds contained by this `Duration`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::new(5, 730023852); +/// assert_eq!(duration.as_micros(), 5730023); +/// ``` + + #[lua(kind = "Method")] + fn as_micros(&self) -> u128; + +"#, + r#" +/// Returns the total number of nanoseconds contained by this `Duration`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::new(5, 730023852); +/// assert_eq!(duration.as_nanos(), 5730023852); +/// ``` + + #[lua(kind = "Method")] + fn as_nanos(&self) -> u128; + +"#, + r#" +/// Saturating `Duration` addition. Computes `self + other`, returning [`Duration::MAX`] +/// if overflow occurred. +/// # Examples +/// ``` +/// #![feature(duration_constants)] +/// use std::time::Duration; +/// assert_eq!(Duration::new(0, 0).saturating_add(Duration::new(0, 1)), Duration::new(0, 1)); +/// assert_eq!(Duration::new(1, 0).saturating_add(Duration::new(u64::MAX, 0)), Duration::MAX); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_add( + self, + #[proxy] + rhs: bevy::utils::Duration, + ) -> bevy::utils::Duration; + +"#, + r#" +/// Saturating `Duration` subtraction. Computes `self - other`, returning [`Duration::ZERO`] +/// if the result would be negative or if overflow occurred. +/// # Examples +/// ``` +/// use std::time::Duration; +/// assert_eq!(Duration::new(0, 1).saturating_sub(Duration::new(0, 0)), Duration::new(0, 1)); +/// assert_eq!(Duration::new(0, 0).saturating_sub(Duration::new(0, 1)), Duration::ZERO); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub( + self, + #[proxy] + rhs: bevy::utils::Duration, + ) -> bevy::utils::Duration; + +"#, + r#" +/// Saturating `Duration` multiplication. Computes `self * other`, returning +/// [`Duration::MAX`] if overflow occurred. +/// # Examples +/// ``` +/// #![feature(duration_constants)] +/// use std::time::Duration; +/// assert_eq!(Duration::new(0, 500_000_001).saturating_mul(2), Duration::new(1, 2)); +/// assert_eq!(Duration::new(u64::MAX - 1, 0).saturating_mul(2), Duration::MAX); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, rhs: u32) -> bevy::utils::Duration; + +"#, + r#" +/// Returns the number of seconds contained by this `Duration` as `f64`. +/// The returned value does include the fractional (nanosecond) part of the duration. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur = Duration::new(2, 700_000_000); +/// assert_eq!(dur.as_secs_f64(), 2.7); +/// ``` + + #[lua(kind = "Method")] + fn as_secs_f64(&self) -> f64; + +"#, + r#" +/// Returns the number of seconds contained by this `Duration` as `f32`. +/// The returned value does include the fractional (nanosecond) part of the duration. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur = Duration::new(2, 700_000_000); +/// assert_eq!(dur.as_secs_f32(), 2.7); +/// ``` + + #[lua(kind = "Method")] + fn as_secs_f32(&self) -> f32; + +"#, + r#" +/// Creates a new `Duration` from the specified number of seconds represented +/// as `f64`. +/// # Panics +/// This constructor will panic if `secs` is negative, overflows `Duration` or not finite. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let res = Duration::from_secs_f64(0.0); +/// assert_eq!(res, Duration::new(0, 0)); +/// let res = Duration::from_secs_f64(1e-20); +/// assert_eq!(res, Duration::new(0, 0)); +/// let res = Duration::from_secs_f64(4.2e-7); +/// assert_eq!(res, Duration::new(0, 420)); +/// let res = Duration::from_secs_f64(2.7); +/// assert_eq!(res, Duration::new(2, 700_000_000)); +/// let res = Duration::from_secs_f64(3e10); +/// assert_eq!(res, Duration::new(30_000_000_000, 0)); +/// // subnormal float +/// let res = Duration::from_secs_f64(f64::from_bits(1)); +/// assert_eq!(res, Duration::new(0, 0)); +/// // conversion uses rounding +/// let res = Duration::from_secs_f64(0.999e-9); +/// assert_eq!(res, Duration::new(0, 1)); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_secs_f64(secs: f64) -> bevy::utils::Duration; + +"#, + r#" +/// Creates a new `Duration` from the specified number of seconds represented +/// as `f32`. +/// # Panics +/// This constructor will panic if `secs` is negative, overflows `Duration` or not finite. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let res = Duration::from_secs_f32(0.0); +/// assert_eq!(res, Duration::new(0, 0)); +/// let res = Duration::from_secs_f32(1e-20); +/// assert_eq!(res, Duration::new(0, 0)); +/// let res = Duration::from_secs_f32(4.2e-7); +/// assert_eq!(res, Duration::new(0, 420)); +/// let res = Duration::from_secs_f32(2.7); +/// assert_eq!(res, Duration::new(2, 700_000_048)); +/// let res = Duration::from_secs_f32(3e10); +/// assert_eq!(res, Duration::new(30_000_001_024, 0)); +/// // subnormal float +/// let res = Duration::from_secs_f32(f32::from_bits(1)); +/// assert_eq!(res, Duration::new(0, 0)); +/// // conversion uses rounding +/// let res = Duration::from_secs_f32(0.999e-9); +/// assert_eq!(res, Duration::new(0, 1)); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_secs_f32(secs: f32) -> bevy::utils::Duration; + +"#, + r#" +/// Multiplies `Duration` by `f64`. +/// # Panics +/// This method will panic if result is negative, overflows `Duration` or not finite. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur = Duration::new(2, 700_000_000); +/// assert_eq!(dur.mul_f64(3.14), Duration::new(8, 478_000_000)); +/// assert_eq!(dur.mul_f64(3.14e5), Duration::new(847_800, 0)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn mul_f64(self, rhs: f64) -> bevy::utils::Duration; + +"#, + r#" +/// Multiplies `Duration` by `f32`. +/// # Panics +/// This method will panic if result is negative, overflows `Duration` or not finite. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur = Duration::new(2, 700_000_000); +/// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_641)); +/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847800, 0)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn mul_f32(self, rhs: f32) -> bevy::utils::Duration; + +"#, + r#" +/// Divide `Duration` by `f64`. +/// # Panics +/// This method will panic if result is negative, overflows `Duration` or not finite. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur = Duration::new(2, 700_000_000); +/// assert_eq!(dur.div_f64(3.14), Duration::new(0, 859_872_611)); +/// assert_eq!(dur.div_f64(3.14e5), Duration::new(0, 8_599)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn div_f64(self, rhs: f64) -> bevy::utils::Duration; + +"#, + r#" +/// Divide `Duration` by `f32`. +/// # Panics +/// This method will panic if result is negative, overflows `Duration` or not finite. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur = Duration::new(2, 700_000_000); +/// // note that due to rounding errors result is slightly +/// // different from 0.859_872_611 +/// assert_eq!(dur.div_f32(3.14), Duration::new(0, 859_872_580)); +/// assert_eq!(dur.div_f32(3.14e5), Duration::new(0, 8_599)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn div_f32(self, rhs: f32) -> bevy::utils::Duration; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Duration {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::utils::Instant", + functions[r#" +/// # Panics +/// This function may panic if the resulting point in time cannot be represented by the +/// underlying data structure. See [`Instant::checked_add`] for a version without panic. + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_utils::Instant) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::utils::Instant; + +"#, + r#" +/// Returns an instant corresponding to "now". +/// # Examples +/// ``` +/// use std::time::Instant; +/// let now = Instant::now(); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn now() -> bevy::utils::Instant; + +"#, + r#" +/// Returns the amount of time elapsed from another instant to this one, +/// or zero duration if that instant is later than this one. +/// # Panics +/// Previous rust versions panicked when `earlier` was later than `self`. Currently this +/// method saturates. Future versions may reintroduce the panic in some circumstances. +/// See [Monotonicity]. +/// [Monotonicity]: Instant#monotonicity +/// # Examples +/// ```no_run +/// use std::time::{Duration, Instant}; +/// use std::thread::sleep; +/// let now = Instant::now(); +/// sleep(Duration::new(1, 0)); +/// let new_now = Instant::now(); +/// println!("{:?}", new_now.duration_since(now)); +/// println!("{:?}", now.duration_since(new_now)); // 0ns +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn duration_since( + &self, + #[proxy] + earlier: bevy::utils::Instant, + ) -> bevy::utils::Duration; + +"#, + r#" +/// Returns the amount of time elapsed from another instant to this one, +/// or zero duration if that instant is later than this one. +/// # Examples +/// ```no_run +/// use std::time::{Duration, Instant}; +/// use std::thread::sleep; +/// let now = Instant::now(); +/// sleep(Duration::new(1, 0)); +/// let new_now = Instant::now(); +/// println!("{:?}", new_now.saturating_duration_since(now)); +/// println!("{:?}", now.saturating_duration_since(new_now)); // 0ns +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_duration_since( + &self, + #[proxy] + earlier: bevy::utils::Instant, + ) -> bevy::utils::Duration; + +"#, + r#" +/// Returns the amount of time elapsed since this instant. +/// # Panics +/// Previous rust versions panicked when the current time was earlier than self. Currently this +/// method returns a Duration of zero in that case. Future versions may reintroduce the panic. +/// See [Monotonicity]. +/// [Monotonicity]: Instant#monotonicity +/// # Examples +/// ```no_run +/// use std::thread::sleep; +/// use std::time::{Duration, Instant}; +/// let instant = Instant::now(); +/// let three_secs = Duration::from_secs(3); +/// sleep(three_secs); +/// assert!(instant.elapsed() >= three_secs); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn elapsed(&self) -> bevy::utils::Duration; + +"#, + r#" +/// Returns the amount of time elapsed from another instant to this one, +/// or zero duration if that instant is later than this one. +/// # Panics +/// Previous rust versions panicked when `other` was later than `self`. Currently this +/// method saturates. Future versions may reintroduce the panic in some circumstances. +/// See [Monotonicity]. +/// [Monotonicity]: Instant#monotonicity + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] other: bevy::utils::Instant) -> bevy::utils::Duration; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Instant(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::num::NonZeroI128", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::num::NonZeroI128; + +"#, + r#" +/// Creates a non-zero without checking whether the value is non-zero. +/// This results in undefined behaviour if the value is zero. +/// # Safety +/// The value must not be zero. + + #[lua(kind = "Function", output(proxy))] + unsafe fn new_unchecked(n: i128) -> std::num::NonZeroI128; + +"#, + r#" +/// Returns the value as a primitive type. + + #[lua(kind = "Method")] + fn get(self) -> i128; + +"#, + r#" +/// Returns the number of leading zeros in the binary representation of `self`. +/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroI128::new(-1i128).unwrap(); +/// assert_eq!(n.leading_zeros(), 0); +/// ``` + + #[lua(kind = "Method")] + fn leading_zeros(self) -> u32; + +"#, + r#" +/// Returns the number of trailing zeros in the binary representation +/// of `self`. +/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroI128::new(0b0101000).unwrap(); +/// assert_eq!(n.trailing_zeros(), 3); +/// ``` + + #[lua(kind = "Method")] + fn trailing_zeros(self) -> u32; + +"#, + r#" +/// Computes the absolute value of self. +///See [`i128::abs`] +/// for documentation on overflow behaviour. +/// # Example +/// ``` +///# use std::num::NonZeroI128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI128::new(1)?; +///let neg = NonZeroI128::new(-1)?; +/// assert_eq!(pos, pos.abs()); +/// assert_eq!(pos, neg.abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> std::num::NonZeroI128; + +"#, + r#" +/// Saturating absolute value, see +///[`i128::saturating_abs`]. +/// # Example +/// ``` +///# use std::num::NonZeroI128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI128::new(1)?; +///let neg = NonZeroI128::new(-1)?; +///let min = NonZeroI128::new(i128::MIN)?; +///let min_plus = NonZeroI128::new(i128::MIN + 1)?; +///let max = NonZeroI128::new(i128::MAX)?; +/// assert_eq!(pos, pos.saturating_abs()); +/// assert_eq!(pos, neg.saturating_abs()); +/// assert_eq!(max, min.saturating_abs()); +/// assert_eq!(max, min_plus.saturating_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_abs(self) -> std::num::NonZeroI128; + +"#, + r#" +/// Wrapping absolute value, see +///[`i128::wrapping_abs`]. +/// # Example +/// ``` +///# use std::num::NonZeroI128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI128::new(1)?; +///let neg = NonZeroI128::new(-1)?; +///let min = NonZeroI128::new(i128::MIN)?; +///# let max = NonZeroI128::new(i128::MAX)?; +/// assert_eq!(pos, pos.wrapping_abs()); +/// assert_eq!(pos, neg.wrapping_abs()); +/// assert_eq!(min, min.wrapping_abs()); +/// assert_eq!(max, (-max).wrapping_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn wrapping_abs(self) -> std::num::NonZeroI128; + +"#, + r#" +/// Computes the absolute value of self +/// without any wrapping or panicking. +/// # Example +/// ``` +///# use std::num::NonZeroI128; +///# use std::num::NonZeroU128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let u_pos = NonZeroU128::new(1)?; +///let i_pos = NonZeroI128::new(1)?; +///let i_neg = NonZeroI128::new(-1)?; +///let i_min = NonZeroI128::new(i128::MIN)?; +///let u_max = NonZeroU128::new(u128::MAX / 2 + 1)?; +/// assert_eq!(u_pos, i_pos.unsigned_abs()); +/// assert_eq!(u_pos, i_neg.unsigned_abs()); +/// assert_eq!(u_max, i_min.unsigned_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn unsigned_abs(self) -> std::num::NonZeroU128; + +"#, + r#" +/// Returns `true` if `self` is positive and `false` if the +/// number is negative. +/// # Example +/// ``` +///# use std::num::NonZeroI128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI128::new(5)?; +///let neg_five = NonZeroI128::new(-5)?; +/// assert!(pos_five.is_positive()); +/// assert!(!neg_five.is_positive()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn is_positive(self) -> bool; + +"#, + r#" +/// Returns `true` if `self` is negative and `false` if the +/// number is positive. +/// # Example +/// ``` +///# use std::num::NonZeroI128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI128::new(5)?; +///let neg_five = NonZeroI128::new(-5)?; +/// assert!(neg_five.is_negative()); +/// assert!(!pos_five.is_negative()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn is_negative(self) -> bool; + +"#, + r#" +/// Saturating negation. Computes `-self`, +///returning [`NonZeroI128::MAX`] +///if `self == NonZeroI128::MIN` +/// instead of overflowing. +/// # Example +/// ``` +///# use std::num::NonZeroI128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI128::new(5)?; +///let neg_five = NonZeroI128::new(-5)?; +///let min = NonZeroI128::new(i128::MIN)?; +///let min_plus_one = NonZeroI128::new(i128::MIN + 1)?; +///let max = NonZeroI128::new(i128::MAX)?; +/// assert_eq!(pos_five.saturating_neg(), neg_five); +/// assert_eq!(min.saturating_neg(), max); +/// assert_eq!(max.saturating_neg(), min_plus_one); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_neg(self) -> std::num::NonZeroI128; + +"#, + r#" +/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary +/// of the type. +///See [`i128::wrapping_neg`] +/// for documentation on overflow behaviour. +/// # Example +/// ``` +///# use std::num::NonZeroI128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI128::new(5)?; +///let neg_five = NonZeroI128::new(-5)?; +///let min = NonZeroI128::new(i128::MIN)?; +/// assert_eq!(pos_five.wrapping_neg(), neg_five); +/// assert_eq!(min.wrapping_neg(), min); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn wrapping_neg(self) -> std::num::NonZeroI128; + +"#, + r#" +/// Multiplies two non-zero integers together. +///Return [`NonZeroI128::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroI128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let two = NonZeroI128::new(2)?; +///let four = NonZeroI128::new(4)?; +///let max = NonZeroI128::new(i128::MAX)?; +/// assert_eq!(four, two.saturating_mul(two)); +/// assert_eq!(max, four.saturating_mul(max)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul( + self, + #[proxy] + other: std::num::NonZeroI128, + ) -> std::num::NonZeroI128; + +"#, + r#" +/// Raise non-zero value to an integer power. +///Return [`NonZeroI128::MIN`] or [`NonZeroI128::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroI128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let three = NonZeroI128::new(3)?; +///let twenty_seven = NonZeroI128::new(27)?; +///let max = NonZeroI128::new(i128::MAX)?; +/// assert_eq!(twenty_seven, three.saturating_pow(3)); +/// assert_eq!(max, max.saturating_pow(3)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_pow(self, other: u32) -> std::num::NonZeroI128; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::num::NonZeroI128) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> std::num::NonZeroI128; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct NonZeroI128(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::num::NonZeroI16", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::num::NonZeroI16) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::num::NonZeroI16; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +/// Creates a non-zero without checking whether the value is non-zero. +/// This results in undefined behaviour if the value is zero. +/// # Safety +/// The value must not be zero. + + #[lua(kind = "Function", output(proxy))] + unsafe fn new_unchecked(n: i16) -> std::num::NonZeroI16; + +"#, + r#" +/// Returns the value as a primitive type. + + #[lua(kind = "Method")] + fn get(self) -> i16; + +"#, + r#" +/// Returns the number of leading zeros in the binary representation of `self`. +/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroI16::new(-1i16).unwrap(); +/// assert_eq!(n.leading_zeros(), 0); +/// ``` + + #[lua(kind = "Method")] + fn leading_zeros(self) -> u32; + +"#, + r#" +/// Returns the number of trailing zeros in the binary representation +/// of `self`. +/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroI16::new(0b0101000).unwrap(); +/// assert_eq!(n.trailing_zeros(), 3); +/// ``` + + #[lua(kind = "Method")] + fn trailing_zeros(self) -> u32; + +"#, + r#" +/// Computes the absolute value of self. +///See [`i16::abs`] +/// for documentation on overflow behaviour. +/// # Example +/// ``` +///# use std::num::NonZeroI16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI16::new(1)?; +///let neg = NonZeroI16::new(-1)?; +/// assert_eq!(pos, pos.abs()); +/// assert_eq!(pos, neg.abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> std::num::NonZeroI16; + +"#, + r#" +/// Saturating absolute value, see +///[`i16::saturating_abs`]. +/// # Example +/// ``` +///# use std::num::NonZeroI16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI16::new(1)?; +///let neg = NonZeroI16::new(-1)?; +///let min = NonZeroI16::new(i16::MIN)?; +///let min_plus = NonZeroI16::new(i16::MIN + 1)?; +///let max = NonZeroI16::new(i16::MAX)?; +/// assert_eq!(pos, pos.saturating_abs()); +/// assert_eq!(pos, neg.saturating_abs()); +/// assert_eq!(max, min.saturating_abs()); +/// assert_eq!(max, min_plus.saturating_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_abs(self) -> std::num::NonZeroI16; + +"#, + r#" +/// Wrapping absolute value, see +///[`i16::wrapping_abs`]. +/// # Example +/// ``` +///# use std::num::NonZeroI16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI16::new(1)?; +///let neg = NonZeroI16::new(-1)?; +///let min = NonZeroI16::new(i16::MIN)?; +///# let max = NonZeroI16::new(i16::MAX)?; +/// assert_eq!(pos, pos.wrapping_abs()); +/// assert_eq!(pos, neg.wrapping_abs()); +/// assert_eq!(min, min.wrapping_abs()); +/// assert_eq!(max, (-max).wrapping_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn wrapping_abs(self) -> std::num::NonZeroI16; + +"#, + r#" +/// Computes the absolute value of self +/// without any wrapping or panicking. +/// # Example +/// ``` +///# use std::num::NonZeroI16; +///# use std::num::NonZeroU16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let u_pos = NonZeroU16::new(1)?; +///let i_pos = NonZeroI16::new(1)?; +///let i_neg = NonZeroI16::new(-1)?; +///let i_min = NonZeroI16::new(i16::MIN)?; +///let u_max = NonZeroU16::new(u16::MAX / 2 + 1)?; +/// assert_eq!(u_pos, i_pos.unsigned_abs()); +/// assert_eq!(u_pos, i_neg.unsigned_abs()); +/// assert_eq!(u_max, i_min.unsigned_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn unsigned_abs(self) -> std::num::NonZeroU16; + +"#, + r#" +/// Returns `true` if `self` is positive and `false` if the +/// number is negative. +/// # Example +/// ``` +///# use std::num::NonZeroI16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI16::new(5)?; +///let neg_five = NonZeroI16::new(-5)?; +/// assert!(pos_five.is_positive()); +/// assert!(!neg_five.is_positive()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn is_positive(self) -> bool; + +"#, + r#" +/// Returns `true` if `self` is negative and `false` if the +/// number is positive. +/// # Example +/// ``` +///# use std::num::NonZeroI16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI16::new(5)?; +///let neg_five = NonZeroI16::new(-5)?; +/// assert!(neg_five.is_negative()); +/// assert!(!pos_five.is_negative()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn is_negative(self) -> bool; + +"#, + r#" +/// Saturating negation. Computes `-self`, +///returning [`NonZeroI16::MAX`] +///if `self == NonZeroI16::MIN` +/// instead of overflowing. +/// # Example +/// ``` +///# use std::num::NonZeroI16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI16::new(5)?; +///let neg_five = NonZeroI16::new(-5)?; +///let min = NonZeroI16::new(i16::MIN)?; +///let min_plus_one = NonZeroI16::new(i16::MIN + 1)?; +///let max = NonZeroI16::new(i16::MAX)?; +/// assert_eq!(pos_five.saturating_neg(), neg_five); +/// assert_eq!(min.saturating_neg(), max); +/// assert_eq!(max.saturating_neg(), min_plus_one); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_neg(self) -> std::num::NonZeroI16; + +"#, + r#" +/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary +/// of the type. +///See [`i16::wrapping_neg`] +/// for documentation on overflow behaviour. +/// # Example +/// ``` +///# use std::num::NonZeroI16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI16::new(5)?; +///let neg_five = NonZeroI16::new(-5)?; +///let min = NonZeroI16::new(i16::MIN)?; +/// assert_eq!(pos_five.wrapping_neg(), neg_five); +/// assert_eq!(min.wrapping_neg(), min); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn wrapping_neg(self) -> std::num::NonZeroI16; + +"#, + r#" +/// Multiplies two non-zero integers together. +///Return [`NonZeroI16::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroI16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let two = NonZeroI16::new(2)?; +///let four = NonZeroI16::new(4)?; +///let max = NonZeroI16::new(i16::MAX)?; +/// assert_eq!(four, two.saturating_mul(two)); +/// assert_eq!(max, four.saturating_mul(max)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul( + self, + #[proxy] + other: std::num::NonZeroI16, + ) -> std::num::NonZeroI16; + +"#, + r#" +/// Raise non-zero value to an integer power. +///Return [`NonZeroI16::MIN`] or [`NonZeroI16::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroI16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let three = NonZeroI16::new(3)?; +///let twenty_seven = NonZeroI16::new(27)?; +///let max = NonZeroI16::new(i16::MAX)?; +/// assert_eq!(twenty_seven, three.saturating_pow(3)); +/// assert_eq!(max, max.saturating_pow(3)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_pow(self, other: u32) -> std::num::NonZeroI16; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> std::num::NonZeroI16; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct NonZeroI16(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::num::NonZeroI32", + functions[r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> std::num::NonZeroI32; + +"#, + r#" +/// Creates a non-zero without checking whether the value is non-zero. +/// This results in undefined behaviour if the value is zero. +/// # Safety +/// The value must not be zero. + + #[lua(kind = "Function", output(proxy))] + unsafe fn new_unchecked(n: i32) -> std::num::NonZeroI32; + +"#, + r#" +/// Returns the value as a primitive type. + + #[lua(kind = "Method")] + fn get(self) -> i32; + +"#, + r#" +/// Returns the number of leading zeros in the binary representation of `self`. +/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroI32::new(-1i32).unwrap(); +/// assert_eq!(n.leading_zeros(), 0); +/// ``` + + #[lua(kind = "Method")] + fn leading_zeros(self) -> u32; + +"#, + r#" +/// Returns the number of trailing zeros in the binary representation +/// of `self`. +/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroI32::new(0b0101000).unwrap(); +/// assert_eq!(n.trailing_zeros(), 3); +/// ``` + + #[lua(kind = "Method")] + fn trailing_zeros(self) -> u32; + +"#, + r#" +/// Computes the absolute value of self. +///See [`i32::abs`] +/// for documentation on overflow behaviour. +/// # Example +/// ``` +///# use std::num::NonZeroI32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI32::new(1)?; +///let neg = NonZeroI32::new(-1)?; +/// assert_eq!(pos, pos.abs()); +/// assert_eq!(pos, neg.abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> std::num::NonZeroI32; + +"#, + r#" +/// Saturating absolute value, see +///[`i32::saturating_abs`]. +/// # Example +/// ``` +///# use std::num::NonZeroI32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI32::new(1)?; +///let neg = NonZeroI32::new(-1)?; +///let min = NonZeroI32::new(i32::MIN)?; +///let min_plus = NonZeroI32::new(i32::MIN + 1)?; +///let max = NonZeroI32::new(i32::MAX)?; +/// assert_eq!(pos, pos.saturating_abs()); +/// assert_eq!(pos, neg.saturating_abs()); +/// assert_eq!(max, min.saturating_abs()); +/// assert_eq!(max, min_plus.saturating_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_abs(self) -> std::num::NonZeroI32; + +"#, + r#" +/// Wrapping absolute value, see +///[`i32::wrapping_abs`]. +/// # Example +/// ``` +///# use std::num::NonZeroI32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI32::new(1)?; +///let neg = NonZeroI32::new(-1)?; +///let min = NonZeroI32::new(i32::MIN)?; +///# let max = NonZeroI32::new(i32::MAX)?; +/// assert_eq!(pos, pos.wrapping_abs()); +/// assert_eq!(pos, neg.wrapping_abs()); +/// assert_eq!(min, min.wrapping_abs()); +/// assert_eq!(max, (-max).wrapping_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn wrapping_abs(self) -> std::num::NonZeroI32; + +"#, + r#" +/// Computes the absolute value of self +/// without any wrapping or panicking. +/// # Example +/// ``` +///# use std::num::NonZeroI32; +///# use std::num::NonZeroU32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let u_pos = NonZeroU32::new(1)?; +///let i_pos = NonZeroI32::new(1)?; +///let i_neg = NonZeroI32::new(-1)?; +///let i_min = NonZeroI32::new(i32::MIN)?; +///let u_max = NonZeroU32::new(u32::MAX / 2 + 1)?; +/// assert_eq!(u_pos, i_pos.unsigned_abs()); +/// assert_eq!(u_pos, i_neg.unsigned_abs()); +/// assert_eq!(u_max, i_min.unsigned_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn unsigned_abs(self) -> std::num::NonZeroU32; + +"#, + r#" +/// Returns `true` if `self` is positive and `false` if the +/// number is negative. +/// # Example +/// ``` +///# use std::num::NonZeroI32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI32::new(5)?; +///let neg_five = NonZeroI32::new(-5)?; +/// assert!(pos_five.is_positive()); +/// assert!(!neg_five.is_positive()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn is_positive(self) -> bool; + +"#, + r#" +/// Returns `true` if `self` is negative and `false` if the +/// number is positive. +/// # Example +/// ``` +///# use std::num::NonZeroI32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI32::new(5)?; +///let neg_five = NonZeroI32::new(-5)?; +/// assert!(neg_five.is_negative()); +/// assert!(!pos_five.is_negative()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn is_negative(self) -> bool; + +"#, + r#" +/// Saturating negation. Computes `-self`, +///returning [`NonZeroI32::MAX`] +///if `self == NonZeroI32::MIN` +/// instead of overflowing. +/// # Example +/// ``` +///# use std::num::NonZeroI32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI32::new(5)?; +///let neg_five = NonZeroI32::new(-5)?; +///let min = NonZeroI32::new(i32::MIN)?; +///let min_plus_one = NonZeroI32::new(i32::MIN + 1)?; +///let max = NonZeroI32::new(i32::MAX)?; +/// assert_eq!(pos_five.saturating_neg(), neg_five); +/// assert_eq!(min.saturating_neg(), max); +/// assert_eq!(max.saturating_neg(), min_plus_one); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_neg(self) -> std::num::NonZeroI32; + +"#, + r#" +/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary +/// of the type. +///See [`i32::wrapping_neg`] +/// for documentation on overflow behaviour. +/// # Example +/// ``` +///# use std::num::NonZeroI32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI32::new(5)?; +///let neg_five = NonZeroI32::new(-5)?; +///let min = NonZeroI32::new(i32::MIN)?; +/// assert_eq!(pos_five.wrapping_neg(), neg_five); +/// assert_eq!(min.wrapping_neg(), min); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn wrapping_neg(self) -> std::num::NonZeroI32; + +"#, + r#" +/// Multiplies two non-zero integers together. +///Return [`NonZeroI32::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroI32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let two = NonZeroI32::new(2)?; +///let four = NonZeroI32::new(4)?; +///let max = NonZeroI32::new(i32::MAX)?; +/// assert_eq!(four, two.saturating_mul(two)); +/// assert_eq!(max, four.saturating_mul(max)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul( + self, + #[proxy] + other: std::num::NonZeroI32, + ) -> std::num::NonZeroI32; + +"#, + r#" +/// Raise non-zero value to an integer power. +///Return [`NonZeroI32::MIN`] or [`NonZeroI32::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroI32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let three = NonZeroI32::new(3)?; +///let twenty_seven = NonZeroI32::new(27)?; +///let max = NonZeroI32::new(i32::MAX)?; +/// assert_eq!(twenty_seven, three.saturating_pow(3)); +/// assert_eq!(max, max.saturating_pow(3)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_pow(self, other: u32) -> std::num::NonZeroI32; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::num::NonZeroI32; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::num::NonZeroI32) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct NonZeroI32(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::num::NonZeroI64", + functions[r#" +/// Creates a non-zero without checking whether the value is non-zero. +/// This results in undefined behaviour if the value is zero. +/// # Safety +/// The value must not be zero. + + #[lua(kind = "Function", output(proxy))] + unsafe fn new_unchecked(n: i64) -> std::num::NonZeroI64; + +"#, + r#" +/// Returns the value as a primitive type. + + #[lua(kind = "Method")] + fn get(self) -> i64; + +"#, + r#" +/// Returns the number of leading zeros in the binary representation of `self`. +/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroI64::new(-1i64).unwrap(); +/// assert_eq!(n.leading_zeros(), 0); +/// ``` + + #[lua(kind = "Method")] + fn leading_zeros(self) -> u32; + +"#, + r#" +/// Returns the number of trailing zeros in the binary representation +/// of `self`. +/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroI64::new(0b0101000).unwrap(); +/// assert_eq!(n.trailing_zeros(), 3); +/// ``` + + #[lua(kind = "Method")] + fn trailing_zeros(self) -> u32; + +"#, + r#" +/// Computes the absolute value of self. +///See [`i64::abs`] +/// for documentation on overflow behaviour. +/// # Example +/// ``` +///# use std::num::NonZeroI64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI64::new(1)?; +///let neg = NonZeroI64::new(-1)?; +/// assert_eq!(pos, pos.abs()); +/// assert_eq!(pos, neg.abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> std::num::NonZeroI64; + +"#, + r#" +/// Saturating absolute value, see +///[`i64::saturating_abs`]. +/// # Example +/// ``` +///# use std::num::NonZeroI64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI64::new(1)?; +///let neg = NonZeroI64::new(-1)?; +///let min = NonZeroI64::new(i64::MIN)?; +///let min_plus = NonZeroI64::new(i64::MIN + 1)?; +///let max = NonZeroI64::new(i64::MAX)?; +/// assert_eq!(pos, pos.saturating_abs()); +/// assert_eq!(pos, neg.saturating_abs()); +/// assert_eq!(max, min.saturating_abs()); +/// assert_eq!(max, min_plus.saturating_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_abs(self) -> std::num::NonZeroI64; + +"#, + r#" +/// Wrapping absolute value, see +///[`i64::wrapping_abs`]. +/// # Example +/// ``` +///# use std::num::NonZeroI64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI64::new(1)?; +///let neg = NonZeroI64::new(-1)?; +///let min = NonZeroI64::new(i64::MIN)?; +///# let max = NonZeroI64::new(i64::MAX)?; +/// assert_eq!(pos, pos.wrapping_abs()); +/// assert_eq!(pos, neg.wrapping_abs()); +/// assert_eq!(min, min.wrapping_abs()); +/// assert_eq!(max, (-max).wrapping_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn wrapping_abs(self) -> std::num::NonZeroI64; + +"#, + r#" +/// Computes the absolute value of self +/// without any wrapping or panicking. +/// # Example +/// ``` +///# use std::num::NonZeroI64; +///# use std::num::NonZeroU64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let u_pos = NonZeroU64::new(1)?; +///let i_pos = NonZeroI64::new(1)?; +///let i_neg = NonZeroI64::new(-1)?; +///let i_min = NonZeroI64::new(i64::MIN)?; +///let u_max = NonZeroU64::new(u64::MAX / 2 + 1)?; +/// assert_eq!(u_pos, i_pos.unsigned_abs()); +/// assert_eq!(u_pos, i_neg.unsigned_abs()); +/// assert_eq!(u_max, i_min.unsigned_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn unsigned_abs(self) -> std::num::NonZeroU64; + +"#, + r#" +/// Returns `true` if `self` is positive and `false` if the +/// number is negative. +/// # Example +/// ``` +///# use std::num::NonZeroI64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI64::new(5)?; +///let neg_five = NonZeroI64::new(-5)?; +/// assert!(pos_five.is_positive()); +/// assert!(!neg_five.is_positive()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn is_positive(self) -> bool; + +"#, + r#" +/// Returns `true` if `self` is negative and `false` if the +/// number is positive. +/// # Example +/// ``` +///# use std::num::NonZeroI64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI64::new(5)?; +///let neg_five = NonZeroI64::new(-5)?; +/// assert!(neg_five.is_negative()); +/// assert!(!pos_five.is_negative()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn is_negative(self) -> bool; + +"#, + r#" +/// Saturating negation. Computes `-self`, +///returning [`NonZeroI64::MAX`] +///if `self == NonZeroI64::MIN` +/// instead of overflowing. +/// # Example +/// ``` +///# use std::num::NonZeroI64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI64::new(5)?; +///let neg_five = NonZeroI64::new(-5)?; +///let min = NonZeroI64::new(i64::MIN)?; +///let min_plus_one = NonZeroI64::new(i64::MIN + 1)?; +///let max = NonZeroI64::new(i64::MAX)?; +/// assert_eq!(pos_five.saturating_neg(), neg_five); +/// assert_eq!(min.saturating_neg(), max); +/// assert_eq!(max.saturating_neg(), min_plus_one); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_neg(self) -> std::num::NonZeroI64; + +"#, + r#" +/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary +/// of the type. +///See [`i64::wrapping_neg`] +/// for documentation on overflow behaviour. +/// # Example +/// ``` +///# use std::num::NonZeroI64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI64::new(5)?; +///let neg_five = NonZeroI64::new(-5)?; +///let min = NonZeroI64::new(i64::MIN)?; +/// assert_eq!(pos_five.wrapping_neg(), neg_five); +/// assert_eq!(min.wrapping_neg(), min); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn wrapping_neg(self) -> std::num::NonZeroI64; + +"#, + r#" +/// Multiplies two non-zero integers together. +///Return [`NonZeroI64::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroI64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let two = NonZeroI64::new(2)?; +///let four = NonZeroI64::new(4)?; +///let max = NonZeroI64::new(i64::MAX)?; +/// assert_eq!(four, two.saturating_mul(two)); +/// assert_eq!(max, four.saturating_mul(max)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul( + self, + #[proxy] + other: std::num::NonZeroI64, + ) -> std::num::NonZeroI64; + +"#, + r#" +/// Raise non-zero value to an integer power. +///Return [`NonZeroI64::MIN`] or [`NonZeroI64::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroI64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let three = NonZeroI64::new(3)?; +///let twenty_seven = NonZeroI64::new(27)?; +///let max = NonZeroI64::new(i64::MAX)?; +/// assert_eq!(twenty_seven, three.saturating_pow(3)); +/// assert_eq!(max, max.saturating_pow(3)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_pow(self, other: u32) -> std::num::NonZeroI64; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> std::num::NonZeroI64; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::num::NonZeroI64) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::num::NonZeroI64; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct NonZeroI64(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::num::NonZeroI8", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> std::num::NonZeroI8; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::num::NonZeroI8) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::num::NonZeroI8; + +"#, + r#" +/// Creates a non-zero without checking whether the value is non-zero. +/// This results in undefined behaviour if the value is zero. +/// # Safety +/// The value must not be zero. + + #[lua(kind = "Function", output(proxy))] + unsafe fn new_unchecked(n: i8) -> std::num::NonZeroI8; + +"#, + r#" +/// Returns the value as a primitive type. + + #[lua(kind = "Method")] + fn get(self) -> i8; + +"#, + r#" +/// Returns the number of leading zeros in the binary representation of `self`. +/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroI8::new(-1i8).unwrap(); +/// assert_eq!(n.leading_zeros(), 0); +/// ``` + + #[lua(kind = "Method")] + fn leading_zeros(self) -> u32; + +"#, + r#" +/// Returns the number of trailing zeros in the binary representation +/// of `self`. +/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroI8::new(0b0101000).unwrap(); +/// assert_eq!(n.trailing_zeros(), 3); +/// ``` + + #[lua(kind = "Method")] + fn trailing_zeros(self) -> u32; + +"#, + r#" +/// Computes the absolute value of self. +///See [`i8::abs`] +/// for documentation on overflow behaviour. +/// # Example +/// ``` +///# use std::num::NonZeroI8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI8::new(1)?; +///let neg = NonZeroI8::new(-1)?; +/// assert_eq!(pos, pos.abs()); +/// assert_eq!(pos, neg.abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> std::num::NonZeroI8; + +"#, + r#" +/// Saturating absolute value, see +///[`i8::saturating_abs`]. +/// # Example +/// ``` +///# use std::num::NonZeroI8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI8::new(1)?; +///let neg = NonZeroI8::new(-1)?; +///let min = NonZeroI8::new(i8::MIN)?; +///let min_plus = NonZeroI8::new(i8::MIN + 1)?; +///let max = NonZeroI8::new(i8::MAX)?; +/// assert_eq!(pos, pos.saturating_abs()); +/// assert_eq!(pos, neg.saturating_abs()); +/// assert_eq!(max, min.saturating_abs()); +/// assert_eq!(max, min_plus.saturating_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_abs(self) -> std::num::NonZeroI8; + +"#, + r#" +/// Wrapping absolute value, see +///[`i8::wrapping_abs`]. +/// # Example +/// ``` +///# use std::num::NonZeroI8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroI8::new(1)?; +///let neg = NonZeroI8::new(-1)?; +///let min = NonZeroI8::new(i8::MIN)?; +///# let max = NonZeroI8::new(i8::MAX)?; +/// assert_eq!(pos, pos.wrapping_abs()); +/// assert_eq!(pos, neg.wrapping_abs()); +/// assert_eq!(min, min.wrapping_abs()); +/// assert_eq!(max, (-max).wrapping_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn wrapping_abs(self) -> std::num::NonZeroI8; + +"#, + r#" +/// Computes the absolute value of self +/// without any wrapping or panicking. +/// # Example +/// ``` +///# use std::num::NonZeroI8; +///# use std::num::NonZeroU8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let u_pos = NonZeroU8::new(1)?; +///let i_pos = NonZeroI8::new(1)?; +///let i_neg = NonZeroI8::new(-1)?; +///let i_min = NonZeroI8::new(i8::MIN)?; +///let u_max = NonZeroU8::new(u8::MAX / 2 + 1)?; +/// assert_eq!(u_pos, i_pos.unsigned_abs()); +/// assert_eq!(u_pos, i_neg.unsigned_abs()); +/// assert_eq!(u_max, i_min.unsigned_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn unsigned_abs(self) -> std::num::NonZeroU8; + +"#, + r#" +/// Returns `true` if `self` is positive and `false` if the +/// number is negative. +/// # Example +/// ``` +///# use std::num::NonZeroI8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI8::new(5)?; +///let neg_five = NonZeroI8::new(-5)?; +/// assert!(pos_five.is_positive()); +/// assert!(!neg_five.is_positive()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn is_positive(self) -> bool; + +"#, + r#" +/// Returns `true` if `self` is negative and `false` if the +/// number is positive. +/// # Example +/// ``` +///# use std::num::NonZeroI8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI8::new(5)?; +///let neg_five = NonZeroI8::new(-5)?; +/// assert!(neg_five.is_negative()); +/// assert!(!pos_five.is_negative()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn is_negative(self) -> bool; + +"#, + r#" +/// Saturating negation. Computes `-self`, +///returning [`NonZeroI8::MAX`] +///if `self == NonZeroI8::MIN` +/// instead of overflowing. +/// # Example +/// ``` +///# use std::num::NonZeroI8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI8::new(5)?; +///let neg_five = NonZeroI8::new(-5)?; +///let min = NonZeroI8::new(i8::MIN)?; +///let min_plus_one = NonZeroI8::new(i8::MIN + 1)?; +///let max = NonZeroI8::new(i8::MAX)?; +/// assert_eq!(pos_five.saturating_neg(), neg_five); +/// assert_eq!(min.saturating_neg(), max); +/// assert_eq!(max.saturating_neg(), min_plus_one); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_neg(self) -> std::num::NonZeroI8; + +"#, + r#" +/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary +/// of the type. +///See [`i8::wrapping_neg`] +/// for documentation on overflow behaviour. +/// # Example +/// ``` +///# use std::num::NonZeroI8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroI8::new(5)?; +///let neg_five = NonZeroI8::new(-5)?; +///let min = NonZeroI8::new(i8::MIN)?; +/// assert_eq!(pos_five.wrapping_neg(), neg_five); +/// assert_eq!(min.wrapping_neg(), min); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn wrapping_neg(self) -> std::num::NonZeroI8; + +"#, + r#" +/// Multiplies two non-zero integers together. +///Return [`NonZeroI8::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroI8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let two = NonZeroI8::new(2)?; +///let four = NonZeroI8::new(4)?; +///let max = NonZeroI8::new(i8::MAX)?; +/// assert_eq!(four, two.saturating_mul(two)); +/// assert_eq!(max, four.saturating_mul(max)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] other: std::num::NonZeroI8) -> std::num::NonZeroI8; + +"#, + r#" +/// Raise non-zero value to an integer power. +///Return [`NonZeroI8::MIN`] or [`NonZeroI8::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroI8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let three = NonZeroI8::new(3)?; +///let twenty_seven = NonZeroI8::new(27)?; +///let max = NonZeroI8::new(i8::MAX)?; +/// assert_eq!(twenty_seven, three.saturating_pow(3)); +/// assert_eq!(max, max.saturating_pow(3)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_pow(self, other: u32) -> std::num::NonZeroI8; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct NonZeroI8(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::num::NonZeroU128", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::num::NonZeroU128; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::num::NonZeroU128) -> bool; + +"#, + r#" +/// Creates a non-zero without checking whether the value is non-zero. +/// This results in undefined behaviour if the value is zero. +/// # Safety +/// The value must not be zero. + + #[lua(kind = "Function", output(proxy))] + unsafe fn new_unchecked(n: u128) -> std::num::NonZeroU128; + +"#, + r#" +/// Returns the value as a primitive type. + + #[lua(kind = "Method")] + fn get(self) -> u128; + +"#, + r#" +/// Returns the number of leading zeros in the binary representation of `self`. +/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroU128::new(u128::MAX).unwrap(); +/// assert_eq!(n.leading_zeros(), 0); +/// ``` + + #[lua(kind = "Method")] + fn leading_zeros(self) -> u32; + +"#, + r#" +/// Returns the number of trailing zeros in the binary representation +/// of `self`. +/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroU128::new(0b0101000).unwrap(); +/// assert_eq!(n.trailing_zeros(), 3); +/// ``` + + #[lua(kind = "Method")] + fn trailing_zeros(self) -> u32; + +"#, + r#" +/// Adds an unsigned integer to a non-zero value. +///Return [`NonZeroU128::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let one = NonZeroU128::new(1)?; +///let two = NonZeroU128::new(2)?; +///let max = NonZeroU128::new(u128::MAX)?; +/// assert_eq!(two, one.saturating_add(1)); +/// assert_eq!(max, max.saturating_add(1)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, other: u128) -> std::num::NonZeroU128; + +"#, + r#" +/// Returns the base 2 logarithm of the number, rounded down. +/// This is the same operation as +///[`u128::ilog2`], +/// except that it has no failure cases to worry about +/// since this value can never be zero. +/// # Examples +/// ``` +///# use std::num::NonZeroU128; +///assert_eq!(NonZeroU128::new(7).unwrap().ilog2(), 2); +///assert_eq!(NonZeroU128::new(8).unwrap().ilog2(), 3); +///assert_eq!(NonZeroU128::new(9).unwrap().ilog2(), 3); +/// ``` + + #[lua(kind = "Method")] + fn ilog2(self) -> u32; + +"#, + r#" +/// Returns the base 10 logarithm of the number, rounded down. +/// This is the same operation as +///[`u128::ilog10`], +/// except that it has no failure cases to worry about +/// since this value can never be zero. +/// # Examples +/// ``` +///# use std::num::NonZeroU128; +///assert_eq!(NonZeroU128::new(99).unwrap().ilog10(), 1); +///assert_eq!(NonZeroU128::new(100).unwrap().ilog10(), 2); +///assert_eq!(NonZeroU128::new(101).unwrap().ilog10(), 2); +/// ``` + + #[lua(kind = "Method")] + fn ilog10(self) -> u32; + +"#, + r#" +/// Returns `true` if and only if `self == (1 << k)` for some `k`. +/// On many architectures, this function can perform better than `is_power_of_two()` +/// on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let eight = std::num::NonZeroU128::new(8).unwrap(); +/// assert!(eight.is_power_of_two()); +///let ten = std::num::NonZeroU128::new(10).unwrap(); +/// assert!(!ten.is_power_of_two()); +/// ``` + + #[lua(kind = "Method")] + fn is_power_of_two(self) -> bool; + +"#, + r#" +/// Multiplies two non-zero integers together. +///Return [`NonZeroU128::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let two = NonZeroU128::new(2)?; +///let four = NonZeroU128::new(4)?; +///let max = NonZeroU128::new(u128::MAX)?; +/// assert_eq!(four, two.saturating_mul(two)); +/// assert_eq!(max, four.saturating_mul(max)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul( + self, + #[proxy] + other: std::num::NonZeroU128, + ) -> std::num::NonZeroU128; + +"#, + r#" +/// Raise non-zero value to an integer power. +///Return [`NonZeroU128::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU128; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let three = NonZeroU128::new(3)?; +///let twenty_seven = NonZeroU128::new(27)?; +///let max = NonZeroU128::new(u128::MAX)?; +/// assert_eq!(twenty_seven, three.saturating_pow(3)); +/// assert_eq!(max, max.saturating_pow(3)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_pow(self, other: u32) -> std::num::NonZeroU128; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct NonZeroU128(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::num::NonZeroU16", + functions[r#" +/// Creates a non-zero without checking whether the value is non-zero. +/// This results in undefined behaviour if the value is zero. +/// # Safety +/// The value must not be zero. + + #[lua(kind = "Function", output(proxy))] + unsafe fn new_unchecked(n: u16) -> std::num::NonZeroU16; + +"#, + r#" +/// Returns the value as a primitive type. + + #[lua(kind = "Method")] + fn get(self) -> u16; + +"#, + r#" +/// Returns the number of leading zeros in the binary representation of `self`. +/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroU16::new(u16::MAX).unwrap(); +/// assert_eq!(n.leading_zeros(), 0); +/// ``` + + #[lua(kind = "Method")] + fn leading_zeros(self) -> u32; + +"#, + r#" +/// Returns the number of trailing zeros in the binary representation +/// of `self`. +/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroU16::new(0b0101000).unwrap(); +/// assert_eq!(n.trailing_zeros(), 3); +/// ``` + + #[lua(kind = "Method")] + fn trailing_zeros(self) -> u32; + +"#, + r#" +/// Adds an unsigned integer to a non-zero value. +///Return [`NonZeroU16::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let one = NonZeroU16::new(1)?; +///let two = NonZeroU16::new(2)?; +///let max = NonZeroU16::new(u16::MAX)?; +/// assert_eq!(two, one.saturating_add(1)); +/// assert_eq!(max, max.saturating_add(1)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, other: u16) -> std::num::NonZeroU16; + +"#, + r#" +/// Returns the base 2 logarithm of the number, rounded down. +/// This is the same operation as +///[`u16::ilog2`], +/// except that it has no failure cases to worry about +/// since this value can never be zero. +/// # Examples +/// ``` +///# use std::num::NonZeroU16; +///assert_eq!(NonZeroU16::new(7).unwrap().ilog2(), 2); +///assert_eq!(NonZeroU16::new(8).unwrap().ilog2(), 3); +///assert_eq!(NonZeroU16::new(9).unwrap().ilog2(), 3); +/// ``` + + #[lua(kind = "Method")] + fn ilog2(self) -> u32; + +"#, + r#" +/// Returns the base 10 logarithm of the number, rounded down. +/// This is the same operation as +///[`u16::ilog10`], +/// except that it has no failure cases to worry about +/// since this value can never be zero. +/// # Examples +/// ``` +///# use std::num::NonZeroU16; +///assert_eq!(NonZeroU16::new(99).unwrap().ilog10(), 1); +///assert_eq!(NonZeroU16::new(100).unwrap().ilog10(), 2); +///assert_eq!(NonZeroU16::new(101).unwrap().ilog10(), 2); +/// ``` + + #[lua(kind = "Method")] + fn ilog10(self) -> u32; + +"#, + r#" +/// Returns `true` if and only if `self == (1 << k)` for some `k`. +/// On many architectures, this function can perform better than `is_power_of_two()` +/// on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let eight = std::num::NonZeroU16::new(8).unwrap(); +/// assert!(eight.is_power_of_two()); +///let ten = std::num::NonZeroU16::new(10).unwrap(); +/// assert!(!ten.is_power_of_two()); +/// ``` + + #[lua(kind = "Method")] + fn is_power_of_two(self) -> bool; + +"#, + r#" +/// Multiplies two non-zero integers together. +///Return [`NonZeroU16::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let two = NonZeroU16::new(2)?; +///let four = NonZeroU16::new(4)?; +///let max = NonZeroU16::new(u16::MAX)?; +/// assert_eq!(four, two.saturating_mul(two)); +/// assert_eq!(max, four.saturating_mul(max)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul( + self, + #[proxy] + other: std::num::NonZeroU16, + ) -> std::num::NonZeroU16; + +"#, + r#" +/// Raise non-zero value to an integer power. +///Return [`NonZeroU16::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU16; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let three = NonZeroU16::new(3)?; +///let twenty_seven = NonZeroU16::new(27)?; +///let max = NonZeroU16::new(u16::MAX)?; +/// assert_eq!(twenty_seven, three.saturating_pow(3)); +/// assert_eq!(max, max.saturating_pow(3)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_pow(self, other: u32) -> std::num::NonZeroU16; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::num::NonZeroU16) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::num::NonZeroU16; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct NonZeroU16(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::num::NonZeroU32", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::num::NonZeroU32) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +/// Creates a non-zero without checking whether the value is non-zero. +/// This results in undefined behaviour if the value is zero. +/// # Safety +/// The value must not be zero. + + #[lua(kind = "Function", output(proxy))] + unsafe fn new_unchecked(n: u32) -> std::num::NonZeroU32; + +"#, + r#" +/// Returns the value as a primitive type. + + #[lua(kind = "Method")] + fn get(self) -> u32; + +"#, + r#" +/// Returns the number of leading zeros in the binary representation of `self`. +/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroU32::new(u32::MAX).unwrap(); +/// assert_eq!(n.leading_zeros(), 0); +/// ``` + + #[lua(kind = "Method")] + fn leading_zeros(self) -> u32; + +"#, + r#" +/// Returns the number of trailing zeros in the binary representation +/// of `self`. +/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroU32::new(0b0101000).unwrap(); +/// assert_eq!(n.trailing_zeros(), 3); +/// ``` + + #[lua(kind = "Method")] + fn trailing_zeros(self) -> u32; + +"#, + r#" +/// Adds an unsigned integer to a non-zero value. +///Return [`NonZeroU32::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let one = NonZeroU32::new(1)?; +///let two = NonZeroU32::new(2)?; +///let max = NonZeroU32::new(u32::MAX)?; +/// assert_eq!(two, one.saturating_add(1)); +/// assert_eq!(max, max.saturating_add(1)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, other: u32) -> std::num::NonZeroU32; + +"#, + r#" +/// Returns the base 2 logarithm of the number, rounded down. +/// This is the same operation as +///[`u32::ilog2`], +/// except that it has no failure cases to worry about +/// since this value can never be zero. +/// # Examples +/// ``` +///# use std::num::NonZeroU32; +///assert_eq!(NonZeroU32::new(7).unwrap().ilog2(), 2); +///assert_eq!(NonZeroU32::new(8).unwrap().ilog2(), 3); +///assert_eq!(NonZeroU32::new(9).unwrap().ilog2(), 3); +/// ``` + + #[lua(kind = "Method")] + fn ilog2(self) -> u32; + +"#, + r#" +/// Returns the base 10 logarithm of the number, rounded down. +/// This is the same operation as +///[`u32::ilog10`], +/// except that it has no failure cases to worry about +/// since this value can never be zero. +/// # Examples +/// ``` +///# use std::num::NonZeroU32; +///assert_eq!(NonZeroU32::new(99).unwrap().ilog10(), 1); +///assert_eq!(NonZeroU32::new(100).unwrap().ilog10(), 2); +///assert_eq!(NonZeroU32::new(101).unwrap().ilog10(), 2); +/// ``` + + #[lua(kind = "Method")] + fn ilog10(self) -> u32; + +"#, + r#" +/// Returns `true` if and only if `self == (1 << k)` for some `k`. +/// On many architectures, this function can perform better than `is_power_of_two()` +/// on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let eight = std::num::NonZeroU32::new(8).unwrap(); +/// assert!(eight.is_power_of_two()); +///let ten = std::num::NonZeroU32::new(10).unwrap(); +/// assert!(!ten.is_power_of_two()); +/// ``` + + #[lua(kind = "Method")] + fn is_power_of_two(self) -> bool; + +"#, + r#" +/// Multiplies two non-zero integers together. +///Return [`NonZeroU32::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let two = NonZeroU32::new(2)?; +///let four = NonZeroU32::new(4)?; +///let max = NonZeroU32::new(u32::MAX)?; +/// assert_eq!(four, two.saturating_mul(two)); +/// assert_eq!(max, four.saturating_mul(max)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul( + self, + #[proxy] + other: std::num::NonZeroU32, + ) -> std::num::NonZeroU32; + +"#, + r#" +/// Raise non-zero value to an integer power. +///Return [`NonZeroU32::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU32; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let three = NonZeroU32::new(3)?; +///let twenty_seven = NonZeroU32::new(27)?; +///let max = NonZeroU32::new(u32::MAX)?; +/// assert_eq!(twenty_seven, three.saturating_pow(3)); +/// assert_eq!(max, max.saturating_pow(3)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_pow(self, other: u32) -> std::num::NonZeroU32; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::num::NonZeroU32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct NonZeroU32(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::num::NonZeroU64", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::num::NonZeroU64) -> bool; + +"#, + r#" +/// Creates a non-zero without checking whether the value is non-zero. +/// This results in undefined behaviour if the value is zero. +/// # Safety +/// The value must not be zero. + + #[lua(kind = "Function", output(proxy))] + unsafe fn new_unchecked(n: u64) -> std::num::NonZeroU64; + +"#, + r#" +/// Returns the value as a primitive type. + + #[lua(kind = "Method")] + fn get(self) -> u64; + +"#, + r#" +/// Returns the number of leading zeros in the binary representation of `self`. +/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroU64::new(u64::MAX).unwrap(); +/// assert_eq!(n.leading_zeros(), 0); +/// ``` + + #[lua(kind = "Method")] + fn leading_zeros(self) -> u32; + +"#, + r#" +/// Returns the number of trailing zeros in the binary representation +/// of `self`. +/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroU64::new(0b0101000).unwrap(); +/// assert_eq!(n.trailing_zeros(), 3); +/// ``` + + #[lua(kind = "Method")] + fn trailing_zeros(self) -> u32; + +"#, + r#" +/// Adds an unsigned integer to a non-zero value. +///Return [`NonZeroU64::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let one = NonZeroU64::new(1)?; +///let two = NonZeroU64::new(2)?; +///let max = NonZeroU64::new(u64::MAX)?; +/// assert_eq!(two, one.saturating_add(1)); +/// assert_eq!(max, max.saturating_add(1)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, other: u64) -> std::num::NonZeroU64; + +"#, + r#" +/// Returns the base 2 logarithm of the number, rounded down. +/// This is the same operation as +///[`u64::ilog2`], +/// except that it has no failure cases to worry about +/// since this value can never be zero. +/// # Examples +/// ``` +///# use std::num::NonZeroU64; +///assert_eq!(NonZeroU64::new(7).unwrap().ilog2(), 2); +///assert_eq!(NonZeroU64::new(8).unwrap().ilog2(), 3); +///assert_eq!(NonZeroU64::new(9).unwrap().ilog2(), 3); +/// ``` + + #[lua(kind = "Method")] + fn ilog2(self) -> u32; + +"#, + r#" +/// Returns the base 10 logarithm of the number, rounded down. +/// This is the same operation as +///[`u64::ilog10`], +/// except that it has no failure cases to worry about +/// since this value can never be zero. +/// # Examples +/// ``` +///# use std::num::NonZeroU64; +///assert_eq!(NonZeroU64::new(99).unwrap().ilog10(), 1); +///assert_eq!(NonZeroU64::new(100).unwrap().ilog10(), 2); +///assert_eq!(NonZeroU64::new(101).unwrap().ilog10(), 2); +/// ``` + + #[lua(kind = "Method")] + fn ilog10(self) -> u32; + +"#, + r#" +/// Returns `true` if and only if `self == (1 << k)` for some `k`. +/// On many architectures, this function can perform better than `is_power_of_two()` +/// on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let eight = std::num::NonZeroU64::new(8).unwrap(); +/// assert!(eight.is_power_of_two()); +///let ten = std::num::NonZeroU64::new(10).unwrap(); +/// assert!(!ten.is_power_of_two()); +/// ``` + + #[lua(kind = "Method")] + fn is_power_of_two(self) -> bool; + +"#, + r#" +/// Multiplies two non-zero integers together. +///Return [`NonZeroU64::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let two = NonZeroU64::new(2)?; +///let four = NonZeroU64::new(4)?; +///let max = NonZeroU64::new(u64::MAX)?; +/// assert_eq!(four, two.saturating_mul(two)); +/// assert_eq!(max, four.saturating_mul(max)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul( + self, + #[proxy] + other: std::num::NonZeroU64, + ) -> std::num::NonZeroU64; + +"#, + r#" +/// Raise non-zero value to an integer power. +///Return [`NonZeroU64::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU64; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let three = NonZeroU64::new(3)?; +///let twenty_seven = NonZeroU64::new(27)?; +///let max = NonZeroU64::new(u64::MAX)?; +/// assert_eq!(twenty_seven, three.saturating_pow(3)); +/// assert_eq!(max, max.saturating_pow(3)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_pow(self, other: u32) -> std::num::NonZeroU64; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::num::NonZeroU64; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct NonZeroU64(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::num::NonZeroU8", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::num::NonZeroU8; + +"#, + r#" +/// Creates a non-zero without checking whether the value is non-zero. +/// This results in undefined behaviour if the value is zero. +/// # Safety +/// The value must not be zero. + + #[lua(kind = "Function", output(proxy))] + unsafe fn new_unchecked(n: u8) -> std::num::NonZeroU8; + +"#, + r#" +/// Returns the value as a primitive type. + + #[lua(kind = "Method")] + fn get(self) -> u8; + +"#, + r#" +/// Returns the number of leading zeros in the binary representation of `self`. +/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroU8::new(u8::MAX).unwrap(); +/// assert_eq!(n.leading_zeros(), 0); +/// ``` + + #[lua(kind = "Method")] + fn leading_zeros(self) -> u32; + +"#, + r#" +/// Returns the number of trailing zeros in the binary representation +/// of `self`. +/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroU8::new(0b0101000).unwrap(); +/// assert_eq!(n.trailing_zeros(), 3); +/// ``` + + #[lua(kind = "Method")] + fn trailing_zeros(self) -> u32; + +"#, + r#" +/// Adds an unsigned integer to a non-zero value. +///Return [`NonZeroU8::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let one = NonZeroU8::new(1)?; +///let two = NonZeroU8::new(2)?; +///let max = NonZeroU8::new(u8::MAX)?; +/// assert_eq!(two, one.saturating_add(1)); +/// assert_eq!(max, max.saturating_add(1)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, other: u8) -> std::num::NonZeroU8; + +"#, + r#" +/// Returns the base 2 logarithm of the number, rounded down. +/// This is the same operation as +///[`u8::ilog2`], +/// except that it has no failure cases to worry about +/// since this value can never be zero. +/// # Examples +/// ``` +///# use std::num::NonZeroU8; +///assert_eq!(NonZeroU8::new(7).unwrap().ilog2(), 2); +///assert_eq!(NonZeroU8::new(8).unwrap().ilog2(), 3); +///assert_eq!(NonZeroU8::new(9).unwrap().ilog2(), 3); +/// ``` + + #[lua(kind = "Method")] + fn ilog2(self) -> u32; + +"#, + r#" +/// Returns the base 10 logarithm of the number, rounded down. +/// This is the same operation as +///[`u8::ilog10`], +/// except that it has no failure cases to worry about +/// since this value can never be zero. +/// # Examples +/// ``` +///# use std::num::NonZeroU8; +///assert_eq!(NonZeroU8::new(99).unwrap().ilog10(), 1); +///assert_eq!(NonZeroU8::new(100).unwrap().ilog10(), 2); +///assert_eq!(NonZeroU8::new(101).unwrap().ilog10(), 2); +/// ``` + + #[lua(kind = "Method")] + fn ilog10(self) -> u32; + +"#, + r#" +/// Returns `true` if and only if `self == (1 << k)` for some `k`. +/// On many architectures, this function can perform better than `is_power_of_two()` +/// on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let eight = std::num::NonZeroU8::new(8).unwrap(); +/// assert!(eight.is_power_of_two()); +///let ten = std::num::NonZeroU8::new(10).unwrap(); +/// assert!(!ten.is_power_of_two()); +/// ``` + + #[lua(kind = "Method")] + fn is_power_of_two(self) -> bool; + +"#, + r#" +/// Multiplies two non-zero integers together. +///Return [`NonZeroU8::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let two = NonZeroU8::new(2)?; +///let four = NonZeroU8::new(4)?; +///let max = NonZeroU8::new(u8::MAX)?; +/// assert_eq!(four, two.saturating_mul(two)); +/// assert_eq!(max, four.saturating_mul(max)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] other: std::num::NonZeroU8) -> std::num::NonZeroU8; + +"#, + r#" +/// Raise non-zero value to an integer power. +///Return [`NonZeroU8::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroU8; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let three = NonZeroU8::new(3)?; +///let twenty_seven = NonZeroU8::new(27)?; +///let max = NonZeroU8::new(u8::MAX)?; +/// assert_eq!(twenty_seven, three.saturating_pow(3)); +/// assert_eq!(max, max.saturating_pow(3)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_pow(self, other: u32) -> std::num::NonZeroU8; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::num::NonZeroU8) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct NonZeroU8(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::num::NonZeroUsize", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +/// Creates a non-zero without checking whether the value is non-zero. +/// This results in undefined behaviour if the value is zero. +/// # Safety +/// The value must not be zero. + + #[lua(kind = "Function", output(proxy))] + unsafe fn new_unchecked(n: usize) -> std::num::NonZeroUsize; + +"#, + r#" +/// Returns the value as a primitive type. + + #[lua(kind = "Method")] + fn get(self) -> usize; + +"#, + r#" +/// Returns the number of leading zeros in the binary representation of `self`. +/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroUsize::new(usize::MAX).unwrap(); +/// assert_eq!(n.leading_zeros(), 0); +/// ``` + + #[lua(kind = "Method")] + fn leading_zeros(self) -> u32; + +"#, + r#" +/// Returns the number of trailing zeros in the binary representation +/// of `self`. +/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroUsize::new(0b0101000).unwrap(); +/// assert_eq!(n.trailing_zeros(), 3); +/// ``` + + #[lua(kind = "Method")] + fn trailing_zeros(self) -> u32; + +"#, + r#" +/// Adds an unsigned integer to a non-zero value. +///Return [`NonZeroUsize::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroUsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let one = NonZeroUsize::new(1)?; +///let two = NonZeroUsize::new(2)?; +///let max = NonZeroUsize::new(usize::MAX)?; +/// assert_eq!(two, one.saturating_add(1)); +/// assert_eq!(max, max.saturating_add(1)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, other: usize) -> std::num::NonZeroUsize; + +"#, + r#" +/// Returns the base 2 logarithm of the number, rounded down. +/// This is the same operation as +///[`usize::ilog2`], +/// except that it has no failure cases to worry about +/// since this value can never be zero. +/// # Examples +/// ``` +///# use std::num::NonZeroUsize; +///assert_eq!(NonZeroUsize::new(7).unwrap().ilog2(), 2); +///assert_eq!(NonZeroUsize::new(8).unwrap().ilog2(), 3); +///assert_eq!(NonZeroUsize::new(9).unwrap().ilog2(), 3); +/// ``` + + #[lua(kind = "Method")] + fn ilog2(self) -> u32; + +"#, + r#" +/// Returns the base 10 logarithm of the number, rounded down. +/// This is the same operation as +///[`usize::ilog10`], +/// except that it has no failure cases to worry about +/// since this value can never be zero. +/// # Examples +/// ``` +///# use std::num::NonZeroUsize; +///assert_eq!(NonZeroUsize::new(99).unwrap().ilog10(), 1); +///assert_eq!(NonZeroUsize::new(100).unwrap().ilog10(), 2); +///assert_eq!(NonZeroUsize::new(101).unwrap().ilog10(), 2); +/// ``` + + #[lua(kind = "Method")] + fn ilog10(self) -> u32; + +"#, + r#" +/// Returns `true` if and only if `self == (1 << k)` for some `k`. +/// On many architectures, this function can perform better than `is_power_of_two()` +/// on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let eight = std::num::NonZeroUsize::new(8).unwrap(); +/// assert!(eight.is_power_of_two()); +///let ten = std::num::NonZeroUsize::new(10).unwrap(); +/// assert!(!ten.is_power_of_two()); +/// ``` + + #[lua(kind = "Method")] + fn is_power_of_two(self) -> bool; + +"#, + r#" +/// Multiplies two non-zero integers together. +///Return [`NonZeroUsize::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroUsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let two = NonZeroUsize::new(2)?; +///let four = NonZeroUsize::new(4)?; +///let max = NonZeroUsize::new(usize::MAX)?; +/// assert_eq!(four, two.saturating_mul(two)); +/// assert_eq!(max, four.saturating_mul(max)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul( + self, + #[proxy] + other: std::num::NonZeroUsize, + ) -> std::num::NonZeroUsize; + +"#, + r#" +/// Raise non-zero value to an integer power. +///Return [`NonZeroUsize::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroUsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let three = NonZeroUsize::new(3)?; +///let twenty_seven = NonZeroUsize::new(27)?; +///let max = NonZeroUsize::new(usize::MAX)?; +/// assert_eq!(twenty_seven, three.saturating_pow(3)); +/// assert_eq!(max, max.saturating_pow(3)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_pow(self, other: u32) -> std::num::NonZeroUsize; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::num::NonZeroUsize) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::num::NonZeroUsize; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct NonZeroUsize(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::path::PathBuf", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::path::PathBuf) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::path::PathBuf; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "MutatingMethod", + )] + fn clone_from(&mut self, #[proxy] source: &std::path::PathBuf) -> (); + +"#, + r#" +/// Allocates an empty `PathBuf`. +/// # Examples +/// ``` +/// use std::path::PathBuf; +/// let path = PathBuf::new(); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new() -> std::path::PathBuf; + +"#, + r#" +/// Creates a new `PathBuf` with a given capacity used to create the +/// internal [`OsString`]. See [`with_capacity`] defined on [`OsString`]. +/// # Examples +/// ``` +/// use std::path::PathBuf; +/// let mut path = PathBuf::with_capacity(10); +/// let capacity = path.capacity(); +/// // This push is done without reallocating +/// path.push(r"C:\"); +/// assert_eq!(capacity, path.capacity()); +/// ``` +/// [`with_capacity`]: OsString::with_capacity + + #[lua(kind = "Function", output(proxy))] + fn with_capacity(capacity: usize) -> std::path::PathBuf; + +"#, + r#" +/// Truncates `self` to [`self.parent`]. +/// Returns `false` and does nothing if [`self.parent`] is [`None`]. +/// Otherwise, returns `true`. +/// [`self.parent`]: Path::parent +/// # Examples +/// ``` +/// use std::path::{Path, PathBuf}; +/// let mut p = PathBuf::from("/spirited/away.rs"); +/// p.pop(); +/// assert_eq!(Path::new("/spirited"), p); +/// p.pop(); +/// assert_eq!(Path::new("/"), p); +/// ``` + + #[lua(kind = "MutatingMethod")] + fn pop(&mut self) -> bool; + +"#, + r#" +/// Invokes [`capacity`] on the underlying instance of [`OsString`]. +/// [`capacity`]: OsString::capacity + + #[lua(kind = "Method")] + fn capacity(&self) -> usize; + +"#, + r#" +/// Invokes [`clear`] on the underlying instance of [`OsString`]. +/// [`clear`]: OsString::clear + + #[lua(kind = "MutatingMethod")] + fn clear(&mut self) -> (); + +"#, + r#" +/// Invokes [`reserve`] on the underlying instance of [`OsString`]. +/// [`reserve`]: OsString::reserve + + #[lua(kind = "MutatingMethod")] + fn reserve(&mut self, additional: usize) -> (); + +"#, + r#" +/// Invokes [`reserve_exact`] on the underlying instance of [`OsString`]. +/// [`reserve_exact`]: OsString::reserve_exact + + #[lua(kind = "MutatingMethod")] + fn reserve_exact(&mut self, additional: usize) -> (); + +"#, + r#" +/// Invokes [`shrink_to_fit`] on the underlying instance of [`OsString`]. +/// [`shrink_to_fit`]: OsString::shrink_to_fit + + #[lua(kind = "MutatingMethod")] + fn shrink_to_fit(&mut self) -> (); + +"#, + r#" +/// Invokes [`shrink_to`] on the underlying instance of [`OsString`]. +/// [`shrink_to`]: OsString::shrink_to + + #[lua(kind = "MutatingMethod")] + fn shrink_to(&mut self, min_capacity: usize) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct PathBuf {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::ops::RangeFull", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::ops::RangeFull; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::ops::RangeFull) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct RangeFull {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Quat", + functions[r#" +/// Rotates the [`Direction3d`] using a [`Quat`]. + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul( + self, + #[proxy] + direction: bevy::math::primitives::Direction3d, + ) -> bevy::math::primitives::Direction3d; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + 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( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Quat; + +"#, + r#" +/// Adds two quaternions. +/// The sum is not guaranteed to be normalized. +/// Note that addition is not the same as combining the rotations represented by the +/// two quaternions! That corresponds to multiplication. + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + +"#, + r#" +/// Subtracts the `rhs` quaternion from `self`. +/// The difference is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Quat) -> bool; + +"#, + r#" +/// Divides a quaternion by a scalar value. +/// The quotient is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Quat; + +"#, + 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) -> bevy::math::Quat; + +"#, + r#" +/// Creates a rotation quaternion from an array. +/// # 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_array(a: [f32; 4]) -> bevy::math::Quat; + +"#, + 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::Vec4) -> bevy::math::Quat; + +"#, + 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::Vec3, angle: f32) -> bevy::math::Quat; + +"#, + 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::Vec3) -> bevy::math::Quat; + +"#, + r#" +/// Creates a quaternion from the `angle` (in radians) around the x axis. + + #[lua(kind = "Function", output(proxy))] + fn from_rotation_x(angle: f32) -> bevy::math::Quat; + +"#, + r#" +/// Creates a quaternion from the `angle` (in radians) around the y axis. + + #[lua(kind = "Function", output(proxy))] + fn from_rotation_y(angle: f32) -> bevy::math::Quat; + +"#, + r#" +/// Creates a quaternion from the `angle` (in radians) around the z axis. + + #[lua(kind = "Function", output(proxy))] + fn from_rotation_z(angle: f32) -> bevy::math::Quat; + +"#, + 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, + ) -> bevy::math::Quat; + +"#, + r#" +/// Creates a quaternion from a 3x3 rotation matrix. + + #[lua(kind = "Function", output(proxy))] + fn from_mat3(#[proxy] mat: &glam::Mat3) -> bevy::math::Quat; + +"#, + r#" +/// Creates a quaternion from a 3x3 SIMD aligned rotation matrix. + + #[lua(kind = "Function", output(proxy))] + fn from_mat3a(#[proxy] mat: &glam::Mat3A) -> bevy::math::Quat; + +"#, + r#" +/// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. + + #[lua(kind = "Function", output(proxy))] + fn from_mat4(#[proxy] mat: &glam::Mat4) -> bevy::math::Quat; + +"#, + 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::Vec3, + #[proxy] + to: bevy::math::Vec3, + ) -> bevy::math::Quat; + +"#, + 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::Vec3, + #[proxy] + to: bevy::math::Vec3, + ) -> bevy::math::Quat; + +"#, + 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::Vec2, + #[proxy] + to: bevy::math::Vec2, + ) -> bevy::math::Quat; + +"#, + r#" +/// Returns the rotation axis scaled by the rotation in radians. + + #[lua(kind = "Method", output(proxy))] + fn to_scaled_axis(self) -> bevy::math::Vec3; + +"#, + r#" +/// Returns the rotation angles for the given euler rotation sequence. + + #[lua(kind = "Method")] + fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f32, f32, f32); + +"#, + r#" +/// `[x, y, z, w]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [f32; 4]; + +"#, + r#" +/// Returns the vector part of the quaternion. + + #[lua(kind = "Method", output(proxy))] + fn xyz(self) -> bevy::math::Vec3; + +"#, + r#" +/// Returns the quaternion conjugate of `self`. For a unit quaternion the +/// conjugate is also the inverse. + + #[lua(kind = "Method", output(proxy))] + fn conjugate(self) -> bevy::math::Quat; + +"#, + 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(kind = "Method", output(proxy))] + fn inverse(self) -> bevy::math::Quat; + +"#, + 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(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::Quat) -> f32; + +"#, + r#" +/// Computes the length of `self`. + + #[lua(kind = "Method")] + 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(kind = "Method")] + fn length_squared(self) -> f32; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::Quat; + +"#, + 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(kind = "Method")] + fn is_finite(self) -> bool; + +"#, + r#" + + #[lua(kind = "Method")] + fn is_nan(self) -> bool; + +"#, + r#" +/// Returns whether `self` of length `1.0` or not. +/// Uses a precision threshold of `1e-6`. + + #[lua(kind = "Method")] + fn is_normalized(self) -> bool; + +"#, + r#" + + #[lua(kind = "Method")] + 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(kind = "Method")] + fn angle_between(self, #[proxy] rhs: bevy::math::Quat) -> 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(kind = "Method")] + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Quat, 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(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] end: bevy::math::Quat, s: f32) -> bevy::math::Quat; + +"#, + 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(kind = "Method", output(proxy))] + fn slerp(self, #[proxy] end: bevy::math::Quat, s: f32) -> bevy::math::Quat; + +"#, + 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(kind = "Method", output(proxy))] + fn mul_vec3(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn mul_quat(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + +"#, + r#" +/// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. + + #[lua(kind = "Function", output(proxy))] + fn from_affine3(#[proxy] a: &glam::Affine3A) -> bevy::math::Quat; + +"#, + r#" +/// Multiplies a quaternion and a 3D vector, returning the rotated vector. + + #[lua(kind = "Method", output(proxy))] + fn mul_vec3a(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua(kind = "Method", output(proxy))] + fn as_dquat(self) -> bevy::math::DQuat; + +"#, + r#" + + #[lua(kind = "Method", output(proxy))] + fn as_f64(self) -> bevy::math::DQuat; + +"#, + r#" +/// Multiplies a quaternion by a scalar value. +/// The product is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Quat; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Quat; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct Quat(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Vec3", + functions[r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f32) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: f32) -> bevy::math::Vec3; + +"#, + 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::BVec3, + #[proxy] + if_true: bevy::math::Vec3, + #[proxy] + if_false: bevy::math::Vec3, + ) -> bevy::math::Vec3; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f32; 3]) -> bevy::math::Vec3; + +"#, + r#" +/// `[x, y, z]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [f32; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, w: f32) -> bevy::math::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(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::Vec2; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::Vec3) -> f32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn cross(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::Vec3, + #[proxy] + max: bevy::math::Vec3, + ) -> bevy::math::Vec3; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> f32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::Vec3; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua(kind = "Method", output(proxy))] + fn copysign(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + 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(kind = "Method")] + 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(kind = "Method")] + fn is_finite(self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn is_nan_mask(self) -> bevy::math::BVec3; + +"#, + r#" +/// Computes the length of `self`. + + #[lua(kind = "Method")] + fn length(self) -> f32; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua(kind = "Method")] + fn length_squared(self) -> f32; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua(kind = "Method")] + fn length_recip(self) -> f32; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance(self, #[proxy] rhs: bevy::math::Vec3) -> f32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::Vec3) -> f32; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f32::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize_or_zero(self) -> bevy::math::Vec3; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of `1e-6`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn project_onto(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn round(self) -> bevy::math::Vec3; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn floor(self) -> bevy::math::Vec3; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn ceil(self) -> bevy::math::Vec3; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua(kind = "Method", output(proxy))] + fn trunc(self) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn fract(self) -> bevy::math::Vec3; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua(kind = "Method", output(proxy))] + fn exp(self) -> bevy::math::Vec3; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua(kind = "Method", output(proxy))] + fn powf(self, n: f32) -> bevy::math::Vec3; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn recip(self) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] rhs: bevy::math::Vec3, s: f32) -> bevy::math::Vec3; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec3, 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(kind = "Method", output(proxy))] + fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3; + +"#, + r#" +/// Returns a vector with a length no more than `max` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_max(self, max: f32) -> bevy::math::Vec3; + +"#, + r#" +/// Returns a vector with a length no less than `min` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_min(self, min: f32) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn mul_add( + self, + #[proxy] + a: bevy::math::Vec3, + #[proxy] + b: bevy::math::Vec3, + ) -> bevy::math::Vec3; + +"#, + 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(kind = "Method")] + fn angle_between(self, #[proxy] rhs: bevy::math::Vec3) -> 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(kind = "Method", output(proxy))] + fn any_orthogonal_vector(&self) -> bevy::math::Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn any_orthonormal_vector(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec3(&self) -> bevy::math::DVec3; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec3(&self) -> bevy::math::IVec3; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec3(&self) -> bevy::math::UVec3; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec3(&self) -> bevy::math::I64Vec3; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec3(&self) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f32) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::Vec3) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct Vec3 { + x: f32, + y: f32, + z: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::IVec2", + functions[r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: i32) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i32) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::IVec2) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i32) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i32) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: i32, y: i32) -> bevy::math::IVec2; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: i32) -> bevy::math::IVec2; + +"#, + 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::BVec2, + #[proxy] + if_true: bevy::math::IVec2, + #[proxy] + if_false: bevy::math::IVec2, + ) -> bevy::math::IVec2; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [i32; 2]) -> bevy::math::IVec2; + +"#, + r#" +/// `[x, y]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [i32; 2]; + +"#, + r#" +/// Creates a 3D vector from `self` and the given `z` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, z: i32) -> bevy::math::IVec3; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::IVec2) -> i32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::IVec2, + #[proxy] + max: bevy::math::IVec2, + ) -> bevy::math::IVec2; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> i32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::IVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::IVec2; + +"#, + 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(kind = "Method")] + fn is_negative_bitmask(self) -> u32; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua(kind = "Method")] + fn length_squared(self) -> i32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::IVec2) -> i32; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. +/// [Euclidean division]: i32::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" +/// Returns a vector that is equal to `self` rotated by 90 degrees. + + #[lua(kind = "Method", output(proxy))] + fn perp(self) -> bevy::math::IVec2; + +"#, + r#" +/// The perpendicular dot product of `self` and `rhs`. +/// Also known as the wedge product, 2D cross product, and determinant. + + #[lua(kind = "Method")] + fn perp_dot(self, #[proxy] rhs: bevy::math::IVec2) -> 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(kind = "Method", output(proxy))] + fn rotate(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec2(&self) -> bevy::math::Vec2; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec2(&self) -> bevy::math::DVec2; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec2(&self) -> bevy::math::UVec2; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec2(&self) -> bevy::math::I64Vec2; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec2(&self) -> bevy::math::U64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: i32) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::IVec2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct IVec2 { + x: i32, + y: i32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::IVec3", + functions[r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i32) -> bevy::math::IVec3; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: i32, y: i32, z: i32) -> bevy::math::IVec3; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: i32) -> bevy::math::IVec3; + +"#, + 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::BVec3, + #[proxy] + if_true: bevy::math::IVec3, + #[proxy] + if_false: bevy::math::IVec3, + ) -> bevy::math::IVec3; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [i32; 3]) -> bevy::math::IVec3; + +"#, + r#" +/// `[x, y, z]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [i32; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, w: i32) -> bevy::math::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(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::IVec2; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::IVec3) -> i32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn cross(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::IVec3, + #[proxy] + max: bevy::math::IVec3, + ) -> bevy::math::IVec3; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> i32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::IVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::IVec3; + +"#, + 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(kind = "Method")] + fn is_negative_bitmask(self) -> u32; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua(kind = "Method")] + fn length_squared(self) -> i32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::IVec3) -> i32; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. +/// [Euclidean division]: i32::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec3(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec3a(&self) -> bevy::math::Vec3A; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec3(&self) -> bevy::math::DVec3; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec3(&self) -> bevy::math::UVec3; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec3(&self) -> bevy::math::I64Vec3; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec3(&self) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i32) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: i32) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: i32) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i32) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::IVec3) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct IVec3 { + x: i32, + y: i32, + z: i32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::IVec4", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i32) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: i32, y: i32, z: i32, w: i32) -> bevy::math::IVec4; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: i32) -> bevy::math::IVec4; + +"#, + 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::BVec4, + #[proxy] + if_true: bevy::math::IVec4, + #[proxy] + if_false: bevy::math::IVec4, + ) -> bevy::math::IVec4; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [i32; 4]) -> bevy::math::IVec4; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [i32; 4]; + +"#, + r#" +/// Creates a 3D 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(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::IVec3; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::IVec4) -> i32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::IVec4, + #[proxy] + max: bevy::math::IVec4, + ) -> bevy::math::IVec4; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> i32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::IVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::IVec4; + +"#, + 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(kind = "Method")] + fn is_negative_bitmask(self) -> u32; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua(kind = "Method")] + fn length_squared(self) -> i32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::IVec4) -> i32; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. +/// [Euclidean division]: i32::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec4(&self) -> bevy::math::Vec4; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec4(&self) -> bevy::math::DVec4; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec4(&self) -> bevy::math::UVec4; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec4(&self) -> bevy::math::I64Vec4; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec4(&self) -> bevy::math::U64Vec4; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::IVec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: i32) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i32) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: i32) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i32) -> bevy::math::IVec4; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct IVec4 { + x: i32, + y: i32, + z: i32, + w: i32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::I64Vec2", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i64) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: i64) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i64) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i64) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::I64Vec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: i64) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::I64Vec2; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: i64, y: i64) -> bevy::math::I64Vec2; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: i64) -> bevy::math::I64Vec2; + +"#, + 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::BVec2, + #[proxy] + if_true: bevy::math::I64Vec2, + #[proxy] + if_false: bevy::math::I64Vec2, + ) -> bevy::math::I64Vec2; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [i64; 2]) -> bevy::math::I64Vec2; + +"#, + r#" +/// `[x, y]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [i64; 2]; + +"#, + r#" +/// Creates a 3D vector from `self` and the given `z` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, z: i64) -> bevy::math::I64Vec3; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Component-wise clamping of values, similar to [`i64::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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::I64Vec2, + #[proxy] + max: bevy::math::I64Vec2, + ) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> i64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + fn max_element(self) -> i64; + +"#, + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::I64Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::I64Vec2; + +"#, + 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(kind = "Method")] + fn is_negative_bitmask(self) -> u32; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua(kind = "Method")] + fn length_squared(self) -> i64; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. +/// [Euclidean division]: i64::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector that is equal to `self` rotated by 90 degrees. + + #[lua(kind = "Method", output(proxy))] + fn perp(self) -> bevy::math::I64Vec2; + +"#, + r#" +/// The perpendicular dot product of `self` and `rhs`. +/// Also known as the wedge product, 2D cross product, and determinant. + + #[lua(kind = "Method")] + fn perp_dot(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; + +"#, + 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(kind = "Method", output(proxy))] + fn rotate(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec2(&self) -> bevy::math::Vec2; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec2(&self) -> bevy::math::DVec2; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec2(&self) -> bevy::math::IVec2; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec2(&self) -> bevy::math::UVec2; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec2(&self) -> bevy::math::U64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct I64Vec2 { + x: i64, + y: i64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::I64Vec3", + functions[r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i64) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: i64) -> bevy::math::I64Vec3; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: i64, y: i64, z: i64) -> bevy::math::I64Vec3; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: i64) -> bevy::math::I64Vec3; + +"#, + 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::BVec3, + #[proxy] + if_true: bevy::math::I64Vec3, + #[proxy] + if_false: bevy::math::I64Vec3, + ) -> bevy::math::I64Vec3; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [i64; 3]) -> bevy::math::I64Vec3; + +"#, + r#" +/// `[x, y, z]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [i64; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, w: i64) -> bevy::math::I64Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::I64Vec2; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::I64Vec3) -> i64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn cross(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +/// Component-wise clamping of values, similar to [`i64::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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::I64Vec3, + #[proxy] + max: bevy::math::I64Vec3, + ) -> bevy::math::I64Vec3; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> i64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + fn max_element(self) -> i64; + +"#, + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::I64Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::I64Vec3; + +"#, + 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(kind = "Method")] + fn is_negative_bitmask(self) -> u32; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua(kind = "Method")] + fn length_squared(self) -> i64; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec3) -> i64; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. +/// [Euclidean division]: i64::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec3(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec3a(&self) -> bevy::math::Vec3A; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec3(&self) -> bevy::math::DVec3; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec3(&self) -> bevy::math::IVec3; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec3(&self) -> bevy::math::UVec3; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec3(&self) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i64) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: i64) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::I64Vec3) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i64) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct I64Vec3 { + x: i64, + y: i64, + z: i64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::I64Vec4", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i64) -> bevy::math::I64Vec4; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: i64, y: i64, z: i64, w: i64) -> bevy::math::I64Vec4; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: i64) -> bevy::math::I64Vec4; + +"#, + 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::BVec4, + #[proxy] + if_true: bevy::math::I64Vec4, + #[proxy] + if_false: bevy::math::I64Vec4, + ) -> bevy::math::I64Vec4; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [i64; 4]) -> bevy::math::I64Vec4; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [i64; 4]; + +"#, + r#" +/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. +/// Truncation to [`I64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. + + #[lua(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::I64Vec3; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::I64Vec4) -> i64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" +/// Component-wise clamping of values, similar to [`i64::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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::I64Vec4, + #[proxy] + max: bevy::math::I64Vec4, + ) -> bevy::math::I64Vec4; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> i64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + fn max_element(self) -> i64; + +"#, + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::I64Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::I64Vec4; + +"#, + 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(kind = "Method")] + fn is_negative_bitmask(self) -> u32; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua(kind = "Method")] + fn length_squared(self) -> i64; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec4) -> i64; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. +/// [Euclidean division]: i64::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec4(&self) -> bevy::math::Vec4; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec4(&self) -> bevy::math::DVec4; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec4(&self) -> bevy::math::IVec4; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec4(&self) -> bevy::math::UVec4; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec4(&self) -> bevy::math::U64Vec4; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i64) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::I64Vec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: i64) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: i64) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i64) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct I64Vec4 { + x: i64, + y: i64, + z: i64, + w: i64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::UVec2", + functions[r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u32) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u32) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::UVec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u32) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u32) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u32) -> bevy::math::UVec2; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: u32, y: u32) -> bevy::math::UVec2; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: u32) -> bevy::math::UVec2; + +"#, + 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::BVec2, + #[proxy] + if_true: bevy::math::UVec2, + #[proxy] + if_false: bevy::math::UVec2, + ) -> bevy::math::UVec2; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [u32; 2]) -> bevy::math::UVec2; + +"#, + r#" +/// `[x, y]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [u32; 2]; + +"#, + r#" +/// Creates a 3D vector from `self` and the given `z` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, z: u32) -> bevy::math::UVec3; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::UVec2) -> u32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::UVec2, + #[proxy] + max: bevy::math::UVec2, + ) -> bevy::math::UVec2; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> u32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua(kind = "Method")] + fn length_squared(self) -> u32; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec2(&self) -> bevy::math::Vec2; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec2(&self) -> bevy::math::DVec2; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec2(&self) -> bevy::math::IVec2; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec2(&self) -> bevy::math::I64Vec2; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec2(&self) -> bevy::math::U64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct UVec2 { + x: u32, + y: u32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::UVec3", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u32) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u32) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u32) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: u32, y: u32, z: u32) -> bevy::math::UVec3; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: u32) -> bevy::math::UVec3; + +"#, + 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::BVec3, + #[proxy] + if_true: bevy::math::UVec3, + #[proxy] + if_false: bevy::math::UVec3, + ) -> bevy::math::UVec3; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [u32; 3]) -> bevy::math::UVec3; + +"#, + r#" +/// `[x, y, z]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [u32; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, w: u32) -> bevy::math::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(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::UVec2; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::UVec3) -> u32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn cross(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::UVec3, + #[proxy] + max: bevy::math::UVec3, + ) -> bevy::math::UVec3; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> u32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua(kind = "Method")] + fn length_squared(self) -> u32; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec3(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec3a(&self) -> bevy::math::Vec3A; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec3(&self) -> bevy::math::DVec3; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec3(&self) -> bevy::math::IVec3; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec3(&self) -> bevy::math::I64Vec3; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec3(&self) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::UVec3) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u32) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u32) -> bevy::math::UVec3; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct UVec3 { + x: u32, + y: u32, + z: u32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::UVec4", + functions[r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u32) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u32) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u32) -> bevy::math::UVec4; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: u32, y: u32, z: u32, w: u32) -> bevy::math::UVec4; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: u32) -> bevy::math::UVec4; + +"#, + 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::BVec4, + #[proxy] + if_true: bevy::math::UVec4, + #[proxy] + if_false: bevy::math::UVec4, + ) -> bevy::math::UVec4; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [u32; 4]) -> bevy::math::UVec4; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [u32; 4]; + +"#, + r#" +/// Creates a 3D 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(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::UVec3; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::UVec4) -> u32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::UVec4, + #[proxy] + max: bevy::math::UVec4, + ) -> bevy::math::UVec4; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> u32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua(kind = "Method")] + fn length_squared(self) -> u32; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec4(&self) -> bevy::math::Vec4; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec4(&self) -> bevy::math::DVec4; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec4(&self) -> bevy::math::IVec4; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec4(&self) -> bevy::math::I64Vec4; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec4(&self) -> bevy::math::U64Vec4; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::UVec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u32) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u32) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct UVec4 { + x: u32, + y: u32, + z: u32, + w: u32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::U64Vec2", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u64) -> bevy::math::U64Vec2; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: u64, y: u64) -> bevy::math::U64Vec2; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: u64) -> bevy::math::U64Vec2; + +"#, + 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::BVec2, + #[proxy] + if_true: bevy::math::U64Vec2, + #[proxy] + if_false: bevy::math::U64Vec2, + ) -> bevy::math::U64Vec2; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [u64; 2]) -> bevy::math::U64Vec2; + +"#, + r#" +/// `[x, y]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [u64; 2]; + +"#, + r#" +/// Creates a 3D vector from `self` and the given `z` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, z: u64) -> bevy::math::U64Vec3; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::U64Vec2) -> u64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" +/// Component-wise clamping of values, similar to [`u64::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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::U64Vec2, + #[proxy] + max: bevy::math::U64Vec2, + ) -> bevy::math::U64Vec2; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> u64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + fn max_element(self) -> u64; + +"#, + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua(kind = "Method")] + fn length_squared(self) -> u64; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec2(&self) -> bevy::math::Vec2; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec2(&self) -> bevy::math::DVec2; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec2(&self) -> bevy::math::IVec2; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec2(&self) -> bevy::math::UVec2; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec2(&self) -> bevy::math::I64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u64) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u64) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::U64Vec2) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u64) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u64) -> bevy::math::U64Vec2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct U64Vec2 { + x: u64, + y: u64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::U64Vec3", + functions[r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: u64, y: u64, z: u64) -> bevy::math::U64Vec3; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: u64) -> bevy::math::U64Vec3; + +"#, + 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::BVec3, + #[proxy] + if_true: bevy::math::U64Vec3, + #[proxy] + if_false: bevy::math::U64Vec3, + ) -> bevy::math::U64Vec3; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [u64; 3]) -> bevy::math::U64Vec3; + +"#, + r#" +/// `[x, y, z]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [u64; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, w: u64) -> bevy::math::U64Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::U64Vec2; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::U64Vec3) -> u64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn cross(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +/// Component-wise clamping of values, similar to [`u64::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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::U64Vec3, + #[proxy] + max: bevy::math::U64Vec3, + ) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> u64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + fn max_element(self) -> u64; + +"#, + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua(kind = "Method")] + fn length_squared(self) -> u64; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec3(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec3a(&self) -> bevy::math::Vec3A; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec3(&self) -> bevy::math::DVec3; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec3(&self) -> bevy::math::IVec3; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec3(&self) -> bevy::math::UVec3; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec3(&self) -> bevy::math::I64Vec3; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::U64Vec3) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct U64Vec3 { + x: u64, + y: u64, + z: u64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::U64Vec4", + functions[r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: u64, y: u64, z: u64, w: u64) -> bevy::math::U64Vec4; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: u64) -> bevy::math::U64Vec4; + +"#, + 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::BVec4, + #[proxy] + if_true: bevy::math::U64Vec4, + #[proxy] + if_false: bevy::math::U64Vec4, + ) -> bevy::math::U64Vec4; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [u64; 4]) -> bevy::math::U64Vec4; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [u64; 4]; + +"#, + r#" +/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. +/// Truncation to [`U64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. + + #[lua(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::U64Vec3; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::U64Vec4) -> u64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" +/// Component-wise clamping of values, similar to [`u64::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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::U64Vec4, + #[proxy] + max: bevy::math::U64Vec4, + ) -> bevy::math::U64Vec4; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> u64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + fn max_element(self) -> u64; + +"#, + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua(kind = "Method")] + fn length_squared(self) -> u64; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec4(&self) -> bevy::math::Vec4; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec4(&self) -> bevy::math::DVec4; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec4(&self) -> bevy::math::IVec4; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec4(&self) -> bevy::math::UVec4; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec4(&self) -> bevy::math::I64Vec4; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u64) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u64) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u64) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u64) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::U64Vec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u64) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::U64Vec4; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct U64Vec4 { + x: u64, + y: u64, + z: u64, + w: u64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Vec2", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f32) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::Vec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec2; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: f32, y: f32) -> bevy::math::Vec2; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: f32) -> bevy::math::Vec2; + +"#, + 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::BVec2, + #[proxy] + if_true: bevy::math::Vec2, + #[proxy] + if_false: bevy::math::Vec2, + ) -> bevy::math::Vec2; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f32; 2]) -> bevy::math::Vec2; + +"#, + r#" +/// `[x, y]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [f32; 2]; + +"#, + r#" +/// Creates a 3D vector from `self` and the given `z` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, z: f32) -> bevy::math::Vec3; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::Vec2, + #[proxy] + max: bevy::math::Vec2, + ) -> bevy::math::Vec2; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> f32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::Vec2; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua(kind = "Method", output(proxy))] + fn copysign(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + 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(kind = "Method")] + 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(kind = "Method")] + fn is_finite(self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn is_nan_mask(self) -> bevy::math::BVec2; + +"#, + r#" +/// Computes the length of `self`. + + #[lua(kind = "Method")] + fn length(self) -> f32; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua(kind = "Method")] + fn length_squared(self) -> f32; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua(kind = "Method")] + fn length_recip(self) -> f32; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f32::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize_or_zero(self) -> bevy::math::Vec2; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of `1e-6`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn project_onto(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn round(self) -> bevy::math::Vec2; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn floor(self) -> bevy::math::Vec2; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn ceil(self) -> bevy::math::Vec2; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua(kind = "Method", output(proxy))] + fn trunc(self) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn fract(self) -> bevy::math::Vec2; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua(kind = "Method", output(proxy))] + fn exp(self) -> bevy::math::Vec2; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua(kind = "Method", output(proxy))] + fn powf(self, n: f32) -> bevy::math::Vec2; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn recip(self) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] rhs: bevy::math::Vec2, s: f32) -> bevy::math::Vec2; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec2, 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(kind = "Method", output(proxy))] + fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec2; + +"#, + r#" +/// Returns a vector with a length no more than `max` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_max(self, max: f32) -> bevy::math::Vec2; + +"#, + r#" +/// Returns a vector with a length no less than `min` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_min(self, min: f32) -> bevy::math::Vec2; + +"#, + 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(kind = "Method", output(proxy))] + fn mul_add( + self, + #[proxy] + a: bevy::math::Vec2, + #[proxy] + b: bevy::math::Vec2, + ) -> bevy::math::Vec2; + +"#, + 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) -> bevy::math::Vec2; + +"#, + r#" +/// Returns the angle (in radians) of this vector in the range `[-π, +π]`. +/// The input does not need to be a unit vector however it must be non-zero. + + #[lua(kind = "Method")] + fn to_angle(self) -> f32; + +"#, + 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(kind = "Method")] + fn angle_between(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + +"#, + r#" +/// Returns a vector that is equal to `self` rotated by 90 degrees. + + #[lua(kind = "Method", output(proxy))] + fn perp(self) -> bevy::math::Vec2; + +"#, + r#" +/// The perpendicular dot product of `self` and `rhs`. +/// Also known as the wedge product, 2D cross product, and determinant. + + #[lua(kind = "Method")] + fn perp_dot(self, #[proxy] rhs: bevy::math::Vec2) -> 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(kind = "Method", output(proxy))] + fn rotate(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec2(&self) -> bevy::math::DVec2; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec2(&self) -> bevy::math::IVec2; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec2(&self) -> bevy::math::UVec2; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec2(&self) -> bevy::math::I64Vec2; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec2(&self) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f32) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Vec2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct Vec2 { + x: f32, + y: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Vec3A", + functions[r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f32) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Vec3A) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec3A; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3A; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: f32) -> bevy::math::Vec3A; + +"#, + 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::BVec3A, + #[proxy] + if_true: bevy::math::Vec3A, + #[proxy] + if_false: bevy::math::Vec3A, + ) -> bevy::math::Vec3A; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f32; 3]) -> bevy::math::Vec3A; + +"#, + r#" +/// `[x, y, z]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [f32; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, w: f32) -> bevy::math::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(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::Vec2; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn cross(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::Vec3A, + #[proxy] + max: bevy::math::Vec3A, + ) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> f32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua(kind = "Method", output(proxy))] + fn copysign(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method")] + 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(kind = "Method")] + fn is_finite(self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn is_nan_mask(self) -> bevy::math::BVec3A; + +"#, + r#" +/// Computes the length of `self`. + + #[lua(kind = "Method")] + fn length(self) -> f32; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua(kind = "Method")] + fn length_squared(self) -> f32; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua(kind = "Method")] + fn length_recip(self) -> f32; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f32::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize_or_zero(self) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of `1e-6`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn project_onto(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn project_onto_normalized( + self, + #[proxy] + rhs: bevy::math::Vec3A, + ) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from_normalized( + self, + #[proxy] + rhs: bevy::math::Vec3A, + ) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn round(self) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn floor(self) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn ceil(self) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua(kind = "Method", output(proxy))] + fn trunc(self) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn fract(self) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua(kind = "Method", output(proxy))] + fn exp(self) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua(kind = "Method", output(proxy))] + fn powf(self, n: f32) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn recip(self) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] rhs: bevy::math::Vec3A, s: f32) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec3A, 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(kind = "Method", output(proxy))] + fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns a vector with a length no more than `max` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_max(self, max: f32) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns a vector with a length no less than `min` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_min(self, min: f32) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn mul_add( + self, + #[proxy] + a: bevy::math::Vec3A, + #[proxy] + b: bevy::math::Vec3A, + ) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method")] + fn angle_between(self, #[proxy] rhs: bevy::math::Vec3A) -> 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(kind = "Method", output(proxy))] + fn any_orthogonal_vector(&self) -> bevy::math::Vec3A; + +"#, + 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(kind = "Method", output(proxy))] + fn any_orthonormal_vector(&self) -> bevy::math::Vec3A; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec3(&self) -> bevy::math::DVec3; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec3(&self) -> bevy::math::IVec3; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec3(&self) -> bevy::math::UVec3; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec3(&self) -> bevy::math::I64Vec3; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec3(&self) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f32) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct Vec3A(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Vec4", + functions[r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Vec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Vec4; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: f32, y: f32, z: f32, w: f32) -> bevy::math::Vec4; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: f32) -> bevy::math::Vec4; + +"#, + 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::BVec4A, + #[proxy] + if_true: bevy::math::Vec4, + #[proxy] + if_false: bevy::math::Vec4, + ) -> bevy::math::Vec4; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f32; 4]) -> bevy::math::Vec4; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [f32; 4]; + +"#, + r#" +/// Creates a 3D 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(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::Vec3; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::Vec4) -> f32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::Vec4, + #[proxy] + max: bevy::math::Vec4, + ) -> bevy::math::Vec4; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> f32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::Vec4; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua(kind = "Method", output(proxy))] + fn copysign(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + 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(kind = "Method")] + 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(kind = "Method")] + fn is_finite(self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn is_nan_mask(self) -> bevy::math::BVec4A; + +"#, + r#" +/// Computes the length of `self`. + + #[lua(kind = "Method")] + fn length(self) -> f32; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua(kind = "Method")] + fn length_squared(self) -> f32; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua(kind = "Method")] + fn length_recip(self) -> f32; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance(self, #[proxy] rhs: bevy::math::Vec4) -> f32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::Vec4) -> f32; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f32::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize_or_zero(self) -> bevy::math::Vec4; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of `1e-6`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn project_onto(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn round(self) -> bevy::math::Vec4; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn floor(self) -> bevy::math::Vec4; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn ceil(self) -> bevy::math::Vec4; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua(kind = "Method", output(proxy))] + fn trunc(self) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn fract(self) -> bevy::math::Vec4; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua(kind = "Method", output(proxy))] + fn exp(self) -> bevy::math::Vec4; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua(kind = "Method", output(proxy))] + fn powf(self, n: f32) -> bevy::math::Vec4; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn recip(self) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] rhs: bevy::math::Vec4, s: f32) -> bevy::math::Vec4; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec4, 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(kind = "Method", output(proxy))] + fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec4; + +"#, + r#" +/// Returns a vector with a length no more than `max` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_max(self, max: f32) -> bevy::math::Vec4; + +"#, + r#" +/// Returns a vector with a length no less than `min` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_min(self, min: f32) -> bevy::math::Vec4; + +"#, + 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(kind = "Method", output(proxy))] + fn mul_add( + self, + #[proxy] + a: bevy::math::Vec4, + #[proxy] + b: bevy::math::Vec4, + ) -> bevy::math::Vec4; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec4(&self) -> bevy::math::DVec4; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec4(&self) -> bevy::math::IVec4; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec4(&self) -> bevy::math::UVec4; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec4(&self) -> bevy::math::I64Vec4; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec4(&self) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f32) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f32) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Vec4; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct Vec4(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::BVec2", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec2; + +"#, + r#" +/// Creates a new vector mask. + + #[lua(kind = "Function", output(proxy))] + fn new(x: bool, y: bool) -> bevy::math::BVec2; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: bool) -> bevy::math::BVec2; + +"#, + 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(kind = "Method")] + fn bitmask(self) -> u32; + +"#, + r#" +/// Returns true if any of the elements are true, false otherwise. + + #[lua(kind = "Method")] + fn any(self) -> bool; + +"#, + r#" +/// Returns true if all the elements are true, false otherwise. + + #[lua(kind = "Method")] + fn all(self) -> bool; + +"#, + r#" +/// Tests the value at `index`. +/// Panics if `index` is greater than 1. + + #[lua(kind = "Method")] + fn test(&self, index: usize) -> bool; + +"#, + r#" +/// Sets the element at `index`. +/// Panics if `index` is greater than 1. + + #[lua(kind = "MutatingMethod")] + fn set(&mut self, index: usize, value: bool) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::BVec2) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct BVec2 { + x: bool, + y: bool, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::BVec3", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +/// Creates a new vector mask. + + #[lua(kind = "Function", output(proxy))] + fn new(x: bool, y: bool, z: bool) -> bevy::math::BVec3; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: bool) -> bevy::math::BVec3; + +"#, + 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(kind = "Method")] + fn bitmask(self) -> u32; + +"#, + r#" +/// Returns true if any of the elements are true, false otherwise. + + #[lua(kind = "Method")] + fn any(self) -> bool; + +"#, + r#" +/// Returns true if all the elements are true, false otherwise. + + #[lua(kind = "Method")] + fn all(self) -> bool; + +"#, + r#" +/// Tests the value at `index`. +/// Panics if `index` is greater than 2. + + #[lua(kind = "Method")] + fn test(&self, index: usize) -> bool; + +"#, + r#" +/// Sets the element at `index`. +/// Panics if `index` is greater than 2. + + #[lua(kind = "MutatingMethod")] + fn set(&mut self, index: usize, value: bool) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::BVec3) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec3; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct BVec3 { + x: bool, + y: bool, + z: bool, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::BVec4", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::BVec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec4; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +/// Creates a new vector mask. + + #[lua(kind = "Function", output(proxy))] + fn new(x: bool, y: bool, z: bool, w: bool) -> bevy::math::BVec4; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: bool) -> bevy::math::BVec4; + +"#, + 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(kind = "Method")] + fn bitmask(self) -> u32; + +"#, + r#" +/// Returns true if any of the elements are true, false otherwise. + + #[lua(kind = "Method")] + fn any(self) -> bool; + +"#, + r#" +/// Returns true if all the elements are true, false otherwise. + + #[lua(kind = "Method")] + fn all(self) -> bool; + +"#, + r#" +/// Tests the value at `index`. +/// Panics if `index` is greater than 3. + + #[lua(kind = "Method")] + fn test(&self, index: usize) -> bool; + +"#, + r#" +/// Sets the element at `index`. +/// Panics if `index` is greater than 3. + + #[lua(kind = "MutatingMethod")] + fn set(&mut self, index: usize, value: bool) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct BVec4 { + x: bool, + y: bool, + z: bool, + w: bool, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DVec2", + functions[r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f64) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f64) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f64) -> bevy::math::DVec2; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: f64, y: f64) -> bevy::math::DVec2; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: f64) -> bevy::math::DVec2; + +"#, + 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::BVec2, + #[proxy] + if_true: bevy::math::DVec2, + #[proxy] + if_false: bevy::math::DVec2, + ) -> bevy::math::DVec2; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f64; 2]) -> bevy::math::DVec2; + +"#, + r#" +/// `[x, y]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [f64; 2]; + +"#, + r#" +/// Creates a 3D vector from `self` and the given `z` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, z: f64) -> bevy::math::DVec3; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::DVec2, + #[proxy] + max: bevy::math::DVec2, + ) -> bevy::math::DVec2; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> f64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::DVec2; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua(kind = "Method", output(proxy))] + fn copysign(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + 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(kind = "Method")] + 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(kind = "Method")] + fn is_finite(self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn is_nan_mask(self) -> bevy::math::BVec2; + +"#, + r#" +/// Computes the length of `self`. + + #[lua(kind = "Method")] + fn length(self) -> f64; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua(kind = "Method")] + fn length_squared(self) -> f64; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua(kind = "Method")] + fn length_recip(self) -> f64; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f64::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize_or_zero(self) -> bevy::math::DVec2; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of `1e-6`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn project_onto(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn project_onto_normalized( + self, + #[proxy] + rhs: bevy::math::DVec2, + ) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from_normalized( + self, + #[proxy] + rhs: bevy::math::DVec2, + ) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn round(self) -> bevy::math::DVec2; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn floor(self) -> bevy::math::DVec2; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn ceil(self) -> bevy::math::DVec2; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua(kind = "Method", output(proxy))] + fn trunc(self) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn fract(self) -> bevy::math::DVec2; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua(kind = "Method", output(proxy))] + fn exp(self) -> bevy::math::DVec2; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua(kind = "Method", output(proxy))] + fn powf(self, n: f64) -> bevy::math::DVec2; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn recip(self) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] rhs: bevy::math::DVec2, s: f64) -> bevy::math::DVec2; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec2, 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(kind = "Method", output(proxy))] + fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec2; + +"#, + r#" +/// Returns a vector with a length no more than `max` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_max(self, max: f64) -> bevy::math::DVec2; + +"#, + r#" +/// Returns a vector with a length no less than `min` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_min(self, min: f64) -> bevy::math::DVec2; + +"#, + 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(kind = "Method", output(proxy))] + fn mul_add( + self, + #[proxy] + a: bevy::math::DVec2, + #[proxy] + b: bevy::math::DVec2, + ) -> bevy::math::DVec2; + +"#, + 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) -> bevy::math::DVec2; + +"#, + r#" +/// Returns the angle (in radians) of this vector in the range `[-π, +π]`. +/// The input does not need to be a unit vector however it must be non-zero. + + #[lua(kind = "Method")] + fn to_angle(self) -> f64; + +"#, + 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(kind = "Method")] + fn angle_between(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + +"#, + r#" +/// Returns a vector that is equal to `self` rotated by 90 degrees. + + #[lua(kind = "Method", output(proxy))] + fn perp(self) -> bevy::math::DVec2; + +"#, + r#" +/// The perpendicular dot product of `self` and `rhs`. +/// Also known as the wedge product, 2D cross product, and determinant. + + #[lua(kind = "Method")] + fn perp_dot(self, #[proxy] rhs: bevy::math::DVec2) -> 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(kind = "Method", output(proxy))] + fn rotate(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec2(&self) -> bevy::math::Vec2; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec2(&self) -> bevy::math::IVec2; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec2(&self) -> bevy::math::UVec2; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec2(&self) -> bevy::math::I64Vec2; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec2(&self) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::DVec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DVec2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct DVec2 { + x: f64, + y: f64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DVec3", + functions[r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DVec3; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: f64, y: f64, z: f64) -> bevy::math::DVec3; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: f64) -> bevy::math::DVec3; + +"#, + 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::BVec3, + #[proxy] + if_true: bevy::math::DVec3, + #[proxy] + if_false: bevy::math::DVec3, + ) -> bevy::math::DVec3; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f64; 3]) -> bevy::math::DVec3; + +"#, + r#" +/// `[x, y, z]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [f64; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua(kind = "Method", output(proxy))] + fn extend(self, w: f64) -> bevy::math::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(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::DVec2; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::DVec3) -> f64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn cross(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::DVec3, + #[proxy] + max: bevy::math::DVec3, + ) -> bevy::math::DVec3; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> f64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::DVec3; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua(kind = "Method", output(proxy))] + fn copysign(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + 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(kind = "Method")] + 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(kind = "Method")] + fn is_finite(self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn is_nan_mask(self) -> bevy::math::BVec3; + +"#, + r#" +/// Computes the length of `self`. + + #[lua(kind = "Method")] + fn length(self) -> f64; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua(kind = "Method")] + fn length_squared(self) -> f64; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua(kind = "Method")] + fn length_recip(self) -> f64; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance(self, #[proxy] rhs: bevy::math::DVec3) -> f64; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::DVec3) -> f64; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f64::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize_or_zero(self) -> bevy::math::DVec3; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of `1e-6`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn project_onto(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn project_onto_normalized( + self, + #[proxy] + rhs: bevy::math::DVec3, + ) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from_normalized( + self, + #[proxy] + rhs: bevy::math::DVec3, + ) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn round(self) -> bevy::math::DVec3; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn floor(self) -> bevy::math::DVec3; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn ceil(self) -> bevy::math::DVec3; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua(kind = "Method", output(proxy))] + fn trunc(self) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn fract(self) -> bevy::math::DVec3; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua(kind = "Method", output(proxy))] + fn exp(self) -> bevy::math::DVec3; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua(kind = "Method", output(proxy))] + fn powf(self, n: f64) -> bevy::math::DVec3; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn recip(self) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] rhs: bevy::math::DVec3, s: f64) -> bevy::math::DVec3; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec3, 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(kind = "Method", output(proxy))] + fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec3; + +"#, + r#" +/// Returns a vector with a length no more than `max` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_max(self, max: f64) -> bevy::math::DVec3; + +"#, + r#" +/// Returns a vector with a length no less than `min` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_min(self, min: f64) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn mul_add( + self, + #[proxy] + a: bevy::math::DVec3, + #[proxy] + b: bevy::math::DVec3, + ) -> bevy::math::DVec3; + +"#, + 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(kind = "Method")] + fn angle_between(self, #[proxy] rhs: bevy::math::DVec3) -> 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(kind = "Method", output(proxy))] + fn any_orthogonal_vector(&self) -> bevy::math::DVec3; + +"#, + 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(kind = "Method", output(proxy))] + fn any_orthonormal_vector(&self) -> bevy::math::DVec3; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec3(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec3a(&self) -> bevy::math::Vec3A; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec3(&self) -> bevy::math::IVec3; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec3(&self) -> bevy::math::UVec3; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec3(&self) -> bevy::math::I64Vec3; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec3(&self) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::DVec3) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f64) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f64) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f64) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct DVec3 { + x: f64, + y: f64, + z: f64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DVec4", + functions[r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f64) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f64) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f64) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::DVec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DVec4; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: f64, y: f64, z: f64, w: f64) -> bevy::math::DVec4; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: f64) -> bevy::math::DVec4; + +"#, + 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::BVec4, + #[proxy] + if_true: bevy::math::DVec4, + #[proxy] + if_false: bevy::math::DVec4, + ) -> bevy::math::DVec4; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f64; 4]) -> bevy::math::DVec4; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [f64; 4]; + +"#, + r#" +/// Creates a 3D 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(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::DVec3; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::DVec4) -> f64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::DVec4, + #[proxy] + max: bevy::math::DVec4, + ) -> bevy::math::DVec4; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua(kind = "Method")] + fn min_element(self) -> f64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::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(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::DVec4; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua(kind = "Method", output(proxy))] + fn copysign(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + 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(kind = "Method")] + 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(kind = "Method")] + fn is_finite(self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn is_nan_mask(self) -> bevy::math::BVec4; + +"#, + r#" +/// Computes the length of `self`. + + #[lua(kind = "Method")] + fn length(self) -> f64; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua(kind = "Method")] + fn length_squared(self) -> f64; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua(kind = "Method")] + fn length_recip(self) -> f64; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance(self, #[proxy] rhs: bevy::math::DVec4) -> f64; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::DVec4) -> f64; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f64::rem_euclid + + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn normalize_or_zero(self) -> bevy::math::DVec4; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of `1e-6`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn project_onto(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn project_onto_normalized( + self, + #[proxy] + rhs: bevy::math::DVec4, + ) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn reject_from_normalized( + self, + #[proxy] + rhs: bevy::math::DVec4, + ) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn round(self) -> bevy::math::DVec4; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn floor(self) -> bevy::math::DVec4; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn ceil(self) -> bevy::math::DVec4; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua(kind = "Method", output(proxy))] + fn trunc(self) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn fract(self) -> bevy::math::DVec4; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua(kind = "Method", output(proxy))] + fn exp(self) -> bevy::math::DVec4; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua(kind = "Method", output(proxy))] + fn powf(self, n: f64) -> bevy::math::DVec4; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua(kind = "Method", output(proxy))] + fn recip(self) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] rhs: bevy::math::DVec4, s: f64) -> bevy::math::DVec4; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec4, 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(kind = "Method", output(proxy))] + fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec4; + +"#, + r#" +/// Returns a vector with a length no more than `max` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_max(self, max: f64) -> bevy::math::DVec4; + +"#, + r#" +/// Returns a vector with a length no less than `min` + + #[lua(kind = "Method", output(proxy))] + fn clamp_length_min(self, min: f64) -> bevy::math::DVec4; + +"#, + 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(kind = "Method", output(proxy))] + fn mul_add( + self, + #[proxy] + a: bevy::math::DVec4, + #[proxy] + b: bevy::math::DVec4, + ) -> bevy::math::DVec4; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec4(&self) -> bevy::math::Vec4; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec4(&self) -> bevy::math::IVec4; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec4(&self) -> bevy::math::UVec4; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec4(&self) -> bevy::math::I64Vec4; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec4(&self) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DVec4; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +pub struct DVec4 { + x: f64, + y: f64, + z: f64, + w: f64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Mat2", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + +"#, + r#" +/// Creates a 2x2 matrix from two column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::Vec2, + #[proxy] + y_axis: bevy::math::Vec2, + ) -> bevy::math::Mat2; + +"#, + r#" +/// Creates a `[f32; 4]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f32; 4]; + +"#, + r#" +/// Creates a `[[f32; 2]; 2]` 2D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array_2d(&self) -> [[f32; 2]; 2]; + +"#, + 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::Vec2) -> bevy::math::Mat2; + +"#, + 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::Vec2, + angle: f32, + ) -> bevy::math::Mat2; + +"#, + r#" +/// Creates a 2x2 matrix containing a rotation of `angle` (in radians). + + #[lua(kind = "Function", output(proxy))] + fn from_angle(angle: f32) -> bevy::math::Mat2; + +"#, + 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::Mat3) -> bevy::math::Mat2; + +"#, + 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::Mat3A) -> bevy::math::Mat2; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 1. + + #[lua(kind = "Method", output(proxy))] + fn col(&self, index: usize) -> bevy::math::Vec2; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 1. + + #[lua(kind = "Method", output(proxy))] + fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + fn is_nan(&self) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua(kind = "Method", output(proxy))] + fn transpose(&self) -> bevy::math::Mat2; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::Mat2; + +"#, + r#" +/// Transforms a 2D vector. + + #[lua(kind = "Method", output(proxy))] + fn mul_vec2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" +/// Multiplies two 2x2 matrices. + + #[lua(kind = "Method", output(proxy))] + fn mul_mat2(&self, #[proxy] rhs: &glam::Mat2) -> bevy::math::Mat2; + +"#, + r#" +/// Adds two 2x2 matrices. + + #[lua(kind = "Method", output(proxy))] + fn add_mat2(&self, #[proxy] rhs: &glam::Mat2) -> bevy::math::Mat2; + +"#, + r#" +/// Subtracts two 2x2 matrices. + + #[lua(kind = "Method", output(proxy))] + fn sub_mat2(&self, #[proxy] rhs: &glam::Mat2) -> bevy::math::Mat2; + +"#, + r#" +/// Multiplies a 2x2 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat2; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat2, max_abs_diff: f32) -> bool; + +"#, + r#" + + #[lua(kind = "Method", output(proxy))] + fn as_dmat2(&self) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Mat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Mat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Mat2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Mat2) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind = "MetaMethod", raw, metamethod="Index")] +fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(LuaVec2::new_ref( + self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + label:"col", + get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ + path: "".to_owned(), + msg: "Cannot get column of matrix with immutable reference".to_owned() + })), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(*idx)) + } else { + Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) + } + }) + }) + ) + ) +} +"#] +)] +pub struct Mat2(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Mat3", + functions[r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Mat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Mat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Mat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3; + +"#, + r#" +/// Creates a 3x3 matrix from three column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::Vec3, + #[proxy] + y_axis: bevy::math::Vec3, + #[proxy] + z_axis: bevy::math::Vec3, + ) -> bevy::math::Mat3; + +"#, + r#" +/// Creates a `[f32; 9]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f32; 9]; + +"#, + r#" +/// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array_2d(&self) -> [[f32; 3]; 3]; + +"#, + 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::Vec3) -> bevy::math::Mat3; + +"#, + 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::Mat4) -> bevy::math::Mat3; + +"#, + 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::Quat) -> bevy::math::Mat3; + +"#, + 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::Vec3, angle: f32) -> bevy::math::Mat3; + +"#, + 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, + ) -> bevy::math::Mat3; + +"#, + 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) -> bevy::math::Mat3; + +"#, + 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) -> bevy::math::Mat3; + +"#, + 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) -> bevy::math::Mat3; + +"#, + 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::Vec2) -> bevy::math::Mat3; + +"#, + 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) -> bevy::math::Mat3; + +"#, + 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::Vec2, + angle: f32, + #[proxy] + translation: bevy::math::Vec2, + ) -> bevy::math::Mat3; + +"#, + 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::Vec2) -> bevy::math::Mat3; + +"#, + 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::Mat2) -> bevy::math::Mat3; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 2. + + #[lua(kind = "Method", output(proxy))] + fn col(&self, index: usize) -> bevy::math::Vec3; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 2. + + #[lua(kind = "Method", output(proxy))] + fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + fn is_nan(&self) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua(kind = "Method", output(proxy))] + fn transpose(&self) -> bevy::math::Mat3; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::Mat3; + +"#, + 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(kind = "Method", output(proxy))] + fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" +/// Transforms a 3D vector. + + #[lua(kind = "Method", output(proxy))] + fn mul_vec3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" +/// Transforms a [`Vec3A`]. + + #[lua(kind = "Method", output(proxy))] + fn mul_vec3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +/// Multiplies two 3x3 matrices. + + #[lua(kind = "Method", output(proxy))] + fn mul_mat3(&self, #[proxy] rhs: &glam::Mat3) -> bevy::math::Mat3; + +"#, + r#" +/// Adds two 3x3 matrices. + + #[lua(kind = "Method", output(proxy))] + fn add_mat3(&self, #[proxy] rhs: &glam::Mat3) -> bevy::math::Mat3; + +"#, + r#" +/// Subtracts two 3x3 matrices. + + #[lua(kind = "Method", output(proxy))] + fn sub_mat3(&self, #[proxy] rhs: &glam::Mat3) -> bevy::math::Mat3; + +"#, + r#" +/// Multiplies a 3x3 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat3; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat3, max_abs_diff: f32) -> bool; + +"#, + r#" + + #[lua(kind = "Method", output(proxy))] + fn as_dmat3(&self) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Mat3) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind = "MetaMethod", raw, metamethod="Index")] +fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(LuaVec3::new_ref( + self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + label:"col", + get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ + path: "".to_owned(), + msg: "Cannot get column of matrix with immutable reference".to_owned() + })), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(*idx)) + } else { + Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) + } + }) + }) + ) + ) +} +"#] +)] +pub struct Mat3 { + #[lua(output(proxy))] + x_axis: bevy::math::Vec3, + #[lua(output(proxy))] + y_axis: bevy::math::Vec3, + #[lua(output(proxy))] + z_axis: bevy::math::Vec3, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Mat3A", + functions[r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Mat3A; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Mat3A; + +"#, + r#" +/// Creates a 3x3 matrix from three column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::Vec3A, + #[proxy] + y_axis: bevy::math::Vec3A, + #[proxy] + z_axis: bevy::math::Vec3A, + ) -> bevy::math::Mat3A; + +"#, + r#" +/// Creates a `[f32; 9]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f32; 9]; + +"#, + r#" +/// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array_2d(&self) -> [[f32; 3]; 3]; + +"#, + 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::Vec3) -> bevy::math::Mat3A; + +"#, + 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::Mat4) -> bevy::math::Mat3A; + +"#, + 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::Quat) -> bevy::math::Mat3A; + +"#, + 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::Vec3, angle: f32) -> bevy::math::Mat3A; + +"#, + 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, + ) -> bevy::math::Mat3A; + +"#, + 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) -> bevy::math::Mat3A; + +"#, + 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) -> bevy::math::Mat3A; + +"#, + 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) -> bevy::math::Mat3A; + +"#, + 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::Vec2) -> bevy::math::Mat3A; + +"#, + 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) -> bevy::math::Mat3A; + +"#, + 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::Vec2, + angle: f32, + #[proxy] + translation: bevy::math::Vec2, + ) -> bevy::math::Mat3A; + +"#, + 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::Vec2) -> bevy::math::Mat3A; + +"#, + 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::Mat2) -> bevy::math::Mat3A; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 2. + + #[lua(kind = "Method", output(proxy))] + fn col(&self, index: usize) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 2. + + #[lua(kind = "Method", output(proxy))] + fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + fn is_nan(&self) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua(kind = "Method", output(proxy))] + fn transpose(&self) -> bevy::math::Mat3A; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::Mat3A; + +"#, + 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(kind = "Method", output(proxy))] + fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" +/// Transforms a 3D vector. + + #[lua(kind = "Method", output(proxy))] + fn mul_vec3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" +/// Transforms a [`Vec3A`]. + + #[lua(kind = "Method", output(proxy))] + fn mul_vec3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +/// Multiplies two 3x3 matrices. + + #[lua(kind = "Method", output(proxy))] + fn mul_mat3(&self, #[proxy] rhs: &glam::Mat3A) -> bevy::math::Mat3A; + +"#, + r#" +/// Adds two 3x3 matrices. + + #[lua(kind = "Method", output(proxy))] + fn add_mat3(&self, #[proxy] rhs: &glam::Mat3A) -> bevy::math::Mat3A; + +"#, + r#" +/// Subtracts two 3x3 matrices. + + #[lua(kind = "Method", output(proxy))] + fn sub_mat3(&self, #[proxy] rhs: &glam::Mat3A) -> bevy::math::Mat3A; + +"#, + r#" +/// Multiplies a 3x3 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat3A; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat3A, max_abs_diff: f32) -> bool; + +"#, + r#" + + #[lua(kind = "Method", output(proxy))] + fn as_dmat3(&self) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Mat3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Mat3A) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind = "MetaMethod", raw, metamethod="Index")] +fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(LuaVec3A::new_ref( + self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + label:"col", + get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ + path: "".to_owned(), + msg: "Cannot get column of matrix with immutable reference".to_owned() + })), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(*idx)) + } else { + Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) + } + }) + }) + ) + ) +} +"#] +)] +pub struct Mat3A { + #[lua(output(proxy))] + x_axis: bevy::math::Vec3A, + #[lua(output(proxy))] + y_axis: bevy::math::Vec3A, + #[lua(output(proxy))] + z_axis: bevy::math::Vec3A, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Mat4", + functions[r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Mat4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Mat4; + +"#, + r#" +/// Creates a 4x4 matrix from four column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::Vec4, + #[proxy] + y_axis: bevy::math::Vec4, + #[proxy] + z_axis: bevy::math::Vec4, + #[proxy] + w_axis: bevy::math::Vec4, + ) -> bevy::math::Mat4; + +"#, + r#" +/// Creates a `[f32; 16]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f32; 16]; + +"#, + r#" +/// Creates a `[[f32; 4]; 4]` 4D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array_2d(&self) -> [[f32; 4]; 4]; + +"#, + 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::Vec4) -> bevy::math::Mat4; + +"#, + 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::Vec3, + #[proxy] + rotation: bevy::math::Quat, + #[proxy] + translation: bevy::math::Vec3, + ) -> bevy::math::Mat4; + +"#, + 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::Quat, + #[proxy] + translation: bevy::math::Vec3, + ) -> bevy::math::Mat4; + +"#, + 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::Quat) -> bevy::math::Mat4; + +"#, + 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::Mat3) -> bevy::math::Mat4; + +"#, + 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::Mat3A) -> bevy::math::Mat4; + +"#, + 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::Vec3) -> bevy::math::Mat4; + +"#, + 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::Vec3, angle: f32) -> bevy::math::Mat4; + +"#, + 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, + ) -> bevy::math::Mat4; + +"#, + 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) -> bevy::math::Mat4; + +"#, + 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) -> bevy::math::Mat4; + +"#, + 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) -> bevy::math::Mat4; + +"#, + 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::Vec3) -> bevy::math::Mat4; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 3. + + #[lua(kind = "Method", output(proxy))] + fn col(&self, index: usize) -> bevy::math::Vec4; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 3. + + #[lua(kind = "Method", output(proxy))] + fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + fn is_nan(&self) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua(kind = "Method", output(proxy))] + fn transpose(&self) -> bevy::math::Mat4; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::Mat4; + +"#, + 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::Vec3, + #[proxy] + dir: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::math::Mat4; + +"#, + 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::Vec3, + #[proxy] + dir: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::math::Mat4; + +"#, + 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::Vec3, + #[proxy] + center: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::math::Mat4; + +"#, + 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::Vec3, + #[proxy] + center: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::math::Mat4; + +"#, + 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, + ) -> bevy::math::Mat4; + +"#, + 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, + ) -> bevy::math::Mat4; + +"#, + 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, + ) -> bevy::math::Mat4; + +"#, + 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, + ) -> bevy::math::Mat4; + +"#, + 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, + ) -> bevy::math::Mat4; + +"#, + 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, + ) -> bevy::math::Mat4; + +"#, + 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, + ) -> bevy::math::Mat4; + +"#, + 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, + ) -> bevy::math::Mat4; + +"#, + 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, + ) -> bevy::math::Mat4; + +"#, + 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, + ) -> bevy::math::Mat4; + +"#, + 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(kind = "Method", output(proxy))] + fn project_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_vector3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_point3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_vector3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +/// Transforms a 4D vector. + + #[lua(kind = "Method", output(proxy))] + fn mul_vec4(&self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" +/// Multiplies two 4x4 matrices. + + #[lua(kind = "Method", output(proxy))] + fn mul_mat4(&self, #[proxy] rhs: &glam::Mat4) -> bevy::math::Mat4; + +"#, + r#" +/// Adds two 4x4 matrices. + + #[lua(kind = "Method", output(proxy))] + fn add_mat4(&self, #[proxy] rhs: &glam::Mat4) -> bevy::math::Mat4; + +"#, + r#" +/// Subtracts two 4x4 matrices. + + #[lua(kind = "Method", output(proxy))] + fn sub_mat4(&self, #[proxy] rhs: &glam::Mat4) -> bevy::math::Mat4; + +"#, + r#" +/// Multiplies a 4x4 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat4; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat4, max_abs_diff: f32) -> bool; + +"#, + r#" + + #[lua(kind = "Method", output(proxy))] + fn as_dmat4(&self) -> bevy::math::DMat4; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind = "MetaMethod", raw, metamethod="Index")] +fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(LuaVec4::new_ref( + self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + label:"col", + get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ + path: "".to_owned(), + msg: "Cannot get column of matrix with immutable reference".to_owned() + })), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(*idx)) + } else { + Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) + } + }) + }) + ) + ) +} +"#] +)] +pub struct Mat4 { + #[lua(output(proxy))] + x_axis: bevy::math::Vec4, + #[lua(output(proxy))] + y_axis: bevy::math::Vec4, + #[lua(output(proxy))] + z_axis: bevy::math::Vec4, + #[lua(output(proxy))] + w_axis: bevy::math::Vec4, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DMat2", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DMat2) -> bool; + +"#, + r#" +/// Creates a 2x2 matrix from two column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::DVec2, + #[proxy] + y_axis: bevy::math::DVec2, + ) -> bevy::math::DMat2; + +"#, + r#" +/// Creates a `[f64; 4]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f64; 4]; + +"#, + r#" +/// Creates a `[[f64; 2]; 2]` 2D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array_2d(&self) -> [[f64; 2]; 2]; + +"#, + 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::DVec2) -> bevy::math::DMat2; + +"#, + 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::DVec2, + angle: f64, + ) -> bevy::math::DMat2; + +"#, + r#" +/// Creates a 2x2 matrix containing a rotation of `angle` (in radians). + + #[lua(kind = "Function", output(proxy))] + fn from_angle(angle: f64) -> bevy::math::DMat2; + +"#, + 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::DMat3) -> bevy::math::DMat2; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 1. + + #[lua(kind = "Method", output(proxy))] + fn col(&self, index: usize) -> bevy::math::DVec2; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 1. + + #[lua(kind = "Method", output(proxy))] + fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + fn is_nan(&self) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua(kind = "Method", output(proxy))] + fn transpose(&self) -> bevy::math::DMat2; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::DMat2; + +"#, + r#" +/// Transforms a 2D vector. + + #[lua(kind = "Method", output(proxy))] + fn mul_vec2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" +/// Multiplies two 2x2 matrices. + + #[lua(kind = "Method", output(proxy))] + fn mul_mat2(&self, #[proxy] rhs: &glam::DMat2) -> bevy::math::DMat2; + +"#, + r#" +/// Adds two 2x2 matrices. + + #[lua(kind = "Method", output(proxy))] + fn add_mat2(&self, #[proxy] rhs: &glam::DMat2) -> bevy::math::DMat2; + +"#, + r#" +/// Subtracts two 2x2 matrices. + + #[lua(kind = "Method", output(proxy))] + fn sub_mat2(&self, #[proxy] rhs: &glam::DMat2) -> bevy::math::DMat2; + +"#, + r#" +/// Multiplies a 2x2 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat2; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DMat2, max_abs_diff: f64) -> bool; + +"#, + r#" + + #[lua(kind = "Method", output(proxy))] + fn as_mat2(&self) -> bevy::math::Mat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind = "MetaMethod", raw, metamethod="Index")] +fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(LuaDVec2::new_ref( + self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + label:"col", + get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ + path: "".to_owned(), + msg: "Cannot get column of matrix with immutable reference".to_owned() + })), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(*idx)) + } else { + Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) + } + }) + }) + ) + ) +} +"#] +)] +pub struct DMat2 { + #[lua(output(proxy))] + x_axis: bevy::math::DVec2, + #[lua(output(proxy))] + y_axis: bevy::math::DVec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DMat3", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + +"#, + r#" +/// Creates a 3x3 matrix from three column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::DVec3, + #[proxy] + y_axis: bevy::math::DVec3, + #[proxy] + z_axis: bevy::math::DVec3, + ) -> bevy::math::DMat3; + +"#, + r#" +/// Creates a `[f64; 9]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f64; 9]; + +"#, + r#" +/// Creates a `[[f64; 3]; 3]` 3D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array_2d(&self) -> [[f64; 3]; 3]; + +"#, + 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::DVec3) -> bevy::math::DMat3; + +"#, + 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::DMat4) -> bevy::math::DMat3; + +"#, + 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::DQuat) -> bevy::math::DMat3; + +"#, + 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::DVec3, + angle: f64, + ) -> bevy::math::DMat3; + +"#, + 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, + ) -> bevy::math::DMat3; + +"#, + 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) -> bevy::math::DMat3; + +"#, + 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) -> bevy::math::DMat3; + +"#, + 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) -> bevy::math::DMat3; + +"#, + 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::DVec2) -> bevy::math::DMat3; + +"#, + 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) -> bevy::math::DMat3; + +"#, + 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::DVec2, + angle: f64, + #[proxy] + translation: bevy::math::DVec2, + ) -> bevy::math::DMat3; + +"#, + 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::DVec2) -> bevy::math::DMat3; + +"#, + 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::DMat2) -> bevy::math::DMat3; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 2. + + #[lua(kind = "Method", output(proxy))] + fn col(&self, index: usize) -> bevy::math::DVec3; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 2. + + #[lua(kind = "Method", output(proxy))] + fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + fn is_nan(&self) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua(kind = "Method", output(proxy))] + fn transpose(&self) -> bevy::math::DMat3; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::DMat3; + +"#, + 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(kind = "Method", output(proxy))] + fn transform_point2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_vector2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" +/// Transforms a 3D vector. + + #[lua(kind = "Method", output(proxy))] + fn mul_vec3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" +/// Multiplies two 3x3 matrices. + + #[lua(kind = "Method", output(proxy))] + fn mul_mat3(&self, #[proxy] rhs: &glam::DMat3) -> bevy::math::DMat3; + +"#, + r#" +/// Adds two 3x3 matrices. + + #[lua(kind = "Method", output(proxy))] + fn add_mat3(&self, #[proxy] rhs: &glam::DMat3) -> bevy::math::DMat3; + +"#, + r#" +/// Subtracts two 3x3 matrices. + + #[lua(kind = "Method", output(proxy))] + fn sub_mat3(&self, #[proxy] rhs: &glam::DMat3) -> bevy::math::DMat3; + +"#, + r#" +/// Multiplies a 3x3 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat3; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DMat3, max_abs_diff: f64) -> bool; + +"#, + r#" + + #[lua(kind = "Method", output(proxy))] + fn as_mat3(&self) -> bevy::math::Mat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DMat3) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind = "MetaMethod", raw, metamethod="Index")] +fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(LuaDVec3::new_ref( + self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + label:"col", + get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ + path: "".to_owned(), + msg: "Cannot get column of matrix with immutable reference".to_owned() + })), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(*idx)) + } else { + Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) + } + }) + }) + ) + ) +} +"#] +)] +pub struct DMat3 { + #[lua(output(proxy))] + x_axis: bevy::math::DVec3, + #[lua(output(proxy))] + y_axis: bevy::math::DVec3, + #[lua(output(proxy))] + z_axis: bevy::math::DVec3, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DMat4", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DMat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DMat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + +"#, + r#" +/// Creates a 4x4 matrix from four column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::DVec4, + #[proxy] + y_axis: bevy::math::DVec4, + #[proxy] + z_axis: bevy::math::DVec4, + #[proxy] + w_axis: bevy::math::DVec4, + ) -> bevy::math::DMat4; + +"#, + r#" +/// Creates a `[f64; 16]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f64; 16]; + +"#, + r#" +/// Creates a `[[f64; 4]; 4]` 4D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array_2d(&self) -> [[f64; 4]; 4]; + +"#, + 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::DVec4) -> bevy::math::DMat4; + +"#, + 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::DVec3, + #[proxy] + rotation: bevy::math::DQuat, + #[proxy] + translation: bevy::math::DVec3, + ) -> bevy::math::DMat4; + +"#, + 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::DQuat, + #[proxy] + translation: bevy::math::DVec3, + ) -> bevy::math::DMat4; + +"#, + 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::DQuat) -> bevy::math::DMat4; + +"#, + 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::DMat3) -> bevy::math::DMat4; + +"#, + 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::DVec3) -> bevy::math::DMat4; + +"#, + 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::DVec3, + angle: f64, + ) -> bevy::math::DMat4; + +"#, + 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, + ) -> bevy::math::DMat4; + +"#, + 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) -> bevy::math::DMat4; + +"#, + 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) -> bevy::math::DMat4; + +"#, + 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) -> bevy::math::DMat4; + +"#, + 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::DVec3) -> bevy::math::DMat4; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 3. + + #[lua(kind = "Method", output(proxy))] + fn col(&self, index: usize) -> bevy::math::DVec4; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 3. + + #[lua(kind = "Method", output(proxy))] + fn row(&self, index: usize) -> bevy::math::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(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + fn is_nan(&self) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua(kind = "Method", output(proxy))] + fn transpose(&self) -> bevy::math::DMat4; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::DMat4; + +"#, + 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::DVec3, + #[proxy] + dir: bevy::math::DVec3, + #[proxy] + up: bevy::math::DVec3, + ) -> bevy::math::DMat4; + +"#, + 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::DVec3, + #[proxy] + dir: bevy::math::DVec3, + #[proxy] + up: bevy::math::DVec3, + ) -> bevy::math::DMat4; + +"#, + 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::DVec3, + #[proxy] + center: bevy::math::DVec3, + #[proxy] + up: bevy::math::DVec3, + ) -> bevy::math::DMat4; + +"#, + 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::DVec3, + #[proxy] + center: bevy::math::DVec3, + #[proxy] + up: bevy::math::DVec3, + ) -> bevy::math::DMat4; + +"#, + 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, + ) -> bevy::math::DMat4; + +"#, + 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, + ) -> bevy::math::DMat4; + +"#, + 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, + ) -> bevy::math::DMat4; + +"#, + 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, + ) -> bevy::math::DMat4; + +"#, + 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, + ) -> bevy::math::DMat4; + +"#, + 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, + ) -> bevy::math::DMat4; + +"#, + 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, + ) -> bevy::math::DMat4; + +"#, + 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, + ) -> bevy::math::DMat4; + +"#, + 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, + ) -> bevy::math::DMat4; + +"#, + 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, + ) -> bevy::math::DMat4; + +"#, + 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(kind = "Method", output(proxy))] + fn project_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_vector3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" +/// Transforms a 4D vector. + + #[lua(kind = "Method", output(proxy))] + fn mul_vec4(&self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" +/// Multiplies two 4x4 matrices. + + #[lua(kind = "Method", output(proxy))] + fn mul_mat4(&self, #[proxy] rhs: &glam::DMat4) -> bevy::math::DMat4; + +"#, + r#" +/// Adds two 4x4 matrices. + + #[lua(kind = "Method", output(proxy))] + fn add_mat4(&self, #[proxy] rhs: &glam::DMat4) -> bevy::math::DMat4; + +"#, + r#" +/// Subtracts two 4x4 matrices. + + #[lua(kind = "Method", output(proxy))] + fn sub_mat4(&self, #[proxy] rhs: &glam::DMat4) -> bevy::math::DMat4; + +"#, + r#" +/// Multiplies a 4x4 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat4; + +"#, + 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(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DMat4, max_abs_diff: f64) -> bool; + +"#, + r#" + + #[lua(kind = "Method", output(proxy))] + fn as_mat4(&self) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DMat4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DMat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DMat4; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#, + r#" +#[lua(kind = "MetaMethod", raw, metamethod="Index")] +fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(LuaDVec4::new_ref( + self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + label:"col", + get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ + path: "".to_owned(), + msg: "Cannot get column of matrix with immutable reference".to_owned() + })), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(*idx)) + } else { + Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) + } + }) + }) + ) + ) +} +"#] +)] +pub struct DMat4 { + #[lua(output(proxy))] + x_axis: bevy::math::DVec4, + #[lua(output(proxy))] + y_axis: bevy::math::DVec4, + #[lua(output(proxy))] + z_axis: bevy::math::DVec4, + #[lua(output(proxy))] + w_axis: bevy::math::DVec4, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Affine2", + functions[r#" +/// Creates an affine transform from three column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::Vec2, + #[proxy] + y_axis: bevy::math::Vec2, + #[proxy] + z_axis: bevy::math::Vec2, + ) -> bevy::math::Affine2; + +"#, + r#" +/// Creates a `[f32; 6]` array storing data in column major order. + + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f32; 6]; + +"#, + r#" +/// Creates a `[[f32; 2]; 3]` 2D array storing data in +/// column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array_2d(&self) -> [[f32; 2]; 3]; + +"#, + 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::Vec2) -> bevy::math::Affine2; + +"#, + r#" +/// Creates an affine transform from the given rotation `angle`. + + #[lua(kind = "Function", output(proxy))] + fn from_angle(angle: f32) -> bevy::math::Affine2; + +"#, + r#" +/// Creates an affine transformation from the given 2D `translation`. + + #[lua(kind = "Function", output(proxy))] + fn from_translation(#[proxy] translation: bevy::math::Vec2) -> bevy::math::Affine2; + +"#, + 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::Mat2) -> bevy::math::Affine2; + +"#, + 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::Mat2, + #[proxy] + translation: bevy::math::Vec2, + ) -> bevy::math::Affine2; + +"#, + 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::Vec2, + angle: f32, + #[proxy] + translation: bevy::math::Vec2, + ) -> bevy::math::Affine2; + +"#, + 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::Vec2, + ) -> bevy::math::Affine2; + +"#, + r#" +/// The given `Mat3` must be an affine transform, + + #[lua(kind = "Function", output(proxy))] + fn from_mat3(#[proxy] m: bevy::math::Mat3) -> bevy::math::Affine2; + +"#, + r#" +/// The given [`Mat3A`] must be an affine transform, + + #[lua(kind = "Function", output(proxy))] + fn from_mat3a(#[proxy] m: bevy::math::Mat3A) -> bevy::math::Affine2; + +"#, + r#" +/// Transforms the given 2D point, applying shear, scale, rotation and translation. + + #[lua(kind = "Method", output(proxy))] + fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::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(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + 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(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Affine2, 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::Affine2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Affine2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Affine2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Affine2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct Affine2 { + #[lua(output(proxy))] + matrix2: bevy::math::Mat2, + #[lua(output(proxy))] + translation: bevy::math::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Affine3A", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Affine3A; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Affine3A; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Affine3A) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + +"#, + r#" +/// Creates an affine transform from three column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::Vec3A, + #[proxy] + y_axis: bevy::math::Vec3A, + #[proxy] + z_axis: bevy::math::Vec3A, + #[proxy] + w_axis: bevy::math::Vec3A, + ) -> bevy::math::Affine3A; + +"#, + r#" +/// Creates a `[f32; 12]` array storing data in column major order. + + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f32; 12]; + +"#, + r#" +/// Creates a `[[f32; 3]; 4]` 3D array storing data in +/// column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array_2d(&self) -> [[f32; 3]; 4]; + +"#, + 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::Vec3) -> bevy::math::Affine3A; + +"#, + r#" +/// Creates an affine transform from the given `rotation` quaternion. + + #[lua(kind = "Function", output(proxy))] + fn from_quat(#[proxy] rotation: bevy::math::Quat) -> bevy::math::Affine3A; + +"#, + 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::Vec3, + angle: f32, + ) -> bevy::math::Affine3A; + +"#, + 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) -> bevy::math::Affine3A; + +"#, + 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) -> bevy::math::Affine3A; + +"#, + 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) -> bevy::math::Affine3A; + +"#, + r#" +/// Creates an affine transformation from the given 3D `translation`. + + #[lua(kind = "Function", output(proxy))] + fn from_translation(#[proxy] translation: bevy::math::Vec3) -> bevy::math::Affine3A; + +"#, + 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::Mat3) -> bevy::math::Affine3A; + +"#, + 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::Mat3, + #[proxy] + translation: bevy::math::Vec3, + ) -> bevy::math::Affine3A; + +"#, + 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::Vec3, + #[proxy] + rotation: bevy::math::Quat, + #[proxy] + translation: bevy::math::Vec3, + ) -> bevy::math::Affine3A; + +"#, + 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::Quat, + #[proxy] + translation: bevy::math::Vec3, + ) -> bevy::math::Affine3A; + +"#, + 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::Mat4) -> bevy::math::Affine3A; + +"#, + 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::Vec3, + #[proxy] + dir: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::math::Affine3A; + +"#, + 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::Vec3, + #[proxy] + dir: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::math::Affine3A; + +"#, + 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::Vec3, + #[proxy] + center: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::math::Affine3A; + +"#, + 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::Vec3, + #[proxy] + center: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::math::Affine3A; + +"#, + r#" +/// Transforms the given 3D points, applying shear, scale, rotation and translation. + + #[lua(kind = "Method", output(proxy))] + fn transform_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_vector3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" +/// Transforms the given [`Vec3A`], applying shear, scale, rotation and translation. + + #[lua(kind = "Method", output(proxy))] + fn transform_point3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +/// Transforms the given [`Vec3A`], applying shear, scale and rotation (but NOT +/// translation). +/// To also apply translation, use [`Self::transform_point3a()`] instead. + + #[lua(kind = "Method", output(proxy))] + fn transform_vector3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::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(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + 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(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Affine3A, 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::Affine3A; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct Affine3A { + #[lua(output(proxy))] + matrix3: bevy::math::Mat3A, + #[lua(output(proxy))] + translation: bevy::math::Vec3A, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DAffine2", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DAffine2) -> bool; + +"#, + r#" +/// Creates an affine transform from three column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::DVec2, + #[proxy] + y_axis: bevy::math::DVec2, + #[proxy] + z_axis: bevy::math::DVec2, + ) -> bevy::math::DAffine2; + +"#, + r#" +/// Creates a `[f64; 6]` array storing data in column major order. + + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f64; 6]; + +"#, + r#" +/// Creates a `[[f64; 2]; 3]` 2D array storing data in +/// column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array_2d(&self) -> [[f64; 2]; 3]; + +"#, + 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::DVec2) -> bevy::math::DAffine2; + +"#, + r#" +/// Creates an affine transform from the given rotation `angle`. + + #[lua(kind = "Function", output(proxy))] + fn from_angle(angle: f64) -> bevy::math::DAffine2; + +"#, + r#" +/// Creates an affine transformation from the given 2D `translation`. + + #[lua(kind = "Function", output(proxy))] + fn from_translation(#[proxy] translation: bevy::math::DVec2) -> bevy::math::DAffine2; + +"#, + 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::DMat2) -> bevy::math::DAffine2; + +"#, + 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::DMat2, + #[proxy] + translation: bevy::math::DVec2, + ) -> bevy::math::DAffine2; + +"#, + 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::DVec2, + angle: f64, + #[proxy] + translation: bevy::math::DVec2, + ) -> bevy::math::DAffine2; + +"#, + 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::DVec2, + ) -> bevy::math::DAffine2; + +"#, + r#" +/// The given `DMat3` must be an affine transform, + + #[lua(kind = "Function", output(proxy))] + fn from_mat3(#[proxy] m: bevy::math::DMat3) -> bevy::math::DAffine2; + +"#, + r#" +/// Transforms the given 2D point, applying shear, scale, rotation and translation. + + #[lua(kind = "Method", output(proxy))] + fn transform_point2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_vector2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::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(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + 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(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DAffine2, 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::DAffine2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DAffine2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DAffine2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct DAffine2 { + #[lua(output(proxy))] + matrix2: bevy::math::DMat2, + #[lua(output(proxy))] + translation: bevy::math::DVec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DAffine3", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DAffine3; + +"#, + r#" +/// Creates an affine transform from three column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::DVec3, + #[proxy] + y_axis: bevy::math::DVec3, + #[proxy] + z_axis: bevy::math::DVec3, + #[proxy] + w_axis: bevy::math::DVec3, + ) -> bevy::math::DAffine3; + +"#, + r#" +/// Creates a `[f64; 12]` array storing data in column major order. + + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f64; 12]; + +"#, + r#" +/// Creates a `[[f64; 3]; 4]` 3D array storing data in +/// column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array_2d(&self) -> [[f64; 3]; 4]; + +"#, + 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::DVec3) -> bevy::math::DAffine3; + +"#, + r#" +/// Creates an affine transform from the given `rotation` quaternion. + + #[lua(kind = "Function", output(proxy))] + fn from_quat(#[proxy] rotation: bevy::math::DQuat) -> bevy::math::DAffine3; + +"#, + 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::DVec3, + angle: f64, + ) -> bevy::math::DAffine3; + +"#, + 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) -> bevy::math::DAffine3; + +"#, + 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) -> bevy::math::DAffine3; + +"#, + 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) -> bevy::math::DAffine3; + +"#, + r#" +/// Creates an affine transformation from the given 3D `translation`. + + #[lua(kind = "Function", output(proxy))] + fn from_translation(#[proxy] translation: bevy::math::DVec3) -> bevy::math::DAffine3; + +"#, + 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::DMat3) -> bevy::math::DAffine3; + +"#, + 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::DMat3, + #[proxy] + translation: bevy::math::DVec3, + ) -> bevy::math::DAffine3; + +"#, + 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::DVec3, + #[proxy] + rotation: bevy::math::DQuat, + #[proxy] + translation: bevy::math::DVec3, + ) -> bevy::math::DAffine3; + +"#, + 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::DQuat, + #[proxy] + translation: bevy::math::DVec3, + ) -> bevy::math::DAffine3; + +"#, + 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::DMat4) -> bevy::math::DAffine3; + +"#, + 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::DVec3, + #[proxy] + dir: bevy::math::DVec3, + #[proxy] + up: bevy::math::DVec3, + ) -> bevy::math::DAffine3; + +"#, + 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::DVec3, + #[proxy] + dir: bevy::math::DVec3, + #[proxy] + up: bevy::math::DVec3, + ) -> bevy::math::DAffine3; + +"#, + 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::DVec3, + #[proxy] + center: bevy::math::DVec3, + #[proxy] + up: bevy::math::DVec3, + ) -> bevy::math::DAffine3; + +"#, + 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::DVec3, + #[proxy] + center: bevy::math::DVec3, + #[proxy] + up: bevy::math::DVec3, + ) -> bevy::math::DAffine3; + +"#, + r#" +/// Transforms the given 3D points, applying shear, scale, rotation and translation. + + #[lua(kind = "Method", output(proxy))] + fn transform_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn transform_vector3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + 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(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DAffine3, 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(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::DAffine3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DAffine3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DAffine3) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct DAffine3 { + #[lua(output(proxy))] + matrix3: bevy::math::DMat3, + #[lua(output(proxy))] + translation: bevy::math::DVec3, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DQuat", + functions[r#" +/// Adds two quaternions. +/// The sum is not guaranteed to be normalized. +/// Note that addition is not the same as combining the rotations represented by the +/// two quaternions! That corresponds to multiplication. + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DQuat; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DQuat) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DQuat; + +"#, + r#" +/// Divides a quaternion by a scalar value. +/// The quotient is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DQuat; + +"#, + 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( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + +"#, + r#" +/// Subtracts the `rhs` quaternion from `self`. +/// The difference is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + +"#, + r#" +/// Multiplies a quaternion by a scalar value. +/// The product is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DQuat; + +"#, + 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( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + 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) -> bevy::math::DQuat; + +"#, + r#" +/// Creates a rotation quaternion from an array. +/// # 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_array(a: [f64; 4]) -> bevy::math::DQuat; + +"#, + 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::DVec4) -> bevy::math::DQuat; + +"#, + 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::DVec3, + angle: f64, + ) -> bevy::math::DQuat; + +"#, + 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::DVec3) -> bevy::math::DQuat; + +"#, + r#" +/// Creates a quaternion from the `angle` (in radians) around the x axis. + + #[lua(kind = "Function", output(proxy))] + fn from_rotation_x(angle: f64) -> bevy::math::DQuat; + +"#, + r#" +/// Creates a quaternion from the `angle` (in radians) around the y axis. + + #[lua(kind = "Function", output(proxy))] + fn from_rotation_y(angle: f64) -> bevy::math::DQuat; + +"#, + r#" +/// Creates a quaternion from the `angle` (in radians) around the z axis. + + #[lua(kind = "Function", output(proxy))] + fn from_rotation_z(angle: f64) -> bevy::math::DQuat; + +"#, + 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, + ) -> bevy::math::DQuat; + +"#, + r#" +/// Creates a quaternion from a 3x3 rotation matrix. + + #[lua(kind = "Function", output(proxy))] + fn from_mat3(#[proxy] mat: &glam::DMat3) -> bevy::math::DQuat; + +"#, + r#" +/// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. + + #[lua(kind = "Function", output(proxy))] + fn from_mat4(#[proxy] mat: &glam::DMat4) -> bevy::math::DQuat; + +"#, + 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::DVec3, + #[proxy] + to: bevy::math::DVec3, + ) -> bevy::math::DQuat; + +"#, + 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::DVec3, + #[proxy] + to: bevy::math::DVec3, + ) -> bevy::math::DQuat; + +"#, + 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::DVec2, + #[proxy] + to: bevy::math::DVec2, + ) -> bevy::math::DQuat; + +"#, + r#" +/// Returns the rotation axis scaled by the rotation in radians. + + #[lua(kind = "Method", output(proxy))] + fn to_scaled_axis(self) -> bevy::math::DVec3; + +"#, + r#" +/// Returns the rotation angles for the given euler rotation sequence. + + #[lua(kind = "Method")] + fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f64, f64, f64); + +"#, + r#" +/// `[x, y, z, w]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [f64; 4]; + +"#, + r#" +/// Returns the vector part of the quaternion. + + #[lua(kind = "Method", output(proxy))] + fn xyz(self) -> bevy::math::DVec3; + +"#, + r#" +/// Returns the quaternion conjugate of `self`. For a unit quaternion the +/// conjugate is also the inverse. + + #[lua(kind = "Method", output(proxy))] + fn conjugate(self) -> bevy::math::DQuat; + +"#, + 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(kind = "Method", output(proxy))] + fn inverse(self) -> bevy::math::DQuat; + +"#, + 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(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::DQuat) -> f64; + +"#, + r#" +/// Computes the length of `self`. + + #[lua(kind = "Method")] + 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(kind = "Method")] + fn length_squared(self) -> f64; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua(kind = "Method")] + 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(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::DQuat; + +"#, + 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(kind = "Method")] + fn is_finite(self) -> bool; + +"#, + r#" + + #[lua(kind = "Method")] + fn is_nan(self) -> bool; + +"#, + r#" +/// Returns whether `self` of length `1.0` or not. +/// Uses a precision threshold of `1e-6`. + + #[lua(kind = "Method")] + fn is_normalized(self) -> bool; + +"#, + r#" + + #[lua(kind = "Method")] + 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(kind = "Method")] + fn angle_between(self, #[proxy] rhs: bevy::math::DQuat) -> 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(kind = "Method")] + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DQuat, 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(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; + +"#, + 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(kind = "Method", output(proxy))] + fn slerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; + +"#, + 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(kind = "Method", output(proxy))] + fn mul_vec3(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::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(kind = "Method", output(proxy))] + fn mul_quat(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + +"#, + r#" +/// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. + + #[lua(kind = "Function", output(proxy))] + fn from_affine3(#[proxy] a: &glam::DAffine3) -> bevy::math::DQuat; + +"#, + r#" + + #[lua(kind = "Method", output(proxy))] + fn as_quat(self) -> bevy::math::Quat; + +"#, + r#" + + #[lua(kind = "Method", output(proxy))] + fn as_f32(self) -> bevy::math::Quat; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct DQuat { + x: f64, + y: f64, + z: f64, + w: f64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::EulerRot", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::EulerRot) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::EulerRot; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct EulerRot {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::BVec3A", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec3A; + +"#, + r#" +/// Creates a new vector mask. + + #[lua(kind = "Function", output(proxy))] + fn new(x: bool, y: bool, z: bool) -> bevy::math::BVec3A; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: bool) -> bevy::math::BVec3A; + +"#, + 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(kind = "Method")] + fn bitmask(self) -> u32; + +"#, + r#" +/// Returns true if any of the elements are true, false otherwise. + + #[lua(kind = "Method")] + fn any(self) -> bool; + +"#, + r#" +/// Returns true if all the elements are true, false otherwise. + + #[lua(kind = "Method")] + fn all(self) -> bool; + +"#, + r#" +/// Tests the value at `index`. +/// Panics if `index` is greater than 2. + + #[lua(kind = "Method")] + fn test(&self, index: usize) -> bool; + +"#, + r#" +/// Sets the element at `index`. +/// Panics if `index` is greater than 2. + + #[lua(kind = "MutatingMethod")] + fn set(&mut self, index: usize, value: bool) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::BVec3A) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct BVec3A(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::BVec4A", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec4A; + +"#, + r#" +/// Creates a new vector mask. + + #[lua(kind = "Function", output(proxy))] + fn new(x: bool, y: bool, z: bool, w: bool) -> bevy::math::BVec4A; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: bool) -> bevy::math::BVec4A; + +"#, + 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(kind = "Method")] + fn bitmask(self) -> u32; + +"#, + r#" +/// Returns true if any of the elements are true, false otherwise. + + #[lua(kind = "Method")] + fn any(self) -> bool; + +"#, + r#" +/// Returns true if all the elements are true, false otherwise. + + #[lua(kind = "Method")] + fn all(self) -> bool; + +"#, + r#" +/// Tests the value at `index`. +/// Panics if `index` is greater than 3. + + #[lua(kind = "Method")] + fn test(&self, index: usize) -> bool; + +"#, + r#" +/// Sets the element at `index`. +/// Panics if `index` is greater than 3. + + #[lua(kind = "MutatingMethod")] + fn set(&mut self, index: usize, value: bool) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::BVec4A) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct BVec4A(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Direction2d", + functions[r#" +/// Create a [`Direction2d`] from a [`Vec2`] that is already normalized. +/// # Warning +/// `value` must be normalized, i.e it's length must be `1.0`. + + #[lua(kind = "Function", output(proxy))] + fn new_unchecked( + #[proxy] + value: bevy::math::Vec2, + ) -> bevy::math::primitives::Direction2d; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction2d) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Direction2d; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::primitives::Direction2d; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Direction2d(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Circle", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Circle; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Circle) -> bool; + +"#, + r#" +/// Create a new [`Circle`] from a `radius` + + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32) -> bevy::math::primitives::Circle; + +"#, + r#" +/// Get the diameter of the circle + + #[lua(kind = "Method")] + fn diameter(&self) -> f32; + +"#, + r#" +/// Get the area of the circle + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +/// Get the perimeter or circumference of the circle + + #[lua(kind = "Method")] + fn perimeter(&self) -> f32; + +"#, + r#" +/// Finds the point on the circle that is closest to the given `point`. +/// If the point is outside the circle, the returned point will be on the perimeter of the circle. +/// Otherwise, it will be inside the circle and returned as is. + + #[lua(kind = "Method", output(proxy))] + fn closest_point(&self, #[proxy] point: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Circle { + radius: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Ellipse", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Ellipse; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Ellipse) -> bool; + +"#, + r#" +/// Create a new `Ellipse` from half of its width and height. +/// This corresponds to the two perpendicular radii defining the ellipse. + + #[lua(kind = "Function", output(proxy))] + fn new(half_width: f32, half_height: f32) -> bevy::math::primitives::Ellipse; + +"#, + r#" +/// Create a new `Ellipse` from a given full size. +/// `size.x` is the diameter along the X axis, and `size.y` is the diameter along the Y axis. + + #[lua(kind = "Function", output(proxy))] + fn from_size(#[proxy] size: bevy::math::Vec2) -> bevy::math::primitives::Ellipse; + +"#, + r#" +/// Returns the length of the semi-major axis. This corresponds to the longest radius of the ellipse. + + #[lua(kind = "Method")] + fn semi_major(self) -> f32; + +"#, + r#" +/// Returns the length of the semi-minor axis. This corresponds to the shortest radius of the ellipse. + + #[lua(kind = "Method")] + fn semi_minor(self) -> f32; + +"#, + r#" +/// Get the area of the ellipse + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Ellipse { + #[lua(output(proxy))] + half_size: bevy::math::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Plane2d", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Plane2d) -> bool; + +"#, + r#" +/// Create a new `Plane2d` from a normal +/// # Panics +/// Panics if the given `normal` is zero (or very close to zero), or non-finite. + + #[lua(kind = "Function", output(proxy))] + fn new(#[proxy] normal: bevy::math::Vec2) -> bevy::math::primitives::Plane2d; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Plane2d; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Plane2d { + #[lua(output(proxy))] + normal: bevy::math::primitives::Direction2d, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Line2d", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Line2d) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Line2d; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Line2d { + #[lua(output(proxy))] + direction: bevy::math::primitives::Direction2d, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Segment2d", + functions[r#" +/// Create a new `Segment2d` from a direction and full length of the segment + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + direction: bevy::math::primitives::Direction2d, + length: f32, + ) -> bevy::math::primitives::Segment2d; + +"#, + r#" +/// Get the position of the first point on the line segment + + #[lua(kind = "Method", output(proxy))] + fn point1(&self) -> bevy::math::Vec2; + +"#, + r#" +/// Get the position of the second point on the line segment + + #[lua(kind = "Method", output(proxy))] + fn point2(&self) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Segment2d; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Segment2d) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Segment2d { + #[lua(output(proxy))] + direction: bevy::math::primitives::Direction2d, + half_length: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Triangle2d", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Triangle2d; + +"#, + r#" +/// Create a new `Triangle2d` from points `a`, `b`, and `c` + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + a: bevy::math::Vec2, + #[proxy] + b: bevy::math::Vec2, + #[proxy] + c: bevy::math::Vec2, + ) -> bevy::math::primitives::Triangle2d; + +"#, + r#" +/// Get the area of the triangle + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +/// Get the perimeter of the triangle + + #[lua(kind = "Method")] + fn perimeter(&self) -> f32; + +"#, + r#" +/// Reverse the [`WindingOrder`] of the triangle +/// by swapping the second and third vertices + + #[lua(kind = "MutatingMethod")] + fn reverse(&mut self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Triangle2d) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Triangle2d { + vertices: ReflectedValue, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Rectangle", + functions[r#" +/// Create a new `Rectangle` from a full width and height + + #[lua(kind = "Function", output(proxy))] + fn new(width: f32, height: f32) -> bevy::math::primitives::Rectangle; + +"#, + r#" +/// Create a new `Rectangle` from a given full size + + #[lua(kind = "Function", output(proxy))] + fn from_size(#[proxy] size: bevy::math::Vec2) -> bevy::math::primitives::Rectangle; + +"#, + r#" +/// Create a new `Rectangle` from two corner points + + #[lua(kind = "Function", output(proxy))] + fn from_corners( + #[proxy] + point1: bevy::math::Vec2, + #[proxy] + point2: bevy::math::Vec2, + ) -> bevy::math::primitives::Rectangle; + +"#, + r#" +/// Get the size of the rectangle + + #[lua(kind = "Method", output(proxy))] + fn size(&self) -> bevy::math::Vec2; + +"#, + r#" +/// Get the area of the rectangle + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +/// Get the perimeter of the rectangle + + #[lua(kind = "Method")] + fn perimeter(&self) -> f32; + +"#, + r#" +/// Finds the point on the rectangle that is closest to the given `point`. +/// If the point is outside the rectangle, the returned point will be on the perimeter of the rectangle. +/// Otherwise, it will be inside the rectangle and returned as is. + + #[lua(kind = "Method", output(proxy))] + fn closest_point(&self, #[proxy] point: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Rectangle) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Rectangle; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Rectangle { + #[lua(output(proxy))] + half_size: bevy::math::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::RegularPolygon", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::RegularPolygon; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::RegularPolygon) -> bool; + +"#, + r#" +/// Create a new `RegularPolygon` +/// from the radius of the circumcircle and a number of sides +/// # Panics +/// Panics if `circumradius` is non-positive + + #[lua(kind = "Function", output(proxy))] + fn new(circumradius: f32, sides: usize) -> bevy::math::primitives::RegularPolygon; + +"#, + r#" +/// Get the radius of the circumcircle on which all vertices +/// of the regular polygon lie + + #[lua(kind = "Method")] + fn circumradius(&self) -> f32; + +"#, + r#" +/// Get the inradius or apothem of the regular polygon. +/// This is the radius of the largest circle that can +/// be drawn within the polygon + + #[lua(kind = "Method")] + fn inradius(&self) -> f32; + +"#, + r#" +/// Get the length of one side of the regular polygon + + #[lua(kind = "Method")] + fn side_length(&self) -> f32; + +"#, + r#" +/// Get the area of the regular polygon + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +/// Get the perimeter of the regular polygon. +/// This is the sum of its sides + + #[lua(kind = "Method")] + fn perimeter(&self) -> f32; + +"#, + r#" +/// Get the internal angle of the regular polygon in degrees. +/// This is the angle formed by two adjacent sides with points +/// within the angle being in the interior of the polygon + + #[lua(kind = "Method")] + fn internal_angle_degrees(&self) -> f32; + +"#, + r#" +/// Get the internal angle of the regular polygon in radians. +/// This is the angle formed by two adjacent sides with points +/// within the angle being in the interior of the polygon + + #[lua(kind = "Method")] + fn internal_angle_radians(&self) -> f32; + +"#, + r#" +/// Get the external angle of the regular polygon in degrees. +/// This is the angle formed by two adjacent sides with points +/// within the angle being in the exterior of the polygon + + #[lua(kind = "Method")] + fn external_angle_degrees(&self) -> f32; + +"#, + r#" +/// Get the external angle of the regular polygon in radians. +/// This is the angle formed by two adjacent sides with points +/// within the angle being in the exterior of the polygon + + #[lua(kind = "Method")] + fn external_angle_radians(&self) -> f32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct RegularPolygon { + #[lua(output(proxy))] + circumcircle: bevy::math::primitives::Circle, + sides: usize, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Capsule2d", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule2d) -> bool; + +"#, + r#" +/// Create a new `Capsule2d` from a radius and length + + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule2d; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Capsule2d; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Capsule2d { + radius: f32, + half_length: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Direction3d", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction3d) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Direction3d; + +"#, + r#" +/// Create a [`Direction3d`] from a [`Vec3`] that is already normalized. +/// # Warning +/// `value` must be normalized, i.e it's length must be `1.0`. + + #[lua(kind = "Function", output(proxy))] + fn new_unchecked( + #[proxy] + value: bevy::math::Vec3, + ) -> bevy::math::primitives::Direction3d; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::primitives::Direction3d; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Direction3d(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Sphere", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Sphere; + +"#, + r#" +/// Create a new [`Sphere`] from a `radius` + + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32) -> bevy::math::primitives::Sphere; + +"#, + r#" +/// Get the diameter of the sphere + + #[lua(kind = "Method")] + fn diameter(&self) -> f32; + +"#, + r#" +/// Get the surface area of the sphere + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +/// Get the volume of the sphere + + #[lua(kind = "Method")] + fn volume(&self) -> f32; + +"#, + r#" +/// Finds the point on the sphere that is closest to the given `point`. +/// If the point is outside the sphere, the returned point will be on the surface of the sphere. +/// Otherwise, it will be inside the sphere and returned as is. + + #[lua(kind = "Method", output(proxy))] + fn closest_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Sphere) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Sphere { + radius: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Plane3d", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Plane3d; + +"#, + r#" +/// Create a new `Plane3d` from a normal +/// # Panics +/// Panics if the given `normal` is zero (or very close to zero), or non-finite. + + #[lua(kind = "Function", output(proxy))] + fn new(#[proxy] normal: bevy::math::Vec3) -> bevy::math::primitives::Plane3d; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Plane3d) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Plane3d { + #[lua(output(proxy))] + normal: bevy::math::primitives::Direction3d, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Line3d", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Line3d; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Line3d) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Line3d { + #[lua(output(proxy))] + direction: bevy::math::primitives::Direction3d, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Segment3d", + functions[r#" +/// Create a new `Segment3d` from a direction and full length of the segment + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + direction: bevy::math::primitives::Direction3d, + length: f32, + ) -> bevy::math::primitives::Segment3d; + +"#, + r#" +/// Get the position of the first point on the line segment + + #[lua(kind = "Method", output(proxy))] + fn point1(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Get the position of the second point on the line segment + + #[lua(kind = "Method", output(proxy))] + fn point2(&self) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Segment3d; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Segment3d) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Segment3d { + #[lua(output(proxy))] + direction: bevy::math::primitives::Direction3d, + half_length: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Cuboid", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Cuboid; + +"#, + r#" +/// Create a new `Cuboid` from a full x, y, and z length + + #[lua(kind = "Function", output(proxy))] + fn new( + x_length: f32, + y_length: f32, + z_length: f32, + ) -> bevy::math::primitives::Cuboid; + +"#, + r#" +/// Create a new `Cuboid` from a given full size + + #[lua(kind = "Function", output(proxy))] + fn from_size(#[proxy] size: bevy::math::Vec3) -> bevy::math::primitives::Cuboid; + +"#, + r#" +/// Create a new `Cuboid` from two corner points + + #[lua(kind = "Function", output(proxy))] + fn from_corners( + #[proxy] + point1: bevy::math::Vec3, + #[proxy] + point2: bevy::math::Vec3, + ) -> bevy::math::primitives::Cuboid; + +"#, + r#" +/// Get the size of the cuboid + + #[lua(kind = "Method", output(proxy))] + fn size(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Get the surface area of the cuboid + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +/// Get the volume of the cuboid + + #[lua(kind = "Method")] + fn volume(&self) -> f32; + +"#, + r#" +/// Finds the point on the cuboid that is closest to the given `point`. +/// If the point is outside the cuboid, the returned point will be on the surface of the cuboid. +/// Otherwise, it will be inside the cuboid and returned as is. + + #[lua(kind = "Method", output(proxy))] + fn closest_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Cuboid) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Cuboid { + #[lua(output(proxy))] + half_size: bevy::math::Vec3, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Cylinder", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Cylinder; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Cylinder) -> bool; + +"#, + r#" +/// Create a new `Cylinder` from a radius and full height + + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32, height: f32) -> bevy::math::primitives::Cylinder; + +"#, + r#" +/// Get the base of the cylinder as a [`Circle`] + + #[lua(kind = "Method", output(proxy))] + fn base(&self) -> bevy::math::primitives::Circle; + +"#, + r#" +/// Get the surface area of the side of the cylinder, +/// also known as the lateral area + + #[lua(kind = "Method")] + fn lateral_area(&self) -> f32; + +"#, + r#" +/// Get the surface area of one base of the cylinder + + #[lua(kind = "Method")] + fn base_area(&self) -> f32; + +"#, + r#" +/// Get the total surface area of the cylinder + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +/// Get the volume of the cylinder + + #[lua(kind = "Method")] + fn volume(&self) -> f32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Cylinder { + radius: f32, + half_height: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Capsule3d", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Capsule3d; + +"#, + r#" +/// Create a new `Capsule3d` from a radius and length + + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule3d; + +"#, + r#" +/// Get the part connecting the hemispherical ends +/// of the capsule as a [`Cylinder`] + + #[lua(kind = "Method", output(proxy))] + fn to_cylinder(&self) -> bevy::math::primitives::Cylinder; + +"#, + r#" +/// Get the surface area of the capsule + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +/// Get the volume of the capsule + + #[lua(kind = "Method")] + fn volume(&self) -> f32; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule3d) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Capsule3d { + radius: f32, + half_length: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Cone", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Cone; + +"#, + r#" +/// Get the base of the cone as a [`Circle`] + + #[lua(kind = "Method", output(proxy))] + fn base(&self) -> bevy::math::primitives::Circle; + +"#, + r#" +/// Get the slant height of the cone, the length of the line segment +/// connecting a point on the base to the apex + + #[lua(kind = "Method")] + fn slant_height(&self) -> f32; + +"#, + r#" +/// Get the surface area of the side of the cone, +/// also known as the lateral area + + #[lua(kind = "Method")] + fn lateral_area(&self) -> f32; + +"#, + r#" +/// Get the surface area of the base of the cone + + #[lua(kind = "Method")] + fn base_area(&self) -> f32; + +"#, + r#" +/// Get the total surface area of the cone + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +/// Get the volume of the cone + + #[lua(kind = "Method")] + fn volume(&self) -> f32; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Cone) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Cone { + radius: f32, + height: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::ConicalFrustum", + functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::ConicalFrustum; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::ConicalFrustum) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ConicalFrustum { + radius_top: f32, + radius_bottom: f32, + height: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Torus", + functions[r#" +/// Create a new `Torus` from an inner and outer radius. +/// The inner radius is the radius of the hole, and the outer radius +/// is the radius of the entire object + + #[lua(kind = "Function", output(proxy))] + fn new(inner_radius: f32, outer_radius: f32) -> bevy::math::primitives::Torus; + +"#, + r#" +/// Get the inner radius of the torus. +/// For a ring torus, this corresponds to the radius of the hole, +/// or `major_radius - minor_radius` + + #[lua(kind = "Method")] + fn inner_radius(&self) -> f32; + +"#, + r#" +/// Get the outer radius of the torus. +/// This corresponds to the overall radius of the entire object, +/// or `major_radius + minor_radius` + + #[lua(kind = "Method")] + fn outer_radius(&self) -> f32; + +"#, + r#" +/// Get the surface area of the torus. Note that this only produces +/// the expected result when the torus has a ring and isn't self-intersecting + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +/// Get the volume of the torus. Note that this only produces +/// the expected result when the torus has a ring and isn't self-intersecting + + #[lua(kind = "Method")] + fn volume(&self) -> f32; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::primitives::Torus; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::primitives::Torus) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Torus { + minor_radius: f32, + major_radius: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::IRect", + 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 +/// ``` +/// # use bevy_math::IRect; +/// let r = IRect::new(0, 4, 10, 6); // w=10 h=2 +/// let r = IRect::new(2, 3, 5, -1); // w=3 h=4 +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(x0: i32, y0: i32, x1: i32, y1: i32) -> bevy::math::IRect; + +"#, + 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 +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// // Unit rect from [0,0] to [1,1] +/// let r = IRect::from_corners(IVec2::ZERO, IVec2::ONE); // w=1 h=1 +/// // Same; the points do not need to be ordered +/// let r = IRect::from_corners(IVec2::ONE, IVec2::ZERO); // w=1 h=1 +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_corners( + #[proxy] + p0: bevy::math::IVec2, + #[proxy] + p1: bevy::math::IVec2, + ) -> bevy::math::IRect; + +"#, + r#" +/// Create a new rectangle from its center and size. +/// # Rounding Behaviour +/// If the size contains odd numbers they will be rounded down to the nearest whole number. +/// # Panics +/// This method panics if any of the components of the size is negative. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::from_center_size(IVec2::ZERO, IVec2::new(3, 2)); // w=2 h=2 +/// assert_eq!(r.min, IVec2::splat(-1)); +/// assert_eq!(r.max, IVec2::splat(1)); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_center_size( + #[proxy] + origin: bevy::math::IVec2, + #[proxy] + size: bevy::math::IVec2, + ) -> bevy::math::IRect; + +"#, + 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 +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::from_center_half_size(IVec2::ZERO, IVec2::ONE); // w=2 h=2 +/// assert_eq!(r.min, IVec2::splat(-1)); +/// assert_eq!(r.max, IVec2::splat(1)); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_center_half_size( + #[proxy] + origin: bevy::math::IVec2, + #[proxy] + half_size: bevy::math::IVec2, + ) -> bevy::math::IRect; + +"#, + r#" +/// Check if the rectangle is empty. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::from_corners(IVec2::ZERO, IVec2::new(0, 1)); // w=0 h=1 +/// assert!(r.is_empty()); +/// ``` + + #[lua(kind = "Method")] + fn is_empty(&self) -> bool; + +"#, + r#" +/// Rectangle width (max.x - min.x). +/// # Examples +/// ``` +/// # use bevy_math::IRect; +/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// assert_eq!(r.width(), 5); +/// ``` + + #[lua(kind = "Method")] + fn width(&self) -> i32; + +"#, + r#" +/// Rectangle height (max.y - min.y). +/// # Examples +/// ``` +/// # use bevy_math::IRect; +/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// assert_eq!(r.height(), 1); +/// ``` + + #[lua(kind = "Method")] + fn height(&self) -> i32; + +"#, + r#" +/// Rectangle size. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// assert_eq!(r.size(), IVec2::new(5, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn size(&self) -> bevy::math::IVec2; + +"#, + r#" +/// Rectangle half-size. +/// # Rounding Behaviour +/// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::new(0, 0, 4, 3); // w=4 h=3 +/// assert_eq!(r.half_size(), IVec2::new(2, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn half_size(&self) -> bevy::math::IVec2; + +"#, + r#" +/// The center point of the rectangle. +/// # Rounding Behaviour +/// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::new(0, 0, 5, 2); // w=5 h=2 +/// assert_eq!(r.center(), IVec2::new(2, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn center(&self) -> bevy::math::IVec2; + +"#, + r#" +/// Check if a point lies within this rectangle, inclusive of its edges. +/// # Examples +/// ``` +/// # use bevy_math::IRect; +/// let r = IRect::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(kind = "Method")] + fn contains(&self, #[proxy] point: bevy::math::IVec2) -> 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 +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r1 = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// let r2 = IRect::new(1, -1, 3, 3); // w=2 h=4 +/// let r = r1.union(r2); +/// assert_eq!(r.min, IVec2::new(0, -1)); +/// assert_eq!(r.max, IVec2::new(5, 3)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn union(&self, #[proxy] other: bevy::math::IRect) -> bevy::math::IRect; + +"#, + 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 +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// let u = r.union_point(IVec2::new(3, 6)); +/// assert_eq!(u.min, IVec2::ZERO); +/// assert_eq!(u.max, IVec2::new(5, 6)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn union_point(&self, #[proxy] other: bevy::math::IVec2) -> bevy::math::IRect; + +"#, + 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 ([`IRect::is_empty()`] returns `true`), but +/// the actual values of [`IRect::min`] and [`IRect::max`] are implementation-dependent. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r1 = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// let r2 = IRect::new(1, -1, 3, 3); // w=2 h=4 +/// let r = r1.intersect(r2); +/// assert_eq!(r.min, IVec2::new(1, 0)); +/// assert_eq!(r.max, IVec2::new(3, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn intersect(&self, #[proxy] other: bevy::math::IRect) -> bevy::math::IRect; + +"#, + 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 +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// let r2 = r.inset(3); // w=11 h=7 +/// assert_eq!(r2.min, IVec2::splat(-3)); +/// assert_eq!(r2.max, IVec2::new(8, 4)); +/// let r = IRect::new(0, -1, 4, 3); // w=4 h=4 +/// let r2 = r.inset(-1); // w=2 h=2 +/// assert_eq!(r2.min, IVec2::new(1, 0)); +/// assert_eq!(r2.max, IVec2::new(3, 2)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn inset(&self, inset: i32) -> bevy::math::IRect; + +"#, + r#" +/// Returns self as [`Rect`] (f32) + + #[lua(kind = "Method", output(proxy))] + fn as_rect(&self) -> bevy::math::Rect; + +"#, + r#" +/// Returns self as [`URect`] (u32) + + #[lua(kind = "Method", output(proxy))] + fn as_urect(&self) -> bevy::math::URect; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::IRect; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::IRect) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct IRect { + #[lua(output(proxy))] + min: bevy::math::IVec2, + #[lua(output(proxy))] + max: bevy::math::IVec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + 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 +/// ``` +/// # 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) -> bevy::math::Rect; + +"#, + 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 +/// ``` +/// # 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::Vec2, + #[proxy] + p1: bevy::math::Vec2, + ) -> bevy::math::Rect; + +"#, + 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 +/// ``` +/// # 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::Vec2, + #[proxy] + size: bevy::math::Vec2, + ) -> bevy::math::Rect; + +"#, + 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 +/// ``` +/// # 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::Vec2, + #[proxy] + half_size: bevy::math::Vec2, + ) -> bevy::math::Rect; + +"#, + r#" +/// Check if the rectangle is empty. +/// # Examples +/// ``` +/// # 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(kind = "Method")] + fn is_empty(&self) -> bool; + +"#, + r#" +/// Rectangle width (max.x - min.x). +/// # Examples +/// ``` +/// # use bevy_math::Rect; +/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 +/// assert!((r.width() - 5.).abs() <= 1e-5); +/// ``` + + #[lua(kind = "Method")] + fn width(&self) -> f32; + +"#, + r#" +/// Rectangle height (max.y - min.y). +/// # Examples +/// ``` +/// # use bevy_math::Rect; +/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 +/// assert!((r.height() - 1.).abs() <= 1e-5); +/// ``` + + #[lua(kind = "Method")] + fn height(&self) -> f32; + +"#, + r#" +/// Rectangle size. +/// # Examples +/// ``` +/// # 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(kind = "Method", output(proxy))] + fn size(&self) -> bevy::math::Vec2; + +"#, + r#" +/// Rectangle half-size. +/// # Examples +/// ``` +/// # 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(kind = "Method", output(proxy))] + fn half_size(&self) -> bevy::math::Vec2; + +"#, + r#" +/// The center point of the rectangle. +/// # Examples +/// ``` +/// # 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(kind = "Method", output(proxy))] + fn center(&self) -> bevy::math::Vec2; + +"#, + r#" +/// Check if a point lies within this rectangle, inclusive of its edges. +/// # Examples +/// ``` +/// # 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(kind = "Method")] + fn contains(&self, #[proxy] point: bevy::math::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 +/// ``` +/// # 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(kind = "Method", output(proxy))] + fn union(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; + +"#, + 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 +/// ``` +/// # 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(kind = "Method", output(proxy))] + fn union_point(&self, #[proxy] other: bevy::math::Vec2) -> bevy::math::Rect; + +"#, + 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 +/// ``` +/// # 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(kind = "Method", output(proxy))] + fn intersect(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; + +"#, + 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 +/// ``` +/// # 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(kind = "Method", output(proxy))] + fn inset(&self, inset: f32) -> bevy::math::Rect; + +"#, + r#" +/// Build a new rectangle from this one with its coordinates expressed +/// relative to `other` in a normalized ([0..1] x [0..1]) coordinate system. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// let r = Rect::new(2., 3., 4., 6.); +/// let s = Rect::new(0., 0., 10., 10.); +/// let n = r.normalize(s); +/// assert_eq!(n.min.x, 0.2); +/// assert_eq!(n.min.y, 0.3); +/// assert_eq!(n.max.x, 0.4); +/// assert_eq!(n.max.y, 0.6); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn normalize(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; + +"#, + r#" +/// Returns self as [`IRect`] (i32) + + #[lua(kind = "Method", output(proxy))] + fn as_irect(&self) -> bevy::math::IRect; + +"#, + r#" +/// Returns self as [`URect`] (u32) + + #[lua(kind = "Method", output(proxy))] + fn as_urect(&self) -> bevy::math::URect; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::Rect) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Rect; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Rect { + #[lua(output(proxy))] + min: bevy::math::Vec2, + #[lua(output(proxy))] + max: bevy::math::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::URect", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_math::URect) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::URect; + +"#, + 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 +/// ``` +/// # use bevy_math::URect; +/// let r = URect::new(0, 4, 10, 6); // w=10 h=2 +/// let r = URect::new(2, 4, 5, 0); // w=3 h=4 +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(x0: u32, y0: u32, x1: u32, y1: u32) -> bevy::math::URect; + +"#, + 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 +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// // Unit rect from [0,0] to [1,1] +/// let r = URect::from_corners(UVec2::ZERO, UVec2::ONE); // w=1 h=1 +/// // Same; the points do not need to be ordered +/// let r = URect::from_corners(UVec2::ONE, UVec2::ZERO); // w=1 h=1 +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_corners( + #[proxy] + p0: bevy::math::UVec2, + #[proxy] + p1: bevy::math::UVec2, + ) -> bevy::math::URect; + +"#, + r#" +/// Create a new rectangle from its center and size. +/// # Rounding Behaviour +/// If the size contains odd numbers they will be rounded down to the nearest whole number. +/// # Panics +/// This method panics if any of the components of the size is negative or if `origin - (size / 2)` results in any negatives. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::from_center_size(UVec2::ONE, UVec2::splat(2)); // w=2 h=2 +/// assert_eq!(r.min, UVec2::splat(0)); +/// assert_eq!(r.max, UVec2::splat(2)); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_center_size( + #[proxy] + origin: bevy::math::UVec2, + #[proxy] + size: bevy::math::UVec2, + ) -> bevy::math::URect; + +"#, + 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 or if `origin - half_size` results in any negatives. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::from_center_half_size(UVec2::ONE, UVec2::ONE); // w=2 h=2 +/// assert_eq!(r.min, UVec2::splat(0)); +/// assert_eq!(r.max, UVec2::splat(2)); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_center_half_size( + #[proxy] + origin: bevy::math::UVec2, + #[proxy] + half_size: bevy::math::UVec2, + ) -> bevy::math::URect; + +"#, + r#" +/// Check if the rectangle is empty. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::from_corners(UVec2::ZERO, UVec2::new(0, 1)); // w=0 h=1 +/// assert!(r.is_empty()); +/// ``` + + #[lua(kind = "Method")] + fn is_empty(&self) -> bool; + +"#, + r#" +/// Rectangle width (max.x - min.x). +/// # Examples +/// ``` +/// # use bevy_math::URect; +/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 +/// assert_eq!(r.width(), 5); +/// ``` + + #[lua(kind = "Method")] + fn width(&self) -> u32; + +"#, + r#" +/// Rectangle height (max.y - min.y). +/// # Examples +/// ``` +/// # use bevy_math::URect; +/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 +/// assert_eq!(r.height(), 1); +/// ``` + + #[lua(kind = "Method")] + fn height(&self) -> u32; + +"#, + r#" +/// Rectangle size. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 +/// assert_eq!(r.size(), UVec2::new(5, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn size(&self) -> bevy::math::UVec2; + +"#, + r#" +/// Rectangle half-size. +/// # Rounding Behaviour +/// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::new(0, 0, 4, 2); // w=4 h=2 +/// assert_eq!(r.half_size(), UVec2::new(2, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn half_size(&self) -> bevy::math::UVec2; + +"#, + r#" +/// The center point of the rectangle. +/// # Rounding Behaviour +/// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::new(0, 0, 4, 2); // w=4 h=2 +/// assert_eq!(r.center(), UVec2::new(2, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn center(&self) -> bevy::math::UVec2; + +"#, + r#" +/// Check if a point lies within this rectangle, inclusive of its edges. +/// # Examples +/// ``` +/// # use bevy_math::URect; +/// let r = URect::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(kind = "Method")] + fn contains(&self, #[proxy] point: bevy::math::UVec2) -> 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 +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r1 = URect::new(0, 0, 5, 1); // w=5 h=1 +/// let r2 = URect::new(1, 0, 3, 8); // w=2 h=4 +/// let r = r1.union(r2); +/// assert_eq!(r.min, UVec2::new(0, 0)); +/// assert_eq!(r.max, UVec2::new(5, 8)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn union(&self, #[proxy] other: bevy::math::URect) -> bevy::math::URect; + +"#, + 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 +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 +/// let u = r.union_point(UVec2::new(3, 6)); +/// assert_eq!(u.min, UVec2::ZERO); +/// assert_eq!(u.max, UVec2::new(5, 6)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn union_point(&self, #[proxy] other: bevy::math::UVec2) -> bevy::math::URect; + +"#, + 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 ([`URect::is_empty()`] returns `true`), but +/// the actual values of [`URect::min`] and [`URect::max`] are implementation-dependent. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r1 = URect::new(0, 0, 2, 2); // w=2 h=2 +/// let r2 = URect::new(1, 1, 3, 3); // w=2 h=2 +/// let r = r1.intersect(r2); +/// assert_eq!(r.min, UVec2::new(1, 1)); +/// assert_eq!(r.max, UVec2::new(2, 2)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn intersect(&self, #[proxy] other: bevy::math::URect) -> bevy::math::URect; + +"#, + 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 +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::new(4, 4, 6, 6); // w=2 h=2 +/// let r2 = r.inset(1); // w=4 h=4 +/// assert_eq!(r2.min, UVec2::splat(3)); +/// assert_eq!(r2.max, UVec2::splat(7)); +/// let r = URect::new(4, 4, 8, 8); // w=4 h=4 +/// let r2 = r.inset(-1); // w=2 h=2 +/// assert_eq!(r2.min, UVec2::splat(5)); +/// assert_eq!(r2.max, UVec2::splat(7)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn inset(&self, inset: i32) -> bevy::math::URect; + +"#, + r#" +/// Returns self as [`Rect`] (f32) + + #[lua(kind = "Method", output(proxy))] + fn as_rect(&self) -> bevy::math::Rect; + +"#, + r#" +/// Returns self as [`IRect`] (i32) + + #[lua(kind = "Method", output(proxy))] + fn as_irect(&self) -> bevy::math::IRect; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct URect { + #[lua(output(proxy))] + min: bevy::math::UVec2, + #[lua(output(proxy))] + max: bevy::math::UVec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "smol_str::SmolStr", + functions[r#" + + #[lua(kind = "Method")] + fn to_string(&self) -> std::string::String; + +"#, + r#" + + #[lua(kind = "Method")] + fn len(&self) -> usize; + +"#, + r#" + + #[lua(kind = "Method")] + fn is_empty(&self) -> bool; + +"#, + r#" + + #[lua(kind = "Method")] + fn is_heap_allocated(&self) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &smol_str::SmolStr) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> smol_str::SmolStr; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct SmolStr(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "std::num::NonZeroIsize", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::num::NonZeroIsize) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +/// Creates a non-zero without checking whether the value is non-zero. +/// This results in undefined behaviour if the value is zero. +/// # Safety +/// The value must not be zero. + + #[lua(kind = "Function", output(proxy))] + unsafe fn new_unchecked(n: isize) -> std::num::NonZeroIsize; + +"#, + r#" +/// Returns the value as a primitive type. + + #[lua(kind = "Method")] + fn get(self) -> isize; + +"#, + r#" +/// Returns the number of leading zeros in the binary representation of `self`. +/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroIsize::new(-1isize).unwrap(); +/// assert_eq!(n.leading_zeros(), 0); +/// ``` + + #[lua(kind = "Method")] + fn leading_zeros(self) -> u32; + +"#, + r#" +/// Returns the number of trailing zeros in the binary representation +/// of `self`. +/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// # Examples +/// Basic usage: +/// ``` +///let n = std::num::NonZeroIsize::new(0b0101000).unwrap(); +/// assert_eq!(n.trailing_zeros(), 3); +/// ``` + + #[lua(kind = "Method")] + fn trailing_zeros(self) -> u32; + +"#, + r#" +/// Computes the absolute value of self. +///See [`isize::abs`] +/// for documentation on overflow behaviour. +/// # Example +/// ``` +///# use std::num::NonZeroIsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroIsize::new(1)?; +///let neg = NonZeroIsize::new(-1)?; +/// assert_eq!(pos, pos.abs()); +/// assert_eq!(pos, neg.abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> std::num::NonZeroIsize; + +"#, + r#" +/// Saturating absolute value, see +///[`isize::saturating_abs`]. +/// # Example +/// ``` +///# use std::num::NonZeroIsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroIsize::new(1)?; +///let neg = NonZeroIsize::new(-1)?; +///let min = NonZeroIsize::new(isize::MIN)?; +///let min_plus = NonZeroIsize::new(isize::MIN + 1)?; +///let max = NonZeroIsize::new(isize::MAX)?; +/// assert_eq!(pos, pos.saturating_abs()); +/// assert_eq!(pos, neg.saturating_abs()); +/// assert_eq!(max, min.saturating_abs()); +/// assert_eq!(max, min_plus.saturating_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_abs(self) -> std::num::NonZeroIsize; + +"#, + r#" +/// Wrapping absolute value, see +///[`isize::wrapping_abs`]. +/// # Example +/// ``` +///# use std::num::NonZeroIsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos = NonZeroIsize::new(1)?; +///let neg = NonZeroIsize::new(-1)?; +///let min = NonZeroIsize::new(isize::MIN)?; +///# let max = NonZeroIsize::new(isize::MAX)?; +/// assert_eq!(pos, pos.wrapping_abs()); +/// assert_eq!(pos, neg.wrapping_abs()); +/// assert_eq!(min, min.wrapping_abs()); +/// assert_eq!(max, (-max).wrapping_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn wrapping_abs(self) -> std::num::NonZeroIsize; + +"#, + r#" +/// Computes the absolute value of self +/// without any wrapping or panicking. +/// # Example +/// ``` +///# use std::num::NonZeroIsize; +///# use std::num::NonZeroUsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let u_pos = NonZeroUsize::new(1)?; +///let i_pos = NonZeroIsize::new(1)?; +///let i_neg = NonZeroIsize::new(-1)?; +///let i_min = NonZeroIsize::new(isize::MIN)?; +///let u_max = NonZeroUsize::new(usize::MAX / 2 + 1)?; +/// assert_eq!(u_pos, i_pos.unsigned_abs()); +/// assert_eq!(u_pos, i_neg.unsigned_abs()); +/// assert_eq!(u_max, i_min.unsigned_abs()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn unsigned_abs(self) -> std::num::NonZeroUsize; + +"#, + r#" +/// Returns `true` if `self` is positive and `false` if the +/// number is negative. +/// # Example +/// ``` +///# use std::num::NonZeroIsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroIsize::new(5)?; +///let neg_five = NonZeroIsize::new(-5)?; +/// assert!(pos_five.is_positive()); +/// assert!(!neg_five.is_positive()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn is_positive(self) -> bool; + +"#, + r#" +/// Returns `true` if `self` is negative and `false` if the +/// number is positive. +/// # Example +/// ``` +///# use std::num::NonZeroIsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroIsize::new(5)?; +///let neg_five = NonZeroIsize::new(-5)?; +/// assert!(neg_five.is_negative()); +/// assert!(!pos_five.is_negative()); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn is_negative(self) -> bool; + +"#, + r#" +/// Saturating negation. Computes `-self`, +///returning [`NonZeroIsize::MAX`] +///if `self == NonZeroIsize::MIN` +/// instead of overflowing. +/// # Example +/// ``` +///# use std::num::NonZeroIsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroIsize::new(5)?; +///let neg_five = NonZeroIsize::new(-5)?; +///let min = NonZeroIsize::new(isize::MIN)?; +///let min_plus_one = NonZeroIsize::new(isize::MIN + 1)?; +///let max = NonZeroIsize::new(isize::MAX)?; +/// assert_eq!(pos_five.saturating_neg(), neg_five); +/// assert_eq!(min.saturating_neg(), max); +/// assert_eq!(max.saturating_neg(), min_plus_one); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_neg(self) -> std::num::NonZeroIsize; + +"#, + r#" +/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary +/// of the type. +///See [`isize::wrapping_neg`] +/// for documentation on overflow behaviour. +/// # Example +/// ``` +///# use std::num::NonZeroIsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let pos_five = NonZeroIsize::new(5)?; +///let neg_five = NonZeroIsize::new(-5)?; +///let min = NonZeroIsize::new(isize::MIN)?; +/// assert_eq!(pos_five.wrapping_neg(), neg_five); +/// assert_eq!(min.wrapping_neg(), min); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn wrapping_neg(self) -> std::num::NonZeroIsize; + +"#, + r#" +/// Multiplies two non-zero integers together. +///Return [`NonZeroIsize::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroIsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let two = NonZeroIsize::new(2)?; +///let four = NonZeroIsize::new(4)?; +///let max = NonZeroIsize::new(isize::MAX)?; +/// assert_eq!(four, two.saturating_mul(two)); +/// assert_eq!(max, four.saturating_mul(max)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul( + self, + #[proxy] + other: std::num::NonZeroIsize, + ) -> std::num::NonZeroIsize; + +"#, + r#" +/// Raise non-zero value to an integer power. +///Return [`NonZeroIsize::MIN`] or [`NonZeroIsize::MAX`] on overflow. +/// # Examples +/// ``` +///# use std::num::NonZeroIsize; +/// # fn main() { test().unwrap(); } +/// # fn test() -> Option<()> { +///let three = NonZeroIsize::new(3)?; +///let twenty_seven = NonZeroIsize::new(27)?; +///let max = NonZeroIsize::new(isize::MAX)?; +/// assert_eq!(twenty_seven, three.saturating_pow(3)); +/// assert_eq!(max, max.saturating_pow(3)); +/// # Some(()) +/// # } +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn saturating_pow(self, other: u32) -> std::num::NonZeroIsize; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::num::NonZeroIsize; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> std::num::NonZeroIsize; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct NonZeroIsize(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::utils::Uuid", + functions[r#" +/// Creates a random UUID. +/// This uses the [`getrandom`] crate to utilise the operating system's RNG +/// as the source of random numbers. If you'd like to use a custom +/// generator, don't use this method: generate random bytes using your +/// custom generator and pass them to the +/// [`uuid::Builder::from_random_bytes`][from_random_bytes] function +/// instead. +/// Note that usage of this method requires the `v4` feature of this crate +/// to be enabled. +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::{Uuid, Version}; +/// let uuid = Uuid::new_v4(); +/// assert_eq!(Some(Version::Random), uuid.get_version()); +/// ``` +/// # References +/// * [Version 4 UUIDs in RFC4122](https://www.rfc-editor.org/rfc/rfc4122#section-4.4) +/// [`getrandom`]: https://crates.io/crates/getrandom +/// [from_random_bytes]: struct.Builder.html#method.from_random_bytes + + #[lua(kind = "Function", output(proxy))] + fn new_v4() -> bevy::utils::Uuid; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_utils::Uuid) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::utils::Uuid; + +"#, + r#" +/// Returns the version number of the UUID. +/// This represents the algorithm used to generate the value. +/// This method is the future-proof alternative to [`Uuid::get_version`]. +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// # fn main() -> Result<(), uuid::Error> { +/// let my_uuid = Uuid::parse_str("02f09a3f-1624-3b1d-8409-44eff7708208")?; +/// assert_eq!(3, my_uuid.get_version_num()); +/// # Ok(()) +/// # } +/// ``` +/// # References +/// * [Version in RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.3) + + #[lua(kind = "Method")] + fn get_version_num(&self) -> usize; + +"#, + r#" +/// Returns a 128bit value containing the value. +/// The bytes in the UUID will be packed directly into a `u128`. +/// # Examples +/// ``` +/// # use uuid::Uuid; +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; +/// assert_eq!( +/// uuid.as_u128(), +/// 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8, +/// ); +/// # Ok(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn as_u128(&self) -> u128; + +"#, + r#" +/// Returns a 128bit little-endian value containing the value. +/// The bytes in the `u128` will be flipped to convert into big-endian +/// order. This is based on the endianness of the UUID, rather than the +/// target environment so bytes will be flipped on both big and little +/// endian machines. +/// Note that this will produce a different result than +/// [`Uuid::to_fields_le`], because the entire UUID is reversed, rather +/// than reversing the individual fields in-place. +/// # Examples +/// ``` +/// # use uuid::Uuid; +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; +/// assert_eq!( +/// uuid.to_u128_le(), +/// 0xd8d7d6d5d4d3d2d1c2c1b2b1a4a3a2a1, +/// ); +/// # Ok(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn to_u128_le(&self) -> u128; + +"#, + r#" +/// Returns two 64bit values containing the value. +/// The bytes in the UUID will be split into two `u64`. +/// The first u64 represents the 64 most significant bits, +/// the second one represents the 64 least significant. +/// # Examples +/// ``` +/// # use uuid::Uuid; +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; +/// assert_eq!( +/// uuid.as_u64_pair(), +/// (0xa1a2a3a4b1b2c1c2, 0xd1d2d3d4d5d6d7d8), +/// ); +/// # Ok(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn as_u64_pair(&self) -> (u64, u64); + +"#, + r#" +/// Consumes self and returns the underlying byte value of the UUID. +/// # Examples +/// ``` +/// # use uuid::Uuid; +/// let bytes = [ +/// 0xa1, 0xa2, 0xa3, 0xa4, +/// 0xb1, 0xb2, +/// 0xc1, 0xc2, +/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, +/// ]; +/// let uuid = Uuid::from_bytes(bytes); +/// assert_eq!(bytes, uuid.into_bytes()); +/// ``` + + #[lua(kind = "Method")] + fn into_bytes(self) -> [u8; 16]; + +"#, + r#" +/// Returns the bytes of the UUID in little-endian order. +/// The bytes will be flipped to convert into little-endian order. This is +/// based on the endianness of the UUID, rather than the target environment +/// so bytes will be flipped on both big and little endian machines. +/// # Examples +/// ``` +/// use uuid::Uuid; +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; +/// assert_eq!( +/// uuid.to_bytes_le(), +/// ([ +/// 0xa4, 0xa3, 0xa2, 0xa1, 0xb2, 0xb1, 0xc2, 0xc1, 0xd1, 0xd2, +/// 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 +/// ]) +/// ); +/// # Ok(()) +/// # } +/// ``` + + #[lua(kind = "Method")] + fn to_bytes_le(&self) -> [u8; 16]; + +"#, + r#" +/// Tests if the UUID is nil (all zeros). + + #[lua(kind = "Method")] + fn is_nil(&self) -> bool; + +"#, + r#" +/// Tests if the UUID is max (all ones). + + #[lua(kind = "Method")] + fn is_max(&self) -> bool; + +"#, + r#" +/// A buffer that can be used for `encode_...` calls, that is +/// guaranteed to be long enough for any of the format adapters. +/// # Examples +/// ``` +/// # use uuid::Uuid; +/// let uuid = Uuid::nil(); +/// assert_eq!( +/// uuid.simple().encode_lower(&mut Uuid::encode_buffer()), +/// "00000000000000000000000000000000" +/// ); +/// assert_eq!( +/// uuid.hyphenated() +/// .encode_lower(&mut Uuid::encode_buffer()), +/// "00000000-0000-0000-0000-000000000000" +/// ); +/// assert_eq!( +/// uuid.urn().encode_lower(&mut Uuid::encode_buffer()), +/// "urn:uuid:00000000-0000-0000-0000-000000000000" +/// ); +/// ``` + + #[lua(kind = "Function")] + fn encode_buffer() -> [u8; 45]; + +"#, + r#" +/// The 'nil UUID' (all zeros). +/// The nil UUID is a special form of UUID that is specified to have all +/// 128 bits set to zero. +/// # References +/// * [Nil UUID in RFC4122](https://tools.ietf.org/html/rfc4122.html#section-4.1.7) +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// let uuid = Uuid::nil(); +/// assert_eq!( +/// "00000000-0000-0000-0000-000000000000", +/// uuid.hyphenated().to_string(), +/// ); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn nil() -> bevy::utils::Uuid; + +"#, + r#" +/// The 'max UUID' (all ones). +/// The max UUID is a special form of UUID that is specified to have all +/// 128 bits set to one. +/// # References +/// * [Max UUID in Draft RFC: New UUID Formats, Version 4](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04#section-5.4) +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// let uuid = Uuid::max(); +/// assert_eq!( +/// "ffffffff-ffff-ffff-ffff-ffffffffffff", +/// uuid.hyphenated().to_string(), +/// ); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn max() -> bevy::utils::Uuid; + +"#, + r#" +/// Creates a UUID from a 128bit value. +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128; +/// let uuid = Uuid::from_u128(v); +/// assert_eq!( +/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", +/// uuid.hyphenated().to_string(), +/// ); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_u128(v: u128) -> bevy::utils::Uuid; + +"#, + r#" +/// Creates a UUID from a 128bit value in little-endian order. +/// The entire value will be flipped to convert into big-endian order. +/// This is based on the endianness of the UUID, rather than the target +/// environment so bytes will be flipped on both big and little endian +/// machines. +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128; +/// let uuid = Uuid::from_u128_le(v); +/// assert_eq!( +/// "d8d7d6d5-d4d3-d2d1-c2c1-b2b1a4a3a2a1", +/// uuid.hyphenated().to_string(), +/// ); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_u128_le(v: u128) -> bevy::utils::Uuid; + +"#, + r#" +/// Creates a UUID from two 64bit values. +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// let hi = 0xa1a2a3a4b1b2c1c2u64; +/// let lo = 0xd1d2d3d4d5d6d7d8u64; +/// let uuid = Uuid::from_u64_pair(hi, lo); +/// assert_eq!( +/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", +/// uuid.hyphenated().to_string(), +/// ); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_u64_pair(high_bits: u64, low_bits: u64) -> bevy::utils::Uuid; + +"#, + r#" +/// Creates a UUID using the supplied bytes. +/// # Examples +/// Basic usage: +/// ``` +/// # fn main() -> Result<(), uuid::Error> { +/// # use uuid::Uuid; +/// let bytes = [ +/// 0xa1, 0xa2, 0xa3, 0xa4, +/// 0xb1, 0xb2, +/// 0xc1, 0xc2, +/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, +/// ]; +/// let uuid = Uuid::from_bytes(bytes); +/// assert_eq!( +/// uuid.hyphenated().to_string(), +/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8" +/// ); +/// # Ok(()) +/// # } +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_bytes(bytes: [u8; 16]) -> bevy::utils::Uuid; + +"#, + r#" +/// Creates a UUID using the supplied bytes in little endian order. +/// The individual fields encoded in the buffer will be flipped. +/// # Examples +/// Basic usage: +/// ``` +/// # fn main() -> Result<(), uuid::Error> { +/// # use uuid::Uuid; +/// let bytes = [ +/// 0xa1, 0xa2, 0xa3, 0xa4, +/// 0xb1, 0xb2, +/// 0xc1, 0xc2, +/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, +/// ]; +/// let uuid = Uuid::from_bytes_le(bytes); +/// assert_eq!( +/// "a4a3a2a1-b2b1-c2c1-d1d2-d3d4d5d6d7d8", +/// uuid.hyphenated().to_string(), +/// ); +/// # Ok(()) +/// # } +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_bytes_le(b: [u8; 16]) -> bevy::utils::Uuid; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct Uuid(); +#[derive(Default)] +pub(crate) struct Globals; +impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { + 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<()> { + instances + .add_instance( + "Duration", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Instant", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "NonZeroI128", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "NonZeroI16", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "NonZeroI32", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "NonZeroI64", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "NonZeroI8", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "NonZeroU128", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "NonZeroU16", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "NonZeroU32", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "NonZeroU64", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "NonZeroU8", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "NonZeroUsize", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "PathBuf", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Quat", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Vec3", + 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( + "I64Vec2", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "I64Vec3", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "I64Vec4", + 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( + "U64Vec2", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "U64Vec3", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "U64Vec4", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Vec2", + 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( + "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( + "Mat2", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Mat3", + 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( + "DQuat", + 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( + "Direction2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Circle", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Ellipse", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Plane2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Segment2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Triangle2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Rectangle", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "RegularPolygon", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaRegularPolygon, + >::new, + )?; + instances + .add_instance( + "Capsule2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Direction3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Sphere", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Plane3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Segment3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Cuboid", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Cylinder", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Capsule3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Torus", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "IRect", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Rect", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "URect", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "NonZeroIsize", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Uuid", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + Ok(()) + } +} +fn bevy_reflect_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut bevy_mod_scripting_lua::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyReflectScriptingPlugin; +impl bevy::app::Plugin for BevyReflectScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::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::(); + 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::(); + 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::(); + 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::(); + 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::(); + 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.add_context_initializer::<()>(bevy_reflect_context_initializer); + app.add_documentation_fragment( + bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + "BevyReflectAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaDuration, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaNonZeroI128, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaNonZeroI16, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaNonZeroI32, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaNonZeroI64, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaNonZeroI8, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaNonZeroU128, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaNonZeroU16, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaNonZeroU32, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaNonZeroU64, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaNonZeroU8, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaNonZeroUsize, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAffine3A, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaDAffine2, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaDAffine3, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaDirection2d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaSegment2d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaTriangle2d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaRectangle, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaRegularPolygon, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaCapsule2d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaDirection3d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaSegment3d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaCylinder, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaCapsule3d, + >, + >() + .process_type::() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaNonZeroIsize, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + }, + ), + ); + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs new file mode 100644 index 00000000..b61a7ede --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs @@ -0,0 +1,701 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_ecs::*; +use super::bevy_reflect::*; +extern crate self as bevy_script_api; +use bevy_script_api::{ + lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, +}; +use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::time::prelude::Fixed", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::time::prelude::Fixed; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Fixed {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::time::prelude::Real", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::time::prelude::Real; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Real {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::time::prelude::Timer", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::time::prelude::Timer; + +"#, + r#" +/// Creates a new timer with a given duration. +/// See also [`Timer::from_seconds`](Timer::from_seconds). + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + duration: bevy::utils::Duration, + #[proxy] + mode: bevy::time::prelude::TimerMode, + ) -> bevy::time::prelude::Timer; + +"#, + r#" +/// Creates a new timer with a given duration in seconds. +/// # Example +/// ``` +/// # use bevy_time::*; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_seconds( + duration: f32, + #[proxy] + mode: bevy::time::prelude::TimerMode, + ) -> bevy::time::prelude::Timer; + +"#, + r#" +/// Returns `true` if the timer has reached its duration. +/// For repeating timers, this method behaves identically to [`Timer::just_finished`]. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut timer_once = Timer::from_seconds(1.0, TimerMode::Once); +/// timer_once.tick(Duration::from_secs_f32(1.5)); +/// assert!(timer_once.finished()); +/// timer_once.tick(Duration::from_secs_f32(0.5)); +/// assert!(timer_once.finished()); +/// let mut timer_repeating = Timer::from_seconds(1.0, TimerMode::Repeating); +/// timer_repeating.tick(Duration::from_secs_f32(1.1)); +/// assert!(timer_repeating.finished()); +/// timer_repeating.tick(Duration::from_secs_f32(0.8)); +/// assert!(!timer_repeating.finished()); +/// timer_repeating.tick(Duration::from_secs_f32(0.6)); +/// assert!(timer_repeating.finished()); +/// ``` + + #[lua(kind = "Method")] + fn finished(&self) -> bool; + +"#, + r#" +/// 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()); +/// ``` + + #[lua(kind = "Method")] + fn just_finished(&self) -> bool; + +"#, + r#" +/// Returns the time elapsed on the timer. Guaranteed to be between 0.0 and `duration`. +/// Will only equal `duration` when the timer is finished and non repeating. +/// See also [`Stopwatch::elapsed`](Stopwatch::elapsed). +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); +/// timer.tick(Duration::from_secs_f32(0.5)); +/// assert_eq!(timer.elapsed(), Duration::from_secs_f32(0.5)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn elapsed(&self) -> bevy::utils::Duration; + +"#, + r#" +/// Returns the time elapsed on the timer as an `f32`. +/// See also [`Timer::elapsed`](Timer::elapsed). + + #[lua(kind = "Method")] + fn elapsed_secs(&self) -> f32; + +"#, + r#" +/// Sets the elapsed time of the timer without any other considerations. +/// See also [`Stopwatch::set`](Stopwatch::set). +/// # +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); +/// timer.set_elapsed(Duration::from_secs(2)); +/// assert_eq!(timer.elapsed(), Duration::from_secs(2)); +/// // the timer is not finished even if the elapsed time is greater than the duration. +/// assert!(!timer.finished()); +/// ``` + + #[lua(kind = "MutatingMethod")] + fn set_elapsed(&mut self, #[proxy] time: bevy::utils::Duration) -> (); + +"#, + r#" +/// Returns the duration of the timer. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let timer = Timer::new(Duration::from_secs(1), TimerMode::Once); +/// assert_eq!(timer.duration(), Duration::from_secs(1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn duration(&self) -> bevy::utils::Duration; + +"#, + r#" +/// Sets the duration of the timer. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut timer = Timer::from_seconds(1.5, TimerMode::Once); +/// timer.set_duration(Duration::from_secs(1)); +/// assert_eq!(timer.duration(), Duration::from_secs(1)); +/// ``` + + #[lua(kind = "MutatingMethod")] + fn set_duration(&mut self, #[proxy] duration: bevy::utils::Duration) -> (); + +"#, + r#" +/// Returns the mode of the timer. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating); +/// assert_eq!(timer.mode(), TimerMode::Repeating); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn mode(&self) -> bevy::time::prelude::TimerMode; + +"#, + r#" +/// Sets the mode of the timer. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating); +/// timer.set_mode(TimerMode::Once); +/// assert_eq!(timer.mode(), TimerMode::Once); +/// ``` + + #[lua(kind = "MutatingMethod")] + fn set_mode(&mut self, #[proxy] mode: bevy::time::prelude::TimerMode) -> (); + +"#, + r#" +/// 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); +/// ``` + + #[lua(kind = "MutatingMethod")] + fn pause(&mut self) -> (); + +"#, + r#" +/// 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); +/// ``` + + #[lua(kind = "MutatingMethod")] + fn unpause(&mut self) -> (); + +"#, + r#" +/// 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()); +/// ``` + + #[lua(kind = "Method")] + fn paused(&self) -> bool; + +"#, + r#" +/// 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); +/// ``` + + #[lua(kind = "MutatingMethod")] + fn reset(&mut self) -> (); + +"#, + r#" +/// Returns the fraction 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.fraction(), 0.25); +/// ``` + + #[lua(kind = "Method")] + fn fraction(&self) -> f32; + +"#, + r#" +/// Returns the fraction 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.fraction_remaining(), 0.75); +/// ``` + + #[lua(kind = "Method")] + fn fraction_remaining(&self) -> f32; + +"#, + r#" +/// 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); +/// ``` + + #[lua(kind = "Method")] + fn remaining_secs(&self) -> f32; + +"#, + r#" +/// Returns the remaining time using Duration +/// # 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.remaining(), Duration::from_secs_f32(1.5)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn remaining(&self) -> bevy::utils::Duration; + +"#, + r#" +/// 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); +/// ``` + + #[lua(kind = "Method")] + fn times_finished_this_tick(&self) -> u32; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &timer::Timer) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Timer {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::time::prelude::TimerMode", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &timer::TimerMode) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::time::prelude::TimerMode; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct TimerMode {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::time::prelude::Virtual", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::time::prelude::Virtual; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Virtual {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::time::Stopwatch", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &stopwatch::Stopwatch) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::time::Stopwatch; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + 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() -> bevy::time::Stopwatch; + +"#, + r#" +/// Returns the elapsed time since the last [`reset`](Stopwatch::reset) +/// of the stopwatch. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut stopwatch = Stopwatch::new(); +/// stopwatch.tick(Duration::from_secs(1)); +/// assert_eq!(stopwatch.elapsed(), Duration::from_secs(1)); +/// ``` +/// # See Also +/// [`elapsed_secs`](Stopwatch::elapsed_secs) - if an `f32` value is desirable instead. +/// [`elapsed_secs_f64`](Stopwatch::elapsed_secs_f64) - if an `f64` is desirable instead. + + #[lua(kind = "Method", output(proxy))] + fn elapsed(&self) -> bevy::utils::Duration; + +"#, + 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(); +/// 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(kind = "Method")] + 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(kind = "Method")] + fn elapsed_secs_f64(&self) -> f64; + +"#, + r#" +/// Sets the elapsed time of the stopwatch. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut stopwatch = Stopwatch::new(); +/// stopwatch.set_elapsed(Duration::from_secs_f32(1.0)); +/// assert_eq!(stopwatch.elapsed_secs(), 1.0); +/// ``` + + #[lua(kind = "MutatingMethod")] + fn set_elapsed(&mut self, #[proxy] time: bevy::utils::Duration) -> (); + +"#, + 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(kind = "MutatingMethod")] + 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)); +/// stopwatch.unpause(); +/// stopwatch.tick(Duration::from_secs_f32(1.0)); +/// assert!(!stopwatch.paused()); +/// assert_eq!(stopwatch.elapsed_secs(), 1.0); +/// ``` + + #[lua(kind = "MutatingMethod")] + fn unpause(&mut self) -> (); + +"#, + r#" +/// 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()); +/// ``` + + #[lua(kind = "Method")] + 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); +/// ``` + + #[lua(kind = "MutatingMethod")] + fn reset(&mut self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Stopwatch {} +#[derive(Default)] +pub(crate) struct Globals; +impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { + 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<()> { + instances + .add_instance( + "Timer", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Stopwatch", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + Ok(()) + } +} +fn bevy_time_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut bevy_mod_scripting_lua::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyTimeScriptingPlugin; +impl bevy::app::Plugin for BevyTimeScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::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.add_context_initializer::<()>(bevy_time_context_initializer); + app.add_documentation_fragment( + bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + "BevyTimeAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaStopwatch, + >, + >() + }, + ), + ); + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs new file mode 100644 index 00000000..36948b0d --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs @@ -0,0 +1,716 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_ecs::*; +use super::bevy_reflect::*; +use super::bevy_core::*; +use super::bevy_hierarchy::*; +extern crate self as bevy_script_api; +use bevy_script_api::{ + lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, +}; +use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::transform::components::GlobalTransform", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul( + self, + #[proxy] + transform: bevy::transform::components::Transform, + ) -> bevy::transform::components::GlobalTransform; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::transform::components::GlobalTransform; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &components::global_transform::GlobalTransform) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul( + self, + #[proxy] + global_transform: bevy::transform::components::GlobalTransform, + ) -> bevy::transform::components::GlobalTransform; + +"#, + r#" + + #[lua(kind = "Function", output(proxy))] + fn from_xyz(x: f32, y: f32, z: f32) -> bevy::transform::components::GlobalTransform; + +"#, + r#" + + #[lua(kind = "Function", output(proxy))] + fn from_translation( + #[proxy] + translation: bevy::math::Vec3, + ) -> bevy::transform::components::GlobalTransform; + +"#, + r#" + + #[lua(kind = "Function", output(proxy))] + fn from_rotation( + #[proxy] + rotation: bevy::math::Quat, + ) -> bevy::transform::components::GlobalTransform; + +"#, + r#" + + #[lua(kind = "Function", output(proxy))] + fn from_scale( + #[proxy] + scale: bevy::math::Vec3, + ) -> bevy::transform::components::GlobalTransform; + +"#, + r#" +/// Returns the 3d affine transformation matrix as a [`Mat4`]. + + #[lua(kind = "Method", output(proxy))] + fn compute_matrix(&self) -> bevy::math::Mat4; + +"#, + r#" +/// Returns the 3d affine transformation matrix as an [`Affine3A`]. + + #[lua(kind = "Method", output(proxy))] + fn affine(&self) -> bevy::math::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(kind = "Method", 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: +/// ``` +/// # 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. + + #[lua(kind = "Method", output(proxy))] + fn reparented_to( + &self, + #[proxy] + parent: &components::global_transform::GlobalTransform, + ) -> bevy::transform::components::Transform; + +"#, + r#" +///Return the local right vector (X). + + #[lua(kind = "Method", output(proxy))] + fn right(&self) -> bevy::math::Vec3; + +"#, + r#" +///Return the local left vector (-X). + + #[lua(kind = "Method", output(proxy))] + fn left(&self) -> bevy::math::Vec3; + +"#, + r#" +///Return the local up vector (Y). + + #[lua(kind = "Method", output(proxy))] + fn up(&self) -> bevy::math::Vec3; + +"#, + r#" +///Return the local down vector (-Y). + + #[lua(kind = "Method", output(proxy))] + fn down(&self) -> bevy::math::Vec3; + +"#, + r#" +///Return the local back vector (Z). + + #[lua(kind = "Method", output(proxy))] + fn back(&self) -> bevy::math::Vec3; + +"#, + r#" +///Return the local forward vector (-Z). + + #[lua(kind = "Method", output(proxy))] + fn forward(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Get the translation as a [`Vec3`]. + + #[lua(kind = "Method", output(proxy))] + fn translation(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Get the translation as a [`Vec3A`]. + + #[lua(kind = "Method", output(proxy))] + fn translation_vec3a(&self) -> bevy::math::Vec3A; + +"#, + r#" +/// Get an upper bound of the radius from the given `extents`. + + #[lua(kind = "Method")] + fn radius_vec3a(&self, #[proxy] extents: bevy::math::Vec3A) -> f32; + +"#, + r#" +/// Transforms the given `point`, applying shear, scale, rotation and translation. +/// This moves `point` into the local space of this [`GlobalTransform`]. + + #[lua(kind = "Method", output(proxy))] + fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" +/// Multiplies `self` with `transform` component by component, returning the +/// resulting [`GlobalTransform`] + + #[lua(kind = "Method", output(proxy))] + fn mul_transform( + &self, + #[proxy] + transform: bevy::transform::components::Transform, + ) -> bevy::transform::components::GlobalTransform; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GlobalTransform(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::transform::components::Transform", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &components::transform::Transform) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul( + self, + #[proxy] + transform: bevy::transform::components::Transform, + ) -> bevy::transform::components::Transform; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::transform::components::Transform; + +"#, + 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) -> bevy::transform::components::Transform; + +"#, + 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::Mat4, + ) -> bevy::transform::components::Transform; + +"#, + 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::Vec3, + ) -> bevy::transform::components::Transform; + +"#, + 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::Quat, + ) -> bevy::transform::components::Transform; + +"#, + 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::Vec3, + ) -> bevy::transform::components::Transform; + +"#, + r#" +/// 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 + + #[lua(kind = "Method", output(proxy))] + fn looking_at( + self, + #[proxy] + target: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::transform::components::Transform; + +"#, + r#" +/// 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 + + #[lua(kind = "Method", output(proxy))] + fn looking_to( + self, + #[proxy] + direction: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::transform::components::Transform; + +"#, + r#" +/// Returns this [`Transform`] with a new translation. + + #[lua(kind = "Method", output(proxy))] + fn with_translation( + self, + #[proxy] + translation: bevy::math::Vec3, + ) -> bevy::transform::components::Transform; + +"#, + r#" +/// Returns this [`Transform`] with a new rotation. + + #[lua(kind = "Method", output(proxy))] + fn with_rotation( + self, + #[proxy] + rotation: bevy::math::Quat, + ) -> bevy::transform::components::Transform; + +"#, + r#" +/// Returns this [`Transform`] with a new scale. + + #[lua(kind = "Method", output(proxy))] + fn with_scale( + self, + #[proxy] + scale: bevy::math::Vec3, + ) -> bevy::transform::components::Transform; + +"#, + r#" +/// Returns the 3d affine transformation matrix from this transforms translation, +/// rotation, and scale. + + #[lua(kind = "Method", output(proxy))] + fn compute_matrix(&self) -> bevy::math::Mat4; + +"#, + r#" +/// Returns the 3d affine transformation matrix from this transforms translation, +/// rotation, and scale. + + #[lua(kind = "Method", output(proxy))] + fn compute_affine(&self) -> bevy::math::Affine3A; + +"#, + r#" +/// 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 + + #[lua(kind = "MutatingMethod")] + fn rotate(&mut self, #[proxy] rotation: bevy::math::Quat) -> (); + +"#, + r#" +/// 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. + + #[lua(kind = "MutatingMethod")] + fn rotate_axis(&mut self, #[proxy] axis: bevy::math::Vec3, angle: f32) -> (); + +"#, + r#" +/// 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. + + #[lua(kind = "MutatingMethod")] + fn rotate_x(&mut self, angle: f32) -> (); + +"#, + r#" +/// 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. + + #[lua(kind = "MutatingMethod")] + fn rotate_y(&mut self, angle: f32) -> (); + +"#, + r#" +/// 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. + + #[lua(kind = "MutatingMethod")] + fn rotate_z(&mut self, angle: f32) -> (); + +"#, + r#" +/// Rotates this [`Transform`] by the given `rotation`. +/// The `rotation` is relative to this [`Transform`]'s current rotation. + + #[lua(kind = "MutatingMethod")] + fn rotate_local(&mut self, #[proxy] rotation: bevy::math::Quat) -> (); + +"#, + r#" +/// Rotates this [`Transform`] around its local `axis` by `angle` (in radians). + + #[lua(kind = "MutatingMethod")] + fn rotate_local_axis(&mut self, #[proxy] axis: bevy::math::Vec3, angle: f32) -> (); + +"#, + r#" +/// Rotates this [`Transform`] around its local `X` axis by `angle` (in radians). + + #[lua(kind = "MutatingMethod")] + fn rotate_local_x(&mut self, angle: f32) -> (); + +"#, + r#" +/// Rotates this [`Transform`] around its local `Y` axis by `angle` (in radians). + + #[lua(kind = "MutatingMethod")] + fn rotate_local_y(&mut self, angle: f32) -> (); + +"#, + r#" +/// Rotates this [`Transform`] around its local `Z` axis by `angle` (in radians). + + #[lua(kind = "MutatingMethod")] + fn rotate_local_z(&mut self, angle: f32) -> (); + +"#, + r#" +/// Translates this [`Transform`] around a `point` in space. +/// If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent. + + #[lua(kind = "MutatingMethod")] + fn translate_around( + &mut self, + #[proxy] + point: bevy::math::Vec3, + #[proxy] + rotation: bevy::math::Quat, + ) -> (); + +"#, + r#" +/// Rotates this [`Transform`] around a `point` in space. +/// If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent. + + #[lua(kind = "MutatingMethod")] + fn rotate_around( + &mut self, + #[proxy] + point: bevy::math::Vec3, + #[proxy] + rotation: bevy::math::Quat, + ) -> (); + +"#, + r#" +/// 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 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(kind = "MutatingMethod")] + fn look_at( + &mut self, + #[proxy] + target: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> (); + +"#, + r#" +/// 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 + + #[lua(kind = "MutatingMethod")] + fn look_to( + &mut self, + #[proxy] + direction: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> (); + +"#, + r#" +/// Multiplies `self` with `transform` component by component, returning the +/// resulting [`Transform`] + + #[lua(kind = "Method", output(proxy))] + fn mul_transform( + &self, + #[proxy] + transform: bevy::transform::components::Transform, + ) -> bevy::transform::components::Transform; + +"#, + r#" +/// 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. + + #[lua(kind = "Method", output(proxy))] + fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" +/// Returns `true` if, and only if, translation, rotation and scale all are +/// finite. If any of them contains a `NaN`, positive or negative infinity, +/// this will return `false`. + + #[lua(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul( + self, + #[proxy] + global_transform: bevy::transform::components::GlobalTransform, + ) -> bevy::transform::components::GlobalTransform; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Transform { + #[lua(output(proxy))] + translation: bevy::math::Vec3, + #[lua(output(proxy))] + rotation: bevy::math::Quat, + #[lua(output(proxy))] + scale: bevy::math::Vec3, +} +#[derive(Default)] +pub(crate) struct Globals; +impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { + 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<()> { + instances + .add_instance( + "GlobalTransform", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaGlobalTransform, + >::new, + )?; + instances + .add_instance( + "Transform", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + Ok(()) + } +} +fn bevy_transform_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut bevy_mod_scripting_lua::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyTransformScriptingPlugin; +impl bevy::app::Plugin for BevyTransformScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.add_context_initializer::<()>(bevy_transform_context_initializer); + app.add_documentation_fragment( + bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + "BevyTransformAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaGlobalTransform, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaTransform, + >, + >() + }, + ), + ); + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs new file mode 100644 index 00000000..8c02027d --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs @@ -0,0 +1,1624 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_ecs::*; +use super::bevy_reflect::*; +use super::bevy_input::*; +extern crate self as bevy_script_api; +use bevy_script_api::{ + lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, +}; +use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::prelude::CursorEntered", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::CursorEntered) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::CursorEntered; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct CursorEntered { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::prelude::CursorIcon", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &cursor::CursorIcon) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::CursorIcon; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct CursorIcon {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::prelude::CursorLeft", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::CursorLeft) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::CursorLeft; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct CursorLeft { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::prelude::CursorMoved", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::CursorMoved) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::CursorMoved; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct CursorMoved { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, + #[lua(output(proxy))] + position: bevy::math::Vec2, + delta: ReflectedValue, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::prelude::FileDragAndDrop", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::FileDragAndDrop; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::FileDragAndDrop) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct FileDragAndDrop {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::prelude::Ime", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::Ime; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::Ime) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Ime {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::prelude::MonitorSelection", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::MonitorSelection) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::MonitorSelection; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct MonitorSelection {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::prelude::ReceivedCharacter", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::ReceivedCharacter; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::ReceivedCharacter) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ReceivedCharacter { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, + #[lua(output(proxy))] + char: smol_str::SmolStr, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::prelude::Window", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::Window; + +"#, + r#" +/// Setting to true will attempt to maximize the window. +/// Setting to false will attempt to un-maximize the window. + + #[lua(kind = "MutatingMethod")] + fn set_maximized(&mut self, maximized: bool) -> (); + +"#, + r#" +/// Setting to true will attempt to minimize the window. +/// Setting to false will attempt to un-minimize the window. + + #[lua(kind = "MutatingMethod")] + fn set_minimized(&mut self, minimized: bool) -> (); + +"#, + r#" +/// The window's client area width in logical pixels. +/// See [`WindowResolution`] for an explanation about logical/physical sizes. + + #[lua(kind = "Method")] + fn width(&self) -> f32; + +"#, + r#" +/// The window's client area height in logical pixels. +/// See [`WindowResolution`] for an explanation about logical/physical sizes. + + #[lua(kind = "Method")] + fn height(&self) -> f32; + +"#, + r#" +/// The window's client area width in physical pixels. +/// See [`WindowResolution`] for an explanation about logical/physical sizes. + + #[lua(kind = "Method")] + fn physical_width(&self) -> u32; + +"#, + r#" +/// The window's client area height in physical pixels. +/// See [`WindowResolution`] for an explanation about logical/physical sizes. + + #[lua(kind = "Method")] + fn physical_height(&self) -> u32; + +"#, + r#" +/// The window's scale factor. +/// Ratio of physical size to logical size, see [`WindowResolution`]. + + #[lua(kind = "Method")] + fn scale_factor(&self) -> f32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Window { + #[lua(output(proxy))] + cursor: bevy::window::Cursor, + #[lua(output(proxy))] + present_mode: bevy::window::PresentMode, + #[lua(output(proxy))] + mode: bevy::window::WindowMode, + #[lua(output(proxy))] + position: bevy::window::prelude::WindowPosition, + #[lua(output(proxy))] + resolution: bevy::window::WindowResolution, + title: std::string::String, + name: std::option::Option, + #[lua(output(proxy))] + composite_alpha_mode: bevy::window::CompositeAlphaMode, + #[lua(output(proxy))] + resize_constraints: bevy::window::prelude::WindowResizeConstraints, + resizable: bool, + #[lua(output(proxy))] + enabled_buttons: bevy::window::EnabledButtons, + decorations: bool, + transparent: bool, + focused: bool, + #[lua(output(proxy))] + window_level: bevy::window::WindowLevel, + canvas: std::option::Option, + prevent_default_event_handling: bool, + #[lua(output(proxy))] + internal: bevy::window::InternalWindowState, + ime_enabled: bool, + #[lua(output(proxy))] + ime_position: bevy::math::Vec2, + window_theme: ReflectedValue, + visible: bool, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::prelude::WindowMoved", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowMoved) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::WindowMoved; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowMoved { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, + #[lua(output(proxy))] + position: bevy::math::IVec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::prelude::WindowPosition", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::WindowPosition; + +"#, + r#" +/// Creates a new [`WindowPosition`] at a position. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + position: bevy::math::IVec2, + ) -> bevy::window::prelude::WindowPosition; + +"#, + r#" +/// Set the position to a specific point. + + #[lua(kind = "MutatingMethod")] + fn set(&mut self, #[proxy] position: bevy::math::IVec2) -> (); + +"#, + r#" +/// Set the window to a specific monitor. + + #[lua(kind = "MutatingMethod")] + fn center( + &mut self, + #[proxy] + monitor: bevy::window::prelude::MonitorSelection, + ) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowPosition) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowPosition {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::prelude::WindowResizeConstraints", + functions[r#" +/// Checks if the constraints are valid. +/// Will output warnings if it isn't. + + #[lua(kind = "Method", output(proxy))] + fn check_constraints(&self) -> bevy::window::prelude::WindowResizeConstraints; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowResizeConstraints) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::WindowResizeConstraints; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowResizeConstraints { + min_width: f32, + min_height: f32, + max_width: f32, + max_height: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowResized", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowResized) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowResized; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowResized { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, + width: f32, + height: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowCreated", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowCreated) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowCreated; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowCreated { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowClosed", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowClosed; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowClosed) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowClosed { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowCloseRequested", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowCloseRequested; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowCloseRequested) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowCloseRequested { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowDestroyed", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowDestroyed) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowDestroyed; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowDestroyed { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::RequestRedraw", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::RequestRedraw) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::RequestRedraw; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct RequestRedraw {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowFocused", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowFocused) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowFocused; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowFocused { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, + focused: bool, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowOccluded", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowOccluded) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowOccluded; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowOccluded { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, + occluded: bool, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowScaleFactorChanged", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowScaleFactorChanged; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowScaleFactorChanged) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowScaleFactorChanged { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, + scale_factor: f64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowBackendScaleFactorChanged", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowBackendScaleFactorChanged; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowBackendScaleFactorChanged) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowBackendScaleFactorChanged { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, + scale_factor: f64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowThemeChanged", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowThemeChanged; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowThemeChanged) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowThemeChanged { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, + #[lua(output(proxy))] + theme: bevy::window::WindowTheme, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::ApplicationLifetime", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::ApplicationLifetime; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::ApplicationLifetime) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ApplicationLifetime {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::PrimaryWindow", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::PrimaryWindow; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::PrimaryWindow) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct PrimaryWindow {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::Cursor", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::Cursor; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Cursor { + #[lua(output(proxy))] + icon: bevy::window::prelude::CursorIcon, + visible: bool, + #[lua(output(proxy))] + grab_mode: bevy::window::CursorGrabMode, + hit_test: bool, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::CursorGrabMode", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::CursorGrabMode) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::CursorGrabMode; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct CursorGrabMode {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::CompositeAlphaMode", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::CompositeAlphaMode; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::CompositeAlphaMode) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct CompositeAlphaMode {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowResolution", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowResolution) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowResolution; + +"#, + r#" +/// Creates a new [`WindowResolution`]. + + #[lua(kind = "Function", output(proxy))] + fn new(logical_width: f32, logical_height: f32) -> bevy::window::WindowResolution; + +"#, + r#" +/// Builder method for adding a scale factor override to the resolution. + + #[lua(kind = "Method", output(proxy))] + fn with_scale_factor_override( + self, + scale_factor_override: f32, + ) -> bevy::window::WindowResolution; + +"#, + r#" +/// The window's client area width in logical pixels. + + #[lua(kind = "Method")] + fn width(&self) -> f32; + +"#, + r#" +/// The window's client area height in logical pixels. + + #[lua(kind = "Method")] + fn height(&self) -> f32; + +"#, + r#" +/// The window's client area width in physical pixels. + + #[lua(kind = "Method")] + fn physical_width(&self) -> u32; + +"#, + r#" +/// The window's client area height in physical pixels. + + #[lua(kind = "Method")] + fn physical_height(&self) -> u32; + +"#, + r#" +/// The ratio of physical pixels to logical pixels. +/// `physical_pixels = logical_pixels * scale_factor` + + #[lua(kind = "Method")] + fn scale_factor(&self) -> f32; + +"#, + r#" +/// The window scale factor as reported by the window backend. +/// This value is unaffected by [`WindowResolution::scale_factor_override`]. + + #[lua(kind = "Method")] + fn base_scale_factor(&self) -> f32; + +"#, + r#" +/// The scale factor set with [`WindowResolution::set_scale_factor_override`]. +/// This value may be different from the scale factor reported by the window backend. + + #[lua(kind = "Method")] + fn scale_factor_override(&self) -> std::option::Option; + +"#, + r#" +/// Set the window's logical resolution. + + #[lua(kind = "MutatingMethod")] + fn set(&mut self, width: f32, height: f32) -> (); + +"#, + r#" +/// Set the window's physical resolution. +/// This will ignore the scale factor setting, so most of the time you should +/// prefer to use [`WindowResolution::set`]. + + #[lua(kind = "MutatingMethod")] + fn set_physical_resolution(&mut self, width: u32, height: u32) -> (); + +"#, + r#" +/// Set the window's scale factor, this may get overridden by the backend. + + #[lua(kind = "MutatingMethod")] + fn set_scale_factor(&mut self, scale_factor: f32) -> (); + +"#, + r#" +/// Set the window's scale factor, this will be used over what the backend decides. +/// This can change the logical and physical sizes if the resulting physical +/// size is not within the limits. + + #[lua(kind = "MutatingMethod")] + fn set_scale_factor_override( + &mut self, + scale_factor_override: std::option::Option, + ) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowResolution {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowMode", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowMode) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowMode; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowMode {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowLevel", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowLevel) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowLevel; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowLevel {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::PresentMode", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::PresentMode) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::PresentMode; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct PresentMode {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::InternalWindowState", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::InternalWindowState; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::InternalWindowState) -> bool; + +"#, + r#" +/// Consumes the current maximize request, if it exists. This should only be called by window backends. + + #[lua(kind = "MutatingMethod")] + fn take_maximize_request(&mut self) -> std::option::Option; + +"#, + r#" +/// Consumes the current minimize request, if it exists. This should only be called by window backends. + + #[lua(kind = "MutatingMethod")] + fn take_minimize_request(&mut self) -> std::option::Option; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct InternalWindowState {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowTheme", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowTheme; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowTheme) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowTheme {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::EnabledButtons", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::EnabledButtons; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::EnabledButtons) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct EnabledButtons { + minimize: bool, + maximize: bool, + close: bool, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::WindowRef", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowRef; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct WindowRef {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + remote = "bevy::window::NormalizedWindowRef", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::NormalizedWindowRef; + +"#, + r#" +/// Fetch the entity of this window reference + + #[lua(kind = "Method", output(proxy))] + fn entity(&self) -> bevy::ecs::entity::Entity; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::NormalizedWindowRef) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct NormalizedWindowRef(); +#[derive(Default)] +pub(crate) struct Globals; +impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { + 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<()> { + instances + .add_instance( + "WindowPosition", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaWindowPosition, + >::new, + )?; + instances + .add_instance( + "WindowResolution", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaWindowResolution, + >::new, + )?; + Ok(()) + } +} +fn bevy_window_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut bevy_mod_scripting_lua::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyWindowScriptingPlugin; +impl bevy::app::Plugin for BevyWindowScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::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::< + bevy::window::prelude::WindowResizeConstraints, + >(); + 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::(); + 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.add_context_initializer::<()>(bevy_window_context_initializer); + app.add_documentation_fragment( + bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + "BevyWindowAPI", + |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::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaWindowPosition, + >, + >() + .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::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaWindowResolution, + >, + >() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + }, + ), + ); + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/mod.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/mod.rs index 6dcdc78e..69711bee 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/mod.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/mod.rs @@ -1,19 +1,26 @@ -use bevy_mod_scripting_lua_derive::LuaProxy; -use tealr::mlu::mlua::{Lua, UserData}; - -#[derive(LuaProxy)] -#[proxy(bms_lua_path = "crate", bms_core_path = "bevy_mod_scripting_core")] -#[proxy(functions[r#" -fn hello2(asd: usize, asd2: usize) -> (); - -"#])] -pub struct Vec3 { - pub x: f32, - pub y: f32, - pub z: f32, -} - -impl Vec3 { - pub fn hello() {} - pub fn hello2(asd: usize, asd2: usize) {} +// @generated by cargo bevy-api-gen collect, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +pub(crate) mod bevy_ecs; +pub(crate) mod bevy_transform; +pub(crate) mod bevy_input; +pub(crate) mod bevy_core; +pub(crate) mod bevy_time; +pub(crate) mod bevy_hierarchy; +pub(crate) mod bevy_window; +pub(crate) mod bevy_reflect; +extern crate self as bevy_script_api; +pub struct LuaBevyScriptingPlugin; +impl bevy::app::Plugin for LuaBevyScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + bevy_ecs::BevyEcsScriptingPlugin.build(app); + bevy_transform::BevyTransformScriptingPlugin.build(app); + bevy_input::BevyInputScriptingPlugin.build(app); + bevy_core::BevyCoreScriptingPlugin.build(app); + bevy_time::BevyTimeScriptingPlugin.build(app); + bevy_hierarchy::BevyHierarchyScriptingPlugin.build(app); + bevy_window::BevyWindowScriptingPlugin.build(app); + bevy_reflect::BevyReflectScriptingPlugin.build(app); + } } diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs index e9859c03..f085faec 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs @@ -15,12 +15,12 @@ pub trait LuaProxied { type Proxy; } -pub struct LuaNonReflectProxy(pub ValProxy); -pub struct LuaValProxy(pub ReflectValProxy); -pub struct LuaRefProxy(pub ReflectRefProxy); -pub struct LuaRefMutProxy(pub ReflectRefMutProxy); +pub struct LuaValProxy(pub ValProxy); +pub struct LuaReflectValProxy(pub ReflectValProxy); +pub struct LuaReflectRefProxy(pub ReflectRefProxy); +pub struct LuaReflectRefMutProxy(pub ReflectRefMutProxy); -macro_rules! impl_lua_proxy { +macro_rules! impl_lua_unproxy { ($ty:ident as $as:ident => $generic:tt : $($bounds:path),* $(| T::Proxy: $($proxy_bounds:tt)*)?) => { impl<'w, 'c, $generic:'c> Unproxy<'w, 'c> for $ty<$generic> where @@ -67,22 +67,40 @@ macro_rules! impl_lua_proxy { Ok(Self(inner)) } } + + impl<'lua, $generic: LuaProxied> IntoLua<'lua> for $ty<$generic> + where + $generic::Proxy: IntoLua<'lua>, + { + fn into_lua(self, lua: &'lua Lua) -> tealr::mlu::mlua::prelude::LuaResult> { + self.0.0.into_lua(lua) + } + } }; } -impl<'lua, T: LuaProxied> IntoLua<'lua> for LuaNonReflectProxy -where - T::Proxy: IntoLua<'lua>, -{ - fn into_lua(self, lua: &'lua Lua) -> tealr::mlu::mlua::prelude::LuaResult> { - todo!() - } +macro_rules! impl_lua_proxy { + ($ty:ident as $as:ident => $generic:tt : $($bounds:path),* $(| T::Proxy: $($proxy_bounds:tt)*)?) => { + impl<'a,$generic> bevy_mod_scripting_core::proxy::Proxy<'a> for $ty<$generic> + where + T::Proxy: $($($proxy_bounds)*)?, + T: $($bounds+)*, + { + type Input=<$as<$generic, $generic::Proxy> as bevy_mod_scripting_core::proxy::Proxy<'a>>::Input; + fn proxy(value: Self::Input) -> Result { + Ok(Self($as::<$generic,$generic::Proxy>::proxy(value)?)) + } + } + }; } -impl_lua_proxy!(LuaNonReflectProxy as ValProxy => T : LuaProxied,From<&'c T::Proxy>); -impl_lua_proxy!(LuaValProxy as ReflectValProxy => T : LuaProxied,FromReflect | T::Proxy: AsRef); -impl_lua_proxy!(LuaRefProxy as ReflectRefProxy => T : LuaProxied,Reflect | T::Proxy: AsRef); -impl_lua_proxy!(LuaRefMutProxy as ReflectRefMutProxy => T: LuaProxied,Reflect | T::Proxy: AsRef); +impl_lua_proxy!(LuaValProxy as ValProxy => T : LuaProxied | T::Proxy: From); +impl_lua_proxy!(LuaReflectValProxy as ReflectValProxy => T : LuaProxied,Reflect | T::Proxy: From ); + +impl_lua_unproxy!(LuaValProxy as ValProxy => T : LuaProxied,From<&'c T::Proxy>); +impl_lua_unproxy!(LuaReflectValProxy as ReflectValProxy => T : LuaProxied,FromReflect | T::Proxy: AsRef); +impl_lua_unproxy!(LuaReflectRefProxy as ReflectRefProxy => T : LuaProxied,Reflect | T::Proxy: AsRef); +impl_lua_unproxy!(LuaReflectRefMutProxy as ReflectRefMutProxy => T: LuaProxied,Reflect | T::Proxy: AsRef); #[cfg(test)] mod test { @@ -154,7 +172,7 @@ mod test { impl UserData for TestProxy { fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) { - methods.add_method("set", |_lua, _self_, _val: LuaRefProxy| Ok(())) + methods.add_method("set", |_lua, _self_, _val: LuaReflectRefProxy| Ok(())) } } diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs index ce3a9c1a..b3c9f80d 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs @@ -49,7 +49,7 @@ mod test { use tealr::mlu::mlua::Lua; use super::*; - use crate::bindings::proxy::LuaNonReflectProxy; + use crate::bindings::proxy::LuaValProxy; use tealr::mlu::mlua::IntoLua; #[test] @@ -58,13 +58,12 @@ mod test { let world_access_guard = Arc::new(WorldAccessGuard::new(&mut world)); let callback_access = unsafe { WorldCallbackAccess::new(Arc::downgrade(&world_access_guard)) }; - let proxy = - LuaNonReflectProxy::(ValProxy::new(LuaWorld(callback_access))); + let proxy = LuaValProxy::(ValProxy::new(LuaWorld(callback_access))); let lua = Lua::new(); let lua_val = proxy.into_lua(&lua).unwrap(); - let mut val = LuaNonReflectProxy::::from_lua(lua_val, &lua).unwrap(); + let mut val = LuaValProxy::::from_lua(lua_val, &lua).unwrap(); - let val = val.unproxy().unwrap(); + let _val = val.unproxy().unwrap(); } } diff --git a/crates/languages/bevy_mod_scripting_lua/src/lib.rs b/crates/languages/bevy_mod_scripting_lua/src/lib.rs index 0deea728..685aa9a0 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/lib.rs @@ -14,6 +14,7 @@ use bevy_mod_scripting_core::{ script::ScriptId, ScriptingPlugin, }; +use bindings::world::LuaWorld; pub use tealr; pub mod bindings; use tealr::mlu::mlua::{Function, IntoLuaMulti, Lua}; @@ -140,10 +141,8 @@ pub fn with_world Result<(), ScriptError>>( f: F, ) -> Result<(), ScriptError> { WorldCallbackAccess::with_callback_access(world, |guard| { - context - .create_any_userdata(guard.clone()) - .and_then(|guard| context.globals().set("world", guard))?; - + context.globals().set("world", LuaWorld(guard.clone())); + // TODO set entity + script id as well f(context) }) } diff --git a/crates/languages/bevy_mod_scripting_lua/src/util.rs b/crates/languages/bevy_mod_scripting_lua/src/util.rs index 00357a8d..25758547 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/util.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/util.rs @@ -160,7 +160,7 @@ macro_rules! impl_userdata_from_lua { impl<'lua> FromLua<'lua> for $ty { fn from_lua( value: ::tealr::mlu::mlua::Value<'lua>, - lua: &::tealr::mlu::mlua::Lua, + _lua: &::tealr::mlu::mlua::Lua, ) -> Result { match value { tealr::mlu::mlua::Value::UserData(ud) => Ok(ud.borrow::()?.clone()), diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs index c1f2fa0e..4039619d 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -38,9 +38,9 @@ fn standardise_receiver<'a>(receiver: &mut FnArg, target_type_ident: &Ident, bms let self_ident = syn::Ident::new(SELF_ALIAS, receiver.span()); let unproxy_container_name = match (ref_.is_some(), receiver.mutability.is_some()) { - (true, true) => "LuaRefMutProxy", - (true, false) => "LuaRefProxy", - (false, _) => "ValLuProxy", + (true, true) => "LuaReflectRefMutProxy", + (true, false) => "LuaReflectRefProxy", + (false, _) => "LuaReflectValProxy", }; Some(syn::FnArg::Typed(parse_quote_spanned! {receiver.span()=> @@ -180,8 +180,8 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { // wrap function body in our unwrapping and wrapping logic, ignore pre-existing body f.default = Some(parse_quote_spanned! {span=> { - let mut world: #bms_lua::bindings::proxy::LuaNonReflectProxy<#bms_core::bindings::WorldCallbackAccess> = lua.globals().get("world")?; - let mut world = <#bms_lua::bindings::proxy::LuaNonReflectProxy<#bms_core::bindings::WorldCallbackAccess> as #bms_core::proxy::Unproxy>::unproxy(&mut world).map_err(#mlua::Error::external)?; + let mut world: #bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> = lua.globals().get("world")?; + let mut world = <#bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> as #bms_core::proxy::Unproxy>::unproxy(&mut world).map_err(#mlua::Error::external)?; let mut world = world.read().ok_or_else(|| #mlua::Error::external("World no longer exists"))?; // get allocator and type registry @@ -190,10 +190,10 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let allocator_resource_id = cell.components().resource_id::<#bms_core::allocator::ReflectAllocator>().expect("Reflect Allocator wasn't initialized"); let type_registry_resource_id = cell.components().resource_id::().expect("Type Registry wasn't initialized"); - let allocator_access = world.get_access(allocator_resource_id.into()).expect("Deadlock while accessing allocator"); + let mut allocator_access = world.get_access(allocator_resource_id.into()).expect("Deadlock while accessing allocator"); let type_registry_access = world.get_access(type_registry_resource_id.into()).expect("Deadlock while accessing type registry"); - let allocator = world.get_resource::<#bms_core::allocator::ReflectAllocator>(&allocator_access).unwrap().unwrap(); + let mut allocator = world.get_resource_mut::<#bms_core::allocator::ReflectAllocator>(&mut allocator_access).unwrap().unwrap(); let type_registry = world.get_resource::(&type_registry_access).unwrap().unwrap(); let type_registry = type_registry.read(); let mut world_acceses = Vec::default(); @@ -202,8 +202,10 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { // call proxy function let out = #target_type_ident::#func_name(#(#original_arg_idents),*); + let out = <#out_type as #bms_core::proxy::Proxy>::proxy_with_allocator(out, &mut allocator).map_err(#mlua::Error::external)?; + // TODO: output proxies - Ok(<#out_type as #bms_core::proxy::Proxy>::proxy(out)) + Ok(out) } }); diff --git a/makefile b/makefile index 2a39b284..6dc18e84 100644 --- a/makefile +++ b/makefile @@ -28,7 +28,7 @@ CODEGEN_PATH=${PWD}/target/codegen BEVY_PATH=${CODEGEN_PATH}/bevy GLAM_PATH=${CODEGEN_PATH}/glam OUTPUT_PATH=${CODEGEN_PATH}/output -GENERATED_SRC_PATH=./crates/bevy_script_api/src/providers +GENERATED_SRC_PATH=./crates/languages/bevy_mod_scripting_lua/src/bindings/providers GEN_BEVY_FEATURES=bevy_asset,bevy_gltf,bevy_animation,bevy_core_pipeline,bevy_ui,bevy_pbr,bevy_render,bevy_text,bevy_sprite,file_watcher,multi-threaded build_test_in_package: From 98989a9952b8ec960cf5be3056c9a02451fa8ab0 Mon Sep 17 00:00:00 2001 From: makspll Date: Sun, 21 Apr 2024 20:16:12 +0100 Subject: [PATCH 10/17] More work on migrating doc gen --- crates/bevy_api_gen/templates/footer.tera | 22 +- crates/bevy_api_gen/templates/function.tera | 11 +- crates/bevy_api_gen/templates/header.tera | 4 - crates/bevy_api_gen/templates/item.tera | 7 +- crates/bevy_api_gen/templates/macros.tera | 16 +- crates/bevy_api_gen/templates/mod.tera | 4 - .../src/bindings/providers/bevy_core.rs | 35 +- .../src/bindings/providers/bevy_ecs.rs | 139 +- .../src/bindings/providers/bevy_hierarchy.rs | 45 +- .../src/bindings/providers/bevy_input.rs | 613 +- .../src/bindings/providers/bevy_reflect.rs | 7970 ++++++----------- .../src/bindings/providers/bevy_time.rs | 170 +- .../src/bindings/providers/bevy_transform.rs | 210 +- .../src/bindings/providers/bevy_window.rs | 674 +- .../src/bindings/providers/mod.rs | 1 - .../src/bindings/proxy.rs | 13 +- .../bevy_mod_scripting_lua_derive/src/lib.rs | 87 +- makefile | 4 +- 18 files changed, 3593 insertions(+), 6432 deletions(-) diff --git a/crates/bevy_api_gen/templates/footer.tera b/crates/bevy_api_gen/templates/footer.tera index 05083f92..bdf763fc 100644 --- a/crates/bevy_api_gen/templates/footer.tera +++ b/crates/bevy_api_gen/templates/footer.tera @@ -1,15 +1,21 @@ +{% if args.self_is_bms_lua %} +{% set bms_lua_path="crate" %} +{% else %} +{% set bms_lua_path="bevy_mod_scripting::lua"%} +{% endif %} + #[derive(Default)] pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - fn add_instances<'lua, T: bevy_mod_scripting_lua::tealr::mlu::InstanceCollector<'lua>>( +impl {{bms_lua_path}}::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: {{bms_lua_path}}::tealr::mlu::InstanceCollector<'lua>>( self, instances: &mut T, - ) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> { + ) -> {{bms_lua_path}}::tealr::mlu::mlua::Result<()> { {% for item in items %} {% if item.has_static_methods %} instances.add_instance("{{ item.ident }}", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::<{{item.ident | prefix_lua}}>::new)?; + {{bms_lua_path}}::tealr::mlu::UserDataProxy::<{{item.ident | prefix_lua}}>::new)?; {% endif %} {% endfor %} Ok(()) @@ -17,8 +23,8 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { } -fn {{ "ContextInitializer" | prefix_cratename | convert_case(case="snake") }} (_: &bevy_mod_scripting_core::script::ScriptId, ctx: &mut bevy_mod_scripting_lua::prelude::Lua) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; +fn {{ "ContextInitializer" | prefix_cratename | convert_case(case="snake") }} (_: &bevy_mod_scripting_core::script::ScriptId, ctx: &mut {{bms_lua_path}}::prelude::Lua) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + {{bms_lua_path}}::tealr::mlu::set_global_env(Globals, ctx)?; Ok(()) } @@ -31,13 +37,13 @@ impl bevy::app::Plugin for {{ "ScriptingPlugin" | prefix_cratename | convert_cas {% endfor %} app.add_context_initializer::<()>({{ "ContextInitializer" | prefix_cratename | convert_case(case="snake") }}); app.add_documentation_fragment( - bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new("{{ "A P I" | prefix_cratename | convert_case(case="upper_camel") }}", |tw| { + {{bms_lua_path}}::docs::LuaDocumentationFragment::new("{{ "A P I" | prefix_cratename | convert_case(case="upper_camel") }}", |tw| { tw .document_global_instance::().expect("Something went wrong documenting globals") {% for item in items %} .process_type::<{{ item.ident | prefix_lua }}>() {% if item.has_static_methods %} - .process_type::>() + .process_type::<{{bms_lua_path}}::tealr::mlu::UserDataProxy<{{ item.ident | prefix_lua }}>>() {% endif %} {% endfor %} } diff --git a/crates/bevy_api_gen/templates/function.tera b/crates/bevy_api_gen/templates/function.tera index a525af9b..b8bc2637 100644 --- a/crates/bevy_api_gen/templates/function.tera +++ b/crates/bevy_api_gen/templates/function.tera @@ -13,6 +13,11 @@ r#" as_trait="{{ function.from_trait_path }}", {%- endif -%} +{% if is_op %} +composite="{{ function.ident }}", +{% endif %} + +{# {% if function.has_self and not is_op %} kind="{% if function.args.0.ty is starting_with("&mut") %}Mutating{% endif %}Method", {% elif is_op %} @@ -25,9 +30,7 @@ kind="Function", output(proxy), {%- endif -%} -{% if is_op %} -composite="{{ function.ident }}", -{% endif %} + {% if function.from_trait_path == "std::ops::Neg" %} metamethod="Unm", @@ -44,7 +47,7 @@ metamethod="Mod", {% elif function.from_trait_path == "std::cmp::PartialEq" %} metamethod="Eq", {% endif %} - +#} )] {% if function.is_unsafe %}unsafe {% endif -%}fn {{ function.ident }} ( {%- filter separated(delimeter=", ", split_at="---", ignore_first=true) -%} diff --git a/crates/bevy_api_gen/templates/header.tera b/crates/bevy_api_gen/templates/header.tera index 67f3dbe4..c71af291 100644 --- a/crates/bevy_api_gen/templates/header.tera +++ b/crates/bevy_api_gen/templates/header.tera @@ -8,9 +8,5 @@ use super::{{crate}}::*; {% endif %} {% endfor %} -{% if args.self_is_bevy_script_api %} -extern crate self as bevy_script_api; -{% endif %} -use bevy_script_api::{lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld}; use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; \ No newline at end of file diff --git a/crates/bevy_api_gen/templates/item.tera b/crates/bevy_api_gen/templates/item.tera index f1446d51..b11b90d0 100644 --- a/crates/bevy_api_gen/templates/item.tera +++ b/crates/bevy_api_gen/templates/item.tera @@ -6,6 +6,11 @@ #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote="{{ item.import_path }}", +{% if args.self_is_bms_lua %} +bms_core_path="bevy_mod_scripting_core", +bms_lua_path="crate", +{% endif %} + functions[ {%- filter separated(delimeter=",\n\t\t\t", split_at="---", ignore_first=true) -%} {%- for function in item.functions -%} @@ -71,7 +76,7 @@ functions[ {% set close_item = "}" %} {% endif %} -pub struct {{ item.ident -}} {{ open_item }} +pub struct {{ item.ident | prefix_lua -}} {{ open_item }} {% if not item.is_enum %} {% for field in item.variants[0].fields %} {% if field.reflection_strategy != "Filtered" %} diff --git a/crates/bevy_api_gen/templates/macros.tera b/crates/bevy_api_gen/templates/macros.tera index 4e75fc50..0cd829e1 100644 --- a/crates/bevy_api_gen/templates/macros.tera +++ b/crates/bevy_api_gen/templates/macros.tera @@ -1,22 +1,22 @@ {% macro vector_index(num_type) %} -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result<{{ num_type }},_> { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } {% endmacro vector_index %} {% macro vector_newindex(num_type) %} -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: {{ num_type }}) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } {% endmacro vector_newindex %} {% macro matrix_index(col_type, mat_type) %} -#[lua(kind = "MetaMethod", raw, metamethod="Index")] +#[lua(raw, metamethod="Index")] fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result<{{ col_type | prefix_lua }},_> { Ok({{ col_type | prefix_lua }}::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ label:"col", get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ path: "".to_owned(), @@ -38,14 +38,14 @@ fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result<{{ col_ty {% endmacro matrix_index %} {% macro debug_as_to_string() %} -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } {% endmacro debug_as_to_string %} {% macro display_as_to_string() %} -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } diff --git a/crates/bevy_api_gen/templates/mod.tera b/crates/bevy_api_gen/templates/mod.tera index 7f7a7ed7..44530bb5 100644 --- a/crates/bevy_api_gen/templates/mod.tera +++ b/crates/bevy_api_gen/templates/mod.tera @@ -7,10 +7,6 @@ pub(crate) mod {{ crate.name }}; {% endfor -%} -{% if args.self_is_bevy_script_api %} -extern crate self as bevy_script_api; -{% endif %} - pub struct {{ api_name }}; impl bevy::app::Plugin for {{ api_name }} { diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs index 66488afd..a15b602a 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs @@ -4,54 +4,47 @@ #![cfg_attr(rustfmt, rustfmt_skip)] use super::bevy_ecs::*; use super::bevy_reflect::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::core::prelude::Name", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &name::Name) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::core::prelude::Name; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct Name {} +pub struct LuaName {} #[derive(Default)] pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { Ok(()) } } fn bevy_core_context_initializer( _: &bevy_mod_scripting_core::script::ScriptId, - ctx: &mut bevy_mod_scripting_lua::prelude::Lua, + ctx: &mut crate::prelude::Lua, ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + crate::tealr::mlu::set_global_env(Globals, ctx)?; Ok(()) } pub struct BevyCoreScriptingPlugin; @@ -60,7 +53,7 @@ impl bevy::app::Plugin for BevyCoreScriptingPlugin { app.register_foreign_lua_type::(); app.add_context_initializer::<()>(bevy_core_context_initializer); app.add_documentation_fragment( - bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + crate::docs::LuaDocumentationFragment::new( "BevyCoreAPI", |tw| { tw.document_global_instance::() diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs index f1efa51f..a28e9594 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs @@ -3,17 +3,15 @@ #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] use super::bevy_reflect::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::ecs::entity::Entity", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::ecs::entity::Entity; "#, @@ -28,7 +26,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// `Entity` lines up between instances, but instead insert a secondary identifier as /// a component. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_raw(index: u32) -> bevy::ecs::entity::Entity; "#, @@ -38,7 +36,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// for serialization between runs. /// No particular structure is guaranteed for the returned bits. - #[lua(kind = "Method")] + #[lua()] fn to_bits(self) -> u64; "#, @@ -48,7 +46,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// # Panics /// This method will likely panic if given `u64` values that did not come from [`Entity::to_bits`]. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_bits(bits: u64) -> bevy::ecs::entity::Entity; "#, @@ -58,7 +56,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// with both live and dead entities. Useful for compactly representing entities within a /// specific snapshot of the world, such as when serializing. - #[lua(kind = "Method")] + #[lua()] fn index(self) -> u32; "#, @@ -67,46 +65,38 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// 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(kind = "Method")] + #[lua()] fn generation(self) -> u32; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &entity::Entity) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Entity {} +pub struct LuaEntity {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::ecs::component::ComponentId", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::ecs::component::ComponentId; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &component::ComponentId) -> bool; "#, @@ -115,69 +105,66 @@ pub struct Entity {} /// The `index` is a unique value associated with each type of component in a given world. /// Usually, this value is taken from a counter incremented for each type of component registered with the world. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(index: usize) -> bevy::ecs::component::ComponentId; "#, r#" /// Returns the index of the current component. - #[lua(kind = "Method")] + #[lua()] fn index(self) -> usize; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct ComponentId(); +pub struct LuaComponentId(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::ecs::component::Tick", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &component::Tick) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::ecs::component::Tick; "#, r#" /// Creates a new [`Tick`] wrapping the given value. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(tick: u32) -> bevy::ecs::component::Tick; "#, r#" /// Gets the value of this change tick. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> u32; "#, r#" /// Sets the value of this change tick. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set(&mut self, tick: u32) -> (); "#, @@ -185,7 +172,7 @@ pub struct ComponentId(); /// Returns `true` if this `Tick` occurred since the system's `last_run`. /// `this_run` is the current tick of the system, used as a reference to help deal with wraparound. - #[lua(kind = "Method")] + #[lua()] fn is_newer_than( self, #[proxy] @@ -197,31 +184,33 @@ pub struct ComponentId(); "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Tick {} +pub struct LuaTick {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::ecs::component::ComponentTicks", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::ecs::component::ComponentTicks; "#, r#" /// Returns `true` if the component or resource was added after the system last ran. - #[lua(kind = "Method")] + #[lua()] fn is_added( &self, #[proxy] @@ -234,7 +223,7 @@ pub struct Tick {} r#" /// Returns `true` if the component or resource was added or mutably dereferenced after the system last ran. - #[lua(kind = "Method")] + #[lua()] fn is_changed( &self, #[proxy] @@ -247,14 +236,14 @@ pub struct Tick {} r#" /// Returns the tick recording the time this component or resource was most recently changed. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn last_changed_tick(&self) -> bevy::ecs::component::Tick; "#, r#" /// Returns the tick recording the time this component or resource was added. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn added_tick(&self) -> bevy::ecs::component::Tick; "#, @@ -271,59 +260,55 @@ pub struct Tick {} /// component_ticks.set_changed(world.read_change_tick()); /// ``` - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_changed(&mut self, #[proxy] change_tick: bevy::ecs::component::Tick) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct ComponentTicks {} +pub struct LuaComponentTicks {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::ecs::entity::EntityHash", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::ecs::entity::EntityHash; "#] )] -pub struct EntityHash {} +pub struct LuaEntityHash {} #[derive(Default)] pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { instances - .add_instance( - "Entity", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Entity", crate::tealr::mlu::UserDataProxy::::new)?; instances .add_instance( "ComponentId", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances - .add_instance( - "Tick", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Tick", crate::tealr::mlu::UserDataProxy::::new)?; Ok(()) } } fn bevy_ecs_context_initializer( _: &bevy_mod_scripting_core::script::ScriptId, - ctx: &mut bevy_mod_scripting_lua::prelude::Lua, + ctx: &mut crate::prelude::Lua, ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + crate::tealr::mlu::set_global_env(Globals, ctx)?; Ok(()) } pub struct BevyEcsScriptingPlugin; @@ -336,25 +321,19 @@ impl bevy::app::Plugin for BevyEcsScriptingPlugin { app.register_foreign_lua_type::(); app.add_context_initializer::<()>(bevy_ecs_context_initializer); app.add_documentation_fragment( - bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + crate::docs::LuaDocumentationFragment::new( "BevyEcsAPI", |tw| { tw.document_global_instance::() .expect("Something went wrong documenting globals") .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaComponentId, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() .process_type::() }, diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs index 39a14866..d099d3fc 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs @@ -5,79 +5,74 @@ use super::bevy_ecs::*; use super::bevy_reflect::*; use super::bevy_core::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::hierarchy::prelude::Children", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Swaps the child at `a_index` with the child at `b_index`. - #[lua(kind = "MutatingMethod")] + #[lua()] fn swap(&mut self, a_index: usize, b_index: usize) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Children(); +pub struct LuaChildren(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::hierarchy::prelude::Parent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &components::parent::Parent) -> bool; "#, r#" /// Gets the [`Entity`] ID of the parent. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn get(&self) -> bevy::ecs::entity::Entity; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Parent(); +pub struct LuaParent(); #[derive(Default)] pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { Ok(()) } } fn bevy_hierarchy_context_initializer( _: &bevy_mod_scripting_core::script::ScriptId, - ctx: &mut bevy_mod_scripting_lua::prelude::Lua, + ctx: &mut crate::prelude::Lua, ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + crate::tealr::mlu::set_global_env(Globals, ctx)?; Ok(()) } pub struct BevyHierarchyScriptingPlugin; @@ -87,7 +82,7 @@ impl bevy::app::Plugin for BevyHierarchyScriptingPlugin { app.register_foreign_lua_type::(); app.add_context_initializer::<()>(bevy_hierarchy_context_initializer); app.add_documentation_fragment( - bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + crate::docs::LuaDocumentationFragment::new( "BevyHierarchyAPI", |tw| { tw.document_global_instance::() diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs index b1146d8f..05a55fe4 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs @@ -4,77 +4,61 @@ #![cfg_attr(rustfmt, rustfmt_skip)] use super::bevy_ecs::*; use super::bevy_reflect::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::Gamepad", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Creates a new [`Gamepad`]. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(id: usize) -> bevy::input::gamepad::Gamepad; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::Gamepad; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::Gamepad) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Gamepad { +pub struct LuaGamepad { id: usize, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadAxis", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::GamepadAxis; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &gamepad::GamepadAxis) -> bool; "#, @@ -90,7 +74,7 @@ pub struct Gamepad { /// ); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new( #[proxy] gamepad: bevy::input::gamepad::Gamepad, @@ -100,13 +84,13 @@ pub struct Gamepad { "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GamepadAxis { +pub struct LuaGamepadAxis { #[lua(output(proxy))] gamepad: bevy::input::gamepad::Gamepad, #[lua(output(proxy))] @@ -115,40 +99,39 @@ pub struct GamepadAxis { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadAxisType", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::GamepadAxisType; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &gamepad::GamepadAxisType) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GamepadAxisType {} +pub struct LuaGamepadAxisType {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadButton", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Creates a new [`GamepadButton`]. /// # Examples @@ -161,7 +144,7 @@ pub struct GamepadAxisType {} /// ); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new( #[proxy] gamepad: bevy::input::gamepad::Gamepad, @@ -172,35 +155,30 @@ pub struct GamepadAxisType {} "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &gamepad::GamepadButton) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::GamepadButton; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GamepadButton { +pub struct LuaGamepadButton { #[lua(output(proxy))] gamepad: bevy::input::gamepad::Gamepad, #[lua(output(proxy))] @@ -209,133 +187,121 @@ pub struct GamepadButton { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadButtonType", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &gamepad::GamepadButtonType) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::GamepadButtonType; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GamepadButtonType {} +pub struct LuaGamepadButtonType {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::keyboard::KeyCode", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::keyboard::KeyCode; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &keyboard::KeyCode) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct KeyCode {} +pub struct LuaKeyCode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::mouse::MouseButton", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::mouse::MouseButton; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &mouse::MouseButton) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct MouseButton {} +pub struct LuaMouseButton {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::touch::TouchInput", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::touch::TouchInput; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &touch::TouchInput) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct TouchInput { +pub struct LuaTouchInput { #[lua(output(proxy))] phase: bevy::input::touch::TouchPhase, #[lua(output(proxy))] @@ -348,71 +314,65 @@ pub struct TouchInput { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::keyboard::Key", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::keyboard::Key; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &keyboard::Key) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Key {} +pub struct LuaKey {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::keyboard::KeyboardInput", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &keyboard::KeyboardInput) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::keyboard::KeyboardInput; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct KeyboardInput { +pub struct LuaKeyboardInput { #[lua(output(proxy))] key_code: bevy::input::keyboard::KeyCode, #[lua(output(proxy))] @@ -425,105 +385,96 @@ pub struct KeyboardInput { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::keyboard::NativeKey", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &keyboard::NativeKey) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::keyboard::NativeKey; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct NativeKey {} +pub struct LuaNativeKey {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::keyboard::NativeKeyCode", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &keyboard::NativeKeyCode) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::keyboard::NativeKeyCode; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct NativeKeyCode {} +pub struct LuaNativeKeyCode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::mouse::MouseButtonInput", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &mouse::MouseButtonInput) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::mouse::MouseButtonInput; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct MouseButtonInput { +pub struct LuaMouseButtonInput { #[lua(output(proxy))] button: bevy::input::mouse::MouseButton, #[lua(output(proxy))] @@ -534,96 +485,87 @@ pub struct MouseButtonInput { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::mouse::MouseMotion", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &mouse::MouseMotion) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::mouse::MouseMotion; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct MouseMotion { +pub struct LuaMouseMotion { #[lua(output(proxy))] delta: bevy::math::Vec2, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::mouse::MouseScrollUnit", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &mouse::MouseScrollUnit) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::mouse::MouseScrollUnit; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct MouseScrollUnit {} +pub struct LuaMouseScrollUnit {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::mouse::MouseWheel", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::mouse::MouseWheel; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &mouse::MouseWheel) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct MouseWheel { +pub struct LuaMouseWheel { #[lua(output(proxy))] unit: bevy::input::mouse::MouseScrollUnit, x: f32, @@ -634,128 +576,118 @@ pub struct MouseWheel { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::touch::ForceTouch", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &touch::ForceTouch) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::touch::ForceTouch; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct ForceTouch {} +pub struct LuaForceTouch {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::touch::TouchPhase", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &touch::TouchPhase) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::touch::TouchPhase; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct TouchPhase {} +pub struct LuaTouchPhase {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::touchpad::TouchpadMagnify", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &touchpad::TouchpadMagnify) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::touchpad::TouchpadMagnify; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct TouchpadMagnify(f32); +pub struct LuaTouchpadMagnify(f32); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::touchpad::TouchpadRotate", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &touchpad::TouchpadRotate) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::touchpad::TouchpadRotate; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct TouchpadRotate(f32); +pub struct LuaTouchpadRotate(f32); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::AxisSettings", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Get the value above which inputs will be rounded up to 1.0. - #[lua(kind = "Method")] + #[lua()] fn livezone_upperbound(&self) -> f32; "#, @@ -765,14 +697,14 @@ pub struct TouchpadRotate(f32); /// the value will not be changed. /// Returns the new value of `livezone_upperbound`. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_livezone_upperbound(&mut self, value: f32) -> f32; "#, r#" /// Get the value below which positive inputs will be rounded down to 0.0. - #[lua(kind = "Method")] + #[lua()] fn deadzone_upperbound(&self) -> f32; "#, @@ -782,14 +714,14 @@ pub struct TouchpadRotate(f32); /// the value will not be changed. /// Returns the new value of `deadzone_upperbound`. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_deadzone_upperbound(&mut self, value: f32) -> f32; "#, r#" /// Get the value below which negative inputs will be rounded down to -1.0. - #[lua(kind = "Method")] + #[lua()] fn livezone_lowerbound(&self) -> f32; "#, @@ -799,14 +731,14 @@ pub struct TouchpadRotate(f32); /// the value will not be changed. /// Returns the new value of `livezone_lowerbound`. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_livezone_lowerbound(&mut self, value: f32) -> f32; "#, r#" /// Get the value above which inputs will be rounded up to 0.0. - #[lua(kind = "Method")] + #[lua()] fn deadzone_lowerbound(&self) -> f32; "#, @@ -816,14 +748,14 @@ pub struct TouchpadRotate(f32); /// the value will not be changed. /// Returns the new value of `deadzone_lowerbound`. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_deadzone_lowerbound(&mut self, value: f32) -> f32; "#, r#" /// Get the minimum value by which input must change before the change is registered. - #[lua(kind = "Method")] + #[lua()] fn threshold(&self) -> f32; "#, @@ -832,14 +764,14 @@ pub struct TouchpadRotate(f32); /// If the value passed is not within [0.0..=2.0], the value will not be changed. /// Returns the new value of threshold. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_threshold(&mut self, value: f32) -> f32; "#, r#" /// Clamps the `raw_value` according to the `AxisSettings`. - #[lua(kind = "Method")] + #[lua()] fn clamp(&self, new_value: f32) -> f32; "#, @@ -848,7 +780,7 @@ pub struct TouchpadRotate(f32); /// Returns the clamped `new_value` if the change exceeds the settings threshold, /// and `None` otherwise. - #[lua(kind = "Method")] + #[lua()] fn filter( &self, new_value: f32, @@ -858,35 +790,32 @@ pub struct TouchpadRotate(f32); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::AxisSettings; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &gamepad::AxisSettings) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct AxisSettings {} +pub struct LuaAxisSettings {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::ButtonAxisSettings", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::ButtonAxisSettings; "#, @@ -895,7 +824,7 @@ pub struct AxisSettings {} /// Returns the clamped `new_value`, according to the [`ButtonAxisSettings`], if the change /// exceeds the settings threshold, and `None` otherwise. - #[lua(kind = "Method")] + #[lua()] fn filter( &self, new_value: f32, @@ -904,13 +833,13 @@ pub struct AxisSettings {} "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct ButtonAxisSettings { +pub struct LuaButtonAxisSettings { high: f32, low: f32, threshold: f32, @@ -918,9 +847,11 @@ pub struct ButtonAxisSettings { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::ButtonSettings", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::ButtonSettings; "#, @@ -928,7 +859,7 @@ pub struct ButtonAxisSettings { /// Returns `true` if the button is pressed. /// A button is considered pressed if the `value` passed is greater than or equal to the press threshold. - #[lua(kind = "Method")] + #[lua()] fn is_pressed(&self, value: f32) -> bool; "#, @@ -936,14 +867,14 @@ pub struct ButtonAxisSettings { /// Returns `true` if the button is released. /// A button is considered released if the `value` passed is lower than or equal to the release threshold. - #[lua(kind = "Method")] + #[lua()] fn is_released(&self, value: f32) -> bool; "#, r#" /// Get the button input threshold above which the button is considered pressed. - #[lua(kind = "Method")] + #[lua()] fn press_threshold(&self) -> f32; "#, @@ -952,14 +883,14 @@ pub struct ButtonAxisSettings { /// If the value passed is outside the range [release threshold..=1.0], the value will not be changed. /// Returns the new value of the press threshold. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_press_threshold(&mut self, value: f32) -> f32; "#, r#" /// Get the button input threshold below which the button is considered released. - #[lua(kind = "Method")] + #[lua()] fn release_threshold(&self) -> f32; "#, @@ -968,31 +899,33 @@ pub struct ButtonAxisSettings { /// value passed is outside the range [0.0..=press threshold], the value will not be changed. /// Returns the new value of the release threshold. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_release_threshold(&mut self, value: f32) -> f32; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct ButtonSettings {} +pub struct LuaButtonSettings {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadAxisChangedEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::GamepadAxisChangedEvent; "#, r#" /// Creates a [`GamepadAxisChangedEvent`]. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new( #[proxy] gamepad: bevy::input::gamepad::Gamepad, @@ -1004,23 +937,18 @@ pub struct ButtonSettings {} "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &gamepad::GamepadAxisChangedEvent) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GamepadAxisChangedEvent { +pub struct LuaGamepadAxisChangedEvent { #[lua(output(proxy))] gamepad: bevy::input::gamepad::Gamepad, #[lua(output(proxy))] @@ -1030,10 +958,12 @@ pub struct GamepadAxisChangedEvent { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadButtonChangedEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Creates a [`GamepadButtonChangedEvent`]. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new( #[proxy] gamepad: bevy::input::gamepad::Gamepad, @@ -1045,29 +975,24 @@ pub struct GamepadAxisChangedEvent { "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::GamepadButtonChangedEvent; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &gamepad::GamepadButtonChangedEvent) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GamepadButtonChangedEvent { +pub struct LuaGamepadButtonChangedEvent { #[lua(output(proxy))] gamepad: bevy::input::gamepad::Gamepad, #[lua(output(proxy))] @@ -1077,37 +1002,34 @@ pub struct GamepadButtonChangedEvent { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadButtonInput", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &gamepad::GamepadButtonInput) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::GamepadButtonInput; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GamepadButtonInput { +pub struct LuaGamepadButtonInput { #[lua(output(proxy))] button: bevy::input::gamepad::GamepadButton, #[lua(output(proxy))] @@ -1116,38 +1038,37 @@ pub struct GamepadButtonInput { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadConnection", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &gamepad::GamepadConnection) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::GamepadConnection; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GamepadConnection {} +pub struct LuaGamepadConnection {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadConnectionEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Creates a [`GamepadConnectionEvent`]. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new( #[proxy] gamepad: bevy::input::gamepad::Gamepad, @@ -1159,42 +1080,37 @@ pub struct GamepadConnection {} r#" /// Is the gamepad connected? - #[lua(kind = "Method")] + #[lua()] fn connected(&self) -> bool; "#, r#" /// Is the gamepad disconnected? - #[lua(kind = "Method")] + #[lua()] fn disconnected(&self) -> bool; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &gamepad::GamepadConnectionEvent) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::GamepadConnectionEvent; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GamepadConnectionEvent { +pub struct LuaGamepadConnectionEvent { #[lua(output(proxy))] gamepad: bevy::input::gamepad::Gamepad, #[lua(output(proxy))] @@ -1203,42 +1119,41 @@ pub struct GamepadConnectionEvent { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &gamepad::GamepadEvent) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::GamepadEvent; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GamepadEvent {} +pub struct LuaGamepadEvent {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadSettings", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GamepadSettings { +pub struct LuaGamepadSettings { #[lua(output(proxy))] default_button_settings: bevy::input::gamepad::ButtonSettings, #[lua(output(proxy))] @@ -1252,133 +1167,119 @@ pub struct GamepadSettings { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::ButtonState", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Is this button pressed? - #[lua(kind = "Method")] + #[lua()] fn is_pressed(&self) -> bool; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &ButtonState) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::ButtonState; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct ButtonState {} +pub struct LuaButtonState {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadInfo", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &gamepad::GamepadInfo) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::input::gamepad::GamepadInfo; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GamepadInfo { +pub struct LuaGamepadInfo { name: std::string::String, } #[derive(Default)] pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { instances .add_instance( "Gamepad", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "GamepadAxis", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "GamepadButton", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadButton, - >::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "GamepadAxisChangedEvent", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadAxisChangedEvent, - >::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "GamepadButtonChangedEvent", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadButtonChangedEvent, - >::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "GamepadConnectionEvent", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadConnectionEvent, - >::new, + crate::tealr::mlu::UserDataProxy::::new, )?; Ok(()) } } fn bevy_input_context_initializer( _: &bevy_mod_scripting_core::script::ScriptId, - ctx: &mut bevy_mod_scripting_lua::prelude::Lua, + ctx: &mut crate::prelude::Lua, ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + crate::tealr::mlu::set_global_env(Globals, ctx)?; Ok(()) } pub struct BevyInputScriptingPlugin; @@ -1420,27 +1321,21 @@ impl bevy::app::Plugin for BevyInputScriptingPlugin { app.register_foreign_lua_type::(); app.add_context_initializer::<()>(bevy_input_context_initializer); app.add_documentation_fragment( - bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + crate::docs::LuaDocumentationFragment::new( "BevyInputAPI", |tw| { tw.document_global_instance::() .expect("Something went wrong documenting globals") .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadAxis, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadButton, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() .process_type::() @@ -1463,13 +1358,11 @@ impl bevy::app::Plugin for BevyInputScriptingPlugin { .process_type::() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadAxisChangedEvent, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + crate::tealr::mlu::UserDataProxy< LuaGamepadButtonChangedEvent, >, >() @@ -1477,9 +1370,7 @@ impl bevy::app::Plugin for BevyInputScriptingPlugin { .process_type::() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadConnectionEvent, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() .process_type::() diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs index d77ba764..9543f7b7 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs @@ -2,86 +2,51 @@ #![allow(clippy::all)] #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::utils::Duration", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: u32) -> bevy::utils::Duration; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: u32) -> bevy::utils::Duration; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_utils::Duration) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::utils::Duration; "#, @@ -99,7 +64,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// let five_seconds = Duration::new(5, 0); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(secs: u64, nanos: u32) -> bevy::utils::Duration; "#, @@ -113,7 +78,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(0, duration.subsec_nanos()); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_secs(secs: u64) -> bevy::utils::Duration; "#, @@ -127,7 +92,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(569_000_000, duration.subsec_nanos()); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_millis(millis: u64) -> bevy::utils::Duration; "#, @@ -141,7 +106,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(2000, duration.subsec_nanos()); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_micros(micros: u64) -> bevy::utils::Duration; "#, @@ -155,7 +120,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(123, duration.subsec_nanos()); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_nanos(nanos: u64) -> bevy::utils::Duration; "#, @@ -173,7 +138,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert!(!Duration::from_secs(1).is_zero()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_zero(&self) -> bool; "#, @@ -193,7 +158,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// [`as_secs_f32`]: Duration::as_secs_f32 /// [`subsec_nanos`]: Duration::subsec_nanos - #[lua(kind = "Method")] + #[lua()] fn as_secs(&self) -> u64; "#, @@ -210,7 +175,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(duration.subsec_millis(), 432); /// ``` - #[lua(kind = "Method")] + #[lua()] fn subsec_millis(&self) -> u32; "#, @@ -227,7 +192,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(duration.subsec_micros(), 234_567); /// ``` - #[lua(kind = "Method")] + #[lua()] fn subsec_micros(&self) -> u32; "#, @@ -244,7 +209,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(duration.subsec_nanos(), 10_000_000); /// ``` - #[lua(kind = "Method")] + #[lua()] fn subsec_nanos(&self) -> u32; "#, @@ -257,7 +222,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(duration.as_millis(), 5730); /// ``` - #[lua(kind = "Method")] + #[lua()] fn as_millis(&self) -> u128; "#, @@ -270,7 +235,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(duration.as_micros(), 5730023); /// ``` - #[lua(kind = "Method")] + #[lua()] fn as_micros(&self) -> u128; "#, @@ -283,7 +248,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(duration.as_nanos(), 5730023852); /// ``` - #[lua(kind = "Method")] + #[lua()] fn as_nanos(&self) -> u128; "#, @@ -298,7 +263,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(Duration::new(1, 0).saturating_add(Duration::new(u64::MAX, 0)), Duration::MAX); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add( self, #[proxy] @@ -316,7 +281,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(Duration::new(0, 0).saturating_sub(Duration::new(0, 1)), Duration::ZERO); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub( self, #[proxy] @@ -335,7 +300,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(Duration::new(u64::MAX - 1, 0).saturating_mul(2), Duration::MAX); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, rhs: u32) -> bevy::utils::Duration; "#, @@ -349,7 +314,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(dur.as_secs_f64(), 2.7); /// ``` - #[lua(kind = "Method")] + #[lua()] fn as_secs_f64(&self) -> f64; "#, @@ -363,7 +328,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(dur.as_secs_f32(), 2.7); /// ``` - #[lua(kind = "Method")] + #[lua()] fn as_secs_f32(&self) -> f32; "#, @@ -393,7 +358,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(res, Duration::new(0, 1)); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_secs_f64(secs: f64) -> bevy::utils::Duration; "#, @@ -423,7 +388,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(res, Duration::new(0, 1)); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_secs_f32(secs: f32) -> bevy::utils::Duration; "#, @@ -439,7 +404,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(dur.mul_f64(3.14e5), Duration::new(847_800, 0)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_f64(self, rhs: f64) -> bevy::utils::Duration; "#, @@ -455,7 +420,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847800, 0)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_f32(self, rhs: f32) -> bevy::utils::Duration; "#, @@ -471,7 +436,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(dur.div_f64(3.14e5), Duration::new(0, 8_599)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_f64(self, rhs: f64) -> bevy::utils::Duration; "#, @@ -489,72 +454,53 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// assert_eq!(dur.div_f32(3.14e5), Duration::new(0, 8_599)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_f32(self, rhs: f32) -> bevy::utils::Duration; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Duration {} +pub struct LuaDuration {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::utils::Instant", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// # Panics /// This function may panic if the resulting point in time cannot be represented by the /// underlying data structure. See [`Instant::checked_add`] for a version without panic. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_utils::Instant) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::utils::Instant; "#, @@ -566,7 +512,7 @@ pub struct Duration {} /// let now = Instant::now(); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn now() -> bevy::utils::Instant; "#, @@ -589,7 +535,7 @@ pub struct Duration {} /// println!("{:?}", now.duration_since(new_now)); // 0ns /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn duration_since( &self, #[proxy] @@ -611,7 +557,7 @@ pub struct Duration {} /// println!("{:?}", now.saturating_duration_since(new_now)); // 0ns /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_duration_since( &self, #[proxy] @@ -636,7 +582,7 @@ pub struct Duration {} /// assert!(instant.elapsed() >= three_secs); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn elapsed(&self) -> bevy::utils::Duration; "#, @@ -649,34 +595,26 @@ pub struct Duration {} /// See [Monotonicity]. /// [Monotonicity]: Instant#monotonicity - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] other: bevy::utils::Instant) -> bevy::utils::Duration; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Instant(); +pub struct LuaInstant(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroI128", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::num::NonZeroI128; "#, @@ -686,14 +624,14 @@ pub struct Instant(); /// # Safety /// The value must not be zero. - #[lua(kind = "Function", output(proxy))] + #[lua()] unsafe fn new_unchecked(n: i128) -> std::num::NonZeroI128; "#, r#" /// Returns the value as a primitive type. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> i128; "#, @@ -707,7 +645,7 @@ pub struct Instant(); /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn leading_zeros(self) -> u32; "#, @@ -722,7 +660,7 @@ pub struct Instant(); /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn trailing_zeros(self) -> u32; "#, @@ -743,7 +681,7 @@ pub struct Instant(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> std::num::NonZeroI128; "#, @@ -768,7 +706,7 @@ pub struct Instant(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_abs(self) -> std::num::NonZeroI128; "#, @@ -792,7 +730,7 @@ pub struct Instant(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_abs(self) -> std::num::NonZeroI128; "#, @@ -817,7 +755,7 @@ pub struct Instant(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn unsigned_abs(self) -> std::num::NonZeroU128; "#, @@ -837,7 +775,7 @@ pub struct Instant(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_positive(self) -> bool; "#, @@ -857,7 +795,7 @@ pub struct Instant(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_negative(self) -> bool; "#, @@ -883,7 +821,7 @@ pub struct Instant(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_neg(self) -> std::num::NonZeroI128; "#, @@ -906,7 +844,7 @@ pub struct Instant(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_neg(self) -> std::num::NonZeroI128; "#, @@ -927,7 +865,7 @@ pub struct Instant(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul( self, #[proxy] @@ -952,74 +890,56 @@ pub struct Instant(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_pow(self, other: u32) -> std::num::NonZeroI128; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::num::NonZeroI128) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> std::num::NonZeroI128; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct NonZeroI128(); +pub struct LuaNonZeroI128(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroI16", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::num::NonZeroI16) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::num::NonZeroI16; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, @@ -1029,14 +949,14 @@ pub struct NonZeroI128(); /// # Safety /// The value must not be zero. - #[lua(kind = "Function", output(proxy))] + #[lua()] unsafe fn new_unchecked(n: i16) -> std::num::NonZeroI16; "#, r#" /// Returns the value as a primitive type. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> i16; "#, @@ -1050,7 +970,7 @@ pub struct NonZeroI128(); /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn leading_zeros(self) -> u32; "#, @@ -1065,7 +985,7 @@ pub struct NonZeroI128(); /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn trailing_zeros(self) -> u32; "#, @@ -1086,7 +1006,7 @@ pub struct NonZeroI128(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> std::num::NonZeroI16; "#, @@ -1111,7 +1031,7 @@ pub struct NonZeroI128(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_abs(self) -> std::num::NonZeroI16; "#, @@ -1135,7 +1055,7 @@ pub struct NonZeroI128(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_abs(self) -> std::num::NonZeroI16; "#, @@ -1160,7 +1080,7 @@ pub struct NonZeroI128(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn unsigned_abs(self) -> std::num::NonZeroU16; "#, @@ -1180,7 +1100,7 @@ pub struct NonZeroI128(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_positive(self) -> bool; "#, @@ -1200,7 +1120,7 @@ pub struct NonZeroI128(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_negative(self) -> bool; "#, @@ -1226,7 +1146,7 @@ pub struct NonZeroI128(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_neg(self) -> std::num::NonZeroI16; "#, @@ -1249,7 +1169,7 @@ pub struct NonZeroI128(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_neg(self) -> std::num::NonZeroI16; "#, @@ -1270,7 +1190,7 @@ pub struct NonZeroI128(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul( self, #[proxy] @@ -1295,42 +1215,32 @@ pub struct NonZeroI128(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_pow(self, other: u32) -> std::num::NonZeroI16; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> std::num::NonZeroI16; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct NonZeroI16(); +pub struct LuaNonZeroI16(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroI32", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> std::num::NonZeroI32; "#, @@ -1340,14 +1250,14 @@ pub struct NonZeroI16(); /// # Safety /// The value must not be zero. - #[lua(kind = "Function", output(proxy))] + #[lua()] unsafe fn new_unchecked(n: i32) -> std::num::NonZeroI32; "#, r#" /// Returns the value as a primitive type. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> i32; "#, @@ -1361,7 +1271,7 @@ pub struct NonZeroI16(); /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn leading_zeros(self) -> u32; "#, @@ -1376,7 +1286,7 @@ pub struct NonZeroI16(); /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn trailing_zeros(self) -> u32; "#, @@ -1397,7 +1307,7 @@ pub struct NonZeroI16(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> std::num::NonZeroI32; "#, @@ -1422,7 +1332,7 @@ pub struct NonZeroI16(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_abs(self) -> std::num::NonZeroI32; "#, @@ -1446,7 +1356,7 @@ pub struct NonZeroI16(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_abs(self) -> std::num::NonZeroI32; "#, @@ -1471,7 +1381,7 @@ pub struct NonZeroI16(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn unsigned_abs(self) -> std::num::NonZeroU32; "#, @@ -1491,7 +1401,7 @@ pub struct NonZeroI16(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_positive(self) -> bool; "#, @@ -1511,7 +1421,7 @@ pub struct NonZeroI16(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_negative(self) -> bool; "#, @@ -1537,7 +1447,7 @@ pub struct NonZeroI16(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_neg(self) -> std::num::NonZeroI32; "#, @@ -1560,7 +1470,7 @@ pub struct NonZeroI16(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_neg(self) -> std::num::NonZeroI32; "#, @@ -1581,7 +1491,7 @@ pub struct NonZeroI16(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul( self, #[proxy] @@ -1606,62 +1516,55 @@ pub struct NonZeroI16(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_pow(self, other: u32) -> std::num::NonZeroI32; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::num::NonZeroI32; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::num::NonZeroI32) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct NonZeroI32(); +pub struct LuaNonZeroI32(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroI64", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Creates a non-zero without checking whether the value is non-zero. /// This results in undefined behaviour if the value is zero. /// # Safety /// The value must not be zero. - #[lua(kind = "Function", output(proxy))] + #[lua()] unsafe fn new_unchecked(n: i64) -> std::num::NonZeroI64; "#, r#" /// Returns the value as a primitive type. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> i64; "#, @@ -1675,7 +1578,7 @@ pub struct NonZeroI32(); /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn leading_zeros(self) -> u32; "#, @@ -1690,7 +1593,7 @@ pub struct NonZeroI32(); /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn trailing_zeros(self) -> u32; "#, @@ -1711,7 +1614,7 @@ pub struct NonZeroI32(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> std::num::NonZeroI64; "#, @@ -1736,7 +1639,7 @@ pub struct NonZeroI32(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_abs(self) -> std::num::NonZeroI64; "#, @@ -1760,7 +1663,7 @@ pub struct NonZeroI32(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_abs(self) -> std::num::NonZeroI64; "#, @@ -1785,7 +1688,7 @@ pub struct NonZeroI32(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn unsigned_abs(self) -> std::num::NonZeroU64; "#, @@ -1805,7 +1708,7 @@ pub struct NonZeroI32(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_positive(self) -> bool; "#, @@ -1825,7 +1728,7 @@ pub struct NonZeroI32(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_negative(self) -> bool; "#, @@ -1851,7 +1754,7 @@ pub struct NonZeroI32(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_neg(self) -> std::num::NonZeroI64; "#, @@ -1874,7 +1777,7 @@ pub struct NonZeroI32(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_neg(self) -> std::num::NonZeroI64; "#, @@ -1895,7 +1798,7 @@ pub struct NonZeroI32(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul( self, #[proxy] @@ -1920,96 +1823,68 @@ pub struct NonZeroI32(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_pow(self, other: u32) -> std::num::NonZeroI64; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> std::num::NonZeroI64; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::num::NonZeroI64) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::num::NonZeroI64; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct NonZeroI64(); +pub struct LuaNonZeroI64(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroI8", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> std::num::NonZeroI8; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::num::NonZeroI8) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::num::NonZeroI8; "#, @@ -2019,14 +1894,14 @@ pub struct NonZeroI64(); /// # Safety /// The value must not be zero. - #[lua(kind = "Function", output(proxy))] + #[lua()] unsafe fn new_unchecked(n: i8) -> std::num::NonZeroI8; "#, r#" /// Returns the value as a primitive type. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> i8; "#, @@ -2040,7 +1915,7 @@ pub struct NonZeroI64(); /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn leading_zeros(self) -> u32; "#, @@ -2055,7 +1930,7 @@ pub struct NonZeroI64(); /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn trailing_zeros(self) -> u32; "#, @@ -2076,7 +1951,7 @@ pub struct NonZeroI64(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> std::num::NonZeroI8; "#, @@ -2101,7 +1976,7 @@ pub struct NonZeroI64(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_abs(self) -> std::num::NonZeroI8; "#, @@ -2125,7 +2000,7 @@ pub struct NonZeroI64(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_abs(self) -> std::num::NonZeroI8; "#, @@ -2150,7 +2025,7 @@ pub struct NonZeroI64(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn unsigned_abs(self) -> std::num::NonZeroU8; "#, @@ -2170,7 +2045,7 @@ pub struct NonZeroI64(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_positive(self) -> bool; "#, @@ -2190,7 +2065,7 @@ pub struct NonZeroI64(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_negative(self) -> bool; "#, @@ -2216,7 +2091,7 @@ pub struct NonZeroI64(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_neg(self) -> std::num::NonZeroI8; "#, @@ -2239,7 +2114,7 @@ pub struct NonZeroI64(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_neg(self) -> std::num::NonZeroI8; "#, @@ -2260,7 +2135,7 @@ pub struct NonZeroI64(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] other: std::num::NonZeroI8) -> std::num::NonZeroI8; "#, @@ -2281,45 +2156,38 @@ pub struct NonZeroI64(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_pow(self, other: u32) -> std::num::NonZeroI8; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct NonZeroI8(); +pub struct LuaNonZeroI8(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroU128", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::num::NonZeroU128; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::num::NonZeroU128) -> bool; "#, @@ -2329,14 +2197,14 @@ pub struct NonZeroI8(); /// # Safety /// The value must not be zero. - #[lua(kind = "Function", output(proxy))] + #[lua()] unsafe fn new_unchecked(n: u128) -> std::num::NonZeroU128; "#, r#" /// Returns the value as a primitive type. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> u128; "#, @@ -2350,7 +2218,7 @@ pub struct NonZeroI8(); /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn leading_zeros(self) -> u32; "#, @@ -2365,7 +2233,7 @@ pub struct NonZeroI8(); /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn trailing_zeros(self) -> u32; "#, @@ -2386,7 +2254,7 @@ pub struct NonZeroI8(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, other: u128) -> std::num::NonZeroU128; "#, @@ -2404,7 +2272,7 @@ pub struct NonZeroI8(); ///assert_eq!(NonZeroU128::new(9).unwrap().ilog2(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn ilog2(self) -> u32; "#, @@ -2422,7 +2290,7 @@ pub struct NonZeroI8(); ///assert_eq!(NonZeroU128::new(101).unwrap().ilog10(), 2); /// ``` - #[lua(kind = "Method")] + #[lua()] fn ilog10(self) -> u32; "#, @@ -2439,7 +2307,7 @@ pub struct NonZeroI8(); /// assert!(!ten.is_power_of_two()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_power_of_two(self) -> bool; "#, @@ -2460,7 +2328,7 @@ pub struct NonZeroI8(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul( self, #[proxy] @@ -2485,35 +2353,37 @@ pub struct NonZeroI8(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_pow(self, other: u32) -> std::num::NonZeroU128; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct NonZeroU128(); +pub struct LuaNonZeroU128(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroU16", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Creates a non-zero without checking whether the value is non-zero. /// This results in undefined behaviour if the value is zero. /// # Safety /// The value must not be zero. - #[lua(kind = "Function", output(proxy))] + #[lua()] unsafe fn new_unchecked(n: u16) -> std::num::NonZeroU16; "#, r#" /// Returns the value as a primitive type. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> u16; "#, @@ -2527,7 +2397,7 @@ pub struct NonZeroU128(); /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn leading_zeros(self) -> u32; "#, @@ -2542,7 +2412,7 @@ pub struct NonZeroU128(); /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn trailing_zeros(self) -> u32; "#, @@ -2563,7 +2433,7 @@ pub struct NonZeroU128(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, other: u16) -> std::num::NonZeroU16; "#, @@ -2581,7 +2451,7 @@ pub struct NonZeroU128(); ///assert_eq!(NonZeroU16::new(9).unwrap().ilog2(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn ilog2(self) -> u32; "#, @@ -2599,7 +2469,7 @@ pub struct NonZeroU128(); ///assert_eq!(NonZeroU16::new(101).unwrap().ilog10(), 2); /// ``` - #[lua(kind = "Method")] + #[lua()] fn ilog10(self) -> u32; "#, @@ -2616,7 +2486,7 @@ pub struct NonZeroU128(); /// assert!(!ten.is_power_of_two()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_power_of_two(self) -> bool; "#, @@ -2637,7 +2507,7 @@ pub struct NonZeroU128(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul( self, #[proxy] @@ -2662,62 +2532,50 @@ pub struct NonZeroU128(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_pow(self, other: u32) -> std::num::NonZeroU16; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::num::NonZeroU16) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::num::NonZeroU16; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct NonZeroU16(); +pub struct LuaNonZeroU16(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroU32", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::num::NonZeroU32) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, @@ -2727,14 +2585,14 @@ pub struct NonZeroU16(); /// # Safety /// The value must not be zero. - #[lua(kind = "Function", output(proxy))] + #[lua()] unsafe fn new_unchecked(n: u32) -> std::num::NonZeroU32; "#, r#" /// Returns the value as a primitive type. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> u32; "#, @@ -2748,7 +2606,7 @@ pub struct NonZeroU16(); /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn leading_zeros(self) -> u32; "#, @@ -2763,7 +2621,7 @@ pub struct NonZeroU16(); /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn trailing_zeros(self) -> u32; "#, @@ -2784,7 +2642,7 @@ pub struct NonZeroU16(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, other: u32) -> std::num::NonZeroU32; "#, @@ -2802,7 +2660,7 @@ pub struct NonZeroU16(); ///assert_eq!(NonZeroU32::new(9).unwrap().ilog2(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn ilog2(self) -> u32; "#, @@ -2820,7 +2678,7 @@ pub struct NonZeroU16(); ///assert_eq!(NonZeroU32::new(101).unwrap().ilog10(), 2); /// ``` - #[lua(kind = "Method")] + #[lua()] fn ilog10(self) -> u32; "#, @@ -2837,7 +2695,7 @@ pub struct NonZeroU16(); /// assert!(!ten.is_power_of_two()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_power_of_two(self) -> bool; "#, @@ -2858,7 +2716,7 @@ pub struct NonZeroU16(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul( self, #[proxy] @@ -2883,39 +2741,32 @@ pub struct NonZeroU16(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_pow(self, other: u32) -> std::num::NonZeroU32; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::num::NonZeroU32; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct NonZeroU32(); +pub struct LuaNonZeroU32(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroU64", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::num::NonZeroU64) -> bool; "#, @@ -2925,14 +2776,14 @@ pub struct NonZeroU32(); /// # Safety /// The value must not be zero. - #[lua(kind = "Function", output(proxy))] + #[lua()] unsafe fn new_unchecked(n: u64) -> std::num::NonZeroU64; "#, r#" /// Returns the value as a primitive type. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> u64; "#, @@ -2946,7 +2797,7 @@ pub struct NonZeroU32(); /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn leading_zeros(self) -> u32; "#, @@ -2961,7 +2812,7 @@ pub struct NonZeroU32(); /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn trailing_zeros(self) -> u32; "#, @@ -2982,7 +2833,7 @@ pub struct NonZeroU32(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, other: u64) -> std::num::NonZeroU64; "#, @@ -3000,7 +2851,7 @@ pub struct NonZeroU32(); ///assert_eq!(NonZeroU64::new(9).unwrap().ilog2(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn ilog2(self) -> u32; "#, @@ -3018,7 +2869,7 @@ pub struct NonZeroU32(); ///assert_eq!(NonZeroU64::new(101).unwrap().ilog10(), 2); /// ``` - #[lua(kind = "Method")] + #[lua()] fn ilog10(self) -> u32; "#, @@ -3035,7 +2886,7 @@ pub struct NonZeroU32(); /// assert!(!ten.is_power_of_two()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_power_of_two(self) -> bool; "#, @@ -3056,7 +2907,7 @@ pub struct NonZeroU32(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul( self, #[proxy] @@ -3081,50 +2932,44 @@ pub struct NonZeroU32(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_pow(self, other: u32) -> std::num::NonZeroU64; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::num::NonZeroU64; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct NonZeroU64(); +pub struct LuaNonZeroU64(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroU8", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::num::NonZeroU8; "#, @@ -3134,14 +2979,14 @@ pub struct NonZeroU64(); /// # Safety /// The value must not be zero. - #[lua(kind = "Function", output(proxy))] + #[lua()] unsafe fn new_unchecked(n: u8) -> std::num::NonZeroU8; "#, r#" /// Returns the value as a primitive type. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> u8; "#, @@ -3155,7 +3000,7 @@ pub struct NonZeroU64(); /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn leading_zeros(self) -> u32; "#, @@ -3170,7 +3015,7 @@ pub struct NonZeroU64(); /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn trailing_zeros(self) -> u32; "#, @@ -3191,7 +3036,7 @@ pub struct NonZeroU64(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, other: u8) -> std::num::NonZeroU8; "#, @@ -3209,7 +3054,7 @@ pub struct NonZeroU64(); ///assert_eq!(NonZeroU8::new(9).unwrap().ilog2(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn ilog2(self) -> u32; "#, @@ -3227,7 +3072,7 @@ pub struct NonZeroU64(); ///assert_eq!(NonZeroU8::new(101).unwrap().ilog10(), 2); /// ``` - #[lua(kind = "Method")] + #[lua()] fn ilog10(self) -> u32; "#, @@ -3244,7 +3089,7 @@ pub struct NonZeroU64(); /// assert!(!ten.is_power_of_two()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_power_of_two(self) -> bool; "#, @@ -3265,7 +3110,7 @@ pub struct NonZeroU64(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] other: std::num::NonZeroU8) -> std::num::NonZeroU8; "#, @@ -3286,35 +3131,32 @@ pub struct NonZeroU64(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_pow(self, other: u32) -> std::num::NonZeroU8; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::num::NonZeroU8) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct NonZeroU8(); +pub struct LuaNonZeroU8(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroUsize", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, @@ -3324,14 +3166,14 @@ pub struct NonZeroU8(); /// # Safety /// The value must not be zero. - #[lua(kind = "Function", output(proxy))] + #[lua()] unsafe fn new_unchecked(n: usize) -> std::num::NonZeroUsize; "#, r#" /// Returns the value as a primitive type. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> usize; "#, @@ -3345,7 +3187,7 @@ pub struct NonZeroU8(); /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn leading_zeros(self) -> u32; "#, @@ -3360,7 +3202,7 @@ pub struct NonZeroU8(); /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn trailing_zeros(self) -> u32; "#, @@ -3381,7 +3223,7 @@ pub struct NonZeroU8(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, other: usize) -> std::num::NonZeroUsize; "#, @@ -3399,7 +3241,7 @@ pub struct NonZeroU8(); ///assert_eq!(NonZeroUsize::new(9).unwrap().ilog2(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn ilog2(self) -> u32; "#, @@ -3417,7 +3259,7 @@ pub struct NonZeroU8(); ///assert_eq!(NonZeroUsize::new(101).unwrap().ilog10(), 2); /// ``` - #[lua(kind = "Method")] + #[lua()] fn ilog10(self) -> u32; "#, @@ -3434,7 +3276,7 @@ pub struct NonZeroU8(); /// assert!(!ten.is_power_of_two()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_power_of_two(self) -> bool; "#, @@ -3455,7 +3297,7 @@ pub struct NonZeroU8(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul( self, #[proxy] @@ -3480,69 +3322,50 @@ pub struct NonZeroU8(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_pow(self, other: u32) -> std::num::NonZeroUsize; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::num::NonZeroUsize) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::num::NonZeroUsize; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct NonZeroUsize(); +pub struct LuaNonZeroUsize(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::path::PathBuf", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::path::PathBuf) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::path::PathBuf; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "MutatingMethod", - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone_from(&mut self, #[proxy] source: &std::path::PathBuf) -> (); "#, @@ -3554,7 +3377,7 @@ pub struct NonZeroUsize(); /// let path = PathBuf::new(); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new() -> std::path::PathBuf; "#, @@ -3572,7 +3395,7 @@ pub struct NonZeroUsize(); /// ``` /// [`with_capacity`]: OsString::with_capacity - #[lua(kind = "Function", output(proxy))] + #[lua()] fn with_capacity(capacity: usize) -> std::path::PathBuf; "#, @@ -3591,7 +3414,7 @@ pub struct NonZeroUsize(); /// assert_eq!(Path::new("/"), p); /// ``` - #[lua(kind = "MutatingMethod")] + #[lua()] fn pop(&mut self) -> bool; "#, @@ -3599,7 +3422,7 @@ pub struct NonZeroUsize(); /// Invokes [`capacity`] on the underlying instance of [`OsString`]. /// [`capacity`]: OsString::capacity - #[lua(kind = "Method")] + #[lua()] fn capacity(&self) -> usize; "#, @@ -3607,7 +3430,7 @@ pub struct NonZeroUsize(); /// Invokes [`clear`] on the underlying instance of [`OsString`]. /// [`clear`]: OsString::clear - #[lua(kind = "MutatingMethod")] + #[lua()] fn clear(&mut self) -> (); "#, @@ -3615,7 +3438,7 @@ pub struct NonZeroUsize(); /// Invokes [`reserve`] on the underlying instance of [`OsString`]. /// [`reserve`]: OsString::reserve - #[lua(kind = "MutatingMethod")] + #[lua()] fn reserve(&mut self, additional: usize) -> (); "#, @@ -3623,7 +3446,7 @@ pub struct NonZeroUsize(); /// Invokes [`reserve_exact`] on the underlying instance of [`OsString`]. /// [`reserve_exact`]: OsString::reserve_exact - #[lua(kind = "MutatingMethod")] + #[lua()] fn reserve_exact(&mut self, additional: usize) -> (); "#, @@ -3631,7 +3454,7 @@ pub struct NonZeroUsize(); /// Invokes [`shrink_to_fit`] on the underlying instance of [`OsString`]. /// [`shrink_to_fit`]: OsString::shrink_to_fit - #[lua(kind = "MutatingMethod")] + #[lua()] fn shrink_to_fit(&mut self) -> (); "#, @@ -3639,69 +3462,58 @@ pub struct NonZeroUsize(); /// Invokes [`shrink_to`] on the underlying instance of [`OsString`]. /// [`shrink_to`]: OsString::shrink_to - #[lua(kind = "MutatingMethod")] + #[lua()] fn shrink_to(&mut self, min_capacity: usize) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct PathBuf {} +pub struct LuaPathBuf {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::ops::RangeFull", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::ops::RangeFull; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::ops::RangeFull) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct RangeFull {} +pub struct LuaRangeFull {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::Quat", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Rotates the [`Direction3d`] using a [`Quat`]. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul( self, #[proxy] @@ -3711,13 +3523,7 @@ pub struct RangeFull {} "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, @@ -3726,13 +3532,7 @@ pub struct RangeFull {} /// # Panics /// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -3744,23 +3544,13 @@ pub struct RangeFull {} /// # Panics /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::Quat; "#, @@ -3770,13 +3560,7 @@ pub struct RangeFull {} /// Note that addition is not the same as combining the rotations represented by the /// two quaternions! That corresponds to multiplication. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; "#, @@ -3784,24 +3568,13 @@ pub struct RangeFull {} /// Subtracts the `rhs` quaternion from `self`. /// The difference is not guaranteed to be normalized. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::Quat) -> bool; "#, @@ -3809,13 +3582,7 @@ pub struct RangeFull {} /// Divides a quaternion by a scalar value. /// The quotient is not guaranteed to be normalized. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: f32) -> bevy::math::Quat; "#, @@ -3828,7 +3595,7 @@ pub struct RangeFull {} /// 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))] + #[lua()] fn from_xyzw(x: f32, y: f32, z: f32, w: f32) -> bevy::math::Quat; "#, @@ -3838,7 +3605,7 @@ pub struct RangeFull {} /// 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))] + #[lua()] fn from_array(a: [f32; 4]) -> bevy::math::Quat; "#, @@ -3848,7 +3615,7 @@ pub struct RangeFull {} /// 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))] + #[lua()] fn from_vec4(#[proxy] v: bevy::math::Vec4) -> bevy::math::Quat; "#, @@ -3858,7 +3625,7 @@ pub struct RangeFull {} /// # Panics /// Will panic if `axis` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_axis_angle(#[proxy] axis: bevy::math::Vec3, angle: f32) -> bevy::math::Quat; "#, @@ -3866,35 +3633,35 @@ pub struct RangeFull {} /// 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))] + #[lua()] fn from_scaled_axis(#[proxy] v: bevy::math::Vec3) -> bevy::math::Quat; "#, r#" /// Creates a quaternion from the `angle` (in radians) around the x axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_x(angle: f32) -> bevy::math::Quat; "#, r#" /// Creates a quaternion from the `angle` (in radians) around the y axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_y(angle: f32) -> bevy::math::Quat; "#, r#" /// Creates a quaternion from the `angle` (in radians) around the z axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_z(angle: f32) -> bevy::math::Quat; "#, r#" /// Creates a quaternion from the given Euler rotation sequence and the angles (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_euler( #[proxy] euler: bevy::math::EulerRot, @@ -3907,21 +3674,21 @@ pub struct RangeFull {} r#" /// Creates a quaternion from a 3x3 rotation matrix. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3(#[proxy] mat: &glam::Mat3) -> bevy::math::Quat; "#, r#" /// Creates a quaternion from a 3x3 SIMD aligned rotation matrix. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3a(#[proxy] mat: &glam::Mat3A) -> bevy::math::Quat; "#, r#" /// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat4(#[proxy] mat: &glam::Mat4) -> bevy::math::Quat; "#, @@ -3935,7 +3702,7 @@ pub struct RangeFull {} /// # Panics /// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_arc( #[proxy] from: bevy::math::Vec3, @@ -3954,7 +3721,7 @@ pub struct RangeFull {} /// # Panics /// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_arc_colinear( #[proxy] from: bevy::math::Vec3, @@ -3973,7 +3740,7 @@ pub struct RangeFull {} /// # Panics /// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_arc_2d( #[proxy] from: bevy::math::Vec2, @@ -3985,28 +3752,28 @@ pub struct RangeFull {} r#" /// Returns the rotation axis scaled by the rotation in radians. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn to_scaled_axis(self) -> bevy::math::Vec3; "#, r#" /// Returns the rotation angles for the given euler rotation sequence. - #[lua(kind = "Method")] + #[lua()] fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f32, f32, f32); "#, r#" /// `[x, y, z, w]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [f32; 4]; "#, r#" /// Returns the vector part of the quaternion. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn xyz(self) -> bevy::math::Vec3; "#, @@ -4014,7 +3781,7 @@ pub struct RangeFull {} /// Returns the quaternion conjugate of `self`. For a unit quaternion the /// conjugate is also the inverse. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn conjugate(self) -> bevy::math::Quat; "#, @@ -4026,7 +3793,7 @@ pub struct RangeFull {} /// # Panics /// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(self) -> bevy::math::Quat; "#, @@ -4034,14 +3801,14 @@ pub struct RangeFull {} /// Computes the dot product of `self` and `rhs`. The dot product is /// equal to the cosine of the angle between two quaternion rotations. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::Quat) -> f32; "#, r#" /// Computes the length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length(self) -> f32; "#, @@ -4050,7 +3817,7 @@ pub struct RangeFull {} /// This is generally faster than `length()` as it avoids a square /// root operation. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> f32; "#, @@ -4058,7 +3825,7 @@ pub struct RangeFull {} /// Computes `1.0 / length()`. /// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method")] + #[lua()] fn length_recip(self) -> f32; "#, @@ -4068,7 +3835,7 @@ pub struct RangeFull {} /// Panics /// Will panic if `self` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize(self) -> bevy::math::Quat; "#, @@ -4076,13 +3843,13 @@ pub struct RangeFull {} /// 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(kind = "Method")] + #[lua()] fn is_finite(self) -> bool; "#, r#" - #[lua(kind = "Method")] + #[lua()] fn is_nan(self) -> bool; "#, @@ -4090,13 +3857,13 @@ pub struct RangeFull {} /// Returns whether `self` of length `1.0` or not. /// Uses a precision threshold of `1e-6`. - #[lua(kind = "Method")] + #[lua()] fn is_normalized(self) -> bool; "#, r#" - #[lua(kind = "Method")] + #[lua()] fn is_near_identity(self) -> bool; "#, @@ -4107,7 +3874,7 @@ pub struct RangeFull {} /// # Panics /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Method")] + #[lua()] fn angle_between(self, #[proxy] rhs: bevy::math::Quat) -> f32; "#, @@ -4120,7 +3887,7 @@ pub struct RangeFull {} /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Quat, max_abs_diff: f32) -> bool; "#, @@ -4132,7 +3899,7 @@ pub struct RangeFull {} /// # Panics /// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn lerp(self, #[proxy] end: bevy::math::Quat, s: f32) -> bevy::math::Quat; "#, @@ -4144,7 +3911,7 @@ pub struct RangeFull {} /// # Panics /// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn slerp(self, #[proxy] end: bevy::math::Quat, s: f32) -> bevy::math::Quat; "#, @@ -4153,7 +3920,7 @@ pub struct RangeFull {} /// # Panics /// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_vec3(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -4164,33 +3931,33 @@ pub struct RangeFull {} /// # Panics /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_quat(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; "#, r#" /// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_affine3(#[proxy] a: &glam::Affine3A) -> bevy::math::Quat; "#, r#" /// Multiplies a quaternion and a 3D vector, returning the rotated vector. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_vec3a(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dquat(self) -> bevy::math::DQuat; "#, r#" - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_f64(self) -> bevy::math::DQuat; "#, @@ -4198,156 +3965,94 @@ pub struct RangeFull {} /// Multiplies a quaternion by a scalar value. /// The product is not guaranteed to be normalized. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f32) -> bevy::math::Quat; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::Quat; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct Quat(); +pub struct LuaQuat(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::Vec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f32) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: f32) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: f32) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::Vec3; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: f32) -> bevy::math::Vec3; "#, @@ -4357,7 +4062,7 @@ pub struct Quat(); /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec3, @@ -4371,21 +4076,21 @@ pub struct Quat(); r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [f32; 3]) -> bevy::math::Vec3; "#, r#" /// `[x, y, z]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [f32; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, w: f32) -> bevy::math::Vec4; "#, @@ -4393,28 +4098,28 @@ pub struct Quat(); /// 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(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::Vec2; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::Vec3) -> f32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" /// Computes the cross product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cross(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -4422,7 +4127,7 @@ pub struct Quat(); /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -4430,7 +4135,7 @@ pub struct Quat(); /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -4440,7 +4145,7 @@ pub struct Quat(); /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -4454,7 +4159,7 @@ pub struct Quat(); /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> f32; "#, @@ -4462,7 +4167,7 @@ pub struct Quat(); /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> f32; "#, @@ -4472,7 +4177,7 @@ pub struct Quat(); /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; "#, @@ -4482,7 +4187,7 @@ pub struct Quat(); /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; "#, @@ -4492,7 +4197,7 @@ pub struct Quat(); /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; "#, @@ -4502,7 +4207,7 @@ pub struct Quat(); /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; "#, @@ -4512,7 +4217,7 @@ pub struct Quat(); /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; "#, @@ -4522,14 +4227,14 @@ pub struct Quat(); /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::Vec3; "#, @@ -4539,14 +4244,14 @@ pub struct Quat(); /// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` /// - `NAN` if the number is `NAN` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::Vec3; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn copysign(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -4555,7 +4260,7 @@ pub struct Quat(); /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, @@ -4563,14 +4268,14 @@ pub struct Quat(); /// 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(kind = "Method")] + #[lua()] fn is_finite(self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(self) -> bool; "#, @@ -4578,14 +4283,14 @@ pub struct Quat(); /// 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(kind = "Method", output(proxy))] + #[lua()] fn is_nan_mask(self) -> bevy::math::BVec3; "#, r#" /// Computes the length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length(self) -> f32; "#, @@ -4593,7 +4298,7 @@ pub struct Quat(); /// Computes the squared length of `self`. /// This is faster than `length()` as it avoids a square root operation. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> f32; "#, @@ -4601,28 +4306,28 @@ pub struct Quat(); /// Computes `1.0 / length()`. /// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method")] + #[lua()] fn length_recip(self) -> f32; "#, r#" /// Computes the Euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance(self, #[proxy] rhs: bevy::math::Vec3) -> f32; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::Vec3) -> f32; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -4630,7 +4335,7 @@ pub struct Quat(); /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. /// [Euclidean division]: f32::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -4641,7 +4346,7 @@ pub struct Quat(); /// Panics /// Will panic if `self` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize(self) -> bevy::math::Vec3; "#, @@ -4651,7 +4356,7 @@ pub struct Quat(); /// the result of this operation will be zero. /// See also [`Self::try_normalize()`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize_or_zero(self) -> bevy::math::Vec3; "#, @@ -4659,7 +4364,7 @@ pub struct Quat(); /// Returns whether `self` is length `1.0` or not. /// Uses a precision threshold of `1e-6`. - #[lua(kind = "Method")] + #[lua()] fn is_normalized(self) -> bool; "#, @@ -4669,7 +4374,7 @@ pub struct Quat(); /// # Panics /// Will panic if `rhs` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -4681,7 +4386,7 @@ pub struct Quat(); /// # Panics /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -4691,7 +4396,7 @@ pub struct Quat(); /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -4703,7 +4408,7 @@ pub struct Quat(); /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -4711,7 +4416,7 @@ pub struct Quat(); /// Returns a vector containing the nearest integer to a number for each element of `self`. /// Round half-way cases away from 0.0. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn round(self) -> bevy::math::Vec3; "#, @@ -4719,7 +4424,7 @@ pub struct Quat(); /// Returns a vector containing the largest integer less than or equal to a number for each /// element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn floor(self) -> bevy::math::Vec3; "#, @@ -4727,7 +4432,7 @@ pub struct Quat(); /// Returns a vector containing the smallest integer greater than or equal to a number for /// each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn ceil(self) -> bevy::math::Vec3; "#, @@ -4735,7 +4440,7 @@ pub struct Quat(); /// Returns a vector containing the integer part each element of `self`. This means numbers are /// always truncated towards zero. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn trunc(self) -> bevy::math::Vec3; "#, @@ -4744,7 +4449,7 @@ pub struct Quat(); /// self.floor()`. /// Note that this is fast but not precise for large numbers. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn fract(self) -> bevy::math::Vec3; "#, @@ -4752,21 +4457,21 @@ pub struct Quat(); /// Returns a vector containing `e^self` (the exponential function) for each element of /// `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn exp(self) -> bevy::math::Vec3; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn powf(self, n: f32) -> bevy::math::Vec3; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn recip(self) -> bevy::math::Vec3; "#, @@ -4776,7 +4481,7 @@ pub struct Quat(); /// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly /// extrapolated. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn lerp(self, #[proxy] rhs: bevy::math::Vec3, s: f32) -> bevy::math::Vec3; "#, @@ -4789,7 +4494,7 @@ pub struct Quat(); /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec3, max_abs_diff: f32) -> bool; "#, @@ -4798,21 +4503,21 @@ pub struct Quat(); /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3; "#, r#" /// Returns a vector with a length no more than `max` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_max(self, max: f32) -> bevy::math::Vec3; "#, r#" /// Returns a vector with a length no less than `min` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_min(self, min: f32) -> bevy::math::Vec3; "#, @@ -4824,7 +4529,7 @@ pub struct Quat(); /// and will be heavily dependant on designing algorithms with specific target hardware in /// mind. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_add( self, #[proxy] @@ -4838,7 +4543,7 @@ pub struct Quat(); /// Returns the angle (in radians) between two vectors. /// The inputs do not need to be unit vectors however they must be non-zero. - #[lua(kind = "Method")] + #[lua()] fn angle_between(self, #[proxy] rhs: bevy::math::Vec3) -> f32; "#, @@ -4848,7 +4553,7 @@ pub struct Quat(); /// The output vector is not necessarily unit length. For that use /// [`Self::any_orthonormal_vector()`] instead. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn any_orthogonal_vector(&self) -> bevy::math::Vec3; "#, @@ -4858,112 +4563,89 @@ pub struct Quat(); /// # Panics /// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn any_orthonormal_vector(&self) -> bevy::math::Vec3; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec3(&self) -> bevy::math::DVec3; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: f32) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: f32) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::Vec3) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct Vec3 { +pub struct LuaVec3 { x: f32, y: f32, z: f32, @@ -4971,152 +4653,91 @@ pub struct Vec3 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::IVec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: i32) -> bevy::math::IVec2; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: i32) -> bevy::math::IVec2; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::IVec2) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: i32) -> bevy::math::IVec2; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::IVec2; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: i32) -> bevy::math::IVec2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: i32, y: i32) -> bevy::math::IVec2; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: i32) -> bevy::math::IVec2; "#, @@ -5126,7 +4747,7 @@ pub struct Vec3 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec2, @@ -5140,35 +4761,35 @@ pub struct Vec3 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [i32; 2]) -> bevy::math::IVec2; "#, r#" /// `[x, y]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [i32; 2]; "#, r#" /// Creates a 3D vector from `self` and the given `z` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, z: i32) -> bevy::math::IVec3; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::IVec2) -> i32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, @@ -5176,7 +4797,7 @@ pub struct Vec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, @@ -5184,7 +4805,7 @@ pub struct Vec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, @@ -5194,7 +4815,7 @@ pub struct Vec3 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -5208,7 +4829,7 @@ pub struct Vec3 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> i32; "#, @@ -5216,7 +4837,7 @@ pub struct Vec3 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> i32; "#, @@ -5226,7 +4847,7 @@ pub struct Vec3 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; "#, @@ -5236,7 +4857,7 @@ pub struct Vec3 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; "#, @@ -5246,7 +4867,7 @@ pub struct Vec3 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; "#, @@ -5256,7 +4877,7 @@ pub struct Vec3 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; "#, @@ -5266,7 +4887,7 @@ pub struct Vec3 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; "#, @@ -5276,14 +4897,14 @@ pub struct Vec3 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::IVec2; "#, @@ -5293,7 +4914,7 @@ pub struct Vec3 { /// - `1` if the number is positive /// - `-1` if the number is negative - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::IVec2; "#, @@ -5302,21 +4923,21 @@ pub struct Vec3 { /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, r#" /// Computes the squared length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> i32; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::IVec2) -> i32; "#, @@ -5325,7 +4946,7 @@ pub struct Vec3 { /// # Panics /// This function will panic if any `rhs` element is 0 or the division results in overflow. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, @@ -5335,14 +4956,14 @@ pub struct Vec3 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. /// [Euclidean division]: i32::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" /// Returns a vector that is equal to `self` rotated by 90 degrees. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn perp(self) -> bevy::math::IVec2; "#, @@ -5350,7 +4971,7 @@ pub struct Vec3 { /// The perpendicular dot product of `self` and `rhs`. /// Also known as the wedge product, 2D cross product, and determinant. - #[lua(kind = "Method")] + #[lua()] fn perp_dot(self, #[proxy] rhs: bevy::math::IVec2) -> i32; "#, @@ -5359,42 +4980,42 @@ pub struct Vec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn rotate(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec2(&self) -> bevy::math::Vec2; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec2(&self) -> bevy::math::DVec2; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec2(&self) -> bevy::math::UVec2; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec2(&self) -> bevy::math::I64Vec2; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec2(&self) -> bevy::math::U64Vec2; "#, @@ -5402,7 +5023,7 @@ pub struct Vec3 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, @@ -5410,7 +5031,7 @@ pub struct Vec3 { /// Returns a vector containing the wrapping subtraction of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, @@ -5418,7 +5039,7 @@ pub struct Vec3 { /// Returns a vector containing the wrapping multiplication of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, @@ -5426,7 +5047,7 @@ pub struct Vec3 { /// Returns a vector containing the wrapping division of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, @@ -5434,7 +5055,7 @@ pub struct Vec3 { /// Returns a vector containing the saturating addition of `self` and `rhs`. /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, @@ -5442,7 +5063,7 @@ pub struct Vec3 { /// Returns a vector containing the saturating subtraction of `self` and `rhs`. /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, @@ -5450,7 +5071,7 @@ pub struct Vec3 { /// Returns a vector containing the saturating multiplication of `self` and `rhs`. /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, @@ -5458,107 +5079,79 @@ pub struct Vec3 { /// Returns a vector containing the saturating division of `self` and `rhs`. /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: i32) -> bevy::math::IVec2; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::IVec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct IVec2 { +pub struct LuaIVec2 { x: i32, y: i32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::IVec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: i32) -> bevy::math::IVec3; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: i32, y: i32, z: i32) -> bevy::math::IVec3; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: i32) -> bevy::math::IVec3; "#, @@ -5568,7 +5161,7 @@ pub struct IVec2 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec3, @@ -5582,21 +5175,21 @@ pub struct IVec2 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [i32; 3]) -> bevy::math::IVec3; "#, r#" /// `[x, y, z]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [i32; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, w: i32) -> bevy::math::IVec4; "#, @@ -5604,28 +5197,28 @@ pub struct IVec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::IVec2; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::IVec3) -> i32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" /// Computes the cross product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cross(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, @@ -5633,7 +5226,7 @@ pub struct IVec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, @@ -5641,7 +5234,7 @@ pub struct IVec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, @@ -5651,7 +5244,7 @@ pub struct IVec2 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -5665,7 +5258,7 @@ pub struct IVec2 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> i32; "#, @@ -5673,7 +5266,7 @@ pub struct IVec2 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> i32; "#, @@ -5683,7 +5276,7 @@ pub struct IVec2 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; "#, @@ -5693,7 +5286,7 @@ pub struct IVec2 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; "#, @@ -5703,7 +5296,7 @@ pub struct IVec2 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; "#, @@ -5713,7 +5306,7 @@ pub struct IVec2 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; "#, @@ -5723,7 +5316,7 @@ pub struct IVec2 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; "#, @@ -5733,14 +5326,14 @@ pub struct IVec2 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::IVec3; "#, @@ -5750,7 +5343,7 @@ pub struct IVec2 { /// - `1` if the number is positive /// - `-1` if the number is negative - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::IVec3; "#, @@ -5759,21 +5352,21 @@ pub struct IVec2 { /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, r#" /// Computes the squared length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> i32; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::IVec3) -> i32; "#, @@ -5782,7 +5375,7 @@ pub struct IVec2 { /// # Panics /// This function will panic if any `rhs` element is 0 or the division results in overflow. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, @@ -5792,49 +5385,49 @@ pub struct IVec2 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. /// [Euclidean division]: i32::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec3(&self) -> bevy::math::Vec3; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec3a(&self) -> bevy::math::Vec3A; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec3(&self) -> bevy::math::DVec3; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, @@ -5842,7 +5435,7 @@ pub struct IVec2 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, @@ -5850,7 +5443,7 @@ pub struct IVec2 { /// Returns a vector containing the wrapping subtraction of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, @@ -5858,7 +5451,7 @@ pub struct IVec2 { /// Returns a vector containing the wrapping multiplication of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, @@ -5866,7 +5459,7 @@ pub struct IVec2 { /// Returns a vector containing the wrapping division of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, @@ -5874,7 +5467,7 @@ pub struct IVec2 { /// Returns a vector containing the saturating addition of `self` and `rhs`. /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, @@ -5882,7 +5475,7 @@ pub struct IVec2 { /// Returns a vector containing the saturating subtraction of `self` and `rhs`. /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, @@ -5890,7 +5483,7 @@ pub struct IVec2 { /// Returns a vector containing the saturating multiplication of `self` and `rhs`. /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, @@ -5898,153 +5491,96 @@ pub struct IVec2 { /// Returns a vector containing the saturating division of `self` and `rhs`. /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: i32) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: i32) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: i32) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: i32) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::IVec3) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct IVec3 { +pub struct LuaIVec3 { x: i32, y: i32, z: i32, @@ -6052,57 +5588,43 @@ pub struct IVec3 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::IVec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::IVec4; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: i32) -> bevy::math::IVec4; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: i32, y: i32, z: i32, w: i32) -> bevy::math::IVec4; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: i32) -> bevy::math::IVec4; "#, @@ -6112,7 +5634,7 @@ pub struct IVec3 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec4, @@ -6126,14 +5648,14 @@ pub struct IVec3 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [i32; 4]) -> bevy::math::IVec4; "#, r#" /// `[x, y, z, w]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [i32; 4]; "#, @@ -6141,21 +5663,21 @@ pub struct IVec3 { /// Creates a 3D 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(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::IVec3; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::IVec4) -> i32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, @@ -6163,7 +5685,7 @@ pub struct IVec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, @@ -6171,7 +5693,7 @@ pub struct IVec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, @@ -6181,7 +5703,7 @@ pub struct IVec3 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -6195,7 +5717,7 @@ pub struct IVec3 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> i32; "#, @@ -6203,7 +5725,7 @@ pub struct IVec3 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> i32; "#, @@ -6213,7 +5735,7 @@ pub struct IVec3 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; "#, @@ -6223,7 +5745,7 @@ pub struct IVec3 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; "#, @@ -6233,7 +5755,7 @@ pub struct IVec3 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; "#, @@ -6243,7 +5765,7 @@ pub struct IVec3 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; "#, @@ -6253,7 +5775,7 @@ pub struct IVec3 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; "#, @@ -6263,14 +5785,14 @@ pub struct IVec3 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::IVec4; "#, @@ -6280,7 +5802,7 @@ pub struct IVec3 { /// - `1` if the number is positive /// - `-1` if the number is negative - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::IVec4; "#, @@ -6289,21 +5811,21 @@ pub struct IVec3 { /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, r#" /// Computes the squared length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> i32; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::IVec4) -> i32; "#, @@ -6312,7 +5834,7 @@ pub struct IVec3 { /// # Panics /// This function will panic if any `rhs` element is 0 or the division results in overflow. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, @@ -6322,42 +5844,42 @@ pub struct IVec3 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. /// [Euclidean division]: i32::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec4(&self) -> bevy::math::Vec4; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec4(&self) -> bevy::math::DVec4; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec4(&self) -> bevy::math::UVec4; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec4(&self) -> bevy::math::I64Vec4; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec4(&self) -> bevy::math::U64Vec4; "#, @@ -6365,7 +5887,7 @@ pub struct IVec3 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, @@ -6373,7 +5895,7 @@ pub struct IVec3 { /// Returns a vector containing the wrapping subtraction of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, @@ -6381,7 +5903,7 @@ pub struct IVec3 { /// Returns a vector containing the wrapping multiplication of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, @@ -6389,7 +5911,7 @@ pub struct IVec3 { /// Returns a vector containing the wrapping division of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, @@ -6397,7 +5919,7 @@ pub struct IVec3 { /// Returns a vector containing the saturating addition of `self` and `rhs`. /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, @@ -6405,7 +5927,7 @@ pub struct IVec3 { /// Returns a vector containing the saturating subtraction of `self` and `rhs`. /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, @@ -6413,7 +5935,7 @@ pub struct IVec3 { /// Returns a vector containing the saturating multiplication of `self` and `rhs`. /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, @@ -6421,149 +5943,90 @@ pub struct IVec3 { /// Returns a vector containing the saturating division of `self` and `rhs`. /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::IVec4) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: i32) -> bevy::math::IVec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: i32) -> bevy::math::IVec4; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: i32) -> bevy::math::IVec4; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::IVec4; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: i32) -> bevy::math::IVec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct IVec4 { +pub struct LuaIVec4 { x: i32, y: i32, z: i32, @@ -6572,176 +6035,103 @@ pub struct IVec4 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::I64Vec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::I64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::I64Vec2) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::I64Vec2; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: i64, y: i64) -> bevy::math::I64Vec2; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: i64) -> bevy::math::I64Vec2; "#, @@ -6751,7 +6141,7 @@ pub struct IVec4 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec2, @@ -6765,35 +6155,35 @@ pub struct IVec4 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [i64; 2]) -> bevy::math::I64Vec2; "#, r#" /// `[x, y]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [i64; 2]; "#, r#" /// Creates a 3D vector from `self` and the given `z` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, z: i64) -> bevy::math::I64Vec3; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, @@ -6801,7 +6191,7 @@ pub struct IVec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, @@ -6809,7 +6199,7 @@ pub struct IVec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, @@ -6819,7 +6209,7 @@ pub struct IVec4 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -6833,7 +6223,7 @@ pub struct IVec4 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> i64; "#, @@ -6841,7 +6231,7 @@ pub struct IVec4 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> i64; "#, @@ -6851,7 +6241,7 @@ pub struct IVec4 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; "#, @@ -6861,7 +6251,7 @@ pub struct IVec4 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; "#, @@ -6871,7 +6261,7 @@ pub struct IVec4 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; "#, @@ -6881,7 +6271,7 @@ pub struct IVec4 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; "#, @@ -6891,7 +6281,7 @@ pub struct IVec4 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; "#, @@ -6901,14 +6291,14 @@ pub struct IVec4 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::I64Vec2; "#, @@ -6918,7 +6308,7 @@ pub struct IVec4 { /// - `1` if the number is positive /// - `-1` if the number is negative - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::I64Vec2; "#, @@ -6927,21 +6317,21 @@ pub struct IVec4 { /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, r#" /// Computes the squared length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> i64; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; "#, @@ -6950,7 +6340,7 @@ pub struct IVec4 { /// # Panics /// This function will panic if any `rhs` element is 0 or the division results in overflow. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, @@ -6960,14 +6350,14 @@ pub struct IVec4 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. /// [Euclidean division]: i64::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" /// Returns a vector that is equal to `self` rotated by 90 degrees. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn perp(self) -> bevy::math::I64Vec2; "#, @@ -6975,7 +6365,7 @@ pub struct IVec4 { /// The perpendicular dot product of `self` and `rhs`. /// Also known as the wedge product, 2D cross product, and determinant. - #[lua(kind = "Method")] + #[lua()] fn perp_dot(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; "#, @@ -6984,42 +6374,42 @@ pub struct IVec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn rotate(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec2(&self) -> bevy::math::Vec2; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec2(&self) -> bevy::math::DVec2; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec2(&self) -> bevy::math::IVec2; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec2(&self) -> bevy::math::UVec2; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec2(&self) -> bevy::math::U64Vec2; "#, @@ -7027,7 +6417,7 @@ pub struct IVec4 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, @@ -7035,7 +6425,7 @@ pub struct IVec4 { /// Returns a vector containing the wrapping subtraction of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, @@ -7043,7 +6433,7 @@ pub struct IVec4 { /// Returns a vector containing the wrapping multiplication of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, @@ -7051,7 +6441,7 @@ pub struct IVec4 { /// Returns a vector containing the wrapping division of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, @@ -7059,7 +6449,7 @@ pub struct IVec4 { /// Returns a vector containing the saturating addition of `self` and `rhs`. /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, @@ -7067,7 +6457,7 @@ pub struct IVec4 { /// Returns a vector containing the saturating subtraction of `self` and `rhs`. /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, @@ -7075,7 +6465,7 @@ pub struct IVec4 { /// Returns a vector containing the saturating multiplication of `self` and `rhs`. /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, @@ -7083,77 +6473,61 @@ pub struct IVec4 { /// Returns a vector containing the saturating division of `self` and `rhs`. /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct I64Vec2 { +pub struct LuaI64Vec2 { x: i64, y: i64, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::I64Vec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: i64, y: i64, z: i64) -> bevy::math::I64Vec3; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: i64) -> bevy::math::I64Vec3; "#, @@ -7163,7 +6537,7 @@ pub struct I64Vec2 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec3, @@ -7177,21 +6551,21 @@ pub struct I64Vec2 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [i64; 3]) -> bevy::math::I64Vec3; "#, r#" /// `[x, y, z]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [i64; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, w: i64) -> bevy::math::I64Vec4; "#, @@ -7199,28 +6573,28 @@ pub struct I64Vec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::I64Vec2; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::I64Vec3) -> i64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" /// Computes the cross product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cross(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, @@ -7228,7 +6602,7 @@ pub struct I64Vec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, @@ -7236,7 +6610,7 @@ pub struct I64Vec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, @@ -7246,7 +6620,7 @@ pub struct I64Vec2 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -7260,7 +6634,7 @@ pub struct I64Vec2 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> i64; "#, @@ -7268,7 +6642,7 @@ pub struct I64Vec2 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> i64; "#, @@ -7278,7 +6652,7 @@ pub struct I64Vec2 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; "#, @@ -7288,7 +6662,7 @@ pub struct I64Vec2 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; "#, @@ -7298,7 +6672,7 @@ pub struct I64Vec2 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; "#, @@ -7308,7 +6682,7 @@ pub struct I64Vec2 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; "#, @@ -7318,7 +6692,7 @@ pub struct I64Vec2 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; "#, @@ -7328,14 +6702,14 @@ pub struct I64Vec2 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::I64Vec3; "#, @@ -7345,7 +6719,7 @@ pub struct I64Vec2 { /// - `1` if the number is positive /// - `-1` if the number is negative - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::I64Vec3; "#, @@ -7354,21 +6728,21 @@ pub struct I64Vec2 { /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, r#" /// Computes the squared length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> i64; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec3) -> i64; "#, @@ -7377,7 +6751,7 @@ pub struct I64Vec2 { /// # Panics /// This function will panic if any `rhs` element is 0 or the division results in overflow. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, @@ -7387,49 +6761,49 @@ pub struct I64Vec2 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. /// [Euclidean division]: i64::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec3(&self) -> bevy::math::Vec3; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec3a(&self) -> bevy::math::Vec3A; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec3(&self) -> bevy::math::DVec3; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, @@ -7437,7 +6811,7 @@ pub struct I64Vec2 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, @@ -7445,7 +6819,7 @@ pub struct I64Vec2 { /// Returns a vector containing the wrapping subtraction of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, @@ -7453,7 +6827,7 @@ pub struct I64Vec2 { /// Returns a vector containing the wrapping multiplication of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, @@ -7461,7 +6835,7 @@ pub struct I64Vec2 { /// Returns a vector containing the wrapping division of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, @@ -7469,7 +6843,7 @@ pub struct I64Vec2 { /// Returns a vector containing the saturating addition of `self` and `rhs`. /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, @@ -7477,7 +6851,7 @@ pub struct I64Vec2 { /// Returns a vector containing the saturating subtraction of `self` and `rhs`. /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, @@ -7485,7 +6859,7 @@ pub struct I64Vec2 { /// Returns a vector containing the saturating multiplication of `self` and `rhs`. /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, @@ -7493,135 +6867,78 @@ pub struct I64Vec2 { /// Returns a vector containing the saturating division of `self` and `rhs`. /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::I64Vec3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::I64Vec3) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::I64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct I64Vec3 { +pub struct LuaI64Vec3 { x: i64, y: i64, z: i64, @@ -7629,59 +6946,43 @@ pub struct I64Vec3 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::I64Vec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: i64, y: i64, z: i64, w: i64) -> bevy::math::I64Vec4; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: i64) -> bevy::math::I64Vec4; "#, @@ -7691,7 +6992,7 @@ pub struct I64Vec3 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec4, @@ -7705,14 +7006,14 @@ pub struct I64Vec3 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [i64; 4]) -> bevy::math::I64Vec4; "#, r#" /// `[x, y, z, w]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [i64; 4]; "#, @@ -7720,21 +7021,21 @@ pub struct I64Vec3 { /// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. /// Truncation to [`I64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::I64Vec3; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::I64Vec4) -> i64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, @@ -7742,7 +7043,7 @@ pub struct I64Vec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, @@ -7750,7 +7051,7 @@ pub struct I64Vec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, @@ -7760,7 +7061,7 @@ pub struct I64Vec3 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -7774,7 +7075,7 @@ pub struct I64Vec3 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> i64; "#, @@ -7782,7 +7083,7 @@ pub struct I64Vec3 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> i64; "#, @@ -7792,7 +7093,7 @@ pub struct I64Vec3 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; "#, @@ -7802,7 +7103,7 @@ pub struct I64Vec3 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; "#, @@ -7812,7 +7113,7 @@ pub struct I64Vec3 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; "#, @@ -7822,7 +7123,7 @@ pub struct I64Vec3 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; "#, @@ -7832,7 +7133,7 @@ pub struct I64Vec3 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; "#, @@ -7842,14 +7143,14 @@ pub struct I64Vec3 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::I64Vec4; "#, @@ -7859,7 +7160,7 @@ pub struct I64Vec3 { /// - `1` if the number is positive /// - `-1` if the number is negative - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::I64Vec4; "#, @@ -7868,21 +7169,21 @@ pub struct I64Vec3 { /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, r#" /// Computes the squared length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> i64; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec4) -> i64; "#, @@ -7891,7 +7192,7 @@ pub struct I64Vec3 { /// # Panics /// This function will panic if any `rhs` element is 0 or the division results in overflow. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, @@ -7901,42 +7202,42 @@ pub struct I64Vec3 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. /// [Euclidean division]: i64::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec4(&self) -> bevy::math::Vec4; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec4(&self) -> bevy::math::DVec4; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec4(&self) -> bevy::math::IVec4; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec4(&self) -> bevy::math::UVec4; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec4(&self) -> bevy::math::U64Vec4; "#, @@ -7944,7 +7245,7 @@ pub struct I64Vec3 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, @@ -7952,7 +7253,7 @@ pub struct I64Vec3 { /// Returns a vector containing the wrapping subtraction of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, @@ -7960,7 +7261,7 @@ pub struct I64Vec3 { /// Returns a vector containing the wrapping multiplication of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, @@ -7968,7 +7269,7 @@ pub struct I64Vec3 { /// Returns a vector containing the wrapping division of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, @@ -7976,7 +7277,7 @@ pub struct I64Vec3 { /// Returns a vector containing the saturating addition of `self` and `rhs`. /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, @@ -7984,7 +7285,7 @@ pub struct I64Vec3 { /// Returns a vector containing the saturating subtraction of `self` and `rhs`. /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, @@ -7992,7 +7293,7 @@ pub struct I64Vec3 { /// Returns a vector containing the saturating multiplication of `self` and `rhs`. /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, @@ -8000,135 +7301,78 @@ pub struct I64Vec3 { /// Returns a vector containing the saturating division of `self` and `rhs`. /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::I64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::I64Vec4) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::I64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct I64Vec4 { +pub struct LuaI64Vec4 { x: i64, y: i64, z: i64, @@ -8137,164 +7381,97 @@ pub struct I64Vec4 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::UVec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: u32) -> bevy::math::UVec2; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: u32) -> bevy::math::UVec2; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::UVec2) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::UVec2; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: u32) -> bevy::math::UVec2; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: u32) -> bevy::math::UVec2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: u32) -> bevy::math::UVec2; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: u32, y: u32) -> bevy::math::UVec2; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: u32) -> bevy::math::UVec2; "#, @@ -8304,7 +7481,7 @@ pub struct I64Vec4 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec2, @@ -8318,35 +7495,35 @@ pub struct I64Vec4 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [u32; 2]) -> bevy::math::UVec2; "#, r#" /// `[x, y]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [u32; 2]; "#, r#" /// Creates a 3D vector from `self` and the given `z` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, z: u32) -> bevy::math::UVec3; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::UVec2) -> u32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, @@ -8354,7 +7531,7 @@ pub struct I64Vec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, @@ -8362,7 +7539,7 @@ pub struct I64Vec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, @@ -8372,7 +7549,7 @@ pub struct I64Vec4 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -8386,7 +7563,7 @@ pub struct I64Vec4 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> u32; "#, @@ -8394,7 +7571,7 @@ pub struct I64Vec4 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> u32; "#, @@ -8404,7 +7581,7 @@ pub struct I64Vec4 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; "#, @@ -8414,7 +7591,7 @@ pub struct I64Vec4 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; "#, @@ -8424,7 +7601,7 @@ pub struct I64Vec4 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; "#, @@ -8434,7 +7611,7 @@ pub struct I64Vec4 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; "#, @@ -8444,7 +7621,7 @@ pub struct I64Vec4 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; "#, @@ -8454,49 +7631,49 @@ pub struct I64Vec4 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; "#, r#" /// Computes the squared length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> u32; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec2(&self) -> bevy::math::Vec2; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec2(&self) -> bevy::math::DVec2; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec2(&self) -> bevy::math::IVec2; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec2(&self) -> bevy::math::I64Vec2; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec2(&self) -> bevy::math::U64Vec2; "#, @@ -8504,7 +7681,7 @@ pub struct I64Vec4 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, @@ -8512,7 +7689,7 @@ pub struct I64Vec4 { /// Returns a vector containing the wrapping subtraction of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, @@ -8520,7 +7697,7 @@ pub struct I64Vec4 { /// Returns a vector containing the wrapping multiplication of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, @@ -8528,7 +7705,7 @@ pub struct I64Vec4 { /// Returns a vector containing the wrapping division of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, @@ -8536,7 +7713,7 @@ pub struct I64Vec4 { /// Returns a vector containing the saturating addition of `self` and `rhs`. /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, @@ -8544,7 +7721,7 @@ pub struct I64Vec4 { /// Returns a vector containing the saturating subtraction of `self` and `rhs`. /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, @@ -8552,7 +7729,7 @@ pub struct I64Vec4 { /// Returns a vector containing the saturating multiplication of `self` and `rhs`. /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, @@ -8560,119 +7737,85 @@ pub struct I64Vec4 { /// Returns a vector containing the saturating division of `self` and `rhs`. /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct UVec2 { +pub struct LuaUVec2 { x: u32, y: u32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::UVec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: u32) -> bevy::math::UVec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: u32) -> bevy::math::UVec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: u32) -> bevy::math::UVec3; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: u32, y: u32, z: u32) -> bevy::math::UVec3; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: u32) -> bevy::math::UVec3; "#, @@ -8682,7 +7825,7 @@ pub struct UVec2 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec3, @@ -8696,21 +7839,21 @@ pub struct UVec2 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [u32; 3]) -> bevy::math::UVec3; "#, r#" /// `[x, y, z]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [u32; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, w: u32) -> bevy::math::UVec4; "#, @@ -8718,28 +7861,28 @@ pub struct UVec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::UVec2; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::UVec3) -> u32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" /// Computes the cross product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cross(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, @@ -8747,7 +7890,7 @@ pub struct UVec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, @@ -8755,7 +7898,7 @@ pub struct UVec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, @@ -8765,7 +7908,7 @@ pub struct UVec2 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -8779,7 +7922,7 @@ pub struct UVec2 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> u32; "#, @@ -8787,7 +7930,7 @@ pub struct UVec2 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> u32; "#, @@ -8797,7 +7940,7 @@ pub struct UVec2 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; "#, @@ -8807,7 +7950,7 @@ pub struct UVec2 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; "#, @@ -8817,7 +7960,7 @@ pub struct UVec2 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; "#, @@ -8827,7 +7970,7 @@ pub struct UVec2 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; "#, @@ -8837,7 +7980,7 @@ pub struct UVec2 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; "#, @@ -8847,56 +7990,56 @@ pub struct UVec2 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; "#, r#" /// Computes the squared length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> u32; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec3(&self) -> bevy::math::Vec3; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec3a(&self) -> bevy::math::Vec3A; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec3(&self) -> bevy::math::DVec3; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, @@ -8904,7 +8047,7 @@ pub struct UVec2 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, @@ -8912,7 +8055,7 @@ pub struct UVec2 { /// Returns a vector containing the wrapping subtraction of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, @@ -8920,7 +8063,7 @@ pub struct UVec2 { /// Returns a vector containing the wrapping multiplication of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, @@ -8928,7 +8071,7 @@ pub struct UVec2 { /// Returns a vector containing the wrapping division of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, @@ -8936,7 +8079,7 @@ pub struct UVec2 { /// Returns a vector containing the saturating addition of `self` and `rhs`. /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, @@ -8944,7 +8087,7 @@ pub struct UVec2 { /// Returns a vector containing the saturating subtraction of `self` and `rhs`. /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, @@ -8952,7 +8095,7 @@ pub struct UVec2 { /// Returns a vector containing the saturating multiplication of `self` and `rhs`. /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, @@ -8960,105 +8103,72 @@ pub struct UVec2 { /// Returns a vector containing the saturating division of `self` and `rhs`. /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::UVec3) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: u32) -> bevy::math::UVec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::UVec3; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: u32) -> bevy::math::UVec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct UVec3 { +pub struct LuaUVec3 { x: u32, y: u32, z: u32, @@ -9066,95 +8176,61 @@ pub struct UVec3 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::UVec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: u32) -> bevy::math::UVec4; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: u32) -> bevy::math::UVec4; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: u32) -> bevy::math::UVec4; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: u32, y: u32, z: u32, w: u32) -> bevy::math::UVec4; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: u32) -> bevy::math::UVec4; "#, @@ -9164,7 +8240,7 @@ pub struct UVec3 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec4, @@ -9178,14 +8254,14 @@ pub struct UVec3 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [u32; 4]) -> bevy::math::UVec4; "#, r#" /// `[x, y, z, w]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [u32; 4]; "#, @@ -9193,21 +8269,21 @@ pub struct UVec3 { /// Creates a 3D 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(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::UVec3; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::UVec4) -> u32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, @@ -9215,7 +8291,7 @@ pub struct UVec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, @@ -9223,7 +8299,7 @@ pub struct UVec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, @@ -9233,7 +8309,7 @@ pub struct UVec3 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -9247,7 +8323,7 @@ pub struct UVec3 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> u32; "#, @@ -9255,7 +8331,7 @@ pub struct UVec3 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> u32; "#, @@ -9265,7 +8341,7 @@ pub struct UVec3 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; "#, @@ -9275,7 +8351,7 @@ pub struct UVec3 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; "#, @@ -9285,7 +8361,7 @@ pub struct UVec3 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; "#, @@ -9295,7 +8371,7 @@ pub struct UVec3 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; "#, @@ -9305,7 +8381,7 @@ pub struct UVec3 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; "#, @@ -9315,49 +8391,49 @@ pub struct UVec3 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; "#, r#" /// Computes the squared length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> u32; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec4(&self) -> bevy::math::Vec4; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec4(&self) -> bevy::math::DVec4; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec4(&self) -> bevy::math::IVec4; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec4(&self) -> bevy::math::I64Vec4; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec4(&self) -> bevy::math::U64Vec4; "#, @@ -9365,7 +8441,7 @@ pub struct UVec3 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, @@ -9373,7 +8449,7 @@ pub struct UVec3 { /// Returns a vector containing the wrapping subtraction of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, @@ -9381,7 +8457,7 @@ pub struct UVec3 { /// Returns a vector containing the wrapping multiplication of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, @@ -9389,7 +8465,7 @@ pub struct UVec3 { /// Returns a vector containing the wrapping division of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, @@ -9397,7 +8473,7 @@ pub struct UVec3 { /// Returns a vector containing the saturating addition of `self` and `rhs`. /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, @@ -9405,7 +8481,7 @@ pub struct UVec3 { /// Returns a vector containing the saturating subtraction of `self` and `rhs`. /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, @@ -9413,7 +8489,7 @@ pub struct UVec3 { /// Returns a vector containing the saturating multiplication of `self` and `rhs`. /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, @@ -9421,99 +8497,66 @@ pub struct UVec3 { /// Returns a vector containing the saturating division of `self` and `rhs`. /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::UVec4) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: u32) -> bevy::math::UVec4; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::UVec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: u32) -> bevy::math::UVec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct UVec4 { +pub struct LuaUVec4 { x: u32, y: u32, z: u32, @@ -9522,29 +8565,25 @@ pub struct UVec4 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::U64Vec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: u64) -> bevy::math::U64Vec2; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: u64, y: u64) -> bevy::math::U64Vec2; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: u64) -> bevy::math::U64Vec2; "#, @@ -9554,7 +8593,7 @@ pub struct UVec4 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec2, @@ -9568,35 +8607,35 @@ pub struct UVec4 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [u64; 2]) -> bevy::math::U64Vec2; "#, r#" /// `[x, y]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [u64; 2]; "#, r#" /// Creates a 3D vector from `self` and the given `z` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, z: u64) -> bevy::math::U64Vec3; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::U64Vec2) -> u64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, @@ -9604,7 +8643,7 @@ pub struct UVec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, @@ -9612,7 +8651,7 @@ pub struct UVec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, @@ -9622,7 +8661,7 @@ pub struct UVec4 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -9636,7 +8675,7 @@ pub struct UVec4 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> u64; "#, @@ -9644,7 +8683,7 @@ pub struct UVec4 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> u64; "#, @@ -9654,7 +8693,7 @@ pub struct UVec4 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; "#, @@ -9664,7 +8703,7 @@ pub struct UVec4 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; "#, @@ -9674,7 +8713,7 @@ pub struct UVec4 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; "#, @@ -9684,7 +8723,7 @@ pub struct UVec4 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; "#, @@ -9694,7 +8733,7 @@ pub struct UVec4 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; "#, @@ -9704,49 +8743,49 @@ pub struct UVec4 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; "#, r#" /// Computes the squared length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> u64; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec2(&self) -> bevy::math::Vec2; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec2(&self) -> bevy::math::DVec2; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec2(&self) -> bevy::math::IVec2; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec2(&self) -> bevy::math::UVec2; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec2(&self) -> bevy::math::I64Vec2; "#, @@ -9754,7 +8793,7 @@ pub struct UVec4 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, @@ -9762,7 +8801,7 @@ pub struct UVec4 { /// Returns a vector containing the wrapping subtraction of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, @@ -9770,7 +8809,7 @@ pub struct UVec4 { /// Returns a vector containing the wrapping multiplication of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, @@ -9778,7 +8817,7 @@ pub struct UVec4 { /// Returns a vector containing the wrapping division of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, @@ -9786,7 +8825,7 @@ pub struct UVec4 { /// Returns a vector containing the saturating addition of `self` and `rhs`. /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, @@ -9794,7 +8833,7 @@ pub struct UVec4 { /// Returns a vector containing the saturating subtraction of `self` and `rhs`. /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, @@ -9802,7 +8841,7 @@ pub struct UVec4 { /// Returns a vector containing the saturating multiplication of `self` and `rhs`. /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, @@ -9810,182 +8849,115 @@ pub struct UVec4 { /// Returns a vector containing the saturating division of `self` and `rhs`. /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: u64) -> bevy::math::U64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: u64) -> bevy::math::U64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::U64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::U64Vec2) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: u64) -> bevy::math::U64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: u64) -> bevy::math::U64Vec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct U64Vec2 { +pub struct LuaU64Vec2 { x: u64, y: u64, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::U64Vec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: u64) -> bevy::math::U64Vec3; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: u64, y: u64, z: u64) -> bevy::math::U64Vec3; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: u64) -> bevy::math::U64Vec3; "#, @@ -9995,7 +8967,7 @@ pub struct U64Vec2 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec3, @@ -10009,21 +8981,21 @@ pub struct U64Vec2 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [u64; 3]) -> bevy::math::U64Vec3; "#, r#" /// `[x, y, z]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [u64; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, w: u64) -> bevy::math::U64Vec4; "#, @@ -10031,28 +9003,28 @@ pub struct U64Vec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::U64Vec2; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::U64Vec3) -> u64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" /// Computes the cross product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cross(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, @@ -10060,7 +9032,7 @@ pub struct U64Vec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, @@ -10068,7 +9040,7 @@ pub struct U64Vec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, @@ -10078,7 +9050,7 @@ pub struct U64Vec2 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -10092,7 +9064,7 @@ pub struct U64Vec2 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> u64; "#, @@ -10100,7 +9072,7 @@ pub struct U64Vec2 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> u64; "#, @@ -10110,7 +9082,7 @@ pub struct U64Vec2 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; "#, @@ -10120,7 +9092,7 @@ pub struct U64Vec2 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; "#, @@ -10130,7 +9102,7 @@ pub struct U64Vec2 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; "#, @@ -10140,7 +9112,7 @@ pub struct U64Vec2 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; "#, @@ -10150,7 +9122,7 @@ pub struct U64Vec2 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; "#, @@ -10160,56 +9132,56 @@ pub struct U64Vec2 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; "#, r#" /// Computes the squared length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> u64; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec3(&self) -> bevy::math::Vec3; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec3a(&self) -> bevy::math::Vec3A; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec3(&self) -> bevy::math::DVec3; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, @@ -10217,7 +9189,7 @@ pub struct U64Vec2 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, @@ -10225,7 +9197,7 @@ pub struct U64Vec2 { /// Returns a vector containing the wrapping subtraction of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, @@ -10233,7 +9205,7 @@ pub struct U64Vec2 { /// Returns a vector containing the wrapping multiplication of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, @@ -10241,7 +9213,7 @@ pub struct U64Vec2 { /// Returns a vector containing the wrapping division of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, @@ -10249,7 +9221,7 @@ pub struct U64Vec2 { /// Returns a vector containing the saturating addition of `self` and `rhs`. /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, @@ -10257,7 +9229,7 @@ pub struct U64Vec2 { /// Returns a vector containing the saturating subtraction of `self` and `rhs`. /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, @@ -10265,7 +9237,7 @@ pub struct U64Vec2 { /// Returns a vector containing the saturating multiplication of `self` and `rhs`. /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, @@ -10273,153 +9245,90 @@ pub struct U64Vec2 { /// Returns a vector containing the saturating division of `self` and `rhs`. /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: u64) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: u64) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: u64) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::U64Vec3) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: u64) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct U64Vec3 { +pub struct LuaU64Vec3 { x: u64, y: u64, z: u64, @@ -10427,17 +9336,19 @@ pub struct U64Vec3 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::U64Vec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: u64, y: u64, z: u64, w: u64) -> bevy::math::U64Vec4; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: u64) -> bevy::math::U64Vec4; "#, @@ -10447,7 +9358,7 @@ pub struct U64Vec3 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec4, @@ -10461,14 +9372,14 @@ pub struct U64Vec3 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [u64; 4]) -> bevy::math::U64Vec4; "#, r#" /// `[x, y, z, w]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [u64; 4]; "#, @@ -10476,21 +9387,21 @@ pub struct U64Vec3 { /// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. /// Truncation to [`U64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::U64Vec3; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::U64Vec4) -> u64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, @@ -10498,7 +9409,7 @@ pub struct U64Vec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, @@ -10506,7 +9417,7 @@ pub struct U64Vec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, @@ -10516,7 +9427,7 @@ pub struct U64Vec3 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -10530,7 +9441,7 @@ pub struct U64Vec3 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> u64; "#, @@ -10538,7 +9449,7 @@ pub struct U64Vec3 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> u64; "#, @@ -10548,7 +9459,7 @@ pub struct U64Vec3 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; "#, @@ -10558,7 +9469,7 @@ pub struct U64Vec3 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; "#, @@ -10568,7 +9479,7 @@ pub struct U64Vec3 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; "#, @@ -10578,7 +9489,7 @@ pub struct U64Vec3 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; "#, @@ -10588,7 +9499,7 @@ pub struct U64Vec3 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; "#, @@ -10598,49 +9509,49 @@ pub struct U64Vec3 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; "#, r#" /// Computes the squared length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> u64; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec4(&self) -> bevy::math::Vec4; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec4(&self) -> bevy::math::DVec4; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec4(&self) -> bevy::math::IVec4; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec4(&self) -> bevy::math::UVec4; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec4(&self) -> bevy::math::I64Vec4; "#, @@ -10648,7 +9559,7 @@ pub struct U64Vec3 { /// Returns a vector containing the wrapping addition of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, @@ -10656,7 +9567,7 @@ pub struct U64Vec3 { /// Returns a vector containing the wrapping subtraction of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, @@ -10664,7 +9575,7 @@ pub struct U64Vec3 { /// Returns a vector containing the wrapping multiplication of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, @@ -10672,7 +9583,7 @@ pub struct U64Vec3 { /// Returns a vector containing the wrapping division of `self` and `rhs`. /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, @@ -10680,7 +9591,7 @@ pub struct U64Vec3 { /// Returns a vector containing the saturating addition of `self` and `rhs`. /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, @@ -10688,7 +9599,7 @@ pub struct U64Vec3 { /// Returns a vector containing the saturating subtraction of `self` and `rhs`. /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, @@ -10696,7 +9607,7 @@ pub struct U64Vec3 { /// Returns a vector containing the saturating multiplication of `self` and `rhs`. /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, @@ -10704,165 +9615,96 @@ pub struct U64Vec3 { /// Returns a vector containing the saturating division of `self` and `rhs`. /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::U64Vec4) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::U64Vec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct U64Vec4 { +pub struct LuaU64Vec4 { x: u64, y: u64, z: u64, @@ -10871,148 +9713,85 @@ pub struct U64Vec4 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::Vec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: f32) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: f32) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: f32) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::Vec2) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f32) -> bevy::math::Vec2; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: f32, y: f32) -> bevy::math::Vec2; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: f32) -> bevy::math::Vec2; "#, @@ -11022,7 +9801,7 @@ pub struct U64Vec4 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec2, @@ -11036,35 +9815,35 @@ pub struct U64Vec4 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [f32; 2]) -> bevy::math::Vec2; "#, r#" /// `[x, y]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [f32; 2]; "#, r#" /// Creates a 3D vector from `self` and the given `z` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, z: f32) -> bevy::math::Vec3; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::Vec2) -> f32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -11072,7 +9851,7 @@ pub struct U64Vec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -11080,7 +9859,7 @@ pub struct U64Vec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -11090,7 +9869,7 @@ pub struct U64Vec4 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -11104,7 +9883,7 @@ pub struct U64Vec4 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> f32; "#, @@ -11112,7 +9891,7 @@ pub struct U64Vec4 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> f32; "#, @@ -11122,7 +9901,7 @@ pub struct U64Vec4 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; "#, @@ -11132,7 +9911,7 @@ pub struct U64Vec4 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; "#, @@ -11142,7 +9921,7 @@ pub struct U64Vec4 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; "#, @@ -11152,7 +9931,7 @@ pub struct U64Vec4 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; "#, @@ -11162,7 +9941,7 @@ pub struct U64Vec4 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; "#, @@ -11172,14 +9951,14 @@ pub struct U64Vec4 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::Vec2; "#, @@ -11189,14 +9968,14 @@ pub struct U64Vec4 { /// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` /// - `NAN` if the number is `NAN` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::Vec2; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn copysign(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -11205,7 +9984,7 @@ pub struct U64Vec4 { /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, @@ -11213,14 +9992,14 @@ pub struct U64Vec4 { /// 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(kind = "Method")] + #[lua()] fn is_finite(self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(self) -> bool; "#, @@ -11228,14 +10007,14 @@ pub struct U64Vec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn is_nan_mask(self) -> bevy::math::BVec2; "#, r#" /// Computes the length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length(self) -> f32; "#, @@ -11243,7 +10022,7 @@ pub struct U64Vec4 { /// Computes the squared length of `self`. /// This is faster than `length()` as it avoids a square root operation. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> f32; "#, @@ -11251,28 +10030,28 @@ pub struct U64Vec4 { /// Computes `1.0 / length()`. /// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method")] + #[lua()] fn length_recip(self) -> f32; "#, r#" /// Computes the Euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance(self, #[proxy] rhs: bevy::math::Vec2) -> f32; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::Vec2) -> f32; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -11280,7 +10059,7 @@ pub struct U64Vec4 { /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. /// [Euclidean division]: f32::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -11291,7 +10070,7 @@ pub struct U64Vec4 { /// Panics /// Will panic if `self` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize(self) -> bevy::math::Vec2; "#, @@ -11301,7 +10080,7 @@ pub struct U64Vec4 { /// the result of this operation will be zero. /// See also [`Self::try_normalize()`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize_or_zero(self) -> bevy::math::Vec2; "#, @@ -11309,7 +10088,7 @@ pub struct U64Vec4 { /// Returns whether `self` is length `1.0` or not. /// Uses a precision threshold of `1e-6`. - #[lua(kind = "Method")] + #[lua()] fn is_normalized(self) -> bool; "#, @@ -11319,7 +10098,7 @@ pub struct U64Vec4 { /// # Panics /// Will panic if `rhs` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -11331,7 +10110,7 @@ pub struct U64Vec4 { /// # Panics /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -11341,7 +10120,7 @@ pub struct U64Vec4 { /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -11353,7 +10132,7 @@ pub struct U64Vec4 { /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -11361,7 +10140,7 @@ pub struct U64Vec4 { /// Returns a vector containing the nearest integer to a number for each element of `self`. /// Round half-way cases away from 0.0. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn round(self) -> bevy::math::Vec2; "#, @@ -11369,7 +10148,7 @@ pub struct U64Vec4 { /// Returns a vector containing the largest integer less than or equal to a number for each /// element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn floor(self) -> bevy::math::Vec2; "#, @@ -11377,7 +10156,7 @@ pub struct U64Vec4 { /// Returns a vector containing the smallest integer greater than or equal to a number for /// each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn ceil(self) -> bevy::math::Vec2; "#, @@ -11385,7 +10164,7 @@ pub struct U64Vec4 { /// Returns a vector containing the integer part each element of `self`. This means numbers are /// always truncated towards zero. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn trunc(self) -> bevy::math::Vec2; "#, @@ -11394,7 +10173,7 @@ pub struct U64Vec4 { /// self.floor()`. /// Note that this is fast but not precise for large numbers. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn fract(self) -> bevy::math::Vec2; "#, @@ -11402,21 +10181,21 @@ pub struct U64Vec4 { /// Returns a vector containing `e^self` (the exponential function) for each element of /// `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn exp(self) -> bevy::math::Vec2; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn powf(self, n: f32) -> bevy::math::Vec2; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn recip(self) -> bevy::math::Vec2; "#, @@ -11426,7 +10205,7 @@ pub struct U64Vec4 { /// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly /// extrapolated. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn lerp(self, #[proxy] rhs: bevy::math::Vec2, s: f32) -> bevy::math::Vec2; "#, @@ -11439,7 +10218,7 @@ pub struct U64Vec4 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec2, max_abs_diff: f32) -> bool; "#, @@ -11448,21 +10227,21 @@ pub struct U64Vec4 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec2; "#, r#" /// Returns a vector with a length no more than `max` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_max(self, max: f32) -> bevy::math::Vec2; "#, r#" /// Returns a vector with a length no less than `min` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_min(self, min: f32) -> bevy::math::Vec2; "#, @@ -11474,7 +10253,7 @@ pub struct U64Vec4 { /// and will be heavily dependant on designing algorithms with specific target hardware in /// mind. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_add( self, #[proxy] @@ -11490,7 +10269,7 @@ pub struct U64Vec4 { /// `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))] + #[lua()] fn from_angle(angle: f32) -> bevy::math::Vec2; "#, @@ -11498,7 +10277,7 @@ pub struct U64Vec4 { /// Returns the angle (in radians) of this vector in the range `[-Ï€, +Ï€]`. /// The input does not need to be a unit vector however it must be non-zero. - #[lua(kind = "Method")] + #[lua()] fn to_angle(self) -> f32; "#, @@ -11506,14 +10285,14 @@ pub struct U64Vec4 { /// 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(kind = "Method")] + #[lua()] fn angle_between(self, #[proxy] rhs: bevy::math::Vec2) -> f32; "#, r#" /// Returns a vector that is equal to `self` rotated by 90 degrees. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn perp(self) -> bevy::math::Vec2; "#, @@ -11521,7 +10300,7 @@ pub struct U64Vec4 { /// The perpendicular dot product of `self` and `rhs`. /// Also known as the wedge product, 2D cross product, and determinant. - #[lua(kind = "Method")] + #[lua()] fn perp_dot(self, #[proxy] rhs: bevy::math::Vec2) -> f32; "#, @@ -11530,151 +10309,120 @@ pub struct U64Vec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn rotate(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec2(&self) -> bevy::math::DVec2; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec2(&self) -> bevy::math::IVec2; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec2(&self) -> bevy::math::UVec2; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec2(&self) -> bevy::math::I64Vec2; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec2(&self) -> bevy::math::U64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: f32) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::Vec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct Vec2 { +pub struct LuaVec2 { x: f32, y: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::Vec3A", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::Vec3A) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3A; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: f32) -> bevy::math::Vec3A; "#, @@ -11684,7 +10432,7 @@ pub struct Vec2 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec3A, @@ -11698,21 +10446,21 @@ pub struct Vec2 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [f32; 3]) -> bevy::math::Vec3A; "#, r#" /// `[x, y, z]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [f32; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, w: f32) -> bevy::math::Vec4; "#, @@ -11720,28 +10468,28 @@ pub struct Vec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::Vec2; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" /// Computes the cross product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cross(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, @@ -11749,7 +10497,7 @@ pub struct Vec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, @@ -11757,7 +10505,7 @@ pub struct Vec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, @@ -11767,7 +10515,7 @@ pub struct Vec2 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -11781,7 +10529,7 @@ pub struct Vec2 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> f32; "#, @@ -11789,7 +10537,7 @@ pub struct Vec2 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> f32; "#, @@ -11799,7 +10547,7 @@ pub struct Vec2 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; "#, @@ -11809,7 +10557,7 @@ pub struct Vec2 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; "#, @@ -11819,7 +10567,7 @@ pub struct Vec2 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; "#, @@ -11829,7 +10577,7 @@ pub struct Vec2 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; "#, @@ -11839,7 +10587,7 @@ pub struct Vec2 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; "#, @@ -11849,14 +10597,14 @@ pub struct Vec2 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::Vec3A; "#, @@ -11866,14 +10614,14 @@ pub struct Vec2 { /// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` /// - `NAN` if the number is `NAN` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::Vec3A; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn copysign(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, @@ -11882,7 +10630,7 @@ pub struct Vec2 { /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, @@ -11890,14 +10638,14 @@ pub struct 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`. - #[lua(kind = "Method")] + #[lua()] fn is_finite(self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(self) -> bool; "#, @@ -11905,14 +10653,14 @@ pub struct Vec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn is_nan_mask(self) -> bevy::math::BVec3A; "#, r#" /// Computes the length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length(self) -> f32; "#, @@ -11920,7 +10668,7 @@ pub struct Vec2 { /// Computes the squared length of `self`. /// This is faster than `length()` as it avoids a square root operation. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> f32; "#, @@ -11928,28 +10676,28 @@ pub struct Vec2 { /// Computes `1.0 / length()`. /// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method")] + #[lua()] fn length_recip(self) -> f32; "#, r#" /// Computes the Euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, @@ -11957,7 +10705,7 @@ pub struct Vec2 { /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. /// [Euclidean division]: f32::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, @@ -11968,7 +10716,7 @@ pub struct Vec2 { /// Panics /// Will panic if `self` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize(self) -> bevy::math::Vec3A; "#, @@ -11978,7 +10726,7 @@ pub struct Vec2 { /// the result of this operation will be zero. /// See also [`Self::try_normalize()`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize_or_zero(self) -> bevy::math::Vec3A; "#, @@ -11986,7 +10734,7 @@ pub struct Vec2 { /// Returns whether `self` is length `1.0` or not. /// Uses a precision threshold of `1e-6`. - #[lua(kind = "Method")] + #[lua()] fn is_normalized(self) -> bool; "#, @@ -11996,7 +10744,7 @@ pub struct Vec2 { /// # Panics /// Will panic if `rhs` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, @@ -12008,7 +10756,7 @@ pub struct Vec2 { /// # Panics /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, @@ -12018,7 +10766,7 @@ pub struct Vec2 { /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto_normalized( self, #[proxy] @@ -12034,7 +10782,7 @@ pub struct Vec2 { /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from_normalized( self, #[proxy] @@ -12046,7 +10794,7 @@ pub struct Vec2 { /// Returns a vector containing the nearest integer to a number for each element of `self`. /// Round half-way cases away from 0.0. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn round(self) -> bevy::math::Vec3A; "#, @@ -12054,7 +10802,7 @@ pub struct Vec2 { /// Returns a vector containing the largest integer less than or equal to a number for each /// element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn floor(self) -> bevy::math::Vec3A; "#, @@ -12062,7 +10810,7 @@ pub struct Vec2 { /// Returns a vector containing the smallest integer greater than or equal to a number for /// each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn ceil(self) -> bevy::math::Vec3A; "#, @@ -12070,7 +10818,7 @@ pub struct Vec2 { /// Returns a vector containing the integer part each element of `self`. This means numbers are /// always truncated towards zero. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn trunc(self) -> bevy::math::Vec3A; "#, @@ -12079,7 +10827,7 @@ pub struct Vec2 { /// self.floor()`. /// Note that this is fast but not precise for large numbers. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn fract(self) -> bevy::math::Vec3A; "#, @@ -12087,21 +10835,21 @@ pub struct Vec2 { /// Returns a vector containing `e^self` (the exponential function) for each element of /// `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn exp(self) -> bevy::math::Vec3A; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn powf(self, n: f32) -> bevy::math::Vec3A; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn recip(self) -> bevy::math::Vec3A; "#, @@ -12111,7 +10859,7 @@ pub struct Vec2 { /// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly /// extrapolated. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn lerp(self, #[proxy] rhs: bevy::math::Vec3A, s: f32) -> bevy::math::Vec3A; "#, @@ -12124,7 +10872,7 @@ pub struct Vec2 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec3A, max_abs_diff: f32) -> bool; "#, @@ -12133,21 +10881,21 @@ pub struct Vec2 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3A; "#, r#" /// Returns a vector with a length no more than `max` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_max(self, max: f32) -> bevy::math::Vec3A; "#, r#" /// Returns a vector with a length no less than `min` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_min(self, min: f32) -> bevy::math::Vec3A; "#, @@ -12159,7 +10907,7 @@ pub struct Vec2 { /// and will be heavily dependant on designing algorithms with specific target hardware in /// mind. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_add( self, #[proxy] @@ -12173,7 +10921,7 @@ pub struct Vec2 { /// Returns the angle (in radians) between two vectors. /// The inputs do not need to be unit vectors however they must be non-zero. - #[lua(kind = "Method")] + #[lua()] fn angle_between(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; "#, @@ -12183,7 +10931,7 @@ pub struct Vec2 { /// The output vector is not necessarily unit length. For that use /// [`Self::any_orthonormal_vector()`] instead. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn any_orthogonal_vector(&self) -> bevy::math::Vec3A; "#, @@ -12193,230 +10941,159 @@ pub struct Vec2 { /// # Panics /// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn any_orthonormal_vector(&self) -> bevy::math::Vec3A; "#, r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec3(&self) -> bevy::math::DVec3; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::Vec3A; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::Vec3A; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct Vec3A(); +pub struct LuaVec3A(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::Vec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::Vec4) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::Vec4; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: f32, y: f32, z: f32, w: f32) -> bevy::math::Vec4; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: f32) -> bevy::math::Vec4; "#, @@ -12426,7 +11103,7 @@ pub struct Vec3A(); /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec4A, @@ -12440,14 +11117,14 @@ pub struct Vec3A(); r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [f32; 4]) -> bevy::math::Vec4; "#, r#" /// `[x, y, z, w]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [f32; 4]; "#, @@ -12456,21 +11133,21 @@ pub struct Vec3A(); /// Truncation to [`Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. /// To truncate to [`Vec3A`] use [`Vec3A::from()`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::Vec3; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::Vec4) -> f32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, @@ -12478,7 +11155,7 @@ pub struct Vec3A(); /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, @@ -12486,7 +11163,7 @@ pub struct Vec3A(); /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, @@ -12496,7 +11173,7 @@ pub struct Vec3A(); /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -12510,7 +11187,7 @@ pub struct Vec3A(); /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> f32; "#, @@ -12518,7 +11195,7 @@ pub struct Vec3A(); /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> f32; "#, @@ -12528,7 +11205,7 @@ pub struct Vec3A(); /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; "#, @@ -12538,7 +11215,7 @@ pub struct Vec3A(); /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; "#, @@ -12548,7 +11225,7 @@ pub struct Vec3A(); /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; "#, @@ -12558,7 +11235,7 @@ pub struct Vec3A(); /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; "#, @@ -12568,7 +11245,7 @@ pub struct Vec3A(); /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; "#, @@ -12578,14 +11255,14 @@ pub struct Vec3A(); /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::Vec4; "#, @@ -12595,14 +11272,14 @@ pub struct Vec3A(); /// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` /// - `NAN` if the number is `NAN` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::Vec4; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn copysign(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, @@ -12611,7 +11288,7 @@ pub struct Vec3A(); /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, @@ -12619,14 +11296,14 @@ pub struct 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`. - #[lua(kind = "Method")] + #[lua()] fn is_finite(self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(self) -> bool; "#, @@ -12634,14 +11311,14 @@ pub struct Vec3A(); /// 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(kind = "Method", output(proxy))] + #[lua()] fn is_nan_mask(self) -> bevy::math::BVec4A; "#, r#" /// Computes the length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length(self) -> f32; "#, @@ -12649,7 +11326,7 @@ pub struct Vec3A(); /// Computes the squared length of `self`. /// This is faster than `length()` as it avoids a square root operation. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> f32; "#, @@ -12657,28 +11334,28 @@ pub struct Vec3A(); /// Computes `1.0 / length()`. /// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method")] + #[lua()] fn length_recip(self) -> f32; "#, r#" /// Computes the Euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance(self, #[proxy] rhs: bevy::math::Vec4) -> f32; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::Vec4) -> f32; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, @@ -12686,7 +11363,7 @@ pub struct Vec3A(); /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. /// [Euclidean division]: f32::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, @@ -12697,7 +11374,7 @@ pub struct Vec3A(); /// Panics /// Will panic if `self` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize(self) -> bevy::math::Vec4; "#, @@ -12707,7 +11384,7 @@ pub struct Vec3A(); /// the result of this operation will be zero. /// See also [`Self::try_normalize()`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize_or_zero(self) -> bevy::math::Vec4; "#, @@ -12715,7 +11392,7 @@ pub struct Vec3A(); /// Returns whether `self` is length `1.0` or not. /// Uses a precision threshold of `1e-6`. - #[lua(kind = "Method")] + #[lua()] fn is_normalized(self) -> bool; "#, @@ -12725,7 +11402,7 @@ pub struct Vec3A(); /// # Panics /// Will panic if `rhs` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, @@ -12737,7 +11414,7 @@ pub struct Vec3A(); /// # Panics /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, @@ -12747,7 +11424,7 @@ pub struct Vec3A(); /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, @@ -12759,7 +11436,7 @@ pub struct Vec3A(); /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, @@ -12767,7 +11444,7 @@ pub struct Vec3A(); /// Returns a vector containing the nearest integer to a number for each element of `self`. /// Round half-way cases away from 0.0. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn round(self) -> bevy::math::Vec4; "#, @@ -12775,7 +11452,7 @@ pub struct Vec3A(); /// Returns a vector containing the largest integer less than or equal to a number for each /// element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn floor(self) -> bevy::math::Vec4; "#, @@ -12783,7 +11460,7 @@ pub struct Vec3A(); /// Returns a vector containing the smallest integer greater than or equal to a number for /// each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn ceil(self) -> bevy::math::Vec4; "#, @@ -12791,7 +11468,7 @@ pub struct Vec3A(); /// Returns a vector containing the integer part each element of `self`. This means numbers are /// always truncated towards zero. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn trunc(self) -> bevy::math::Vec4; "#, @@ -12800,7 +11477,7 @@ pub struct Vec3A(); /// self.floor()`. /// Note that this is fast but not precise for large numbers. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn fract(self) -> bevy::math::Vec4; "#, @@ -12808,21 +11485,21 @@ pub struct Vec3A(); /// Returns a vector containing `e^self` (the exponential function) for each element of /// `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn exp(self) -> bevy::math::Vec4; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn powf(self, n: f32) -> bevy::math::Vec4; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn recip(self) -> bevy::math::Vec4; "#, @@ -12832,7 +11509,7 @@ pub struct Vec3A(); /// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly /// extrapolated. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn lerp(self, #[proxy] rhs: bevy::math::Vec4, s: f32) -> bevy::math::Vec4; "#, @@ -12845,7 +11522,7 @@ pub struct Vec3A(); /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec4, max_abs_diff: f32) -> bool; "#, @@ -12854,21 +11531,21 @@ pub struct Vec3A(); /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec4; "#, r#" /// Returns a vector with a length no more than `max` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_max(self, max: f32) -> bevy::math::Vec4; "#, r#" /// Returns a vector with a length no less than `min` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_min(self, min: f32) -> bevy::math::Vec4; "#, @@ -12880,7 +11557,7 @@ pub struct Vec3A(); /// and will be heavily dependant on designing algorithms with specific target hardware in /// mind. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_add( self, #[proxy] @@ -12893,190 +11570,134 @@ pub struct Vec3A(); r#" /// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dvec4(&self) -> bevy::math::DVec4; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec4(&self) -> bevy::math::IVec4; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec4(&self) -> bevy::math::UVec4; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec4(&self) -> bevy::math::I64Vec4; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec4(&self) -> bevy::math::U64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: f32) -> bevy::math::Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f32) -> bevy::math::Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: f32) -> bevy::math::Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: f32) -> bevy::math::Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: f32) -> bevy::math::Vec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct Vec4(); +pub struct LuaVec4(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::BVec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::BVec2; "#, r#" /// Creates a new vector mask. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: bool, y: bool) -> bevy::math::BVec2; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: bool) -> bevy::math::BVec2; "#, @@ -13085,21 +11706,21 @@ pub struct Vec4(); /// 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(kind = "Method")] + #[lua()] fn bitmask(self) -> u32; "#, r#" /// Returns true if any of the elements are true, false otherwise. - #[lua(kind = "Method")] + #[lua()] fn any(self) -> bool; "#, r#" /// Returns true if all the elements are true, false otherwise. - #[lua(kind = "Method")] + #[lua()] fn all(self) -> bool; "#, @@ -13107,7 +11728,7 @@ pub struct Vec4(); /// Tests the value at `index`. /// Panics if `index` is greater than 1. - #[lua(kind = "Method")] + #[lua()] fn test(&self, index: usize) -> bool; "#, @@ -13115,58 +11736,55 @@ pub struct Vec4(); /// Sets the element at `index`. /// Panics if `index` is greater than 1. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set(&mut self, index: usize, value: bool) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::BVec2) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct BVec2 { +pub struct LuaBVec2 { x: bool, y: bool, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::BVec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" /// Creates a new vector mask. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: bool, y: bool, z: bool) -> bevy::math::BVec3; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: bool) -> bevy::math::BVec3; "#, @@ -13175,21 +11793,21 @@ pub struct BVec2 { /// 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(kind = "Method")] + #[lua()] fn bitmask(self) -> u32; "#, r#" /// Returns true if any of the elements are true, false otherwise. - #[lua(kind = "Method")] + #[lua()] fn any(self) -> bool; "#, r#" /// Returns true if all the elements are true, false otherwise. - #[lua(kind = "Method")] + #[lua()] fn all(self) -> bool; "#, @@ -13197,7 +11815,7 @@ pub struct BVec2 { /// Tests the value at `index`. /// Panics if `index` is greater than 2. - #[lua(kind = "Method")] + #[lua()] fn test(&self, index: usize) -> bool; "#, @@ -13205,39 +11823,30 @@ pub struct BVec2 { /// Sets the element at `index`. /// Panics if `index` is greater than 2. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set(&mut self, index: usize, value: bool) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::BVec3) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::BVec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct BVec3 { +pub struct LuaBVec3 { x: bool, y: bool, z: bool, @@ -13245,44 +11854,37 @@ pub struct BVec3 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::BVec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::BVec4) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::BVec4; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" /// Creates a new vector mask. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: bool, y: bool, z: bool, w: bool) -> bevy::math::BVec4; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: bool) -> bevy::math::BVec4; "#, @@ -13291,21 +11893,21 @@ pub struct BVec3 { /// 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(kind = "Method")] + #[lua()] fn bitmask(self) -> u32; "#, r#" /// Returns true if any of the elements are true, false otherwise. - #[lua(kind = "Method")] + #[lua()] fn any(self) -> bool; "#, r#" /// Returns true if all the elements are true, false otherwise. - #[lua(kind = "Method")] + #[lua()] fn all(self) -> bool; "#, @@ -13313,7 +11915,7 @@ pub struct BVec3 { /// Tests the value at `index`. /// Panics if `index` is greater than 3. - #[lua(kind = "Method")] + #[lua()] fn test(&self, index: usize) -> bool; "#, @@ -13321,18 +11923,18 @@ pub struct BVec3 { /// Sets the element at `index`. /// Panics if `index` is greater than 3. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set(&mut self, index: usize, value: bool) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct BVec4 { +pub struct LuaBVec4 { x: bool, y: bool, z: bool, @@ -13341,137 +11943,79 @@ pub struct BVec4 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::DVec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: f64) -> bevy::math::DVec2; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: f64) -> bevy::math::DVec2; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: f64) -> bevy::math::DVec2; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::DVec2; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: f64) -> bevy::math::DVec2; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: f64, y: f64) -> bevy::math::DVec2; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: f64) -> bevy::math::DVec2; "#, @@ -13481,7 +12025,7 @@ pub struct BVec4 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec2, @@ -13495,35 +12039,35 @@ pub struct BVec4 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [f64; 2]) -> bevy::math::DVec2; "#, r#" /// `[x, y]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [f64; 2]; "#, r#" /// Creates a 3D vector from `self` and the given `z` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, z: f64) -> bevy::math::DVec3; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::DVec2) -> f64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, @@ -13531,7 +12075,7 @@ pub struct BVec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, @@ -13539,7 +12083,7 @@ pub struct BVec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, @@ -13549,7 +12093,7 @@ pub struct BVec4 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -13563,7 +12107,7 @@ pub struct BVec4 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> f64; "#, @@ -13571,7 +12115,7 @@ pub struct BVec4 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> f64; "#, @@ -13581,7 +12125,7 @@ pub struct BVec4 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; "#, @@ -13591,7 +12135,7 @@ pub struct BVec4 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; "#, @@ -13601,7 +12145,7 @@ pub struct BVec4 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; "#, @@ -13611,7 +12155,7 @@ pub struct BVec4 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; "#, @@ -13621,7 +12165,7 @@ pub struct BVec4 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; "#, @@ -13631,14 +12175,14 @@ pub struct BVec4 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::DVec2; "#, @@ -13648,14 +12192,14 @@ pub struct BVec4 { /// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` /// - `NAN` if the number is `NAN` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::DVec2; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn copysign(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, @@ -13664,7 +12208,7 @@ pub struct BVec4 { /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, @@ -13672,14 +12216,14 @@ pub struct BVec4 { /// 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(kind = "Method")] + #[lua()] fn is_finite(self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(self) -> bool; "#, @@ -13687,14 +12231,14 @@ pub struct BVec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn is_nan_mask(self) -> bevy::math::BVec2; "#, r#" /// Computes the length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length(self) -> f64; "#, @@ -13702,7 +12246,7 @@ pub struct BVec4 { /// Computes the squared length of `self`. /// This is faster than `length()` as it avoids a square root operation. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> f64; "#, @@ -13710,28 +12254,28 @@ pub struct BVec4 { /// Computes `1.0 / length()`. /// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method")] + #[lua()] fn length_recip(self) -> f64; "#, r#" /// Computes the Euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance(self, #[proxy] rhs: bevy::math::DVec2) -> f64; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::DVec2) -> f64; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, @@ -13739,7 +12283,7 @@ pub struct BVec4 { /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. /// [Euclidean division]: f64::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, @@ -13750,7 +12294,7 @@ pub struct BVec4 { /// Panics /// Will panic if `self` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize(self) -> bevy::math::DVec2; "#, @@ -13760,7 +12304,7 @@ pub struct BVec4 { /// the result of this operation will be zero. /// See also [`Self::try_normalize()`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize_or_zero(self) -> bevy::math::DVec2; "#, @@ -13768,7 +12312,7 @@ pub struct BVec4 { /// Returns whether `self` is length `1.0` or not. /// Uses a precision threshold of `1e-6`. - #[lua(kind = "Method")] + #[lua()] fn is_normalized(self) -> bool; "#, @@ -13778,7 +12322,7 @@ pub struct BVec4 { /// # Panics /// Will panic if `rhs` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, @@ -13790,7 +12334,7 @@ pub struct BVec4 { /// # Panics /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, @@ -13800,7 +12344,7 @@ pub struct BVec4 { /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto_normalized( self, #[proxy] @@ -13816,7 +12360,7 @@ pub struct BVec4 { /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from_normalized( self, #[proxy] @@ -13828,7 +12372,7 @@ pub struct BVec4 { /// Returns a vector containing the nearest integer to a number for each element of `self`. /// Round half-way cases away from 0.0. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn round(self) -> bevy::math::DVec2; "#, @@ -13836,7 +12380,7 @@ pub struct BVec4 { /// Returns a vector containing the largest integer less than or equal to a number for each /// element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn floor(self) -> bevy::math::DVec2; "#, @@ -13844,7 +12388,7 @@ pub struct BVec4 { /// Returns a vector containing the smallest integer greater than or equal to a number for /// each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn ceil(self) -> bevy::math::DVec2; "#, @@ -13852,7 +12396,7 @@ pub struct BVec4 { /// Returns a vector containing the integer part each element of `self`. This means numbers are /// always truncated towards zero. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn trunc(self) -> bevy::math::DVec2; "#, @@ -13861,7 +12405,7 @@ pub struct BVec4 { /// self.floor()`. /// Note that this is fast but not precise for large numbers. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn fract(self) -> bevy::math::DVec2; "#, @@ -13869,21 +12413,21 @@ pub struct BVec4 { /// Returns a vector containing `e^self` (the exponential function) for each element of /// `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn exp(self) -> bevy::math::DVec2; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn powf(self, n: f64) -> bevy::math::DVec2; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn recip(self) -> bevy::math::DVec2; "#, @@ -13893,7 +12437,7 @@ pub struct BVec4 { /// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly /// extrapolated. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn lerp(self, #[proxy] rhs: bevy::math::DVec2, s: f64) -> bevy::math::DVec2; "#, @@ -13906,7 +12450,7 @@ pub struct BVec4 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec2, max_abs_diff: f64) -> bool; "#, @@ -13915,21 +12459,21 @@ pub struct BVec4 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec2; "#, r#" /// Returns a vector with a length no more than `max` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_max(self, max: f64) -> bevy::math::DVec2; "#, r#" /// Returns a vector with a length no less than `min` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_min(self, min: f64) -> bevy::math::DVec2; "#, @@ -13941,7 +12485,7 @@ pub struct BVec4 { /// and will be heavily dependant on designing algorithms with specific target hardware in /// mind. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_add( self, #[proxy] @@ -13957,7 +12501,7 @@ pub struct BVec4 { /// `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))] + #[lua()] fn from_angle(angle: f64) -> bevy::math::DVec2; "#, @@ -13965,7 +12509,7 @@ pub struct BVec4 { /// Returns the angle (in radians) of this vector in the range `[-Ï€, +Ï€]`. /// The input does not need to be a unit vector however it must be non-zero. - #[lua(kind = "Method")] + #[lua()] fn to_angle(self) -> f64; "#, @@ -13973,14 +12517,14 @@ pub struct BVec4 { /// 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(kind = "Method")] + #[lua()] fn angle_between(self, #[proxy] rhs: bevy::math::DVec2) -> f64; "#, r#" /// Returns a vector that is equal to `self` rotated by 90 degrees. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn perp(self) -> bevy::math::DVec2; "#, @@ -13988,7 +12532,7 @@ pub struct BVec4 { /// The perpendicular dot product of `self` and `rhs`. /// Also known as the wedge product, 2D cross product, and determinant. - #[lua(kind = "Method")] + #[lua()] fn perp_dot(self, #[proxy] rhs: bevy::math::DVec2) -> f64; "#, @@ -13997,127 +12541,108 @@ pub struct BVec4 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn rotate(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec2(&self) -> bevy::math::Vec2; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec2(&self) -> bevy::math::IVec2; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec2(&self) -> bevy::math::UVec2; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec2(&self) -> bevy::math::I64Vec2; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec2(&self) -> bevy::math::U64Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f64) -> bevy::math::DVec2; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::DVec2) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::DVec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct DVec2 { +pub struct LuaDVec2 { x: f64, y: f64, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::DVec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::DVec3; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: f64, y: f64, z: f64) -> bevy::math::DVec3; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: f64) -> bevy::math::DVec3; "#, @@ -14127,7 +12652,7 @@ pub struct DVec2 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec3, @@ -14141,21 +12666,21 @@ pub struct DVec2 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [f64; 3]) -> bevy::math::DVec3; "#, r#" /// `[x, y, z]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [f64; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn extend(self, w: f64) -> bevy::math::DVec4; "#, @@ -14163,28 +12688,28 @@ pub struct DVec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::DVec2; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::DVec3) -> f64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" /// Computes the cross product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cross(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -14192,7 +12717,7 @@ pub struct DVec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -14200,7 +12725,7 @@ pub struct DVec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -14210,7 +12735,7 @@ pub struct DVec2 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -14224,7 +12749,7 @@ pub struct DVec2 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> f64; "#, @@ -14232,7 +12757,7 @@ pub struct DVec2 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> f64; "#, @@ -14242,7 +12767,7 @@ pub struct DVec2 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; "#, @@ -14252,7 +12777,7 @@ pub struct DVec2 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; "#, @@ -14262,7 +12787,7 @@ pub struct DVec2 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; "#, @@ -14272,7 +12797,7 @@ pub struct DVec2 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; "#, @@ -14282,7 +12807,7 @@ pub struct DVec2 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; "#, @@ -14292,14 +12817,14 @@ pub struct DVec2 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::DVec3; "#, @@ -14309,14 +12834,14 @@ pub struct DVec2 { /// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` /// - `NAN` if the number is `NAN` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::DVec3; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn copysign(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -14325,7 +12850,7 @@ pub struct DVec2 { /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, @@ -14333,14 +12858,14 @@ pub struct 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`. - #[lua(kind = "Method")] + #[lua()] fn is_finite(self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(self) -> bool; "#, @@ -14348,14 +12873,14 @@ pub struct DVec2 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn is_nan_mask(self) -> bevy::math::BVec3; "#, r#" /// Computes the length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length(self) -> f64; "#, @@ -14363,7 +12888,7 @@ pub struct DVec2 { /// Computes the squared length of `self`. /// This is faster than `length()` as it avoids a square root operation. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> f64; "#, @@ -14371,28 +12896,28 @@ pub struct DVec2 { /// Computes `1.0 / length()`. /// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method")] + #[lua()] fn length_recip(self) -> f64; "#, r#" /// Computes the Euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance(self, #[proxy] rhs: bevy::math::DVec3) -> f64; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::DVec3) -> f64; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -14400,7 +12925,7 @@ pub struct DVec2 { /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. /// [Euclidean division]: f64::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -14411,7 +12936,7 @@ pub struct DVec2 { /// Panics /// Will panic if `self` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize(self) -> bevy::math::DVec3; "#, @@ -14421,7 +12946,7 @@ pub struct DVec2 { /// the result of this operation will be zero. /// See also [`Self::try_normalize()`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize_or_zero(self) -> bevy::math::DVec3; "#, @@ -14429,7 +12954,7 @@ pub struct DVec2 { /// Returns whether `self` is length `1.0` or not. /// Uses a precision threshold of `1e-6`. - #[lua(kind = "Method")] + #[lua()] fn is_normalized(self) -> bool; "#, @@ -14439,7 +12964,7 @@ pub struct DVec2 { /// # Panics /// Will panic if `rhs` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -14451,7 +12976,7 @@ pub struct DVec2 { /// # Panics /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -14461,7 +12986,7 @@ pub struct DVec2 { /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto_normalized( self, #[proxy] @@ -14477,7 +13002,7 @@ pub struct DVec2 { /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from_normalized( self, #[proxy] @@ -14489,7 +13014,7 @@ pub struct DVec2 { /// Returns a vector containing the nearest integer to a number for each element of `self`. /// Round half-way cases away from 0.0. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn round(self) -> bevy::math::DVec3; "#, @@ -14497,7 +13022,7 @@ pub struct DVec2 { /// Returns a vector containing the largest integer less than or equal to a number for each /// element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn floor(self) -> bevy::math::DVec3; "#, @@ -14505,7 +13030,7 @@ pub struct DVec2 { /// Returns a vector containing the smallest integer greater than or equal to a number for /// each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn ceil(self) -> bevy::math::DVec3; "#, @@ -14513,7 +13038,7 @@ pub struct DVec2 { /// Returns a vector containing the integer part each element of `self`. This means numbers are /// always truncated towards zero. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn trunc(self) -> bevy::math::DVec3; "#, @@ -14522,7 +13047,7 @@ pub struct DVec2 { /// self.floor()`. /// Note that this is fast but not precise for large numbers. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn fract(self) -> bevy::math::DVec3; "#, @@ -14530,21 +13055,21 @@ pub struct DVec2 { /// Returns a vector containing `e^self` (the exponential function) for each element of /// `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn exp(self) -> bevy::math::DVec3; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn powf(self, n: f64) -> bevy::math::DVec3; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn recip(self) -> bevy::math::DVec3; "#, @@ -14554,7 +13079,7 @@ pub struct DVec2 { /// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly /// extrapolated. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn lerp(self, #[proxy] rhs: bevy::math::DVec3, s: f64) -> bevy::math::DVec3; "#, @@ -14567,7 +13092,7 @@ pub struct DVec2 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec3, max_abs_diff: f64) -> bool; "#, @@ -14576,21 +13101,21 @@ pub struct DVec2 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec3; "#, r#" /// Returns a vector with a length no more than `max` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_max(self, max: f64) -> bevy::math::DVec3; "#, r#" /// Returns a vector with a length no less than `min` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_min(self, min: f64) -> bevy::math::DVec3; "#, @@ -14602,7 +13127,7 @@ pub struct DVec2 { /// and will be heavily dependant on designing algorithms with specific target hardware in /// mind. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_add( self, #[proxy] @@ -14616,7 +13141,7 @@ pub struct DVec2 { /// Returns the angle (in radians) between two vectors. /// The inputs do not need to be unit vectors however they must be non-zero. - #[lua(kind = "Method")] + #[lua()] fn angle_between(self, #[proxy] rhs: bevy::math::DVec3) -> f64; "#, @@ -14626,7 +13151,7 @@ pub struct DVec2 { /// The output vector is not necessarily unit length. For that use /// [`Self::any_orthonormal_vector()`] instead. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn any_orthogonal_vector(&self) -> bevy::math::DVec3; "#, @@ -14636,213 +13161,144 @@ pub struct DVec2 { /// # Panics /// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn any_orthonormal_vector(&self) -> bevy::math::DVec3; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec3(&self) -> bevy::math::Vec3; "#, r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec3a(&self) -> bevy::math::Vec3A; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::DVec3) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f64) -> bevy::math::DVec3; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: f64) -> bevy::math::DVec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: f64) -> bevy::math::DVec3; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: f64) -> bevy::math::DVec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::DVec3; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: f64) -> bevy::math::DVec3; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct DVec3 { +pub struct LuaDVec3 { x: f64, y: f64, z: f64, @@ -14850,146 +13306,85 @@ pub struct DVec3 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::DVec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, rhs: f64) -> bevy::math::DVec4; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, rhs: f64) -> bevy::math::DVec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f64) -> bevy::math::DVec4; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, rhs: f64) -> bevy::math::DVec4; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::DVec4) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::DVec4; "#, r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] + #[lua(as_trait = "std::ops::Rem", composite = "rem")] fn rem(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::DVec4; "#, r#" /// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: f64, y: f64, z: f64, w: f64) -> bevy::math::DVec4; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: f64) -> bevy::math::DVec4; "#, @@ -14999,7 +13394,7 @@ pub struct DVec3 { /// 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))] + #[lua()] fn select( #[proxy] mask: bevy::math::BVec4, @@ -15013,14 +13408,14 @@ pub struct DVec3 { r#" /// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_array(a: [f64; 4]) -> bevy::math::DVec4; "#, r#" /// `[x, y, z, w]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [f64; 4]; "#, @@ -15028,21 +13423,21 @@ pub struct DVec3 { /// Creates a 3D 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(kind = "Method", output(proxy))] + #[lua()] fn truncate(self) -> bevy::math::DVec3; "#, r#" /// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::DVec4) -> f64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, @@ -15050,7 +13445,7 @@ pub struct DVec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn min(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, @@ -15058,7 +13453,7 @@ pub struct DVec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn max(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, @@ -15068,7 +13463,7 @@ pub struct DVec3 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp( self, #[proxy] @@ -15082,7 +13477,7 @@ pub struct DVec3 { /// Returns the horizontal minimum of `self`. /// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn min_element(self) -> f64; "#, @@ -15090,7 +13485,7 @@ pub struct DVec3 { /// Returns the horizontal maximum of `self`. /// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] + #[lua()] fn max_element(self) -> f64; "#, @@ -15100,7 +13495,7 @@ pub struct DVec3 { /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpeq(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; "#, @@ -15110,7 +13505,7 @@ pub struct DVec3 { /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpne(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; "#, @@ -15120,7 +13515,7 @@ pub struct DVec3 { /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpge(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; "#, @@ -15130,7 +13525,7 @@ pub struct DVec3 { /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmpgt(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; "#, @@ -15140,7 +13535,7 @@ pub struct DVec3 { /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmple(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; "#, @@ -15150,14 +13545,14 @@ pub struct DVec3 { /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all /// elements. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn cmplt(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> bevy::math::DVec4; "#, @@ -15167,14 +13562,14 @@ pub struct DVec3 { /// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` /// - `NAN` if the number is `NAN` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn signum(self) -> bevy::math::DVec4; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn copysign(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, @@ -15183,7 +13578,7 @@ pub struct DVec3 { /// 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(kind = "Method")] + #[lua()] fn is_negative_bitmask(self) -> u32; "#, @@ -15191,14 +13586,14 @@ pub struct 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`. - #[lua(kind = "Method")] + #[lua()] fn is_finite(self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(self) -> bool; "#, @@ -15206,14 +13601,14 @@ pub struct DVec3 { /// 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(kind = "Method", output(proxy))] + #[lua()] fn is_nan_mask(self) -> bevy::math::BVec4; "#, r#" /// Computes the length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length(self) -> f64; "#, @@ -15221,7 +13616,7 @@ pub struct DVec3 { /// Computes the squared length of `self`. /// This is faster than `length()` as it avoids a square root operation. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> f64; "#, @@ -15229,28 +13624,28 @@ pub struct DVec3 { /// Computes `1.0 / length()`. /// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method")] + #[lua()] fn length_recip(self) -> f64; "#, r#" /// Computes the Euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance(self, #[proxy] rhs: bevy::math::DVec4) -> f64; "#, r#" /// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] + #[lua()] fn distance_squared(self, #[proxy] rhs: bevy::math::DVec4) -> f64; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn div_euclid(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, @@ -15258,7 +13653,7 @@ pub struct DVec3 { /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. /// [Euclidean division]: f64::rem_euclid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, @@ -15269,7 +13664,7 @@ pub struct DVec3 { /// Panics /// Will panic if `self` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize(self) -> bevy::math::DVec4; "#, @@ -15279,7 +13674,7 @@ pub struct DVec3 { /// the result of this operation will be zero. /// See also [`Self::try_normalize()`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize_or_zero(self) -> bevy::math::DVec4; "#, @@ -15287,7 +13682,7 @@ pub struct DVec3 { /// Returns whether `self` is length `1.0` or not. /// Uses a precision threshold of `1e-6`. - #[lua(kind = "Method")] + #[lua()] fn is_normalized(self) -> bool; "#, @@ -15297,7 +13692,7 @@ pub struct DVec3 { /// # Panics /// Will panic if `rhs` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, @@ -15309,7 +13704,7 @@ pub struct DVec3 { /// # Panics /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, @@ -15319,7 +13714,7 @@ pub struct DVec3 { /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_onto_normalized( self, #[proxy] @@ -15335,7 +13730,7 @@ pub struct DVec3 { /// # Panics /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reject_from_normalized( self, #[proxy] @@ -15347,7 +13742,7 @@ pub struct DVec3 { /// Returns a vector containing the nearest integer to a number for each element of `self`. /// Round half-way cases away from 0.0. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn round(self) -> bevy::math::DVec4; "#, @@ -15355,7 +13750,7 @@ pub struct DVec3 { /// Returns a vector containing the largest integer less than or equal to a number for each /// element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn floor(self) -> bevy::math::DVec4; "#, @@ -15363,7 +13758,7 @@ pub struct DVec3 { /// Returns a vector containing the smallest integer greater than or equal to a number for /// each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn ceil(self) -> bevy::math::DVec4; "#, @@ -15371,7 +13766,7 @@ pub struct DVec3 { /// Returns a vector containing the integer part each element of `self`. This means numbers are /// always truncated towards zero. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn trunc(self) -> bevy::math::DVec4; "#, @@ -15380,7 +13775,7 @@ pub struct DVec3 { /// self.floor()`. /// Note that this is fast but not precise for large numbers. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn fract(self) -> bevy::math::DVec4; "#, @@ -15388,21 +13783,21 @@ pub struct DVec3 { /// Returns a vector containing `e^self` (the exponential function) for each element of /// `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn exp(self) -> bevy::math::DVec4; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn powf(self, n: f64) -> bevy::math::DVec4; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn recip(self) -> bevy::math::DVec4; "#, @@ -15412,7 +13807,7 @@ pub struct DVec3 { /// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly /// extrapolated. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn lerp(self, #[proxy] rhs: bevy::math::DVec4, s: f64) -> bevy::math::DVec4; "#, @@ -15425,7 +13820,7 @@ pub struct DVec3 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec4, max_abs_diff: f64) -> bool; "#, @@ -15434,21 +13829,21 @@ pub struct DVec3 { /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec4; "#, r#" /// Returns a vector with a length no more than `max` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_max(self, max: f64) -> bevy::math::DVec4; "#, r#" /// Returns a vector with a length no less than `min` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn clamp_length_min(self, min: f64) -> bevy::math::DVec4; "#, @@ -15460,7 +13855,7 @@ pub struct DVec3 { /// and will be heavily dependant on designing algorithms with specific target hardware in /// mind. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_add( self, #[proxy] @@ -15473,82 +13868,70 @@ pub struct DVec3 { r#" /// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_vec4(&self) -> bevy::math::Vec4; "#, r#" /// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_ivec4(&self) -> bevy::math::IVec4; "#, r#" /// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_uvec4(&self) -> bevy::math::UVec4; "#, r#" /// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_i64vec4(&self) -> bevy::math::I64Vec4; "#, r#" /// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_u64vec4(&self) -> bevy::math::U64Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: f64) -> bevy::math::DVec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] +#[lua(raw , metamethod="Index")] fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) + Ok(_self.inner()?[*idx]) } "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +#[lua(raw, metamethod="NewIndex")] fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? + _self.val_mut(|s| Ok(s[*idx] = val))? } "#] )] -pub struct DVec4 { +pub struct LuaDVec4 { x: f64, y: f64, z: f64, @@ -15557,34 +13940,24 @@ pub struct DVec4 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::Mat2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; "#, r#" /// Creates a 2x2 matrix from two column vectors. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_cols( #[proxy] x_axis: bevy::math::Vec2, @@ -15597,7 +13970,7 @@ pub struct DVec4 { /// Creates a `[f32; 4]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array(&self) -> [f32; 4]; "#, @@ -15605,14 +13978,14 @@ pub struct DVec4 { /// Creates a `[[f32; 2]; 2]` 2D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array_2d(&self) -> [[f32; 2]; 2]; "#, r#" /// Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_diagonal(#[proxy] diagonal: bevy::math::Vec2) -> bevy::math::Mat2; "#, @@ -15620,7 +13993,7 @@ pub struct DVec4 { /// Creates a 2x2 matrix containing the combining non-uniform `scale` and rotation of /// `angle` (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale_angle( #[proxy] scale: bevy::math::Vec2, @@ -15631,21 +14004,21 @@ pub struct DVec4 { r#" /// Creates a 2x2 matrix containing a rotation of `angle` (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_angle(angle: f32) -> bevy::math::Mat2; "#, r#" /// Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3(#[proxy] m: bevy::math::Mat3) -> bevy::math::Mat2; "#, r#" /// Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3a(#[proxy] m: bevy::math::Mat3A) -> bevy::math::Mat2; "#, @@ -15654,7 +14027,7 @@ pub struct DVec4 { /// # Panics /// Panics if `index` is greater than 1. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn col(&self, index: usize) -> bevy::math::Vec2; "#, @@ -15663,7 +14036,7 @@ pub struct DVec4 { /// # Panics /// Panics if `index` is greater than 1. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn row(&self, index: usize) -> bevy::math::Vec2; "#, @@ -15671,28 +14044,28 @@ pub struct 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`. - #[lua(kind = "Method")] + #[lua()] fn is_finite(&self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(&self) -> bool; "#, r#" /// Returns the transpose of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transpose(&self) -> bevy::math::Mat2; "#, r#" /// Returns the determinant of `self`. - #[lua(kind = "Method")] + #[lua()] fn determinant(&self) -> f32; "#, @@ -15702,42 +14075,42 @@ pub struct DVec4 { /// # Panics /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(&self) -> bevy::math::Mat2; "#, r#" /// Transforms a 2D vector. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_vec2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" /// Multiplies two 2x2 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_mat2(&self, #[proxy] rhs: &glam::Mat2) -> bevy::math::Mat2; "#, r#" /// Adds two 2x2 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn add_mat2(&self, #[proxy] rhs: &glam::Mat2) -> bevy::math::Mat2; "#, r#" /// Subtracts two 2x2 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn sub_mat2(&self, #[proxy] rhs: &glam::Mat2) -> bevy::math::Mat2; "#, r#" /// Multiplies a 2x2 matrix by a scalar. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat2; "#, @@ -15750,96 +14123,63 @@ pub struct DVec4 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat2, max_abs_diff: f32) -> bool; "#, r#" - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dmat2(&self) -> bevy::math::DMat2; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::Mat2; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::Mat2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f32) -> bevy::math::Mat2; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::Mat2) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] +#[lua(raw, metamethod="Index")] fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { Ok(LuaVec2::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ label:"col", get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ path: "".to_owned(), @@ -15860,96 +14200,58 @@ fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result bevy::math::Mat3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::Mat3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f32) -> bevy::math::Mat3; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3; "#, r#" /// Creates a 3x3 matrix from three column vectors. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_cols( #[proxy] x_axis: bevy::math::Vec3, @@ -15964,7 +14266,7 @@ pub struct Mat2(); /// Creates a `[f32; 9]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array(&self) -> [f32; 9]; "#, @@ -15972,21 +14274,21 @@ pub struct Mat2(); /// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array_2d(&self) -> [[f32; 3]; 3]; "#, r#" /// Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_diagonal(#[proxy] diagonal: bevy::math::Vec3) -> bevy::math::Mat3; "#, r#" /// Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat4(#[proxy] m: bevy::math::Mat4) -> bevy::math::Mat3; "#, @@ -15995,7 +14297,7 @@ pub struct Mat2(); /// # Panics /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_quat(#[proxy] rotation: bevy::math::Quat) -> bevy::math::Mat3; "#, @@ -16005,7 +14307,7 @@ pub struct Mat2(); /// # Panics /// Will panic if `axis` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_axis_angle(#[proxy] axis: bevy::math::Vec3, angle: f32) -> bevy::math::Mat3; "#, @@ -16013,7 +14315,7 @@ pub struct Mat2(); /// Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in /// radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_euler( #[proxy] order: bevy::math::EulerRot, @@ -16026,21 +14328,21 @@ pub struct Mat2(); r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_x(angle: f32) -> bevy::math::Mat3; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the y axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_y(angle: f32) -> bevy::math::Mat3; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the z axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_z(angle: f32) -> bevy::math::Mat3; "#, @@ -16049,7 +14351,7 @@ pub struct Mat2(); /// 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))] + #[lua()] fn from_translation(#[proxy] translation: bevy::math::Vec2) -> bevy::math::Mat3; "#, @@ -16059,7 +14361,7 @@ pub struct Mat2(); /// 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))] + #[lua()] fn from_angle(angle: f32) -> bevy::math::Mat3; "#, @@ -16069,7 +14371,7 @@ pub struct Mat2(); /// 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))] + #[lua()] fn from_scale_angle_translation( #[proxy] scale: bevy::math::Vec2, @@ -16086,7 +14388,7 @@ pub struct Mat2(); /// # Panics /// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale(#[proxy] scale: bevy::math::Vec2) -> bevy::math::Mat3; "#, @@ -16095,7 +14397,7 @@ pub struct Mat2(); /// 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))] + #[lua()] fn from_mat2(#[proxy] m: bevy::math::Mat2) -> bevy::math::Mat3; "#, @@ -16104,7 +14406,7 @@ pub struct Mat2(); /// # Panics /// Panics if `index` is greater than 2. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn col(&self, index: usize) -> bevy::math::Vec3; "#, @@ -16113,7 +14415,7 @@ pub struct Mat2(); /// # Panics /// Panics if `index` is greater than 2. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn row(&self, index: usize) -> bevy::math::Vec3; "#, @@ -16121,28 +14423,28 @@ pub struct Mat2(); /// 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(kind = "Method")] + #[lua()] fn is_finite(&self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(&self) -> bool; "#, r#" /// Returns the transpose of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transpose(&self) -> bevy::math::Mat3; "#, r#" /// Returns the determinant of `self`. - #[lua(kind = "Method")] + #[lua()] fn determinant(&self) -> f32; "#, @@ -16152,7 +14454,7 @@ pub struct Mat2(); /// # Panics /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(&self) -> bevy::math::Mat3; "#, @@ -16163,7 +14465,7 @@ pub struct Mat2(); /// # Panics /// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -16174,49 +14476,49 @@ pub struct Mat2(); /// # Panics /// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" /// Transforms a 3D vector. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_vec3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" /// Transforms a [`Vec3A`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_vec3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" /// Multiplies two 3x3 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_mat3(&self, #[proxy] rhs: &glam::Mat3) -> bevy::math::Mat3; "#, r#" /// Adds two 3x3 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn add_mat3(&self, #[proxy] rhs: &glam::Mat3) -> bevy::math::Mat3; "#, r#" /// Subtracts two 3x3 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn sub_mat3(&self, #[proxy] rhs: &glam::Mat3) -> bevy::math::Mat3; "#, r#" /// Multiplies a 3x3 matrix by a scalar. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat3; "#, @@ -16229,62 +14531,45 @@ pub struct Mat2(); /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat3, max_abs_diff: f32) -> bool; "#, r#" - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dmat3(&self) -> bevy::math::DMat3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::Mat3) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] +#[lua(raw, metamethod="Index")] fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { Ok(LuaVec3::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ label:"col", get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ path: "".to_owned(), @@ -16305,7 +14590,7 @@ fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result bevy::math::Mat3A; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3A; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f32) -> bevy::math::Mat3A; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::Mat3A; "#, r#" /// Creates a 3x3 matrix from three column vectors. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_cols( #[proxy] x_axis: bevy::math::Vec3A, @@ -16416,7 +14663,7 @@ pub struct Mat3 { /// Creates a `[f32; 9]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array(&self) -> [f32; 9]; "#, @@ -16424,21 +14671,21 @@ pub struct Mat3 { /// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array_2d(&self) -> [[f32; 3]; 3]; "#, r#" /// Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_diagonal(#[proxy] diagonal: bevy::math::Vec3) -> bevy::math::Mat3A; "#, r#" /// Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat4(#[proxy] m: bevy::math::Mat4) -> bevy::math::Mat3A; "#, @@ -16447,7 +14694,7 @@ pub struct Mat3 { /// # Panics /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_quat(#[proxy] rotation: bevy::math::Quat) -> bevy::math::Mat3A; "#, @@ -16457,7 +14704,7 @@ pub struct Mat3 { /// # Panics /// Will panic if `axis` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_axis_angle(#[proxy] axis: bevy::math::Vec3, angle: f32) -> bevy::math::Mat3A; "#, @@ -16465,7 +14712,7 @@ pub struct Mat3 { /// Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in /// radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_euler( #[proxy] order: bevy::math::EulerRot, @@ -16478,21 +14725,21 @@ pub struct Mat3 { r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_x(angle: f32) -> bevy::math::Mat3A; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the y axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_y(angle: f32) -> bevy::math::Mat3A; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the z axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_z(angle: f32) -> bevy::math::Mat3A; "#, @@ -16501,7 +14748,7 @@ pub struct Mat3 { /// 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))] + #[lua()] fn from_translation(#[proxy] translation: bevy::math::Vec2) -> bevy::math::Mat3A; "#, @@ -16511,7 +14758,7 @@ pub struct Mat3 { /// 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))] + #[lua()] fn from_angle(angle: f32) -> bevy::math::Mat3A; "#, @@ -16521,7 +14768,7 @@ pub struct Mat3 { /// 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))] + #[lua()] fn from_scale_angle_translation( #[proxy] scale: bevy::math::Vec2, @@ -16538,7 +14785,7 @@ pub struct Mat3 { /// # Panics /// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale(#[proxy] scale: bevy::math::Vec2) -> bevy::math::Mat3A; "#, @@ -16547,7 +14794,7 @@ pub struct Mat3 { /// 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))] + #[lua()] fn from_mat2(#[proxy] m: bevy::math::Mat2) -> bevy::math::Mat3A; "#, @@ -16556,7 +14803,7 @@ pub struct Mat3 { /// # Panics /// Panics if `index` is greater than 2. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn col(&self, index: usize) -> bevy::math::Vec3A; "#, @@ -16565,7 +14812,7 @@ pub struct Mat3 { /// # Panics /// Panics if `index` is greater than 2. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn row(&self, index: usize) -> bevy::math::Vec3A; "#, @@ -16573,28 +14820,28 @@ pub struct Mat3 { /// 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(kind = "Method")] + #[lua()] fn is_finite(&self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(&self) -> bool; "#, r#" /// Returns the transpose of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transpose(&self) -> bevy::math::Mat3A; "#, r#" /// Returns the determinant of `self`. - #[lua(kind = "Method")] + #[lua()] fn determinant(&self) -> f32; "#, @@ -16604,7 +14851,7 @@ pub struct Mat3 { /// # Panics /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(&self) -> bevy::math::Mat3A; "#, @@ -16615,7 +14862,7 @@ pub struct Mat3 { /// # Panics /// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -16626,49 +14873,49 @@ pub struct Mat3 { /// # Panics /// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" /// Transforms a 3D vector. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_vec3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" /// Transforms a [`Vec3A`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_vec3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" /// Multiplies two 3x3 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_mat3(&self, #[proxy] rhs: &glam::Mat3A) -> bevy::math::Mat3A; "#, r#" /// Adds two 3x3 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn add_mat3(&self, #[proxy] rhs: &glam::Mat3A) -> bevy::math::Mat3A; "#, r#" /// Subtracts two 3x3 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn sub_mat3(&self, #[proxy] rhs: &glam::Mat3A) -> bevy::math::Mat3A; "#, r#" /// Multiplies a 3x3 matrix by a scalar. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat3A; "#, @@ -16681,62 +14928,45 @@ pub struct Mat3 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat3A, max_abs_diff: f32) -> bool; "#, r#" - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dmat3(&self) -> bevy::math::DMat3; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::Mat3A; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::Mat3A) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] +#[lua(raw, metamethod="Index")] fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { Ok(LuaVec3A::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ label:"col", get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ path: "".to_owned(), @@ -16757,7 +14987,7 @@ fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result bevy::math::Mat4; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f32) -> bevy::math::Mat4; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::Mat4) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Mat4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::Mat4; "#, r#" /// Creates a 4x4 matrix from four column vectors. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_cols( #[proxy] x_axis: bevy::math::Vec4, @@ -16893,7 +15074,7 @@ pub struct Mat3A { /// Creates a `[f32; 16]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array(&self) -> [f32; 16]; "#, @@ -16901,14 +15082,14 @@ pub struct Mat3A { /// Creates a `[[f32; 4]; 4]` 4D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array_2d(&self) -> [[f32; 4]; 4]; "#, r#" /// Creates a 4x4 matrix with its diagonal set to `diagonal` and all other entries set to 0. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_diagonal(#[proxy] diagonal: bevy::math::Vec4) -> bevy::math::Mat4; "#, @@ -16920,7 +15101,7 @@ pub struct Mat3A { /// # Panics /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale_rotation_translation( #[proxy] scale: bevy::math::Vec3, @@ -16938,7 +15119,7 @@ pub struct Mat3A { /// # Panics /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_translation( #[proxy] rotation: bevy::math::Quat, @@ -16954,7 +15135,7 @@ pub struct Mat3A { /// # Panics /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_quat(#[proxy] rotation: bevy::math::Quat) -> bevy::math::Mat4; "#, @@ -16964,7 +15145,7 @@ pub struct Mat3A { /// 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))] + #[lua()] fn from_mat3(#[proxy] m: bevy::math::Mat3) -> bevy::math::Mat4; "#, @@ -16974,7 +15155,7 @@ pub struct Mat3A { /// 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))] + #[lua()] fn from_mat3a(#[proxy] m: bevy::math::Mat3A) -> bevy::math::Mat4; "#, @@ -16983,7 +15164,7 @@ pub struct Mat3A { /// 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))] + #[lua()] fn from_translation(#[proxy] translation: bevy::math::Vec3) -> bevy::math::Mat4; "#, @@ -16995,7 +15176,7 @@ pub struct Mat3A { /// # Panics /// Will panic if `axis` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_axis_angle(#[proxy] axis: bevy::math::Vec3, angle: f32) -> bevy::math::Mat4; "#, @@ -17005,7 +15186,7 @@ pub struct Mat3A { /// 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))] + #[lua()] fn from_euler( #[proxy] order: bevy::math::EulerRot, @@ -17021,7 +15202,7 @@ pub struct Mat3A { /// 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))] + #[lua()] fn from_rotation_x(angle: f32) -> bevy::math::Mat4; "#, @@ -17031,7 +15212,7 @@ pub struct Mat3A { /// 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))] + #[lua()] fn from_rotation_y(angle: f32) -> bevy::math::Mat4; "#, @@ -17041,7 +15222,7 @@ pub struct Mat3A { /// 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))] + #[lua()] fn from_rotation_z(angle: f32) -> bevy::math::Mat4; "#, @@ -17052,7 +15233,7 @@ pub struct Mat3A { /// # Panics /// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale(#[proxy] scale: bevy::math::Vec3) -> bevy::math::Mat4; "#, @@ -17061,7 +15242,7 @@ pub struct Mat3A { /// # Panics /// Panics if `index` is greater than 3. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn col(&self, index: usize) -> bevy::math::Vec4; "#, @@ -17070,7 +15251,7 @@ pub struct Mat3A { /// # Panics /// Panics if `index` is greater than 3. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn row(&self, index: usize) -> bevy::math::Vec4; "#, @@ -17078,28 +15259,28 @@ pub struct Mat3A { /// 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(kind = "Method")] + #[lua()] fn is_finite(&self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(&self) -> bool; "#, r#" /// Returns the transpose of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transpose(&self) -> bevy::math::Mat4; "#, r#" /// Returns the determinant of `self`. - #[lua(kind = "Method")] + #[lua()] fn determinant(&self) -> f32; "#, @@ -17109,7 +15290,7 @@ pub struct Mat3A { /// # Panics /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(&self) -> bevy::math::Mat4; "#, @@ -17118,7 +15299,7 @@ pub struct Mat3A { /// direction. /// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_to_lh( #[proxy] eye: bevy::math::Vec3, @@ -17134,7 +15315,7 @@ pub struct Mat3A { /// direction. /// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_to_rh( #[proxy] eye: bevy::math::Vec3, @@ -17152,7 +15333,7 @@ pub struct Mat3A { /// # Panics /// Will panic if `up` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_at_lh( #[proxy] eye: bevy::math::Vec3, @@ -17170,7 +15351,7 @@ pub struct Mat3A { /// # Panics /// Will panic if `up` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_at_rh( #[proxy] eye: bevy::math::Vec3, @@ -17186,7 +15367,7 @@ pub struct Mat3A { /// This is the same as the OpenGL `gluPerspective` function. /// See - #[lua(kind = "Function", output(proxy))] + #[lua()] fn perspective_rh_gl( fov_y_radians: f32, aspect_ratio: f32, @@ -17201,7 +15382,7 @@ pub struct Mat3A { /// 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))] + #[lua()] fn perspective_lh( fov_y_radians: f32, aspect_ratio: f32, @@ -17216,7 +15397,7 @@ pub struct Mat3A { /// 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))] + #[lua()] fn perspective_rh( fov_y_radians: f32, aspect_ratio: f32, @@ -17230,7 +15411,7 @@ pub struct Mat3A { /// # Panics /// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn perspective_infinite_lh( fov_y_radians: f32, aspect_ratio: f32, @@ -17243,7 +15424,7 @@ pub struct Mat3A { /// # Panics /// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn perspective_infinite_reverse_lh( fov_y_radians: f32, aspect_ratio: f32, @@ -17255,7 +15436,7 @@ pub struct Mat3A { /// Creates an infinite right-handed perspective projection matrix with /// `[0,1]` depth range. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn perspective_infinite_rh( fov_y_radians: f32, aspect_ratio: f32, @@ -17267,7 +15448,7 @@ pub struct Mat3A { /// Creates an infinite reverse right-handed perspective projection matrix /// with `[0,1]` depth range. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn perspective_infinite_reverse_rh( fov_y_radians: f32, aspect_ratio: f32, @@ -17281,7 +15462,7 @@ pub struct Mat3A { /// See /// - #[lua(kind = "Function", output(proxy))] + #[lua()] fn orthographic_rh_gl( left: f32, right: f32, @@ -17295,7 +15476,7 @@ pub struct Mat3A { r#" /// Creates a left-handed orthographic projection matrix with `[0,1]` depth range. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn orthographic_lh( left: f32, right: f32, @@ -17309,7 +15490,7 @@ pub struct Mat3A { r#" /// Creates a right-handed orthographic projection matrix with `[0,1]` depth range. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn orthographic_rh( left: f32, right: f32, @@ -17326,7 +15507,7 @@ pub struct Mat3A { /// The perspective divide is performed meaning the resulting 3D vector is divided by `w`. /// This method assumes that `self` contains a projective transform. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -17340,7 +15521,7 @@ pub struct Mat3A { /// # Panics /// Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -17352,7 +15533,7 @@ pub struct Mat3A { /// # Panics /// Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_vector3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -17360,7 +15541,7 @@ pub struct Mat3A { /// 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(kind = "Method", output(proxy))] + #[lua()] fn transform_point3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, @@ -17368,42 +15549,42 @@ pub struct Mat3A { /// 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(kind = "Method", output(proxy))] + #[lua()] fn transform_vector3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" /// Transforms a 4D vector. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_vec4(&self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" /// Multiplies two 4x4 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_mat4(&self, #[proxy] rhs: &glam::Mat4) -> bevy::math::Mat4; "#, r#" /// Adds two 4x4 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn add_mat4(&self, #[proxy] rhs: &glam::Mat4) -> bevy::math::Mat4; "#, r#" /// Subtracts two 4x4 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn sub_mat4(&self, #[proxy] rhs: &glam::Mat4) -> bevy::math::Mat4; "#, r#" /// Multiplies a 4x4 matrix by a scalar. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat4; "#, @@ -17416,27 +15597,27 @@ pub struct Mat3A { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat4, max_abs_diff: f32) -> bool; "#, r#" - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_dmat4(&self) -> bevy::math::DMat4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] +#[lua(raw, metamethod="Index")] fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { Ok(LuaVec4::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ label:"col", get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ path: "".to_owned(), @@ -17457,7 +15638,7 @@ fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result bevy::math::DVec2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::DMat2; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::DMat2; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::DMat2) -> bool; "#, r#" /// Creates a 2x2 matrix from two column vectors. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_cols( #[proxy] x_axis: bevy::math::DVec2, @@ -17543,7 +15699,7 @@ pub struct Mat4 { /// Creates a `[f64; 4]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array(&self) -> [f64; 4]; "#, @@ -17551,14 +15707,14 @@ pub struct Mat4 { /// Creates a `[[f64; 2]; 2]` 2D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array_2d(&self) -> [[f64; 2]; 2]; "#, r#" /// Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_diagonal(#[proxy] diagonal: bevy::math::DVec2) -> bevy::math::DMat2; "#, @@ -17566,7 +15722,7 @@ pub struct Mat4 { /// Creates a 2x2 matrix containing the combining non-uniform `scale` and rotation of /// `angle` (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale_angle( #[proxy] scale: bevy::math::DVec2, @@ -17577,14 +15733,14 @@ pub struct Mat4 { r#" /// Creates a 2x2 matrix containing a rotation of `angle` (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_angle(angle: f64) -> bevy::math::DMat2; "#, r#" /// Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3(#[proxy] m: bevy::math::DMat3) -> bevy::math::DMat2; "#, @@ -17593,7 +15749,7 @@ pub struct Mat4 { /// # Panics /// Panics if `index` is greater than 1. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn col(&self, index: usize) -> bevy::math::DVec2; "#, @@ -17602,7 +15758,7 @@ pub struct Mat4 { /// # Panics /// Panics if `index` is greater than 1. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn row(&self, index: usize) -> bevy::math::DVec2; "#, @@ -17610,28 +15766,28 @@ pub struct Mat4 { /// 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(kind = "Method")] + #[lua()] fn is_finite(&self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(&self) -> bool; "#, r#" /// Returns the transpose of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transpose(&self) -> bevy::math::DMat2; "#, r#" /// Returns the determinant of `self`. - #[lua(kind = "Method")] + #[lua()] fn determinant(&self) -> f64; "#, @@ -17641,42 +15797,42 @@ pub struct Mat4 { /// # Panics /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(&self) -> bevy::math::DMat2; "#, r#" /// Transforms a 2D vector. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_vec2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" /// Multiplies two 2x2 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_mat2(&self, #[proxy] rhs: &glam::DMat2) -> bevy::math::DMat2; "#, r#" /// Adds two 2x2 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn add_mat2(&self, #[proxy] rhs: &glam::DMat2) -> bevy::math::DMat2; "#, r#" /// Subtracts two 2x2 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn sub_mat2(&self, #[proxy] rhs: &glam::DMat2) -> bevy::math::DMat2; "#, r#" /// Multiplies a 2x2 matrix by a scalar. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat2; "#, @@ -17689,63 +15845,45 @@ pub struct Mat4 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DMat2, max_abs_diff: f64) -> bool; "#, r#" - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_mat2(&self) -> bevy::math::Mat2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f64) -> bevy::math::DMat2; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] +#[lua(raw, metamethod="Index")] fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { Ok(LuaDVec2::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ label:"col", get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ path: "".to_owned(), @@ -17766,7 +15904,7 @@ fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result bevy::math::DMat3; "#, r#" /// Creates a 3x3 matrix from three column vectors. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_cols( #[proxy] x_axis: bevy::math::DVec3, @@ -17805,7 +15939,7 @@ pub struct DMat2 { /// Creates a `[f64; 9]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array(&self) -> [f64; 9]; "#, @@ -17813,21 +15947,21 @@ pub struct DMat2 { /// Creates a `[[f64; 3]; 3]` 3D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array_2d(&self) -> [[f64; 3]; 3]; "#, r#" /// Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_diagonal(#[proxy] diagonal: bevy::math::DVec3) -> bevy::math::DMat3; "#, r#" /// Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat4(#[proxy] m: bevy::math::DMat4) -> bevy::math::DMat3; "#, @@ -17836,7 +15970,7 @@ pub struct DMat2 { /// # Panics /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_quat(#[proxy] rotation: bevy::math::DQuat) -> bevy::math::DMat3; "#, @@ -17846,7 +15980,7 @@ pub struct DMat2 { /// # Panics /// Will panic if `axis` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_axis_angle( #[proxy] axis: bevy::math::DVec3, @@ -17858,7 +15992,7 @@ pub struct DMat2 { /// Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in /// radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_euler( #[proxy] order: bevy::math::EulerRot, @@ -17871,21 +16005,21 @@ pub struct DMat2 { r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_x(angle: f64) -> bevy::math::DMat3; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the y axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_y(angle: f64) -> bevy::math::DMat3; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the z axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_z(angle: f64) -> bevy::math::DMat3; "#, @@ -17894,7 +16028,7 @@ pub struct DMat2 { /// 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))] + #[lua()] fn from_translation(#[proxy] translation: bevy::math::DVec2) -> bevy::math::DMat3; "#, @@ -17904,7 +16038,7 @@ pub struct DMat2 { /// 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))] + #[lua()] fn from_angle(angle: f64) -> bevy::math::DMat3; "#, @@ -17914,7 +16048,7 @@ pub struct DMat2 { /// 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))] + #[lua()] fn from_scale_angle_translation( #[proxy] scale: bevy::math::DVec2, @@ -17931,7 +16065,7 @@ pub struct DMat2 { /// # Panics /// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale(#[proxy] scale: bevy::math::DVec2) -> bevy::math::DMat3; "#, @@ -17940,7 +16074,7 @@ pub struct DMat2 { /// 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))] + #[lua()] fn from_mat2(#[proxy] m: bevy::math::DMat2) -> bevy::math::DMat3; "#, @@ -17949,7 +16083,7 @@ pub struct DMat2 { /// # Panics /// Panics if `index` is greater than 2. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn col(&self, index: usize) -> bevy::math::DVec3; "#, @@ -17958,7 +16092,7 @@ pub struct DMat2 { /// # Panics /// Panics if `index` is greater than 2. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn row(&self, index: usize) -> bevy::math::DVec3; "#, @@ -17966,28 +16100,28 @@ pub struct DMat2 { /// 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(kind = "Method")] + #[lua()] fn is_finite(&self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(&self) -> bool; "#, r#" /// Returns the transpose of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transpose(&self) -> bevy::math::DMat3; "#, r#" /// Returns the determinant of `self`. - #[lua(kind = "Method")] + #[lua()] fn determinant(&self) -> f64; "#, @@ -17997,7 +16131,7 @@ pub struct DMat2 { /// # Panics /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(&self) -> bevy::math::DMat3; "#, @@ -18008,7 +16142,7 @@ pub struct DMat2 { /// # Panics /// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_point2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, @@ -18019,42 +16153,42 @@ pub struct DMat2 { /// # Panics /// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_vector2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" /// Transforms a 3D vector. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_vec3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" /// Multiplies two 3x3 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_mat3(&self, #[proxy] rhs: &glam::DMat3) -> bevy::math::DMat3; "#, r#" /// Adds two 3x3 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn add_mat3(&self, #[proxy] rhs: &glam::DMat3) -> bevy::math::DMat3; "#, r#" /// Subtracts two 3x3 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn sub_mat3(&self, #[proxy] rhs: &glam::DMat3) -> bevy::math::DMat3; "#, r#" /// Multiplies a 3x3 matrix by a scalar. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat3; "#, @@ -18067,120 +16201,75 @@ pub struct DMat2 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DMat3, max_abs_diff: f64) -> bool; "#, r#" - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_mat3(&self) -> bevy::math::Mat3; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::DMat3; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f64) -> bevy::math::DMat3; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::DMat3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DMat3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::DMat3) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] +#[lua(raw, metamethod="Index")] fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { Ok(LuaDVec3::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ label:"col", get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ path: "".to_owned(), @@ -18201,7 +16290,7 @@ fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result bevy::math::DMat4; "#, r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::DMat4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; "#, r#" /// Creates a 4x4 matrix from four column vectors. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_cols( #[proxy] x_axis: bevy::math::DVec4, @@ -18302,7 +16359,7 @@ pub struct DMat3 { /// Creates a `[f64; 16]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array(&self) -> [f64; 16]; "#, @@ -18310,14 +16367,14 @@ pub struct DMat3 { /// Creates a `[[f64; 4]; 4]` 4D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array_2d(&self) -> [[f64; 4]; 4]; "#, r#" /// Creates a 4x4 matrix with its diagonal set to `diagonal` and all other entries set to 0. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_diagonal(#[proxy] diagonal: bevy::math::DVec4) -> bevy::math::DMat4; "#, @@ -18329,7 +16386,7 @@ pub struct DMat3 { /// # Panics /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale_rotation_translation( #[proxy] scale: bevy::math::DVec3, @@ -18347,7 +16404,7 @@ pub struct DMat3 { /// # Panics /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_translation( #[proxy] rotation: bevy::math::DQuat, @@ -18363,7 +16420,7 @@ pub struct DMat3 { /// # Panics /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_quat(#[proxy] rotation: bevy::math::DQuat) -> bevy::math::DMat4; "#, @@ -18373,7 +16430,7 @@ pub struct DMat3 { /// 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))] + #[lua()] fn from_mat3(#[proxy] m: bevy::math::DMat3) -> bevy::math::DMat4; "#, @@ -18382,7 +16439,7 @@ pub struct DMat3 { /// 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))] + #[lua()] fn from_translation(#[proxy] translation: bevy::math::DVec3) -> bevy::math::DMat4; "#, @@ -18394,7 +16451,7 @@ pub struct DMat3 { /// # Panics /// Will panic if `axis` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_axis_angle( #[proxy] axis: bevy::math::DVec3, @@ -18408,7 +16465,7 @@ pub struct DMat3 { /// 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))] + #[lua()] fn from_euler( #[proxy] order: bevy::math::EulerRot, @@ -18424,7 +16481,7 @@ pub struct DMat3 { /// 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))] + #[lua()] fn from_rotation_x(angle: f64) -> bevy::math::DMat4; "#, @@ -18434,7 +16491,7 @@ pub struct DMat3 { /// 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))] + #[lua()] fn from_rotation_y(angle: f64) -> bevy::math::DMat4; "#, @@ -18444,7 +16501,7 @@ pub struct DMat3 { /// 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))] + #[lua()] fn from_rotation_z(angle: f64) -> bevy::math::DMat4; "#, @@ -18455,7 +16512,7 @@ pub struct DMat3 { /// # Panics /// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale(#[proxy] scale: bevy::math::DVec3) -> bevy::math::DMat4; "#, @@ -18464,7 +16521,7 @@ pub struct DMat3 { /// # Panics /// Panics if `index` is greater than 3. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn col(&self, index: usize) -> bevy::math::DVec4; "#, @@ -18473,7 +16530,7 @@ pub struct DMat3 { /// # Panics /// Panics if `index` is greater than 3. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn row(&self, index: usize) -> bevy::math::DVec4; "#, @@ -18481,28 +16538,28 @@ pub struct DMat3 { /// 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(kind = "Method")] + #[lua()] fn is_finite(&self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(&self) -> bool; "#, r#" /// Returns the transpose of `self`. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transpose(&self) -> bevy::math::DMat4; "#, r#" /// Returns the determinant of `self`. - #[lua(kind = "Method")] + #[lua()] fn determinant(&self) -> f64; "#, @@ -18512,7 +16569,7 @@ pub struct DMat3 { /// # Panics /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(&self) -> bevy::math::DMat4; "#, @@ -18521,7 +16578,7 @@ pub struct DMat3 { /// direction. /// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_to_lh( #[proxy] eye: bevy::math::DVec3, @@ -18537,7 +16594,7 @@ pub struct DMat3 { /// direction. /// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_to_rh( #[proxy] eye: bevy::math::DVec3, @@ -18555,7 +16612,7 @@ pub struct DMat3 { /// # Panics /// Will panic if `up` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_at_lh( #[proxy] eye: bevy::math::DVec3, @@ -18573,7 +16630,7 @@ pub struct DMat3 { /// # Panics /// Will panic if `up` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_at_rh( #[proxy] eye: bevy::math::DVec3, @@ -18589,7 +16646,7 @@ pub struct DMat3 { /// This is the same as the OpenGL `gluPerspective` function. /// See - #[lua(kind = "Function", output(proxy))] + #[lua()] fn perspective_rh_gl( fov_y_radians: f64, aspect_ratio: f64, @@ -18604,7 +16661,7 @@ pub struct DMat3 { /// 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))] + #[lua()] fn perspective_lh( fov_y_radians: f64, aspect_ratio: f64, @@ -18619,7 +16676,7 @@ pub struct DMat3 { /// 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))] + #[lua()] fn perspective_rh( fov_y_radians: f64, aspect_ratio: f64, @@ -18633,7 +16690,7 @@ pub struct DMat3 { /// # Panics /// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn perspective_infinite_lh( fov_y_radians: f64, aspect_ratio: f64, @@ -18646,7 +16703,7 @@ pub struct DMat3 { /// # Panics /// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn perspective_infinite_reverse_lh( fov_y_radians: f64, aspect_ratio: f64, @@ -18658,7 +16715,7 @@ pub struct DMat3 { /// Creates an infinite right-handed perspective projection matrix with /// `[0,1]` depth range. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn perspective_infinite_rh( fov_y_radians: f64, aspect_ratio: f64, @@ -18670,7 +16727,7 @@ pub struct DMat3 { /// Creates an infinite reverse right-handed perspective projection matrix /// with `[0,1]` depth range. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn perspective_infinite_reverse_rh( fov_y_radians: f64, aspect_ratio: f64, @@ -18684,7 +16741,7 @@ pub struct DMat3 { /// See /// - #[lua(kind = "Function", output(proxy))] + #[lua()] fn orthographic_rh_gl( left: f64, right: f64, @@ -18698,7 +16755,7 @@ pub struct DMat3 { r#" /// Creates a left-handed orthographic projection matrix with `[0,1]` depth range. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn orthographic_lh( left: f64, right: f64, @@ -18712,7 +16769,7 @@ pub struct DMat3 { r#" /// Creates a right-handed orthographic projection matrix with `[0,1]` depth range. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn orthographic_rh( left: f64, right: f64, @@ -18729,7 +16786,7 @@ pub struct DMat3 { /// The perspective divide is performed meaning the resulting 3D vector is divided by `w`. /// This method assumes that `self` contains a projective transform. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn project_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -18743,7 +16800,7 @@ pub struct DMat3 { /// # Panics /// Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -18755,42 +16812,42 @@ pub struct DMat3 { /// # Panics /// Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_vector3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" /// Transforms a 4D vector. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_vec4(&self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" /// Multiplies two 4x4 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_mat4(&self, #[proxy] rhs: &glam::DMat4) -> bevy::math::DMat4; "#, r#" /// Adds two 4x4 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn add_mat4(&self, #[proxy] rhs: &glam::DMat4) -> bevy::math::DMat4; "#, r#" /// Subtracts two 4x4 matrices. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn sub_mat4(&self, #[proxy] rhs: &glam::DMat4) -> bevy::math::DMat4; "#, r#" /// Multiplies a 4x4 matrix by a scalar. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat4; "#, @@ -18803,62 +16860,45 @@ pub struct DMat3 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DMat4, max_abs_diff: f64) -> bool; "#, r#" - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_mat4(&self) -> bevy::math::Mat4; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::DMat4) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f64) -> bevy::math::DMat4; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::DMat4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#, r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] +#[lua(raw, metamethod="Index")] fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { Ok(LuaDVec4::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ label:"col", get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ path: "".to_owned(), @@ -18879,7 +16919,7 @@ fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result [f32; 6]; "#, @@ -18918,7 +16960,7 @@ pub struct DMat4 { /// column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array_2d(&self) -> [[f32; 2]; 3]; "#, @@ -18926,28 +16968,28 @@ pub struct DMat4 { /// 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))] + #[lua()] fn from_scale(#[proxy] scale: bevy::math::Vec2) -> bevy::math::Affine2; "#, r#" /// Creates an affine transform from the given rotation `angle`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_angle(angle: f32) -> bevy::math::Affine2; "#, r#" /// Creates an affine transformation from the given 2D `translation`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_translation(#[proxy] translation: bevy::math::Vec2) -> bevy::math::Affine2; "#, r#" /// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat2(#[proxy] matrix2: bevy::math::Mat2) -> bevy::math::Affine2; "#, @@ -18957,7 +16999,7 @@ pub struct DMat4 { /// Equivalent to /// `Affine2::from_translation(translation) * Affine2::from_mat2(mat2)` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat2_translation( #[proxy] matrix2: bevy::math::Mat2, @@ -18972,7 +17014,7 @@ pub struct DMat4 { /// Equivalent to `Affine2::from_translation(translation) * /// Affine2::from_angle(angle) * Affine2::from_scale(scale)` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale_angle_translation( #[proxy] scale: bevy::math::Vec2, @@ -18987,7 +17029,7 @@ pub struct DMat4 { /// `translation`. /// Equivalent to `Affine2::from_translation(translation) * Affine2::from_angle(angle)` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_angle_translation( angle: f32, #[proxy] @@ -18998,21 +17040,21 @@ pub struct DMat4 { r#" /// The given `Mat3` must be an affine transform, - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3(#[proxy] m: bevy::math::Mat3) -> bevy::math::Affine2; "#, r#" /// The given [`Mat3A`] must be an affine transform, - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3a(#[proxy] m: bevy::math::Mat3A) -> bevy::math::Affine2; "#, r#" /// Transforms the given 2D point, applying shear, scale, rotation and translation. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -19021,7 +17063,7 @@ pub struct DMat4 { /// translation). /// To also apply translation, use [`Self::transform_point2()`] instead. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, @@ -19030,14 +17072,14 @@ pub struct DMat4 { /// If any element is either `NaN`, positive or negative infinity, this will return /// `false`. - #[lua(kind = "Method")] + #[lua()] fn is_finite(&self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(&self) -> bool; "#, @@ -19050,7 +17092,7 @@ pub struct DMat4 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Affine2, max_abs_diff: f32) -> bool; "#, @@ -19058,75 +17100,48 @@ pub struct DMat4 { /// Return the inverse of this transform. /// Note that if the transform is not invertible the result will be invalid. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(&self) -> bevy::math::Affine2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::Affine2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Affine2; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::Affine2) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct Affine2 { +pub struct LuaAffine2 { #[lua(output(proxy))] matrix2: bevy::math::Mat2, #[lua(output(proxy))] @@ -19135,55 +17150,36 @@ pub struct Affine2 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::Affine3A", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Affine3A; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::Affine3A; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::Affine3A) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; "#, r#" /// Creates an affine transform from three column vectors. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_cols( #[proxy] x_axis: bevy::math::Vec3A, @@ -19199,7 +17195,7 @@ pub struct Affine2 { r#" /// Creates a `[f32; 12]` array storing data in column major order. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array(&self) -> [f32; 12]; "#, @@ -19208,7 +17204,7 @@ pub struct Affine2 { /// column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array_2d(&self) -> [[f32; 3]; 4]; "#, @@ -19216,14 +17212,14 @@ pub struct Affine2 { /// 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))] + #[lua()] fn from_scale(#[proxy] scale: bevy::math::Vec3) -> bevy::math::Affine3A; "#, r#" /// Creates an affine transform from the given `rotation` quaternion. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_quat(#[proxy] rotation: bevy::math::Quat) -> bevy::math::Affine3A; "#, @@ -19231,7 +17227,7 @@ pub struct Affine2 { /// Creates an affine transform containing a 3D rotation around a normalized /// rotation `axis` of `angle` (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_axis_angle( #[proxy] axis: bevy::math::Vec3, @@ -19243,7 +17239,7 @@ pub struct Affine2 { /// Creates an affine transform containing a 3D rotation around the x axis of /// `angle` (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_x(angle: f32) -> bevy::math::Affine3A; "#, @@ -19251,7 +17247,7 @@ pub struct Affine2 { /// Creates an affine transform containing a 3D rotation around the y axis of /// `angle` (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_y(angle: f32) -> bevy::math::Affine3A; "#, @@ -19259,14 +17255,14 @@ pub struct Affine2 { /// Creates an affine transform containing a 3D rotation around the z axis of /// `angle` (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_z(angle: f32) -> bevy::math::Affine3A; "#, r#" /// Creates an affine transformation from the given 3D `translation`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_translation(#[proxy] translation: bevy::math::Vec3) -> bevy::math::Affine3A; "#, @@ -19274,7 +17270,7 @@ pub struct Affine2 { /// Creates an affine transform from a 3x3 matrix (expressing scale, shear and /// rotation) - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3(#[proxy] mat3: bevy::math::Mat3) -> bevy::math::Affine3A; "#, @@ -19283,7 +17279,7 @@ pub struct Affine2 { /// and a translation vector. /// Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_mat3(mat3)` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3_translation( #[proxy] mat3: bevy::math::Mat3, @@ -19298,7 +17294,7 @@ pub struct Affine2 { /// Equivalent to `Affine3A::from_translation(translation) * /// Affine3A::from_quat(rotation) * Affine3A::from_scale(scale)` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale_rotation_translation( #[proxy] scale: bevy::math::Vec3, @@ -19313,7 +17309,7 @@ pub struct Affine2 { /// 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))] + #[lua()] fn from_rotation_translation( #[proxy] rotation: bevy::math::Quat, @@ -19326,7 +17322,7 @@ pub struct Affine2 { /// The given `Mat4` must be an affine transform, /// i.e. contain no perspective transform. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat4(#[proxy] m: bevy::math::Mat4) -> bevy::math::Affine3A; "#, @@ -19335,7 +17331,7 @@ pub struct Affine2 { /// direction. /// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_to_lh( #[proxy] eye: bevy::math::Vec3, @@ -19351,7 +17347,7 @@ pub struct Affine2 { /// direction. /// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_to_rh( #[proxy] eye: bevy::math::Vec3, @@ -19369,7 +17365,7 @@ pub struct Affine2 { /// # Panics /// Will panic if `up` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_at_lh( #[proxy] eye: bevy::math::Vec3, @@ -19387,7 +17383,7 @@ pub struct Affine2 { /// # Panics /// Will panic if `up` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_at_rh( #[proxy] eye: bevy::math::Vec3, @@ -19401,7 +17397,7 @@ pub struct Affine2 { r#" /// Transforms the given 3D points, applying shear, scale, rotation and translation. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -19410,14 +17406,14 @@ pub struct Affine2 { /// translation). /// To also apply translation, use [`Self::transform_point3()`] instead. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_vector3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" /// Transforms the given [`Vec3A`], applying shear, scale, rotation and translation. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_point3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, @@ -19426,7 +17422,7 @@ pub struct Affine2 { /// translation). /// To also apply translation, use [`Self::transform_point3a()`] instead. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_vector3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, @@ -19435,14 +17431,14 @@ pub struct Affine2 { /// If any element is either `NaN`, positive or negative infinity, this will return /// `false`. - #[lua(kind = "Method")] + #[lua()] fn is_finite(&self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(&self) -> bool; "#, @@ -19455,7 +17451,7 @@ pub struct Affine2 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Affine3A, max_abs_diff: f32) -> bool; "#, @@ -19463,18 +17459,18 @@ pub struct Affine2 { /// Return the inverse of this transform. /// Note that if the transform is not invertible the result will be invalid. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(&self) -> bevy::math::Affine3A; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct Affine3A { +pub struct LuaAffine3A { #[lua(output(proxy))] matrix3: bevy::math::Mat3A, #[lua(output(proxy))] @@ -19483,33 +17479,24 @@ pub struct Affine3A { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::DAffine2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::DAffine2) -> bool; "#, r#" /// Creates an affine transform from three column vectors. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_cols( #[proxy] x_axis: bevy::math::DVec2, @@ -19523,7 +17510,7 @@ pub struct Affine3A { r#" /// Creates a `[f64; 6]` array storing data in column major order. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array(&self) -> [f64; 6]; "#, @@ -19532,7 +17519,7 @@ pub struct Affine3A { /// column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array_2d(&self) -> [[f64; 2]; 3]; "#, @@ -19540,28 +17527,28 @@ pub struct Affine3A { /// 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))] + #[lua()] fn from_scale(#[proxy] scale: bevy::math::DVec2) -> bevy::math::DAffine2; "#, r#" /// Creates an affine transform from the given rotation `angle`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_angle(angle: f64) -> bevy::math::DAffine2; "#, r#" /// Creates an affine transformation from the given 2D `translation`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_translation(#[proxy] translation: bevy::math::DVec2) -> bevy::math::DAffine2; "#, r#" /// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat2(#[proxy] matrix2: bevy::math::DMat2) -> bevy::math::DAffine2; "#, @@ -19571,7 +17558,7 @@ pub struct Affine3A { /// Equivalent to /// `DAffine2::from_translation(translation) * DAffine2::from_mat2(mat2)` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat2_translation( #[proxy] matrix2: bevy::math::DMat2, @@ -19586,7 +17573,7 @@ pub struct Affine3A { /// Equivalent to `DAffine2::from_translation(translation) * /// DAffine2::from_angle(angle) * DAffine2::from_scale(scale)` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale_angle_translation( #[proxy] scale: bevy::math::DVec2, @@ -19601,7 +17588,7 @@ pub struct Affine3A { /// `translation`. /// Equivalent to `DAffine2::from_translation(translation) * DAffine2::from_angle(angle)` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_angle_translation( angle: f64, #[proxy] @@ -19612,14 +17599,14 @@ pub struct Affine3A { r#" /// The given `DMat3` must be an affine transform, - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3(#[proxy] m: bevy::math::DMat3) -> bevy::math::DAffine2; "#, r#" /// Transforms the given 2D point, applying shear, scale, rotation and translation. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_point2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, @@ -19628,7 +17615,7 @@ pub struct Affine3A { /// translation). /// To also apply translation, use [`Self::transform_point2()`] instead. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_vector2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, @@ -19637,14 +17624,14 @@ pub struct Affine3A { /// If any element is either `NaN`, positive or negative infinity, this will return /// `false`. - #[lua(kind = "Method")] + #[lua()] fn is_finite(&self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(&self) -> bool; "#, @@ -19657,7 +17644,7 @@ pub struct Affine3A { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DAffine2, max_abs_diff: f64) -> bool; "#, @@ -19665,40 +17652,30 @@ pub struct Affine3A { /// Return the inverse of this transform. /// Note that if the transform is not invertible the result will be invalid. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(&self) -> bevy::math::DAffine2; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::DAffine2; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DAffine2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct DAffine2 { +pub struct LuaDAffine2 { #[lua(output(proxy))] matrix2: bevy::math::DMat2, #[lua(output(proxy))] @@ -19707,32 +17684,24 @@ pub struct DAffine2 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::DAffine3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::DAffine3; "#, r#" /// Creates an affine transform from three column vectors. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_cols( #[proxy] x_axis: bevy::math::DVec3, @@ -19748,7 +17717,7 @@ pub struct DAffine2 { r#" /// Creates a `[f64; 12]` array storing data in column major order. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array(&self) -> [f64; 12]; "#, @@ -19757,7 +17726,7 @@ pub struct DAffine2 { /// column major order. /// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method")] + #[lua()] fn to_cols_array_2d(&self) -> [[f64; 3]; 4]; "#, @@ -19765,14 +17734,14 @@ pub struct DAffine2 { /// 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))] + #[lua()] fn from_scale(#[proxy] scale: bevy::math::DVec3) -> bevy::math::DAffine3; "#, r#" /// Creates an affine transform from the given `rotation` quaternion. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_quat(#[proxy] rotation: bevy::math::DQuat) -> bevy::math::DAffine3; "#, @@ -19780,7 +17749,7 @@ pub struct DAffine2 { /// Creates an affine transform containing a 3D rotation around a normalized /// rotation `axis` of `angle` (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_axis_angle( #[proxy] axis: bevy::math::DVec3, @@ -19792,7 +17761,7 @@ pub struct DAffine2 { /// Creates an affine transform containing a 3D rotation around the x axis of /// `angle` (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_x(angle: f64) -> bevy::math::DAffine3; "#, @@ -19800,7 +17769,7 @@ pub struct DAffine2 { /// Creates an affine transform containing a 3D rotation around the y axis of /// `angle` (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_y(angle: f64) -> bevy::math::DAffine3; "#, @@ -19808,14 +17777,14 @@ pub struct DAffine2 { /// Creates an affine transform containing a 3D rotation around the z axis of /// `angle` (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_z(angle: f64) -> bevy::math::DAffine3; "#, r#" /// Creates an affine transformation from the given 3D `translation`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_translation(#[proxy] translation: bevy::math::DVec3) -> bevy::math::DAffine3; "#, @@ -19823,7 +17792,7 @@ pub struct DAffine2 { /// Creates an affine transform from a 3x3 matrix (expressing scale, shear and /// rotation) - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3(#[proxy] mat3: bevy::math::DMat3) -> bevy::math::DAffine3; "#, @@ -19832,7 +17801,7 @@ pub struct DAffine2 { /// and a translation vector. /// Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_mat3(mat3)` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3_translation( #[proxy] mat3: bevy::math::DMat3, @@ -19847,7 +17816,7 @@ pub struct DAffine2 { /// Equivalent to `DAffine3::from_translation(translation) * /// DAffine3::from_quat(rotation) * DAffine3::from_scale(scale)` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale_rotation_translation( #[proxy] scale: bevy::math::DVec3, @@ -19862,7 +17831,7 @@ pub struct DAffine2 { /// 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))] + #[lua()] fn from_rotation_translation( #[proxy] rotation: bevy::math::DQuat, @@ -19875,7 +17844,7 @@ pub struct DAffine2 { /// The given `DMat4` must be an affine transform, /// i.e. contain no perspective transform. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat4(#[proxy] m: bevy::math::DMat4) -> bevy::math::DAffine3; "#, @@ -19884,7 +17853,7 @@ pub struct DAffine2 { /// direction. /// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_to_lh( #[proxy] eye: bevy::math::DVec3, @@ -19900,7 +17869,7 @@ pub struct DAffine2 { /// direction. /// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_to_rh( #[proxy] eye: bevy::math::DVec3, @@ -19918,7 +17887,7 @@ pub struct DAffine2 { /// # Panics /// Will panic if `up` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_at_lh( #[proxy] eye: bevy::math::DVec3, @@ -19936,7 +17905,7 @@ pub struct DAffine2 { /// # Panics /// Will panic if `up` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn look_at_rh( #[proxy] eye: bevy::math::DVec3, @@ -19950,7 +17919,7 @@ pub struct DAffine2 { r#" /// Transforms the given 3D points, applying shear, scale, rotation and translation. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -19959,7 +17928,7 @@ pub struct DAffine2 { /// translation). /// To also apply translation, use [`Self::transform_point3()`] instead. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_vector3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -19968,14 +17937,14 @@ pub struct DAffine2 { /// If any element is either `NaN`, positive or negative infinity, this will return /// `false`. - #[lua(kind = "Method")] + #[lua()] fn is_finite(&self) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] + #[lua()] fn is_nan(&self) -> bool; "#, @@ -19988,7 +17957,7 @@ pub struct DAffine2 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DAffine3, max_abs_diff: f64) -> bool; "#, @@ -19996,41 +17965,30 @@ pub struct DAffine2 { /// Return the inverse of this transform. /// Note that if the transform is not invertible the result will be invalid. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(&self) -> bevy::math::DAffine3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DAffine3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::DAffine3) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct DAffine3 { +pub struct LuaDAffine3 { #[lua(output(proxy))] matrix3: bevy::math::DMat3, #[lua(output(proxy))] @@ -20039,52 +17997,33 @@ pub struct DAffine3 { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::DQuat", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Adds two quaternions. /// The sum is not guaranteed to be normalized. /// Note that addition is not the same as combining the rotations represented by the /// two quaternions! That corresponds to multiplication. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] + #[lua(as_trait = "std::ops::Add", composite = "add")] fn add(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::DQuat; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::DQuat) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::DQuat; "#, @@ -20092,13 +18031,7 @@ pub struct DAffine3 { /// Divides a quaternion by a scalar value. /// The quotient is not guaranteed to be normalized. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] + #[lua(as_trait = "std::ops::Div", composite = "div")] fn div(self, rhs: f64) -> bevy::math::DQuat; "#, @@ -20110,13 +18043,7 @@ pub struct DAffine3 { /// # Panics /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, @@ -20124,13 +18051,7 @@ pub struct DAffine3 { /// Subtracts the `rhs` quaternion from `self`. /// The difference is not guaranteed to be normalized. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] + #[lua(as_trait = "std::ops::Sub", composite = "sub")] fn sub(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, @@ -20138,13 +18059,7 @@ pub struct DAffine3 { /// Multiplies a quaternion by a scalar value. /// The product is not guaranteed to be normalized. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f64) -> bevy::math::DQuat; "#, @@ -20153,13 +18068,7 @@ pub struct DAffine3 { /// # Panics /// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -20172,7 +18081,7 @@ pub struct DAffine3 { /// 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))] + #[lua()] fn from_xyzw(x: f64, y: f64, z: f64, w: f64) -> bevy::math::DQuat; "#, @@ -20182,7 +18091,7 @@ pub struct DAffine3 { /// 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))] + #[lua()] fn from_array(a: [f64; 4]) -> bevy::math::DQuat; "#, @@ -20192,7 +18101,7 @@ pub struct DAffine3 { /// 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))] + #[lua()] fn from_vec4(#[proxy] v: bevy::math::DVec4) -> bevy::math::DQuat; "#, @@ -20202,7 +18111,7 @@ pub struct DAffine3 { /// # Panics /// Will panic if `axis` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_axis_angle( #[proxy] axis: bevy::math::DVec3, @@ -20214,35 +18123,35 @@ pub struct DAffine3 { /// 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))] + #[lua()] fn from_scaled_axis(#[proxy] v: bevy::math::DVec3) -> bevy::math::DQuat; "#, r#" /// Creates a quaternion from the `angle` (in radians) around the x axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_x(angle: f64) -> bevy::math::DQuat; "#, r#" /// Creates a quaternion from the `angle` (in radians) around the y axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_y(angle: f64) -> bevy::math::DQuat; "#, r#" /// Creates a quaternion from the `angle` (in radians) around the z axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_z(angle: f64) -> bevy::math::DQuat; "#, r#" /// Creates a quaternion from the given Euler rotation sequence and the angles (in radians). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_euler( #[proxy] euler: bevy::math::EulerRot, @@ -20255,14 +18164,14 @@ pub struct DAffine3 { r#" /// Creates a quaternion from a 3x3 rotation matrix. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat3(#[proxy] mat: &glam::DMat3) -> bevy::math::DQuat; "#, r#" /// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_mat4(#[proxy] mat: &glam::DMat4) -> bevy::math::DQuat; "#, @@ -20276,7 +18185,7 @@ pub struct DAffine3 { /// # Panics /// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_arc( #[proxy] from: bevy::math::DVec3, @@ -20295,7 +18204,7 @@ pub struct DAffine3 { /// # Panics /// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_arc_colinear( #[proxy] from: bevy::math::DVec3, @@ -20314,7 +18223,7 @@ pub struct DAffine3 { /// # Panics /// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation_arc_2d( #[proxy] from: bevy::math::DVec2, @@ -20326,28 +18235,28 @@ pub struct DAffine3 { r#" /// Returns the rotation axis scaled by the rotation in radians. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn to_scaled_axis(self) -> bevy::math::DVec3; "#, r#" /// Returns the rotation angles for the given euler rotation sequence. - #[lua(kind = "Method")] + #[lua()] fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f64, f64, f64); "#, r#" /// `[x, y, z, w]` - #[lua(kind = "Method")] + #[lua()] fn to_array(&self) -> [f64; 4]; "#, r#" /// Returns the vector part of the quaternion. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn xyz(self) -> bevy::math::DVec3; "#, @@ -20355,7 +18264,7 @@ pub struct DAffine3 { /// Returns the quaternion conjugate of `self`. For a unit quaternion the /// conjugate is also the inverse. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn conjugate(self) -> bevy::math::DQuat; "#, @@ -20367,7 +18276,7 @@ pub struct DAffine3 { /// # Panics /// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inverse(self) -> bevy::math::DQuat; "#, @@ -20375,14 +18284,14 @@ pub struct DAffine3 { /// Computes the dot product of `self` and `rhs`. The dot product is /// equal to the cosine of the angle between two quaternion rotations. - #[lua(kind = "Method")] + #[lua()] fn dot(self, #[proxy] rhs: bevy::math::DQuat) -> f64; "#, r#" /// Computes the length of `self`. - #[lua(kind = "Method")] + #[lua()] fn length(self) -> f64; "#, @@ -20391,7 +18300,7 @@ pub struct DAffine3 { /// This is generally faster than `length()` as it avoids a square /// root operation. - #[lua(kind = "Method")] + #[lua()] fn length_squared(self) -> f64; "#, @@ -20399,7 +18308,7 @@ pub struct DAffine3 { /// Computes `1.0 / length()`. /// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method")] + #[lua()] fn length_recip(self) -> f64; "#, @@ -20409,7 +18318,7 @@ pub struct DAffine3 { /// Panics /// Will panic if `self` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize(self) -> bevy::math::DQuat; "#, @@ -20417,13 +18326,13 @@ pub struct DAffine3 { /// 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(kind = "Method")] + #[lua()] fn is_finite(self) -> bool; "#, r#" - #[lua(kind = "Method")] + #[lua()] fn is_nan(self) -> bool; "#, @@ -20431,13 +18340,13 @@ pub struct DAffine3 { /// Returns whether `self` of length `1.0` or not. /// Uses a precision threshold of `1e-6`. - #[lua(kind = "Method")] + #[lua()] fn is_normalized(self) -> bool; "#, r#" - #[lua(kind = "Method")] + #[lua()] fn is_near_identity(self) -> bool; "#, @@ -20448,7 +18357,7 @@ pub struct DAffine3 { /// # Panics /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Method")] + #[lua()] fn angle_between(self, #[proxy] rhs: bevy::math::DQuat) -> f64; "#, @@ -20461,7 +18370,7 @@ pub struct DAffine3 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] + #[lua()] fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DQuat, max_abs_diff: f64) -> bool; "#, @@ -20473,7 +18382,7 @@ pub struct DAffine3 { /// # Panics /// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn lerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; "#, @@ -20485,7 +18394,7 @@ pub struct DAffine3 { /// # Panics /// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn slerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; "#, @@ -20494,7 +18403,7 @@ pub struct DAffine3 { /// # Panics /// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_vec3(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, @@ -20505,37 +18414,37 @@ pub struct DAffine3 { /// # Panics /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_quat(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" /// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_affine3(#[proxy] a: &glam::DAffine3) -> bevy::math::DQuat; "#, r#" - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_quat(self) -> bevy::math::Quat; "#, r#" - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_f32(self) -> bevy::math::Quat; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct DQuat { +pub struct LuaDQuat { x: f64, y: f64, z: f64, @@ -20544,65 +18453,56 @@ pub struct DQuat { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::EulerRot", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &glam::EulerRot) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::EulerRot; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct EulerRot {} +pub struct LuaEulerRot {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::BVec3A", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::BVec3A; "#, r#" /// Creates a new vector mask. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: bool, y: bool, z: bool) -> bevy::math::BVec3A; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: bool) -> bevy::math::BVec3A; "#, @@ -20611,21 +18511,21 @@ pub struct EulerRot {} /// 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(kind = "Method")] + #[lua()] fn bitmask(self) -> u32; "#, r#" /// Returns true if any of the elements are true, false otherwise. - #[lua(kind = "Method")] + #[lua()] fn any(self) -> bool; "#, r#" /// Returns true if all the elements are true, false otherwise. - #[lua(kind = "Method")] + #[lua()] fn all(self) -> bool; "#, @@ -20633,7 +18533,7 @@ pub struct EulerRot {} /// Tests the value at `index`. /// Panics if `index` is greater than 2. - #[lua(kind = "Method")] + #[lua()] fn test(&self, index: usize) -> bool; "#, @@ -20641,53 +18541,46 @@ pub struct EulerRot {} /// Sets the element at `index`. /// Panics if `index` is greater than 2. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set(&mut self, index: usize, value: bool) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::BVec3A) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct BVec3A(); +pub struct LuaBVec3A(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::BVec4A", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::BVec4A; "#, r#" /// Creates a new vector mask. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x: bool, y: bool, z: bool, w: bool) -> bevy::math::BVec4A; "#, r#" /// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn splat(v: bool) -> bevy::math::BVec4A; "#, @@ -20696,21 +18589,21 @@ pub struct BVec3A(); /// 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(kind = "Method")] + #[lua()] fn bitmask(self) -> u32; "#, r#" /// Returns true if any of the elements are true, false otherwise. - #[lua(kind = "Method")] + #[lua()] fn any(self) -> bool; "#, r#" /// Returns true if all the elements are true, false otherwise. - #[lua(kind = "Method")] + #[lua()] fn all(self) -> bool; "#, @@ -20718,7 +18611,7 @@ pub struct BVec3A(); /// Tests the value at `index`. /// Panics if `index` is greater than 3. - #[lua(kind = "Method")] + #[lua()] fn test(&self, index: usize) -> bool; "#, @@ -20726,38 +18619,35 @@ pub struct BVec3A(); /// Sets the element at `index`. /// Panics if `index` is greater than 3. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set(&mut self, index: usize, value: bool) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] rhs: &glam::BVec4A) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct BVec4A(); +pub struct LuaBVec4A(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Direction2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Create a [`Direction2d`] from a [`Vec2`] that is already normalized. /// # Warning /// `value` must be normalized, i.e it's length must be `1.0`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new_unchecked( #[proxy] value: bevy::math::Vec2, @@ -20766,94 +18656,72 @@ pub struct BVec4A(); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction2d) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Direction2d; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::primitives::Direction2d; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Direction2d(); +pub struct LuaDirection2d(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Circle", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Circle; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Circle) -> bool; "#, r#" /// Create a new [`Circle`] from a `radius` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(radius: f32) -> bevy::math::primitives::Circle; "#, r#" /// Get the diameter of the circle - #[lua(kind = "Method")] + #[lua()] fn diameter(&self) -> f32; "#, r#" /// Get the area of the circle - #[lua(kind = "Method")] + #[lua()] fn area(&self) -> f32; "#, r#" /// Get the perimeter or circumference of the circle - #[lua(kind = "Method")] + #[lua()] fn perimeter(&self) -> f32; "#, @@ -20862,41 +18730,34 @@ pub struct Direction2d(); /// If the point is outside the circle, the returned point will be on the perimeter of the circle. /// Otherwise, it will be inside the circle and returned as is. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn closest_point(&self, #[proxy] point: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Circle { +pub struct LuaCircle { radius: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Ellipse", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Ellipse; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Ellipse) -> bool; "#, @@ -20904,7 +18765,7 @@ pub struct Circle { /// Create a new `Ellipse` from half of its width and height. /// This corresponds to the two perpendicular radii defining the ellipse. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(half_width: f32, half_height: f32) -> bevy::math::primitives::Ellipse; "#, @@ -20912,53 +18773,50 @@ pub struct Circle { /// Create a new `Ellipse` from a given full size. /// `size.x` is the diameter along the X axis, and `size.y` is the diameter along the Y axis. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_size(#[proxy] size: bevy::math::Vec2) -> bevy::math::primitives::Ellipse; "#, r#" /// Returns the length of the semi-major axis. This corresponds to the longest radius of the ellipse. - #[lua(kind = "Method")] + #[lua()] fn semi_major(self) -> f32; "#, r#" /// Returns the length of the semi-minor axis. This corresponds to the shortest radius of the ellipse. - #[lua(kind = "Method")] + #[lua()] fn semi_minor(self) -> f32; "#, r#" /// Get the area of the ellipse - #[lua(kind = "Method")] + #[lua()] fn area(&self) -> f32; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Ellipse { +pub struct LuaEllipse { #[lua(output(proxy))] half_size: bevy::math::Vec2, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Plane2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Plane2d) -> bool; "#, @@ -20967,73 +18825,64 @@ pub struct Ellipse { /// # Panics /// Panics if the given `normal` is zero (or very close to zero), or non-finite. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(#[proxy] normal: bevy::math::Vec2) -> bevy::math::primitives::Plane2d; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Plane2d; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Plane2d { +pub struct LuaPlane2d { #[lua(output(proxy))] normal: bevy::math::primitives::Direction2d, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Line2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Line2d) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Line2d; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Line2d { +pub struct LuaLine2d { #[lua(output(proxy))] direction: bevy::math::primitives::Direction2d, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Segment2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Create a new `Segment2d` from a direction and full length of the segment - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new( #[proxy] direction: bevy::math::primitives::Direction2d, @@ -21044,46 +18893,37 @@ pub struct Line2d { r#" /// Get the position of the first point on the line segment - #[lua(kind = "Method", output(proxy))] + #[lua()] fn point1(&self) -> bevy::math::Vec2; "#, r#" /// Get the position of the second point on the line segment - #[lua(kind = "Method", output(proxy))] + #[lua()] fn point2(&self) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Segment2d; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Segment2d) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Segment2d { +pub struct LuaSegment2d { #[lua(output(proxy))] direction: bevy::math::primitives::Direction2d, half_length: f32, @@ -21091,20 +18931,18 @@ pub struct Segment2d { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Triangle2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Triangle2d; "#, r#" /// Create a new `Triangle2d` from points `a`, `b`, and `c` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new( #[proxy] a: bevy::math::Vec2, @@ -21118,14 +18956,14 @@ pub struct Segment2d { r#" /// Get the area of the triangle - #[lua(kind = "Method")] + #[lua()] fn area(&self) -> f32; "#, r#" /// Get the perimeter of the triangle - #[lua(kind = "Method")] + #[lua()] fn perimeter(&self) -> f32; "#, @@ -21133,52 +18971,49 @@ pub struct Segment2d { /// Reverse the [`WindingOrder`] of the triangle /// by swapping the second and third vertices - #[lua(kind = "MutatingMethod")] + #[lua()] fn reverse(&mut self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Triangle2d) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Triangle2d { +pub struct LuaTriangle2d { vertices: ReflectedValue, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Rectangle", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Create a new `Rectangle` from a full width and height - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(width: f32, height: f32) -> bevy::math::primitives::Rectangle; "#, r#" /// Create a new `Rectangle` from a given full size - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_size(#[proxy] size: bevy::math::Vec2) -> bevy::math::primitives::Rectangle; "#, r#" /// Create a new `Rectangle` from two corner points - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_corners( #[proxy] point1: bevy::math::Vec2, @@ -21190,21 +19025,21 @@ pub struct Triangle2d { r#" /// Get the size of the rectangle - #[lua(kind = "Method", output(proxy))] + #[lua()] fn size(&self) -> bevy::math::Vec2; "#, r#" /// Get the area of the rectangle - #[lua(kind = "Method")] + #[lua()] fn area(&self) -> f32; "#, r#" /// Get the perimeter of the rectangle - #[lua(kind = "Method")] + #[lua()] fn perimeter(&self) -> f32; "#, @@ -21213,63 +19048,47 @@ pub struct Triangle2d { /// If the point is outside the rectangle, the returned point will be on the perimeter of the rectangle. /// Otherwise, it will be inside the rectangle and returned as is. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn closest_point(&self, #[proxy] point: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Rectangle) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Rectangle; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Rectangle { +pub struct LuaRectangle { #[lua(output(proxy))] half_size: bevy::math::Vec2, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::RegularPolygon", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::RegularPolygon; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::RegularPolygon) -> bool; "#, @@ -21279,7 +19098,7 @@ pub struct Rectangle { /// # Panics /// Panics if `circumradius` is non-positive - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(circumradius: f32, sides: usize) -> bevy::math::primitives::RegularPolygon; "#, @@ -21287,7 +19106,7 @@ pub struct Rectangle { /// Get the radius of the circumcircle on which all vertices /// of the regular polygon lie - #[lua(kind = "Method")] + #[lua()] fn circumradius(&self) -> f32; "#, @@ -21296,21 +19115,21 @@ pub struct Rectangle { /// This is the radius of the largest circle that can /// be drawn within the polygon - #[lua(kind = "Method")] + #[lua()] fn inradius(&self) -> f32; "#, r#" /// Get the length of one side of the regular polygon - #[lua(kind = "Method")] + #[lua()] fn side_length(&self) -> f32; "#, r#" /// Get the area of the regular polygon - #[lua(kind = "Method")] + #[lua()] fn area(&self) -> f32; "#, @@ -21318,7 +19137,7 @@ pub struct Rectangle { /// Get the perimeter of the regular polygon. /// This is the sum of its sides - #[lua(kind = "Method")] + #[lua()] fn perimeter(&self) -> f32; "#, @@ -21327,7 +19146,7 @@ pub struct Rectangle { /// This is the angle formed by two adjacent sides with points /// within the angle being in the interior of the polygon - #[lua(kind = "Method")] + #[lua()] fn internal_angle_degrees(&self) -> f32; "#, @@ -21336,7 +19155,7 @@ pub struct Rectangle { /// This is the angle formed by two adjacent sides with points /// within the angle being in the interior of the polygon - #[lua(kind = "Method")] + #[lua()] fn internal_angle_radians(&self) -> f32; "#, @@ -21345,7 +19164,7 @@ pub struct Rectangle { /// This is the angle formed by two adjacent sides with points /// within the angle being in the exterior of the polygon - #[lua(kind = "Method")] + #[lua()] fn external_angle_degrees(&self) -> f32; "#, @@ -21354,18 +19173,18 @@ pub struct Rectangle { /// This is the angle formed by two adjacent sides with points /// within the angle being in the exterior of the polygon - #[lua(kind = "Method")] + #[lua()] fn external_angle_radians(&self) -> f32; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct RegularPolygon { +pub struct LuaRegularPolygon { #[lua(output(proxy))] circumcircle: bevy::math::primitives::Circle, sides: usize, @@ -21373,78 +19192,58 @@ pub struct RegularPolygon { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Capsule2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule2d) -> bool; "#, r#" /// Create a new `Capsule2d` from a radius and length - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule2d; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Capsule2d; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Capsule2d { +pub struct LuaCapsule2d { radius: f32, half_length: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Direction3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction3d) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, rhs: f32) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Direction3d; "#, @@ -21453,7 +19252,7 @@ pub struct Capsule2d { /// # Warning /// `value` must be normalized, i.e it's length must be `1.0`. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new_unchecked( #[proxy] value: bevy::math::Vec3, @@ -21462,62 +19261,54 @@ pub struct Capsule2d { "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> bevy::math::primitives::Direction3d; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Direction3d(); +pub struct LuaDirection3d(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Sphere", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Sphere; "#, r#" /// Create a new [`Sphere`] from a `radius` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(radius: f32) -> bevy::math::primitives::Sphere; "#, r#" /// Get the diameter of the sphere - #[lua(kind = "Method")] + #[lua()] fn diameter(&self) -> f32; "#, r#" /// Get the surface area of the sphere - #[lua(kind = "Method")] + #[lua()] fn area(&self) -> f32; "#, r#" /// Get the volume of the sphere - #[lua(kind = "Method")] + #[lua()] fn volume(&self) -> f32; "#, @@ -21526,41 +19317,34 @@ pub struct Direction3d(); /// If the point is outside the sphere, the returned point will be on the surface of the sphere. /// Otherwise, it will be inside the sphere and returned as is. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn closest_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Sphere) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Sphere { +pub struct LuaSphere { radius: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Plane3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Plane3d; "#, @@ -21569,74 +19353,64 @@ pub struct Sphere { /// # Panics /// Panics if the given `normal` is zero (or very close to zero), or non-finite. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(#[proxy] normal: bevy::math::Vec3) -> bevy::math::primitives::Plane3d; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Plane3d) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Plane3d { +pub struct LuaPlane3d { #[lua(output(proxy))] normal: bevy::math::primitives::Direction3d, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Line3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Line3d; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Line3d) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Line3d { +pub struct LuaLine3d { #[lua(output(proxy))] direction: bevy::math::primitives::Direction3d, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Segment3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Create a new `Segment3d` from a direction and full length of the segment - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new( #[proxy] direction: bevy::math::primitives::Direction3d, @@ -21647,46 +19421,37 @@ pub struct Line3d { r#" /// Get the position of the first point on the line segment - #[lua(kind = "Method", output(proxy))] + #[lua()] fn point1(&self) -> bevy::math::Vec3; "#, r#" /// Get the position of the second point on the line segment - #[lua(kind = "Method", output(proxy))] + #[lua()] fn point2(&self) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Segment3d; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Segment3d) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Segment3d { +pub struct LuaSegment3d { #[lua(output(proxy))] direction: bevy::math::primitives::Direction3d, half_length: f32, @@ -21694,20 +19459,18 @@ pub struct Segment3d { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Cuboid", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Cuboid; "#, r#" /// Create a new `Cuboid` from a full x, y, and z length - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new( x_length: f32, y_length: f32, @@ -21718,14 +19481,14 @@ pub struct Segment3d { r#" /// Create a new `Cuboid` from a given full size - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_size(#[proxy] size: bevy::math::Vec3) -> bevy::math::primitives::Cuboid; "#, r#" /// Create a new `Cuboid` from two corner points - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_corners( #[proxy] point1: bevy::math::Vec3, @@ -21737,21 +19500,21 @@ pub struct Segment3d { r#" /// Get the size of the cuboid - #[lua(kind = "Method", output(proxy))] + #[lua()] fn size(&self) -> bevy::math::Vec3; "#, r#" /// Get the surface area of the cuboid - #[lua(kind = "Method")] + #[lua()] fn area(&self) -> f32; "#, r#" /// Get the volume of the cuboid - #[lua(kind = "Method")] + #[lua()] fn volume(&self) -> f32; "#, @@ -21760,67 +19523,55 @@ pub struct Segment3d { /// If the point is outside the cuboid, the returned point will be on the surface of the cuboid. /// Otherwise, it will be inside the cuboid and returned as is. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn closest_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Cuboid) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Cuboid { +pub struct LuaCuboid { #[lua(output(proxy))] half_size: bevy::math::Vec3, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Cylinder", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Cylinder; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Cylinder) -> bool; "#, r#" /// Create a new `Cylinder` from a radius and full height - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(radius: f32, height: f32) -> bevy::math::primitives::Cylinder; "#, r#" /// Get the base of the cylinder as a [`Circle`] - #[lua(kind = "Method", output(proxy))] + #[lua()] fn base(&self) -> bevy::math::primitives::Circle; "#, @@ -21828,59 +19579,57 @@ pub struct Cuboid { /// Get the surface area of the side of the cylinder, /// also known as the lateral area - #[lua(kind = "Method")] + #[lua()] fn lateral_area(&self) -> f32; "#, r#" /// Get the surface area of one base of the cylinder - #[lua(kind = "Method")] + #[lua()] fn base_area(&self) -> f32; "#, r#" /// Get the total surface area of the cylinder - #[lua(kind = "Method")] + #[lua()] fn area(&self) -> f32; "#, r#" /// Get the volume of the cylinder - #[lua(kind = "Method")] + #[lua()] fn volume(&self) -> f32; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Cylinder { +pub struct LuaCylinder { radius: f32, half_height: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Capsule3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Capsule3d; "#, r#" /// Create a new `Capsule3d` from a radius and length - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule3d; "#, @@ -21888,63 +19637,56 @@ pub struct Cylinder { /// Get the part connecting the hemispherical ends /// of the capsule as a [`Cylinder`] - #[lua(kind = "Method", output(proxy))] + #[lua()] fn to_cylinder(&self) -> bevy::math::primitives::Cylinder; "#, r#" /// Get the surface area of the capsule - #[lua(kind = "Method")] + #[lua()] fn area(&self) -> f32; "#, r#" /// Get the volume of the capsule - #[lua(kind = "Method")] + #[lua()] fn volume(&self) -> f32; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule3d) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Capsule3d { +pub struct LuaCapsule3d { radius: f32, half_length: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Cone", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Cone; "#, r#" /// Get the base of the cone as a [`Circle`] - #[lua(kind = "Method", output(proxy))] + #[lua()] fn base(&self) -> bevy::math::primitives::Circle; "#, @@ -21952,7 +19694,7 @@ pub struct Capsule3d { /// Get the slant height of the cone, the length of the line segment /// connecting a point on the base to the apex - #[lua(kind = "Method")] + #[lua()] fn slant_height(&self) -> f32; "#, @@ -21960,85 +19702,73 @@ pub struct Capsule3d { /// Get the surface area of the side of the cone, /// also known as the lateral area - #[lua(kind = "Method")] + #[lua()] fn lateral_area(&self) -> f32; "#, r#" /// Get the surface area of the base of the cone - #[lua(kind = "Method")] + #[lua()] fn base_area(&self) -> f32; "#, r#" /// Get the total surface area of the cone - #[lua(kind = "Method")] + #[lua()] fn area(&self) -> f32; "#, r#" /// Get the volume of the cone - #[lua(kind = "Method")] + #[lua()] fn volume(&self) -> f32; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Cone) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Cone { +pub struct LuaCone { radius: f32, height: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::ConicalFrustum", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::ConicalFrustum; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::ConicalFrustum) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct ConicalFrustum { +pub struct LuaConicalFrustum { radius_top: f32, radius_bottom: f32, height: f32, @@ -22046,12 +19776,14 @@ pub struct ConicalFrustum { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Torus", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Create a new `Torus` from an inner and outer radius. /// The inner radius is the radius of the hole, and the outer radius /// is the radius of the entire object - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(inner_radius: f32, outer_radius: f32) -> bevy::math::primitives::Torus; "#, @@ -22060,7 +19792,7 @@ pub struct ConicalFrustum { /// For a ring torus, this corresponds to the radius of the hole, /// or `major_radius - minor_radius` - #[lua(kind = "Method")] + #[lua()] fn inner_radius(&self) -> f32; "#, @@ -22069,7 +19801,7 @@ pub struct ConicalFrustum { /// This corresponds to the overall radius of the entire object, /// or `major_radius + minor_radius` - #[lua(kind = "Method")] + #[lua()] fn outer_radius(&self) -> f32; "#, @@ -22077,7 +19809,7 @@ pub struct ConicalFrustum { /// Get the surface area of the torus. Note that this only produces /// the expected result when the torus has a ring and isn't self-intersecting - #[lua(kind = "Method")] + #[lua()] fn area(&self) -> f32; "#, @@ -22085,45 +19817,38 @@ pub struct ConicalFrustum { /// Get the volume of the torus. Note that this only produces /// the expected result when the torus has a ring and isn't self-intersecting - #[lua(kind = "Method")] + #[lua()] fn volume(&self) -> f32; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::primitives::Torus; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::primitives::Torus) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Torus { +pub struct LuaTorus { minor_radius: f32, major_radius: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::IRect", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Create a new rectangle from two corner points. /// The two points do not need to be the minimum and/or maximum corners. @@ -22135,7 +19860,7 @@ pub struct Torus { /// let r = IRect::new(2, 3, 5, -1); // w=3 h=4 /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x0: i32, y0: i32, x1: i32, y1: i32) -> bevy::math::IRect; "#, @@ -22152,7 +19877,7 @@ pub struct Torus { /// let r = IRect::from_corners(IVec2::ONE, IVec2::ZERO); // w=1 h=1 /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_corners( #[proxy] p0: bevy::math::IVec2, @@ -22175,7 +19900,7 @@ pub struct Torus { /// assert_eq!(r.max, IVec2::splat(1)); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_center_size( #[proxy] origin: bevy::math::IVec2, @@ -22196,7 +19921,7 @@ pub struct Torus { /// assert_eq!(r.max, IVec2::splat(1)); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_center_half_size( #[proxy] origin: bevy::math::IVec2, @@ -22214,7 +19939,7 @@ pub struct Torus { /// assert!(r.is_empty()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_empty(&self) -> bool; "#, @@ -22227,7 +19952,7 @@ pub struct Torus { /// assert_eq!(r.width(), 5); /// ``` - #[lua(kind = "Method")] + #[lua()] fn width(&self) -> i32; "#, @@ -22240,7 +19965,7 @@ pub struct Torus { /// assert_eq!(r.height(), 1); /// ``` - #[lua(kind = "Method")] + #[lua()] fn height(&self) -> i32; "#, @@ -22253,7 +19978,7 @@ pub struct Torus { /// assert_eq!(r.size(), IVec2::new(5, 1)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn size(&self) -> bevy::math::IVec2; "#, @@ -22268,7 +19993,7 @@ pub struct Torus { /// assert_eq!(r.half_size(), IVec2::new(2, 1)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn half_size(&self) -> bevy::math::IVec2; "#, @@ -22283,7 +20008,7 @@ pub struct Torus { /// assert_eq!(r.center(), IVec2::new(2, 1)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn center(&self) -> bevy::math::IVec2; "#, @@ -22298,7 +20023,7 @@ pub struct Torus { /// assert!(r.contains(r.max)); /// ``` - #[lua(kind = "Method")] + #[lua()] fn contains(&self, #[proxy] point: bevy::math::IVec2) -> bool; "#, @@ -22315,7 +20040,7 @@ pub struct Torus { /// assert_eq!(r.max, IVec2::new(5, 3)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn union(&self, #[proxy] other: bevy::math::IRect) -> bevy::math::IRect; "#, @@ -22332,7 +20057,7 @@ pub struct Torus { /// assert_eq!(u.max, IVec2::new(5, 6)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn union_point(&self, #[proxy] other: bevy::math::IVec2) -> bevy::math::IRect; "#, @@ -22351,7 +20076,7 @@ pub struct Torus { /// assert_eq!(r.max, IVec2::new(3, 1)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn intersect(&self, #[proxy] other: bevy::math::IRect) -> bevy::math::IRect; "#, @@ -22373,59 +20098,50 @@ pub struct Torus { /// assert_eq!(r2.max, IVec2::new(3, 2)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inset(&self, inset: i32) -> bevy::math::IRect; "#, r#" /// Returns self as [`Rect`] (f32) - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_rect(&self) -> bevy::math::Rect; "#, r#" /// Returns self as [`URect`] (u32) - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_urect(&self) -> bevy::math::URect; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::IRect; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::IRect) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct IRect { +pub struct LuaIRect { #[lua(output(proxy))] min: bevy::math::IVec2, #[lua(output(proxy))] @@ -22434,6 +20150,8 @@ pub struct IRect { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::Rect", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Create a new rectangle from two corner points. /// The two points do not need to be the minimum and/or maximum corners. @@ -22445,7 +20163,7 @@ pub struct IRect { /// let r = Rect::new(2., 3., 5., -1.); // w=3 h=4 /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x0: f32, y0: f32, x1: f32, y1: f32) -> bevy::math::Rect; "#, @@ -22462,7 +20180,7 @@ pub struct IRect { /// let r = Rect::from_corners(Vec2::ONE, Vec2::ZERO); // w=1 h=1 /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_corners( #[proxy] p0: bevy::math::Vec2, @@ -22483,7 +20201,7 @@ pub struct IRect { /// assert!(r.max.abs_diff_eq(Vec2::splat(0.5), 1e-5)); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_center_size( #[proxy] origin: bevy::math::Vec2, @@ -22504,7 +20222,7 @@ pub struct IRect { /// assert!(r.max.abs_diff_eq(Vec2::splat(1.), 1e-5)); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_center_half_size( #[proxy] origin: bevy::math::Vec2, @@ -22522,7 +20240,7 @@ pub struct IRect { /// assert!(r.is_empty()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_empty(&self) -> bool; "#, @@ -22535,7 +20253,7 @@ pub struct IRect { /// assert!((r.width() - 5.).abs() <= 1e-5); /// ``` - #[lua(kind = "Method")] + #[lua()] fn width(&self) -> f32; "#, @@ -22548,7 +20266,7 @@ pub struct IRect { /// assert!((r.height() - 1.).abs() <= 1e-5); /// ``` - #[lua(kind = "Method")] + #[lua()] fn height(&self) -> f32; "#, @@ -22561,7 +20279,7 @@ pub struct IRect { /// assert!(r.size().abs_diff_eq(Vec2::new(5., 1.), 1e-5)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn size(&self) -> bevy::math::Vec2; "#, @@ -22574,7 +20292,7 @@ pub struct IRect { /// assert!(r.half_size().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn half_size(&self) -> bevy::math::Vec2; "#, @@ -22587,7 +20305,7 @@ pub struct IRect { /// assert!(r.center().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn center(&self) -> bevy::math::Vec2; "#, @@ -22602,7 +20320,7 @@ pub struct IRect { /// assert!(r.contains(r.max)); /// ``` - #[lua(kind = "Method")] + #[lua()] fn contains(&self, #[proxy] point: bevy::math::Vec2) -> bool; "#, @@ -22619,7 +20337,7 @@ pub struct IRect { /// assert!(r.max.abs_diff_eq(Vec2::new(5., 3.), 1e-5)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn union(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; "#, @@ -22636,7 +20354,7 @@ pub struct IRect { /// assert!(u.max.abs_diff_eq(Vec2::new(5., 6.), 1e-5)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn union_point(&self, #[proxy] other: bevy::math::Vec2) -> bevy::math::Rect; "#, @@ -22655,7 +20373,7 @@ pub struct IRect { /// assert!(r.max.abs_diff_eq(Vec2::new(3., 1.), 1e-5)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn intersect(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; "#, @@ -22677,7 +20395,7 @@ pub struct IRect { /// assert!(r2.max.abs_diff_eq(Vec2::new(4., 5.), 1e-5)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inset(&self, inset: f32) -> bevy::math::Rect; "#, @@ -22696,53 +20414,44 @@ pub struct IRect { /// assert_eq!(n.max.y, 0.6); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn normalize(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; "#, r#" /// Returns self as [`IRect`] (i32) - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_irect(&self) -> bevy::math::IRect; "#, r#" /// Returns self as [`URect`] (u32) - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_urect(&self) -> bevy::math::URect; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::Rect) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::Rect; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Rect { +pub struct LuaRect { #[lua(output(proxy))] min: bevy::math::Vec2, #[lua(output(proxy))] @@ -22751,30 +20460,23 @@ pub struct Rect { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::URect", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_math::URect) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::math::URect; "#, @@ -22789,7 +20491,7 @@ pub struct Rect { /// let r = URect::new(2, 4, 5, 0); // w=3 h=4 /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(x0: u32, y0: u32, x1: u32, y1: u32) -> bevy::math::URect; "#, @@ -22806,7 +20508,7 @@ pub struct Rect { /// let r = URect::from_corners(UVec2::ONE, UVec2::ZERO); // w=1 h=1 /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_corners( #[proxy] p0: bevy::math::UVec2, @@ -22829,7 +20531,7 @@ pub struct Rect { /// assert_eq!(r.max, UVec2::splat(2)); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_center_size( #[proxy] origin: bevy::math::UVec2, @@ -22850,7 +20552,7 @@ pub struct Rect { /// assert_eq!(r.max, UVec2::splat(2)); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_center_half_size( #[proxy] origin: bevy::math::UVec2, @@ -22868,7 +20570,7 @@ pub struct Rect { /// assert!(r.is_empty()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_empty(&self) -> bool; "#, @@ -22881,7 +20583,7 @@ pub struct Rect { /// assert_eq!(r.width(), 5); /// ``` - #[lua(kind = "Method")] + #[lua()] fn width(&self) -> u32; "#, @@ -22894,7 +20596,7 @@ pub struct Rect { /// assert_eq!(r.height(), 1); /// ``` - #[lua(kind = "Method")] + #[lua()] fn height(&self) -> u32; "#, @@ -22907,7 +20609,7 @@ pub struct Rect { /// assert_eq!(r.size(), UVec2::new(5, 1)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn size(&self) -> bevy::math::UVec2; "#, @@ -22922,7 +20624,7 @@ pub struct Rect { /// assert_eq!(r.half_size(), UVec2::new(2, 1)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn half_size(&self) -> bevy::math::UVec2; "#, @@ -22937,7 +20639,7 @@ pub struct Rect { /// assert_eq!(r.center(), UVec2::new(2, 1)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn center(&self) -> bevy::math::UVec2; "#, @@ -22952,7 +20654,7 @@ pub struct Rect { /// assert!(r.contains(r.max)); /// ``` - #[lua(kind = "Method")] + #[lua()] fn contains(&self, #[proxy] point: bevy::math::UVec2) -> bool; "#, @@ -22969,7 +20671,7 @@ pub struct Rect { /// assert_eq!(r.max, UVec2::new(5, 8)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn union(&self, #[proxy] other: bevy::math::URect) -> bevy::math::URect; "#, @@ -22986,7 +20688,7 @@ pub struct Rect { /// assert_eq!(u.max, UVec2::new(5, 6)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn union_point(&self, #[proxy] other: bevy::math::UVec2) -> bevy::math::URect; "#, @@ -23005,7 +20707,7 @@ pub struct Rect { /// assert_eq!(r.max, UVec2::new(2, 2)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn intersect(&self, #[proxy] other: bevy::math::URect) -> bevy::math::URect; "#, @@ -23027,32 +20729,32 @@ pub struct Rect { /// assert_eq!(r2.max, UVec2::splat(7)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn inset(&self, inset: i32) -> bevy::math::URect; "#, r#" /// Returns self as [`Rect`] (f32) - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_rect(&self) -> bevy::math::Rect; "#, r#" /// Returns self as [`IRect`] (i32) - #[lua(kind = "Method", output(proxy))] + #[lua()] fn as_irect(&self) -> bevy::math::IRect; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct URect { +pub struct LuaURect { #[lua(output(proxy))] min: bevy::math::UVec2, #[lua(output(proxy))] @@ -23061,76 +20763,66 @@ pub struct URect { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "smol_str::SmolStr", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(kind = "Method")] + #[lua()] fn to_string(&self) -> std::string::String; "#, r#" - #[lua(kind = "Method")] + #[lua()] fn len(&self) -> usize; "#, r#" - #[lua(kind = "Method")] + #[lua()] fn is_empty(&self) -> bool; "#, r#" - #[lua(kind = "Method")] + #[lua()] fn is_heap_allocated(&self) -> bool; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &smol_str::SmolStr) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> smol_str::SmolStr; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct SmolStr(); +pub struct LuaSmolStr(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroIsize", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &std::num::NonZeroIsize) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, @@ -23140,14 +20832,14 @@ pub struct SmolStr(); /// # Safety /// The value must not be zero. - #[lua(kind = "Function", output(proxy))] + #[lua()] unsafe fn new_unchecked(n: isize) -> std::num::NonZeroIsize; "#, r#" /// Returns the value as a primitive type. - #[lua(kind = "Method")] + #[lua()] fn get(self) -> isize; "#, @@ -23161,7 +20853,7 @@ pub struct SmolStr(); /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn leading_zeros(self) -> u32; "#, @@ -23176,7 +20868,7 @@ pub struct SmolStr(); /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[lua(kind = "Method")] + #[lua()] fn trailing_zeros(self) -> u32; "#, @@ -23197,7 +20889,7 @@ pub struct SmolStr(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn abs(self) -> std::num::NonZeroIsize; "#, @@ -23222,7 +20914,7 @@ pub struct SmolStr(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_abs(self) -> std::num::NonZeroIsize; "#, @@ -23246,7 +20938,7 @@ pub struct SmolStr(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_abs(self) -> std::num::NonZeroIsize; "#, @@ -23271,7 +20963,7 @@ pub struct SmolStr(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn unsigned_abs(self) -> std::num::NonZeroUsize; "#, @@ -23291,7 +20983,7 @@ pub struct SmolStr(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_positive(self) -> bool; "#, @@ -23311,7 +21003,7 @@ pub struct SmolStr(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn is_negative(self) -> bool; "#, @@ -23337,7 +21029,7 @@ pub struct SmolStr(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_neg(self) -> std::num::NonZeroIsize; "#, @@ -23360,7 +21052,7 @@ pub struct SmolStr(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn wrapping_neg(self) -> std::num::NonZeroIsize; "#, @@ -23381,7 +21073,7 @@ pub struct SmolStr(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_mul( self, #[proxy] @@ -23406,43 +21098,35 @@ pub struct SmolStr(); /// # } /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn saturating_pow(self, other: u32) -> std::num::NonZeroIsize; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> std::num::NonZeroIsize; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] + #[lua(as_trait = "std::ops::Neg", composite = "neg")] fn neg(self) -> std::num::NonZeroIsize; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct NonZeroIsize(); +pub struct LuaNonZeroIsize(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::utils::Uuid", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Creates a random UUID. /// This uses the [`getrandom`] crate to utilise the operating system's RNG @@ -23465,34 +21149,25 @@ pub struct NonZeroIsize(); /// [`getrandom`]: https://crates.io/crates/getrandom /// [from_random_bytes]: struct.Builder.html#method.from_random_bytes - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new_v4() -> bevy::utils::Uuid; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &bevy_utils::Uuid) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] fn clone(&self) -> bevy::utils::Uuid; "#, @@ -23513,7 +21188,7 @@ pub struct NonZeroIsize(); /// # References /// * [Version in RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.3) - #[lua(kind = "Method")] + #[lua()] fn get_version_num(&self) -> usize; "#, @@ -23533,7 +21208,7 @@ pub struct NonZeroIsize(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn as_u128(&self) -> u128; "#, @@ -23559,7 +21234,7 @@ pub struct NonZeroIsize(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn to_u128_le(&self) -> u128; "#, @@ -23581,7 +21256,7 @@ pub struct NonZeroIsize(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn as_u64_pair(&self) -> (u64, u64); "#, @@ -23600,7 +21275,7 @@ pub struct NonZeroIsize(); /// assert_eq!(bytes, uuid.into_bytes()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn into_bytes(self) -> [u8; 16]; "#, @@ -23625,21 +21300,21 @@ pub struct NonZeroIsize(); /// # } /// ``` - #[lua(kind = "Method")] + #[lua()] fn to_bytes_le(&self) -> [u8; 16]; "#, r#" /// Tests if the UUID is nil (all zeros). - #[lua(kind = "Method")] + #[lua()] fn is_nil(&self) -> bool; "#, r#" /// Tests if the UUID is max (all ones). - #[lua(kind = "Method")] + #[lua()] fn is_max(&self) -> bool; "#, @@ -23665,7 +21340,7 @@ pub struct NonZeroIsize(); /// ); /// ``` - #[lua(kind = "Function")] + #[lua()] fn encode_buffer() -> [u8; 45]; "#, @@ -23686,7 +21361,7 @@ pub struct NonZeroIsize(); /// ); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn nil() -> bevy::utils::Uuid; "#, @@ -23707,7 +21382,7 @@ pub struct NonZeroIsize(); /// ); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn max() -> bevy::utils::Uuid; "#, @@ -23725,7 +21400,7 @@ pub struct NonZeroIsize(); /// ); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_u128(v: u128) -> bevy::utils::Uuid; "#, @@ -23747,7 +21422,7 @@ pub struct NonZeroIsize(); /// ); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_u128_le(v: u128) -> bevy::utils::Uuid; "#, @@ -23766,7 +21441,7 @@ pub struct NonZeroIsize(); /// ); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_u64_pair(high_bits: u64, low_bits: u64) -> bevy::utils::Uuid; "#, @@ -23792,7 +21467,7 @@ pub struct NonZeroIsize(); /// # } /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_bytes(bytes: [u8; 16]) -> bevy::utils::Uuid; "#, @@ -23819,400 +21494,293 @@ pub struct NonZeroIsize(); /// # } /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_bytes_le(b: [u8; 16]) -> bevy::utils::Uuid; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{}", _self) } "#] )] -pub struct Uuid(); +pub struct LuaUuid(); #[derive(Default)] pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { instances .add_instance( "Duration", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "Instant", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "NonZeroI128", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "NonZeroI16", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "NonZeroI32", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "NonZeroI64", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "NonZeroI8", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "NonZeroU128", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "NonZeroU16", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "NonZeroU32", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "NonZeroU64", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "NonZeroU8", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "NonZeroUsize", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "PathBuf", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances - .add_instance( - "Quat", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Quat", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "Vec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Vec3", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "IVec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("IVec2", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "IVec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("IVec3", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "IVec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("IVec4", crate::tealr::mlu::UserDataProxy::::new)?; instances .add_instance( "I64Vec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "I64Vec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "I64Vec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances - .add_instance( - "UVec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("UVec2", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "UVec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("UVec3", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "UVec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("UVec4", crate::tealr::mlu::UserDataProxy::::new)?; instances .add_instance( "U64Vec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "U64Vec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "U64Vec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances - .add_instance( - "Vec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Vec2", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "Vec3A", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Vec3A", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "Vec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Vec4", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "BVec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("BVec2", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "BVec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("BVec3", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "BVec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("BVec4", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "DVec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("DVec2", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "DVec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("DVec3", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "DVec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("DVec4", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "Mat2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Mat2", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "Mat3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Mat3", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "Mat3A", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Mat3A", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "Mat4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Mat4", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "DMat2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("DMat2", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "DMat3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("DMat3", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "DMat4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("DMat4", crate::tealr::mlu::UserDataProxy::::new)?; instances .add_instance( "Affine2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "Affine3A", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "DAffine2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "DAffine3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances - .add_instance( - "DQuat", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("DQuat", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "BVec3A", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("BVec3A", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "BVec4A", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("BVec4A", crate::tealr::mlu::UserDataProxy::::new)?; instances .add_instance( "Direction2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances - .add_instance( - "Circle", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Circle", crate::tealr::mlu::UserDataProxy::::new)?; instances .add_instance( "Ellipse", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "Plane2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "Segment2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "Triangle2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "Rectangle", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "RegularPolygon", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaRegularPolygon, - >::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "Capsule2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "Direction3d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances - .add_instance( - "Sphere", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Sphere", crate::tealr::mlu::UserDataProxy::::new)?; instances .add_instance( "Plane3d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "Segment3d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances - .add_instance( - "Cuboid", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Cuboid", crate::tealr::mlu::UserDataProxy::::new)?; instances .add_instance( "Cylinder", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "Capsule3d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances - .add_instance( - "Torus", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Torus", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "IRect", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("IRect", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "Rect", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Rect", crate::tealr::mlu::UserDataProxy::::new)?; instances - .add_instance( - "URect", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("URect", crate::tealr::mlu::UserDataProxy::::new)?; instances .add_instance( "NonZeroIsize", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances - .add_instance( - "Uuid", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Uuid", crate::tealr::mlu::UserDataProxy::::new)?; Ok(()) } } fn bevy_reflect_context_initializer( _: &bevy_mod_scripting_core::script::ScriptId, - ctx: &mut bevy_mod_scripting_lua::prelude::Lua, + ctx: &mut crate::prelude::Lua, ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + crate::tealr::mlu::set_global_env(Globals, ctx)?; Ok(()) } pub struct BevyReflectScriptingPlugin; @@ -24300,362 +21868,192 @@ impl bevy::app::Plugin for BevyReflectScriptingPlugin { app.register_foreign_lua_type::(); app.add_context_initializer::<()>(bevy_reflect_context_initializer); app.add_documentation_fragment( - bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + crate::docs::LuaDocumentationFragment::new( "BevyReflectAPI", |tw| { tw.document_global_instance::() .expect("Something went wrong documenting globals") .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaDuration, - >, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI128, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI16, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI32, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI64, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI8, - >, - >() + .process_type::>() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU128, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU16, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU32, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU64, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU8, - >, - >() + .process_type::>() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroUsize, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaAffine3A, - >, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaDAffine2, - >, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaDAffine3, - >, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaDirection2d, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaSegment2d, - >, - >() + .process_type::>() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaTriangle2d, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaRectangle, - >, - >() + .process_type::>() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaRegularPolygon, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaCapsule2d, - >, - >() + .process_type::>() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaDirection3d, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaSegment3d, - >, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaCylinder, - >, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaCapsule3d, - >, - >() + .process_type::>() .process_type::() .process_type::() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroIsize, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() }, ), ); diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs index b61a7ede..c9c2d9b3 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs @@ -4,51 +4,53 @@ #![cfg_attr(rustfmt, rustfmt_skip)] use super::bevy_ecs::*; use super::bevy_reflect::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::time::prelude::Fixed", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::time::prelude::Fixed; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Fixed {} +pub struct LuaFixed {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::time::prelude::Real", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::time::prelude::Real; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Real {} +pub struct LuaReal {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::time::prelude::Timer", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::time::prelude::Timer; "#, @@ -56,7 +58,7 @@ pub struct Real {} /// Creates a new timer with a given duration. /// See also [`Timer::from_seconds`](Timer::from_seconds). - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new( #[proxy] duration: bevy::utils::Duration, @@ -73,7 +75,7 @@ pub struct Real {} /// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_seconds( duration: f32, #[proxy] @@ -102,7 +104,7 @@ pub struct Real {} /// assert!(timer_repeating.finished()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn finished(&self) -> bool; "#, @@ -119,7 +121,7 @@ pub struct Real {} /// assert!(!timer.just_finished()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn just_finished(&self) -> bool; "#, @@ -136,7 +138,7 @@ pub struct Real {} /// assert_eq!(timer.elapsed(), Duration::from_secs_f32(0.5)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn elapsed(&self) -> bevy::utils::Duration; "#, @@ -144,7 +146,7 @@ pub struct Real {} /// Returns the time elapsed on the timer as an `f32`. /// See also [`Timer::elapsed`](Timer::elapsed). - #[lua(kind = "Method")] + #[lua()] fn elapsed_secs(&self) -> f32; "#, @@ -162,7 +164,7 @@ pub struct Real {} /// assert!(!timer.finished()); /// ``` - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_elapsed(&mut self, #[proxy] time: bevy::utils::Duration) -> (); "#, @@ -176,7 +178,7 @@ pub struct Real {} /// assert_eq!(timer.duration(), Duration::from_secs(1)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn duration(&self) -> bevy::utils::Duration; "#, @@ -191,7 +193,7 @@ pub struct Real {} /// assert_eq!(timer.duration(), Duration::from_secs(1)); /// ``` - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_duration(&mut self, #[proxy] duration: bevy::utils::Duration) -> (); "#, @@ -204,7 +206,7 @@ pub struct Real {} /// assert_eq!(timer.mode(), TimerMode::Repeating); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mode(&self) -> bevy::time::prelude::TimerMode; "#, @@ -218,7 +220,7 @@ pub struct Real {} /// assert_eq!(timer.mode(), TimerMode::Once); /// ``` - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_mode(&mut self, #[proxy] mode: bevy::time::prelude::TimerMode) -> (); "#, @@ -235,7 +237,7 @@ pub struct Real {} /// assert_eq!(timer.elapsed_secs(), 0.0); /// ``` - #[lua(kind = "MutatingMethod")] + #[lua()] fn pause(&mut self) -> (); "#, @@ -254,7 +256,7 @@ pub struct Real {} /// assert_eq!(timer.elapsed_secs(), 0.5); /// ``` - #[lua(kind = "MutatingMethod")] + #[lua()] fn unpause(&mut self) -> (); "#, @@ -272,7 +274,7 @@ pub struct Real {} /// assert!(!timer.paused()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn paused(&self) -> bool; "#, @@ -291,7 +293,7 @@ pub struct Real {} /// assert_eq!(timer.elapsed_secs(), 0.0); /// ``` - #[lua(kind = "MutatingMethod")] + #[lua()] fn reset(&mut self) -> (); "#, @@ -306,7 +308,7 @@ pub struct Real {} /// assert_eq!(timer.fraction(), 0.25); /// ``` - #[lua(kind = "Method")] + #[lua()] fn fraction(&self) -> f32; "#, @@ -321,7 +323,7 @@ pub struct Real {} /// assert_eq!(timer.fraction_remaining(), 0.75); /// ``` - #[lua(kind = "Method")] + #[lua()] fn fraction_remaining(&self) -> f32; "#, @@ -338,7 +340,7 @@ pub struct Real {} /// assert_eq!(Ordering::Equal, result); /// ``` - #[lua(kind = "Method")] + #[lua()] fn remaining_secs(&self) -> f32; "#, @@ -353,7 +355,7 @@ pub struct Real {} /// assert_eq!(timer.remaining(), Duration::from_secs_f32(1.5)); /// ``` - #[lua(kind = "Method", output(proxy))] + #[lua()] fn remaining(&self) -> bevy::utils::Duration; "#, @@ -375,109 +377,100 @@ pub struct Real {} /// assert_eq!(timer.times_finished_this_tick(), 0); /// ``` - #[lua(kind = "Method")] + #[lua()] fn times_finished_this_tick(&self) -> u32; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &timer::Timer) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Timer {} +pub struct LuaTimer {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::time::prelude::TimerMode", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &timer::TimerMode) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::time::prelude::TimerMode; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct TimerMode {} +pub struct LuaTimerMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::time::prelude::Virtual", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::time::prelude::Virtual; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Virtual {} +pub struct LuaVirtual {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::time::Stopwatch", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &stopwatch::Stopwatch) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::time::Stopwatch; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, @@ -491,7 +484,7 @@ pub struct Virtual {} /// assert_eq!(stopwatch.paused(), false); /// ``` - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new() -> bevy::time::Stopwatch; "#, @@ -510,7 +503,7 @@ pub struct Virtual {} /// [`elapsed_secs`](Stopwatch::elapsed_secs) - if an `f32` value is desirable instead. /// [`elapsed_secs_f64`](Stopwatch::elapsed_secs_f64) - if an `f64` is desirable instead. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn elapsed(&self) -> bevy::utils::Duration; "#, @@ -529,7 +522,7 @@ pub struct Virtual {} /// [`elapsed`](Stopwatch::elapsed) - if a `Duration` is desirable instead. /// [`elapsed_secs_f64`](Stopwatch::elapsed_secs_f64) - if an `f64` is desirable instead. - #[lua(kind = "Method")] + #[lua()] fn elapsed_secs(&self) -> f32; "#, @@ -540,7 +533,7 @@ pub struct Virtual {} /// [`elapsed`](Stopwatch::elapsed) - if a `Duration` is desirable instead. /// [`elapsed_secs`](Stopwatch::elapsed_secs) - if an `f32` is desirable instead. - #[lua(kind = "Method")] + #[lua()] fn elapsed_secs_f64(&self) -> f64; "#, @@ -555,7 +548,7 @@ pub struct Virtual {} /// assert_eq!(stopwatch.elapsed_secs(), 1.0); /// ``` - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_elapsed(&mut self, #[proxy] time: bevy::utils::Duration) -> (); "#, @@ -573,7 +566,7 @@ pub struct Virtual {} /// assert_eq!(stopwatch.elapsed_secs(), 0.0); /// ``` - #[lua(kind = "MutatingMethod")] + #[lua()] fn pause(&mut self) -> (); "#, @@ -592,7 +585,7 @@ pub struct Virtual {} /// assert_eq!(stopwatch.elapsed_secs(), 1.0); /// ``` - #[lua(kind = "MutatingMethod")] + #[lua()] fn unpause(&mut self) -> (); "#, @@ -609,7 +602,7 @@ pub struct Virtual {} /// assert!(!stopwatch.paused()); /// ``` - #[lua(kind = "Method")] + #[lua()] fn paused(&self) -> bool; "#, @@ -625,43 +618,40 @@ pub struct Virtual {} /// assert_eq!(stopwatch.elapsed_secs(), 0.0); /// ``` - #[lua(kind = "MutatingMethod")] + #[lua()] fn reset(&mut self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Stopwatch {} +pub struct LuaStopwatch {} #[derive(Default)] pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { instances - .add_instance( - "Timer", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; + .add_instance("Timer", crate::tealr::mlu::UserDataProxy::::new)?; instances .add_instance( "Stopwatch", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; Ok(()) } } fn bevy_time_context_initializer( _: &bevy_mod_scripting_core::script::ScriptId, - ctx: &mut bevy_mod_scripting_lua::prelude::Lua, + ctx: &mut crate::prelude::Lua, ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + crate::tealr::mlu::set_global_env(Globals, ctx)?; Ok(()) } pub struct BevyTimeScriptingPlugin; @@ -675,7 +665,7 @@ impl bevy::app::Plugin for BevyTimeScriptingPlugin { app.register_foreign_lua_type::(); app.add_context_initializer::<()>(bevy_time_context_initializer); app.add_documentation_fragment( - bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + crate::docs::LuaDocumentationFragment::new( "BevyTimeAPI", |tw| { tw.document_global_instance::() @@ -683,17 +673,11 @@ impl bevy::app::Plugin for BevyTimeScriptingPlugin { .process_type::() .process_type::() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() + .process_type::>() .process_type::() .process_type::() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaStopwatch, - >, - >() + .process_type::>() }, ), ); diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs index 36948b0d..4afe85c0 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs @@ -6,23 +6,15 @@ use super::bevy_ecs::*; use super::bevy_reflect::*; use super::bevy_core::*; use super::bevy_hierarchy::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::transform::components::GlobalTransform", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul( self, #[proxy] @@ -32,42 +24,25 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::transform::components::GlobalTransform; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &components::global_transform::GlobalTransform) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul( self, #[proxy] @@ -77,13 +52,13 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; "#, r#" - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_xyz(x: f32, y: f32, z: f32) -> bevy::transform::components::GlobalTransform; "#, r#" - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_translation( #[proxy] translation: bevy::math::Vec3, @@ -92,7 +67,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; "#, r#" - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation( #[proxy] rotation: bevy::math::Quat, @@ -101,7 +76,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; "#, r#" - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale( #[proxy] scale: bevy::math::Vec3, @@ -111,14 +86,14 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; r#" /// Returns the 3d affine transformation matrix as a [`Mat4`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn compute_matrix(&self) -> bevy::math::Mat4; "#, r#" /// Returns the 3d affine transformation matrix as an [`Affine3A`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn affine(&self) -> bevy::math::Affine3A; "#, @@ -127,7 +102,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// The transform is expected to be non-degenerate and without shearing, or the output /// will be invalid. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn compute_transform(&self) -> bevy::transform::components::Transform; "#, @@ -163,7 +138,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// The transform is expected to be non-degenerate and without shearing, or the output /// will be invalid. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn reparented_to( &self, #[proxy] @@ -174,63 +149,63 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; r#" ///Return the local right vector (X). - #[lua(kind = "Method", output(proxy))] + #[lua()] fn right(&self) -> bevy::math::Vec3; "#, r#" ///Return the local left vector (-X). - #[lua(kind = "Method", output(proxy))] + #[lua()] fn left(&self) -> bevy::math::Vec3; "#, r#" ///Return the local up vector (Y). - #[lua(kind = "Method", output(proxy))] + #[lua()] fn up(&self) -> bevy::math::Vec3; "#, r#" ///Return the local down vector (-Y). - #[lua(kind = "Method", output(proxy))] + #[lua()] fn down(&self) -> bevy::math::Vec3; "#, r#" ///Return the local back vector (Z). - #[lua(kind = "Method", output(proxy))] + #[lua()] fn back(&self) -> bevy::math::Vec3; "#, r#" ///Return the local forward vector (-Z). - #[lua(kind = "Method", output(proxy))] + #[lua()] fn forward(&self) -> bevy::math::Vec3; "#, r#" /// Get the translation as a [`Vec3`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn translation(&self) -> bevy::math::Vec3; "#, r#" /// Get the translation as a [`Vec3A`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn translation_vec3a(&self) -> bevy::math::Vec3A; "#, r#" /// Get an upper bound of the radius from the given `extents`. - #[lua(kind = "Method")] + #[lua()] fn radius_vec3a(&self, #[proxy] extents: bevy::math::Vec3A) -> f32; "#, @@ -238,7 +213,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// Transforms the given `point`, applying shear, scale, rotation and translation. /// This moves `point` into the local space of this [`GlobalTransform`]. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -246,7 +221,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// Multiplies `self` with `transform` component by component, returning the /// resulting [`GlobalTransform`] - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_transform( &self, #[proxy] @@ -255,36 +230,27 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct GlobalTransform(); +pub struct LuaGlobalTransform(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::transform::components::Transform", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &components::transform::Transform) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul( self, #[proxy] @@ -294,19 +260,13 @@ pub struct GlobalTransform(); "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::transform::components::Transform; "#, @@ -315,7 +275,7 @@ pub struct GlobalTransform(); /// is used for z-ordering elements: higher `z`-value will be in front of lower /// `z`-value. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_xyz(x: f32, y: f32, z: f32) -> bevy::transform::components::Transform; "#, @@ -323,7 +283,7 @@ pub struct GlobalTransform(); /// Extracts the translation, rotation, and scale from `matrix`. It must be a 3d affine /// transformation matrix. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_matrix( #[proxy] matrix: bevy::math::Mat4, @@ -334,7 +294,7 @@ pub struct GlobalTransform(); /// Creates a new [`Transform`], with `translation`. Rotation will be 0 and scale 1 on /// all axes. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_translation( #[proxy] translation: bevy::math::Vec3, @@ -345,7 +305,7 @@ pub struct GlobalTransform(); /// Creates a new [`Transform`], with `rotation`. Translation will be 0 and scale 1 on /// all axes. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_rotation( #[proxy] rotation: bevy::math::Quat, @@ -356,7 +316,7 @@ pub struct GlobalTransform(); /// Creates a new [`Transform`], with `scale`. Translation will be 0 and rotation 0 on /// all axes. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn from_scale( #[proxy] scale: bevy::math::Vec3, @@ -371,7 +331,7 @@ pub struct GlobalTransform(); /// * 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(kind = "Method", output(proxy))] + #[lua()] fn looking_at( self, #[proxy] @@ -389,7 +349,7 @@ pub struct GlobalTransform(); /// * 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(kind = "Method", output(proxy))] + #[lua()] fn looking_to( self, #[proxy] @@ -402,7 +362,7 @@ pub struct GlobalTransform(); r#" /// Returns this [`Transform`] with a new translation. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn with_translation( self, #[proxy] @@ -413,7 +373,7 @@ pub struct GlobalTransform(); r#" /// Returns this [`Transform`] with a new rotation. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn with_rotation( self, #[proxy] @@ -424,7 +384,7 @@ pub struct GlobalTransform(); r#" /// Returns this [`Transform`] with a new scale. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn with_scale( self, #[proxy] @@ -436,7 +396,7 @@ pub struct GlobalTransform(); /// Returns the 3d affine transformation matrix from this transforms translation, /// rotation, and scale. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn compute_matrix(&self) -> bevy::math::Mat4; "#, @@ -444,7 +404,7 @@ pub struct GlobalTransform(); /// Returns the 3d affine transformation matrix from this transforms translation, /// rotation, and scale. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn compute_affine(&self) -> bevy::math::Affine3A; "#, @@ -455,7 +415,7 @@ pub struct GlobalTransform(); /// - [`3d_rotation`] /// [`3d_rotation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/3d_rotation.rs - #[lua(kind = "MutatingMethod")] + #[lua()] fn rotate(&mut self, #[proxy] rotation: bevy::math::Quat) -> (); "#, @@ -463,7 +423,7 @@ pub struct GlobalTransform(); /// 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. - #[lua(kind = "MutatingMethod")] + #[lua()] fn rotate_axis(&mut self, #[proxy] axis: bevy::math::Vec3, angle: f32) -> (); "#, @@ -471,7 +431,7 @@ pub struct GlobalTransform(); /// 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. - #[lua(kind = "MutatingMethod")] + #[lua()] fn rotate_x(&mut self, angle: f32) -> (); "#, @@ -479,7 +439,7 @@ pub struct GlobalTransform(); /// 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. - #[lua(kind = "MutatingMethod")] + #[lua()] fn rotate_y(&mut self, angle: f32) -> (); "#, @@ -487,7 +447,7 @@ pub struct GlobalTransform(); /// 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. - #[lua(kind = "MutatingMethod")] + #[lua()] fn rotate_z(&mut self, angle: f32) -> (); "#, @@ -495,35 +455,35 @@ pub struct GlobalTransform(); /// Rotates this [`Transform`] by the given `rotation`. /// The `rotation` is relative to this [`Transform`]'s current rotation. - #[lua(kind = "MutatingMethod")] + #[lua()] fn rotate_local(&mut self, #[proxy] rotation: bevy::math::Quat) -> (); "#, r#" /// Rotates this [`Transform`] around its local `axis` by `angle` (in radians). - #[lua(kind = "MutatingMethod")] + #[lua()] fn rotate_local_axis(&mut self, #[proxy] axis: bevy::math::Vec3, angle: f32) -> (); "#, r#" /// Rotates this [`Transform`] around its local `X` axis by `angle` (in radians). - #[lua(kind = "MutatingMethod")] + #[lua()] fn rotate_local_x(&mut self, angle: f32) -> (); "#, r#" /// Rotates this [`Transform`] around its local `Y` axis by `angle` (in radians). - #[lua(kind = "MutatingMethod")] + #[lua()] fn rotate_local_y(&mut self, angle: f32) -> (); "#, r#" /// Rotates this [`Transform`] around its local `Z` axis by `angle` (in radians). - #[lua(kind = "MutatingMethod")] + #[lua()] fn rotate_local_z(&mut self, angle: f32) -> (); "#, @@ -531,7 +491,7 @@ pub struct GlobalTransform(); /// Translates this [`Transform`] around a `point` in space. /// If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent. - #[lua(kind = "MutatingMethod")] + #[lua()] fn translate_around( &mut self, #[proxy] @@ -545,7 +505,7 @@ pub struct GlobalTransform(); /// Rotates this [`Transform`] around a `point` in space. /// If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent. - #[lua(kind = "MutatingMethod")] + #[lua()] fn rotate_around( &mut self, #[proxy] @@ -563,7 +523,7 @@ pub struct GlobalTransform(); /// * 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(kind = "MutatingMethod")] + #[lua()] fn look_at( &mut self, #[proxy] @@ -581,7 +541,7 @@ pub struct GlobalTransform(); /// * 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(kind = "MutatingMethod")] + #[lua()] fn look_to( &mut self, #[proxy] @@ -595,7 +555,7 @@ pub struct GlobalTransform(); /// Multiplies `self` with `transform` component by component, returning the /// resulting [`Transform`] - #[lua(kind = "Method", output(proxy))] + #[lua()] fn mul_transform( &self, #[proxy] @@ -612,7 +572,7 @@ pub struct GlobalTransform(); /// If you want to transform a `point` in global space to the local space of this [`Transform`], /// consider using [`GlobalTransform::transform_point()`] instead. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; "#, @@ -621,19 +581,13 @@ pub struct GlobalTransform(); /// finite. If any of them contains a `NaN`, positive or negative infinity, /// this will return `false`. - #[lua(kind = "Method")] + #[lua()] fn is_finite(&self) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] + #[lua(as_trait = "std::ops::Mul", composite = "mul")] fn mul( self, #[proxy] @@ -642,13 +596,13 @@ pub struct GlobalTransform(); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Transform { +pub struct LuaTransform { #[lua(output(proxy))] translation: bevy::math::Vec3, #[lua(output(proxy))] @@ -658,31 +612,29 @@ pub struct Transform { } #[derive(Default)] pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { instances .add_instance( "GlobalTransform", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGlobalTransform, - >::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "Transform", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + crate::tealr::mlu::UserDataProxy::::new, )?; Ok(()) } } fn bevy_transform_context_initializer( _: &bevy_mod_scripting_core::script::ScriptId, - ctx: &mut bevy_mod_scripting_lua::prelude::Lua, + ctx: &mut crate::prelude::Lua, ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + crate::tealr::mlu::set_global_env(Globals, ctx)?; Ok(()) } pub struct BevyTransformScriptingPlugin; @@ -692,23 +644,17 @@ impl bevy::app::Plugin for BevyTransformScriptingPlugin { app.register_foreign_lua_type::(); app.add_context_initializer::<()>(bevy_transform_context_initializer); app.add_documentation_fragment( - bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + crate::docs::LuaDocumentationFragment::new( "BevyTransformAPI", |tw| { tw.document_global_instance::() .expect("Something went wrong documenting globals") .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGlobalTransform, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaTransform, - >, - >() + .process_type::>() }, ), ); diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs index 8c02027d..e5311572 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs @@ -5,147 +5,131 @@ use super::bevy_ecs::*; use super::bevy_reflect::*; use super::bevy_input::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::CursorEntered", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::CursorEntered) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::prelude::CursorEntered; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct CursorEntered { +pub struct LuaCursorEntered { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::CursorIcon", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &cursor::CursorIcon) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::prelude::CursorIcon; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct CursorIcon {} +pub struct LuaCursorIcon {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::CursorLeft", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::CursorLeft) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::prelude::CursorLeft; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct CursorLeft { +pub struct LuaCursorLeft { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::CursorMoved", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::CursorMoved) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::prelude::CursorMoved; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct CursorMoved { +pub struct LuaCursorMoved { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, #[lua(output(proxy))] @@ -155,139 +139,127 @@ pub struct CursorMoved { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::FileDragAndDrop", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::prelude::FileDragAndDrop; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::FileDragAndDrop) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct FileDragAndDrop {} +pub struct LuaFileDragAndDrop {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::Ime", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::prelude::Ime; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::Ime) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Ime {} +pub struct LuaIme {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::MonitorSelection", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::MonitorSelection) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::prelude::MonitorSelection; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct MonitorSelection {} +pub struct LuaMonitorSelection {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::ReceivedCharacter", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::prelude::ReceivedCharacter; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::ReceivedCharacter) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct ReceivedCharacter { +pub struct LuaReceivedCharacter { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, #[lua(output(proxy))] @@ -296,9 +268,11 @@ pub struct ReceivedCharacter { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::Window", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::prelude::Window; "#, @@ -306,7 +280,7 @@ pub struct ReceivedCharacter { /// Setting to true will attempt to maximize the window. /// Setting to false will attempt to un-maximize the window. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_maximized(&mut self, maximized: bool) -> (); "#, @@ -314,7 +288,7 @@ pub struct ReceivedCharacter { /// Setting to true will attempt to minimize the window. /// Setting to false will attempt to un-minimize the window. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_minimized(&mut self, minimized: bool) -> (); "#, @@ -322,7 +296,7 @@ pub struct ReceivedCharacter { /// The window's client area width in logical pixels. /// See [`WindowResolution`] for an explanation about logical/physical sizes. - #[lua(kind = "Method")] + #[lua()] fn width(&self) -> f32; "#, @@ -330,7 +304,7 @@ pub struct ReceivedCharacter { /// The window's client area height in logical pixels. /// See [`WindowResolution`] for an explanation about logical/physical sizes. - #[lua(kind = "Method")] + #[lua()] fn height(&self) -> f32; "#, @@ -338,7 +312,7 @@ pub struct ReceivedCharacter { /// The window's client area width in physical pixels. /// See [`WindowResolution`] for an explanation about logical/physical sizes. - #[lua(kind = "Method")] + #[lua()] fn physical_width(&self) -> u32; "#, @@ -346,7 +320,7 @@ pub struct ReceivedCharacter { /// The window's client area height in physical pixels. /// See [`WindowResolution`] for an explanation about logical/physical sizes. - #[lua(kind = "Method")] + #[lua()] fn physical_height(&self) -> u32; "#, @@ -354,18 +328,18 @@ pub struct ReceivedCharacter { /// The window's scale factor. /// Ratio of physical size to logical size, see [`WindowResolution`]. - #[lua(kind = "Method")] + #[lua()] fn scale_factor(&self) -> f32; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Window { +pub struct LuaWindow { #[lua(output(proxy))] cursor: bevy::window::Cursor, #[lua(output(proxy))] @@ -403,37 +377,34 @@ pub struct Window { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::WindowMoved", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::WindowMoved) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::prelude::WindowMoved; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowMoved { +pub struct LuaWindowMoved { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, #[lua(output(proxy))] @@ -442,16 +413,18 @@ pub struct WindowMoved { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::WindowPosition", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::prelude::WindowPosition; "#, r#" /// Creates a new [`WindowPosition`] at a position. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new( #[proxy] position: bevy::math::IVec2, @@ -461,14 +434,14 @@ pub struct WindowMoved { r#" /// Set the position to a specific point. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set(&mut self, #[proxy] position: bevy::math::IVec2) -> (); "#, r#" /// Set the window to a specific monitor. - #[lua(kind = "MutatingMethod")] + #[lua()] fn center( &mut self, #[proxy] @@ -478,59 +451,51 @@ pub struct WindowMoved { "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::WindowPosition) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowPosition {} +pub struct LuaWindowPosition {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::WindowResizeConstraints", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" /// Checks if the constraints are valid. /// Will output warnings if it isn't. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn check_constraints(&self) -> bevy::window::prelude::WindowResizeConstraints; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::WindowResizeConstraints) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::prelude::WindowResizeConstraints; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowResizeConstraints { +pub struct LuaWindowResizeConstraints { min_width: f32, min_height: f32, max_width: f32, @@ -539,31 +504,28 @@ pub struct WindowResizeConstraints { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowResized", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::WindowResized) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowResized; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowResized { +pub struct LuaWindowResized { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, width: f32, @@ -572,219 +534,201 @@ pub struct WindowResized { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowCreated", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::WindowCreated) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowCreated; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowCreated { +pub struct LuaWindowCreated { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowClosed", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowClosed; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::WindowClosed) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowClosed { +pub struct LuaWindowClosed { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowCloseRequested", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowCloseRequested; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::WindowCloseRequested) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowCloseRequested { +pub struct LuaWindowCloseRequested { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowDestroyed", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::WindowDestroyed) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowDestroyed; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowDestroyed { +pub struct LuaWindowDestroyed { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::RequestRedraw", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::RequestRedraw) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::RequestRedraw; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct RequestRedraw {} +pub struct LuaRequestRedraw {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowFocused", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::WindowFocused) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowFocused; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowFocused { +pub struct LuaWindowFocused { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, focused: bool, @@ -792,37 +736,34 @@ pub struct WindowFocused { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowOccluded", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::WindowOccluded) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowOccluded; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowOccluded { +pub struct LuaWindowOccluded { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, occluded: bool, @@ -830,31 +771,28 @@ pub struct WindowOccluded { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowScaleFactorChanged", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowScaleFactorChanged; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::WindowScaleFactorChanged) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowScaleFactorChanged { +pub struct LuaWindowScaleFactorChanged { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, scale_factor: f64, @@ -862,31 +800,28 @@ pub struct WindowScaleFactorChanged { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowBackendScaleFactorChanged", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowBackendScaleFactorChanged; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::WindowBackendScaleFactorChanged) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowBackendScaleFactorChanged { +pub struct LuaWindowBackendScaleFactorChanged { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, scale_factor: f64, @@ -894,37 +829,34 @@ pub struct WindowBackendScaleFactorChanged { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowThemeChanged", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowThemeChanged; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::WindowThemeChanged) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowThemeChanged { +pub struct LuaWindowThemeChanged { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, #[lua(output(proxy))] @@ -933,88 +865,84 @@ pub struct WindowThemeChanged { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::ApplicationLifetime", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::ApplicationLifetime; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &event::ApplicationLifetime) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct ApplicationLifetime {} +pub struct LuaApplicationLifetime {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::PrimaryWindow", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::PrimaryWindow; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::PrimaryWindow) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct PrimaryWindow {} +pub struct LuaPrimaryWindow {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::Cursor", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::Cursor; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct Cursor { +pub struct LuaCursor { #[lua(output(proxy))] icon: bevy::window::prelude::CursorIcon, visible: bool, @@ -1025,102 +953,93 @@ pub struct Cursor { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::CursorGrabMode", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::CursorGrabMode) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::CursorGrabMode; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct CursorGrabMode {} +pub struct LuaCursorGrabMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::CompositeAlphaMode", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::CompositeAlphaMode; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::CompositeAlphaMode) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct CompositeAlphaMode {} +pub struct LuaCompositeAlphaMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowResolution", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::WindowResolution) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowResolution; "#, r#" /// Creates a new [`WindowResolution`]. - #[lua(kind = "Function", output(proxy))] + #[lua()] fn new(logical_width: f32, logical_height: f32) -> bevy::window::WindowResolution; "#, r#" /// Builder method for adding a scale factor override to the resolution. - #[lua(kind = "Method", output(proxy))] + #[lua()] fn with_scale_factor_override( self, scale_factor_override: f32, @@ -1130,28 +1049,28 @@ pub struct CompositeAlphaMode {} r#" /// The window's client area width in logical pixels. - #[lua(kind = "Method")] + #[lua()] fn width(&self) -> f32; "#, r#" /// The window's client area height in logical pixels. - #[lua(kind = "Method")] + #[lua()] fn height(&self) -> f32; "#, r#" /// The window's client area width in physical pixels. - #[lua(kind = "Method")] + #[lua()] fn physical_width(&self) -> u32; "#, r#" /// The window's client area height in physical pixels. - #[lua(kind = "Method")] + #[lua()] fn physical_height(&self) -> u32; "#, @@ -1159,7 +1078,7 @@ pub struct CompositeAlphaMode {} /// The ratio of physical pixels to logical pixels. /// `physical_pixels = logical_pixels * scale_factor` - #[lua(kind = "Method")] + #[lua()] fn scale_factor(&self) -> f32; "#, @@ -1167,7 +1086,7 @@ pub struct CompositeAlphaMode {} /// The window scale factor as reported by the window backend. /// This value is unaffected by [`WindowResolution::scale_factor_override`]. - #[lua(kind = "Method")] + #[lua()] fn base_scale_factor(&self) -> f32; "#, @@ -1175,14 +1094,14 @@ pub struct CompositeAlphaMode {} /// The scale factor set with [`WindowResolution::set_scale_factor_override`]. /// This value may be different from the scale factor reported by the window backend. - #[lua(kind = "Method")] + #[lua()] fn scale_factor_override(&self) -> std::option::Option; "#, r#" /// Set the window's logical resolution. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set(&mut self, width: f32, height: f32) -> (); "#, @@ -1191,14 +1110,14 @@ pub struct CompositeAlphaMode {} /// This will ignore the scale factor setting, so most of the time you should /// prefer to use [`WindowResolution::set`]. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_physical_resolution(&mut self, width: u32, height: u32) -> (); "#, r#" /// Set the window's scale factor, this may get overridden by the backend. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_scale_factor(&mut self, scale_factor: f32) -> (); "#, @@ -1207,7 +1126,7 @@ pub struct CompositeAlphaMode {} /// This can change the logical and physical sizes if the resulting physical /// size is not within the limits. - #[lua(kind = "MutatingMethod")] + #[lua()] fn set_scale_factor_override( &mut self, scale_factor_override: std::option::Option, @@ -1215,219 +1134,201 @@ pub struct CompositeAlphaMode {} "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowResolution {} +pub struct LuaWindowResolution {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowMode", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::WindowMode) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowMode; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowMode {} +pub struct LuaWindowMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowLevel", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::WindowLevel) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowLevel; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowLevel {} +pub struct LuaWindowLevel {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::PresentMode", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::PresentMode) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::PresentMode; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct PresentMode {} +pub struct LuaPresentMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::InternalWindowState", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::InternalWindowState; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::InternalWindowState) -> bool; "#, r#" /// Consumes the current maximize request, if it exists. This should only be called by window backends. - #[lua(kind = "MutatingMethod")] + #[lua()] fn take_maximize_request(&mut self) -> std::option::Option; "#, r#" /// Consumes the current minimize request, if it exists. This should only be called by window backends. - #[lua(kind = "MutatingMethod")] + #[lua()] fn take_minimize_request(&mut self) -> std::option::Option; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct InternalWindowState {} +pub struct LuaInternalWindowState {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowTheme", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowTheme; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::WindowTheme) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowTheme {} +pub struct LuaWindowTheme {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::EnabledButtons", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::EnabledButtons; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::EnabledButtons) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct EnabledButtons { +pub struct LuaEnabledButtons { minimize: bool, maximize: bool, close: bool, @@ -1435,90 +1336,85 @@ pub struct EnabledButtons { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowRef", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::WindowRef; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct WindowRef {} +pub struct LuaWindowRef {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::NormalizedWindowRef", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + #[lua(as_trait = "std::cmp::Eq")] fn assert_receiver_is_total_eq(&self) -> (); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + #[lua(as_trait = "std::clone::Clone")] fn clone(&self) -> bevy::window::NormalizedWindowRef; "#, r#" /// Fetch the entity of this window reference - #[lua(kind = "Method", output(proxy))] + #[lua()] fn entity(&self) -> bevy::ecs::entity::Entity; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] + #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] fn eq(&self, #[proxy] other: &window::NormalizedWindowRef) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] +#[lua(metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -pub struct NormalizedWindowRef(); +pub struct LuaNormalizedWindowRef(); #[derive(Default)] pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - 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<()> { +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { instances .add_instance( "WindowPosition", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaWindowPosition, - >::new, + crate::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( "WindowResolution", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaWindowResolution, - >::new, + crate::tealr::mlu::UserDataProxy::::new, )?; Ok(()) } } fn bevy_window_context_initializer( _: &bevy_mod_scripting_core::script::ScriptId, - ctx: &mut bevy_mod_scripting_lua::prelude::Lua, + ctx: &mut crate::prelude::Lua, ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)?; + crate::tealr::mlu::set_global_env(Globals, ctx)?; Ok(()) } pub struct BevyWindowScriptingPlugin; @@ -1565,7 +1461,7 @@ impl bevy::app::Plugin for BevyWindowScriptingPlugin { app.register_foreign_lua_type::(); app.add_context_initializer::<()>(bevy_window_context_initializer); app.add_documentation_fragment( - bevy_mod_scripting_lua::docs::LuaDocumentationFragment::new( + crate::docs::LuaDocumentationFragment::new( "BevyWindowAPI", |tw| { tw.document_global_instance::() @@ -1582,9 +1478,7 @@ impl bevy::app::Plugin for BevyWindowScriptingPlugin { .process_type::() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaWindowPosition, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() .process_type::() @@ -1605,9 +1499,7 @@ impl bevy::app::Plugin for BevyWindowScriptingPlugin { .process_type::() .process_type::() .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaWindowResolution, - >, + crate::tealr::mlu::UserDataProxy, >() .process_type::() .process_type::() diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/mod.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/mod.rs index 69711bee..bd8adc3d 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/mod.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/mod.rs @@ -10,7 +10,6 @@ pub(crate) mod bevy_time; pub(crate) mod bevy_hierarchy; pub(crate) mod bevy_window; pub(crate) mod bevy_reflect; -extern crate self as bevy_script_api; pub struct LuaBevyScriptingPlugin; impl bevy::app::Plugin for LuaBevyScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs index f085faec..29c34dd2 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs @@ -8,7 +8,10 @@ use bevy_mod_scripting_core::{ error::ReflectionError, proxy::{ReflectRefMutProxy, ReflectRefProxy, ReflectValProxy, Unproxy, ValProxy}, }; -use tealr::mlu::mlua::{Error, FromLua, IntoLua, Lua, Value}; +use tealr::{ + mlu::mlua::{Error, FromLua, IntoLua, Lua, Value}, + ToTypename, +}; /// Local trait alias for the [`Proxied`] trait. pub trait LuaProxied { @@ -76,6 +79,12 @@ macro_rules! impl_lua_unproxy { self.0.0.into_lua(lua) } } + + impl ToTypename for $ty where T::Proxy: ToTypename { + fn to_typename() -> tealr::Type { + T::Proxy::to_typename() + } + } }; } @@ -91,6 +100,8 @@ macro_rules! impl_lua_proxy { Ok(Self($as::<$generic,$generic::Proxy>::proxy(value)?)) } } + + }; } diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 4039619d..dc2d9c1a 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; use bevy_mod_scripting_common::{input::*, utils::doc_attribute_to_string_lit}; +use darling::util::Flag; use syn::punctuated::Punctuated; use syn::{parse_macro_input, parse_quote_spanned, DeriveInput, ExprClosure, FnArg, Variant}; use syn::{ @@ -28,7 +29,7 @@ const VALID_META_METHODS: [&str; 27] = [ /// - instead o a `&self` receiver we have a `_self: LuaRefProxy` /// - instead of a `&mut self` receiver we have a `_self: LuaRefMutProxy` /// - instead of a `self` receiver we have a `_self: ValLuaProxy` -fn standardise_receiver<'a>(receiver: &mut FnArg, target_type_ident: &Ident, bms_core_path: &Path) { +fn standardise_receiver(receiver: &mut FnArg, target_type: &Path, bms_lua_path: &Path) { let replacement = if let FnArg::Receiver(receiver) = receiver { let ref_ = &receiver.reference.as_ref().map(|(amp, lifetime)| { quote_spanned! {receiver.span()=> @@ -42,9 +43,10 @@ fn standardise_receiver<'a>(receiver: &mut FnArg, target_type_ident: &Ident, bms (true, false) => "LuaReflectRefProxy", (false, _) => "LuaReflectValProxy", }; - + let unproxy_ident = syn::Ident::new(unproxy_container_name, receiver.span()); + Some(syn::FnArg::Typed(parse_quote_spanned! {receiver.span()=> - #self_ident: #bms_core_path::proxy::#unproxy_container_name<#target_type_ident> + #self_ident: #bms_lua_path::bindings::proxy::#unproxy_ident::<#target_type> })) } else { None @@ -93,6 +95,32 @@ fn convert_function_def_to_closure(f: TraitItemFn) -> ExprClosure { } } +#[derive(FromAttributes)] +#[darling(attributes(lua))] +struct FunctionAttrs { + #[darling(multiple)] + pub doc: Vec, + + /// Marks the function as a composite with the given ID, at least one another function with the same composite + /// ID must exist resulting in a combined function being generated. The actual function to dispatch to will be decided based on + /// the types of arguments. If the signature is invalid (i.e. doesn't allow us to dispatch) an error will be thrown + #[darling(default)] + pub composite: Option, + + /// Marks this to be ignored, only used for fields as functions are opt-in + pub skip: Flag, + + /// If passed will generate statement before calling the method + /// on the type + pub as_trait: Option, + + /// If passed will generate a metamethod call instead of using the function name + pub metamethod: Option, + + + pub raw: Flag +} + #[proc_macro_derive(LuaProxy, attributes(lua, proxy))] pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let derive_input = parse_macro_input!(input as DeriveInput); @@ -111,9 +139,8 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { .into(); } - let target_type_ident = &meta.ident; - let target_type_path: syn::Path = meta.remote.unwrap_or(meta.ident.clone().into()); - let target_type_str = target_type_path.segments.last().unwrap().ident.to_string(); + let target_type = meta.remote.unwrap_or(meta.ident.clone().into()); + let target_type_str = target_type.segments.last().unwrap().ident.to_string(); let proxy_type_ident = meta.proxy_name.unwrap_or_else(|| { format_ident!("{PROXY_PREFIX}{}", &meta.ident, span = meta.ident.span()) }); @@ -141,8 +168,9 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let add_function_stmts = meta.functions.0.into_iter().map(|mut f| { if let Some(first_arg) = f.sig.inputs.first_mut() { - standardise_receiver(first_arg, target_type_ident, &bms_core) + standardise_receiver(first_arg, &target_type, &bms_lua) }; + // collect all args into tuple and add lua context arg let ctxt_alias = syn::Ident::new(CTXT_ALIAS, f.sig.inputs.span()); let ctxt_arg = parse_quote_spanned! {f.span()=> @@ -162,7 +190,8 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } }) .unzip::<_, _, Vec<_>, Vec<_>>(); - + + let attrs = FunctionAttrs::from_attributes(&f.attrs).unwrap(); let span = f.span(); let args_ident = format_ident!("args", span = f.sig.inputs.span()); f.sig.inputs = Punctuated::from_iter(vec![ @@ -177,7 +206,22 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { syn::ReturnType::Type(_, ty) => ty.to_token_stream(), }; + // wrap function body in our unwrapping and wrapping logic, ignore pre-existing body + let fn_call = match (f.default, attrs.as_trait) { + (Some(body), _) => quote_spanned!(span=> + (||{ #body })() + ), + (_, None) => quote_spanned!(span=> + #target_type::#func_name(#(#original_arg_idents),*) + ), + (_, Some(trait_path)) => { + let trait_path = quote_spanned!(span=> #trait_path); + quote_spanned!(span=> + <#target_type as #trait_path>::#func_name(#(#original_arg_idents),*) + ) + } + }; f.default = Some(parse_quote_spanned! {span=> { let mut world: #bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> = lua.globals().get("world")?; @@ -201,7 +245,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let (#( #original_arg_idents ),*) = unsafe { <(#(#original_arg_types),*) as #bms_core::proxy::Unproxy>::unproxy_with_world(&mut #args_ident, &world, &mut world_acceses, &type_registry, &allocator).map_err(#mlua::Error::external)? }; // call proxy function - let out = #target_type_ident::#func_name(#(#original_arg_idents),*); + let out = #fn_call; let out = <#out_type as #bms_core::proxy::Proxy>::proxy_with_allocator(out, &mut allocator).map_err(#mlua::Error::external)?; // TODO: output proxies @@ -209,7 +253,13 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } }); - let name = f.sig.ident.to_string(); + let name = match attrs.metamethod{ + Some(metamethod) => quote_spanned!(metamethod.span()=> + #mlua::MetaMethod::#metamethod + ), + None => f.sig.ident.to_string().to_token_stream(), + }; + let closure = convert_function_def_to_closure(f); quote_spanned! {span=> methods.add_function(#name, #closure); @@ -219,8 +269,13 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let vis = &meta.vis; quote_spanned! {meta.ident.span()=> + #[derive(Clone, Debug)] #vis struct #proxy_type_ident (pub #bms_core::bindings::ReflectReference); + impl #bms_lua::bindings::proxy::LuaProxied for #target_type { + type Proxy = #proxy_type_ident; + } + impl #tealr::mlu::TealData for #proxy_type_ident { fn add_methods<'lua, M: #tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut M) { #(#type_level_document_calls)* @@ -237,6 +292,18 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } } + impl AsRef<#bms_core::bindings::ReflectReference> for #proxy_type_ident { + fn as_ref(&self) -> &#bms_core::bindings::ReflectReference { + &self.0 + } + } + + impl From<#bms_core::bindings::ReflectReference> for #proxy_type_ident { + fn from(r: #bms_core::bindings::ReflectReference) -> Self { + Self(r) + } + } + } .into() diff --git a/makefile b/makefile index 6dc18e84..f5c44f2a 100644 --- a/makefile +++ b/makefile @@ -60,10 +60,10 @@ clean_bevy: cd ${BEVY_PATH} && cargo clean generate_bevy: - cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen generate --output ${OUTPUT_PATH} --template-args '{ "self_is_bevy_script_api": true}' --features ${GEN_BEVY_FEATURES} + cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen generate --output ${OUTPUT_PATH} --template-args '{ "self_is_bms_lua": true}' --features ${GEN_BEVY_FEATURES} collect_bevy: - cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen collect --output ${OUTPUT_PATH} --template-args '{ "self_is_bevy_script_api": true}' + cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen collect --output ${OUTPUT_PATH} --template-args '{ "self_is_bms_lua": true}' deletion_confirmation: @echo -n "This action will delete ALL files in directories: '${GENERATED_SRC_PATH}' amd ${OUTPUT_PATH} (y/N) " From f0681844a5caa256b5030fd6453c1b2f644bedb7 Mon Sep 17 00:00:00 2001 From: makspll Date: Sun, 5 May 2024 22:31:45 +0100 Subject: [PATCH 11/17] Codegen now compiles with new trait system --- .vscode/settings.json | 2 +- crates/bevy_api_gen/src/bin/main.rs | 15 +- crates/bevy_api_gen/src/callback.rs | 1 + crates/bevy_api_gen/src/context.rs | 2 +- crates/bevy_api_gen/src/import_path.rs | 2 +- crates/bevy_api_gen/src/meta.rs | 22 + crates/bevy_api_gen/src/passes/codegen.rs | 1 + .../src/passes/find_methods_and_fields.rs | 21 +- .../src/passes/find_trait_impls.rs | 1 + .../src/passes/populate_template_data.rs | 343 +- crates/bevy_api_gen/src/plugin.rs | 4 +- crates/bevy_api_gen/src/template.rs | 6 +- crates/bevy_api_gen/templates/field.tera | 6 +- crates/bevy_api_gen/templates/footer.tera | 2 +- crates/bevy_api_gen/templates/function.tera | 13 +- crates/bevy_api_gen/templates/header.tera | 8 +- crates/bevy_api_gen/templates/item.tera | 18 +- crates/bevy_api_gen/templates/macros.tera | 52 +- .../bevy_mod_scripting_core/src/bindings.rs | 72 +- crates/bevy_mod_scripting_core/src/error.rs | 6 +- crates/bevy_mod_scripting_core/src/proxy.rs | 357 +- .../bevy_mod_scripting_lua/Cargo.toml | 1 + .../src/bindings/providers/bevy_core.rs | 29 +- .../src/bindings/providers/bevy_ecs.rs | 146 +- .../src/bindings/providers/bevy_hierarchy.rs | 46 +- .../src/bindings/providers/bevy_input.rs | 805 +- .../src/bindings/providers/bevy_reflect.rs | 10791 +++++++++++----- .../src/bindings/providers/bevy_time.rs | 276 +- .../src/bindings/providers/bevy_transform.rs | 541 +- .../src/bindings/providers/bevy_window.rs | 938 +- .../src/bindings/proxy.rs | 100 +- .../bevy_mod_scripting_lua/src/lib.rs | 48 +- .../bevy_mod_scripting_lua_derive/src/lib.rs | 141 +- makefile | 4 +- 34 files changed, 9604 insertions(+), 5216 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 51072e25..3cf59b30 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,7 +10,7 @@ }, "rust-analyzer.rustc.source": "discover", "rust-analyzer.linkedProjects": [ - // "./crates/bevy_api_gen/Cargo.toml", + "./crates/bevy_api_gen/Cargo.toml", // "./crates/macro_tests/Cargo.toml", "Cargo.toml", ], diff --git a/crates/bevy_api_gen/src/bin/main.rs b/crates/bevy_api_gen/src/bin/main.rs index 81ae80b7..a5c93bf2 100644 --- a/crates/bevy_api_gen/src/bin/main.rs +++ b/crates/bevy_api_gen/src/bin/main.rs @@ -134,12 +134,13 @@ fn main() { let temp_dir = tempdir::TempDir::new("bevy_api_gen_bootstrap") .expect("Error occured when trying to acquire temp file"); + let path = temp_dir.path().to_owned(); - debug!("Temporary directory: {}", &temp_dir.path().display()); + debug!("Temporary directory: {}", &path.display()); - write_bootstrap_files(temp_dir.path()); + write_bootstrap_files(&path); - let bootstrap_rlibs = build_bootstrap(temp_dir.path(), &plugin_target_dir.join("bootstrap")); + let bootstrap_rlibs = build_bootstrap(&path, &plugin_target_dir.join("bootstrap")); if bootstrap_rlibs.len() == BOOTSTRAP_DEPS.len() { let extern_args = bootstrap_rlibs @@ -169,7 +170,13 @@ fn main() { rustc_plugin::cli_main(BevyAnalyzer); // just making sure the temp dir lives until everything is done - drop(temp_dir); + if let Err(err) = std::fs::remove_dir_all(&path) { + log::error!( + "Error occured when trying to delete temporary directory: `{}`. {}", + path.to_string_lossy(), + err + ) + } } /// Build bootstrap files if they don't exist diff --git a/crates/bevy_api_gen/src/callback.rs b/crates/bevy_api_gen/src/callback.rs index 6174de20..a48503ae 100644 --- a/crates/bevy_api_gen/src/callback.rs +++ b/crates/bevy_api_gen/src/callback.rs @@ -87,6 +87,7 @@ impl rustc_driver::Callbacks for BevyAnalyzerCallbacks { if !continue_ { break; } + trace!("Finished pass, continuing"); } }); rustc_driver::Compilation::Continue diff --git a/crates/bevy_api_gen/src/context.rs b/crates/bevy_api_gen/src/context.rs index dd18021d..83ed871b 100644 --- a/crates/bevy_api_gen/src/context.rs +++ b/crates/bevy_api_gen/src/context.rs @@ -152,7 +152,7 @@ pub(crate) struct FunctionContext { pub(crate) def_id: DefId, pub(crate) has_self: bool, pub(crate) is_unsafe: bool, - pub(crate) trait_did: Option, + pub(crate) trait_and_impl_did: Option<(DefId, DefId)>, /// strategies for input and output (last element is the output) pub(crate) reflection_strategies: Vec, } diff --git a/crates/bevy_api_gen/src/import_path.rs b/crates/bevy_api_gen/src/import_path.rs index 2f26fd12..c8f55226 100644 --- a/crates/bevy_api_gen/src/import_path.rs +++ b/crates/bevy_api_gen/src/import_path.rs @@ -27,7 +27,7 @@ impl std::fmt::Debug for ImportPathElement { /// Because we do not need ALL the items in the crate, we start searching from the item itself and traverse up the tree. /// Caches results for already found items. pub(crate) struct ImportPathFinder<'tcx> { - tcx: TyCtxt<'tcx>, + pub(crate) tcx: TyCtxt<'tcx>, pub(crate) cache: IndexMap>>, pub(crate) include_private_paths: bool, pub(crate) import_path_processor: Option String>>, diff --git a/crates/bevy_api_gen/src/meta.rs b/crates/bevy_api_gen/src/meta.rs index 3f85dd30..029c438c 100644 --- a/crates/bevy_api_gen/src/meta.rs +++ b/crates/bevy_api_gen/src/meta.rs @@ -66,6 +66,28 @@ impl MetaLoader { self.meta_for_retry(crate_name, 3) } + /// Searches the given meta sources in order for the provided DefPathHash, once a meta file containing this hash is found + /// the search stops and returns true, if no meta file is found containing the hash, false is returned + /// + /// if a curr_source argument is provided, the search will skip this source as it is assumed that the current crate is still being compiled and not meta file for it exists yet + pub fn one_of_meta_files_contains( + &self, + meta_sources: &[&str], + curr_source: Option<&str>, + target_def_path_hash: DefPathHash, + ) -> bool { + let meta = match meta_sources + .iter() + .filter(|s| curr_source.is_none() || curr_source.is_some_and(|cs| cs == **s)) + .find_map(|s| self.meta_for(s)) + { + Some(meta) => meta, + None => return false, // TODO: is it possible we get false negatives here ? perhaps due to parallel compilation ? or possibly because of dependency order + }; + + meta.contains_def_path_hash(target_def_path_hash) + } + fn meta_for_retry(&self, crate_name: &str, _try_attempts: usize) -> Option { let meta = self .meta_dirs diff --git a/crates/bevy_api_gen/src/passes/codegen.rs b/crates/bevy_api_gen/src/passes/codegen.rs index 6a2a1a68..cd2e9ccd 100644 --- a/crates/bevy_api_gen/src/passes/codegen.rs +++ b/crates/bevy_api_gen/src/passes/codegen.rs @@ -37,6 +37,7 @@ pub(crate) fn codegen(ctxt: &mut BevyCtxt<'_>, args: &Args) -> bool { .expect("Failed to render crate artifact"); file.flush().unwrap(); + log::trace!("Written files"); true } diff --git a/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs b/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs index 9046dadd..5224ae4e 100644 --- a/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs +++ b/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs @@ -205,7 +205,7 @@ pub(crate) fn find_methods_and_fields(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> is_unsafe, def_id: fn_did, has_self, - trait_did, + trait_and_impl_did: trait_did.map(|td| (td, *impl_did)), reflection_strategies, }) }) @@ -331,6 +331,7 @@ fn type_is_adt_and_reflectable<'tcx>( ty.ty_adt_def().is_some_and(|adt_def| { let did = adt_def.did(); + // even though our meta might already be written at this point, we use this as a quick out if reflect_types.contains_key(&did) { // local types are easy to check return true; @@ -343,24 +344,18 @@ fn type_is_adt_and_reflectable<'tcx>( // so search for these metas! let crate_name = tcx.crate_name(did.krate).to_ident_string(); - let meta_sources = if tcx.crate_name(LOCAL_CRATE).as_str() == "bevy_reflect" { - // otherwise meta loader might expect the meta to exist - vec![crate_name] - } else { - vec![crate_name, "bevy_reflect".to_string()] - }; - - let meta = match meta_sources.iter().find_map(|s| meta_loader.meta_for(s)) { - Some(meta) => meta, - None => return false, // TODO: is it possible we get false negatives here ? perhaps due to parallel compilation ? or possibly because of dependency order - }; + let contains_hash = meta_loader.one_of_meta_files_contains( + &[&crate_name, "bevy_reflect"], + Some(&tcx.crate_name(LOCAL_CRATE).to_ident_string()), + tcx.def_path_hash(did), + ); - let contains_hash = meta.contains_def_path_hash(tcx.def_path_hash(did)); log::trace!( "Meta for type: `{}`, contained in meta `{}`", tcx.item_name(did), contains_hash ); + contains_hash }) } diff --git a/crates/bevy_api_gen/src/passes/find_trait_impls.rs b/crates/bevy_api_gen/src/passes/find_trait_impls.rs index 65f65e31..1232fb84 100644 --- a/crates/bevy_api_gen/src/passes/find_trait_impls.rs +++ b/crates/bevy_api_gen/src/passes/find_trait_impls.rs @@ -136,6 +136,7 @@ fn impl_matches<'tcx>(infcx: &InferCtxt<'tcx>, ty: Ty<'tcx>, impl_def_id: DefId) let ocx = ObligationCtxt::new(infcx); let param_env = tcx.param_env_reveal_all_normalized(impl_def_id); let impl_args = infcx.fresh_args_for_item(DUMMY_SP, impl_def_id); + let impl_trait_ref = tcx .impl_trait_ref(impl_def_id) .expect("Expected defid to be an impl for a trait") diff --git a/crates/bevy_api_gen/src/passes/populate_template_data.rs b/crates/bevy_api_gen/src/passes/populate_template_data.rs index e5aff8e6..a5a64a77 100644 --- a/crates/bevy_api_gen/src/passes/populate_template_data.rs +++ b/crates/bevy_api_gen/src/passes/populate_template_data.rs @@ -1,9 +1,11 @@ -use std::fmt::Write; +use std::{any::Any, borrow::Cow, convert::identity}; -use log::trace; +use log::{trace, warn}; use rustc_ast::Attribute; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; -use rustc_middle::ty::{FieldDef, ParamTy, Ty, TyKind, TypeFoldable}; +use rustc_middle::ty::{ + AdtDef, FieldDef, GenericArg, GenericParamDefKind, ParamTy, TraitRef, Ty, TyKind, TypeFoldable, +}; use rustc_span::Symbol; use crate::{ @@ -126,7 +128,7 @@ pub(crate) fn process_fields<'f, I: Iterator>( .map(|field| Field { docstrings: docstrings(ctxt.tcx.get_attrs_unchecked(field.did)), ident: field.name.to_ident_string(), - ty: ty_to_string(ctxt, ctxt.tcx.type_of(field.did).skip_binder()), + ty: ty_to_string(ctxt, ctxt.tcx.type_of(field.did).skip_binder(), false), reflection_strategy: *ty_ctxt .get_field_reflection_strat(field.did) .unwrap_or_else(|| panic!("{ty_ctxt:#?}")), @@ -145,52 +147,25 @@ pub(crate) fn process_functions(ctxt: &BevyCtxt, fns: &[FunctionContext]) -> Vec .zip(fn_sig.inputs()) .enumerate() .map(|(idx, (ident, ty))| { - let (ident, ty) = if fn_ctxt.has_self && idx == 0 { - // self argument, we want to map to something like `&self` instead of `&Component` - // we do that by renaming every adt inside to "self" - // this is a bit hacky but it works, might not work if we decide to support generics in the future - // TODO: fix to work with generics - let ty = ty.fold_with(&mut rustc_middle::ty::fold::BottomUpFolder { - tcx: ctxt.tcx, - ty_op: |ty| { - if ty.is_adt() { - ctxt.tcx.mk_ty_from_kind(TyKind::Param(ParamTy::new( - 0, - Symbol::intern("self"), - ))) - } else { - ty - } - }, - lt_op: |lt| lt, - ct_op: |ct| ct, - }); - (None, ty) - } else { - (ident.to_string().into(), *ty) - }; - // remove projections like `::AssocType` - let ty = ty_to_string( - ctxt, - ctxt.tcx - .normalize_erasing_regions(ctxt.tcx.param_env(fn_ctxt.def_id), ty), - ); + let normalized_ty = ctxt + .tcx + .normalize_erasing_regions(ctxt.tcx.param_env(fn_ctxt.def_id), *ty); Arg { - ident, - ty, + ident: ident.to_string(), + ty: ty_to_string(ctxt, normalized_ty, false), + proxy_ty: ty_to_string(ctxt, normalized_ty, true), reflection_strategy: fn_ctxt.reflection_strategies[idx], } }) .collect(); - let ty = ty_to_string( - ctxt, - ctxt.tcx - .normalize_erasing_regions(ctxt.tcx.param_env(fn_ctxt.def_id), fn_sig.output()), - ); + let out_ty = ctxt + .tcx + .normalize_erasing_regions(ctxt.tcx.param_env(fn_ctxt.def_id), fn_sig.output()); let output = Output { - ty, + ty: ty_to_string(ctxt, out_ty, false), + proxy_ty: ty_to_string(ctxt, out_ty, true), reflection_strategy: *fn_ctxt.reflection_strategies.last().unwrap(), }; @@ -203,9 +178,11 @@ pub(crate) fn process_functions(ctxt: &BevyCtxt, fns: &[FunctionContext]) -> Vec output, has_self: fn_ctxt.has_self, docstrings: docstrings(ctxt.tcx.get_attrs_unchecked(fn_ctxt.def_id)), - from_trait_path: fn_ctxt - .trait_did - .map(|trait_did| import_path(ctxt, trait_did)), + from_trait_path: fn_ctxt.trait_and_impl_did.map(|(_, impl_did)| { + let trait_ref = ctxt.tcx.impl_trait_ref(impl_did).unwrap().skip_binder(); + + trait_ref_to_string(ctxt, trait_ref) + }), } }) .collect() @@ -236,51 +213,271 @@ pub(crate) fn import_path(ctxt: &BevyCtxt, def_id: DefId) -> String { } /// Normalizes type import paths in types before printing them -fn ty_to_string<'tcx>(ctxt: &BevyCtxt<'tcx>, ty: Ty<'tcx>) -> String { +fn ty_to_string<'tcx>(ctxt: &BevyCtxt<'tcx>, ty: Ty<'tcx>, proxy_types: bool) -> String { // walk through the type and replace all paths with their standardised import paths - TyPrinter::new().print(&ctxt.path_finder, ty) + TyPrinter::new( + Box::new(|ty| { + ty.ty_adt_def() + .map(|def| { + let def_id = def.did(); + let def_path_hash = ctxt.tcx.def_path_hash(def_id); + let meta_sources = [ + &ctxt.tcx.crate_name(def_id.krate).to_ident_string(), + "bevy_reflect", + ]; + + ctxt.meta_loader.one_of_meta_files_contains( + &meta_sources, + Some(&ctxt.tcx.crate_name(LOCAL_CRATE).to_ident_string()), + def_path_hash, + ) + }) + .is_some_and(identity) + }), + Box::new(|did| Cow::Owned(import_path(ctxt, did))), + proxy_types, + ) + .print(ty) } -struct TyPrinter { +/// Converts a specific trait instantiation (in the context of an impl) into a string taking into account correctly the +/// import transformations and generics +/// TODO: this doesn't explicitly print out associated types, because I don't think it's necessary yet and annoying to do (idk how to do it) +fn trait_ref_to_string<'tcx>(ctxt: &BevyCtxt<'tcx>, trait_ref: TraitRef<'tcx>) -> String { + let generics_def = ctxt.tcx.generics_of(trait_ref.def_id); + + let generic_args = trait_ref + .args + .iter() + .enumerate() + .skip(if generics_def.has_self { 1 } else { 0 }) + .map(|(idx, a)| (a, generics_def.param_at(idx, ctxt.tcx))) + // filter out non const | type generics and the compiler generated ones + .filter(|(_, arg_def)| match arg_def.kind { + GenericParamDefKind::Lifetime => false, + GenericParamDefKind::Const { is_host_effect, .. } => !is_host_effect, + _ => true, + }) + .map(|(arg, arg_def)| { + log::trace!("Printing for trait: `{trait_ref}` arg: `{arg}`, with def: `{arg_def:#?}`"); + + let arg_ty = if let Some(ty) = arg.as_type() { + ty + } else if let Some(const_) = arg.as_const() { + const_.ty() + } else { + unreachable!("should be filtered") + }; + + ty_to_string(ctxt, arg_ty, false) + }) + .collect::>(); + + let trait_path = import_path(ctxt, trait_ref.def_id); + + if generic_args.is_empty() { + trait_path + } else { + format!("{trait_path}::<{}>", generic_args.join(", ")) + } +} + +#[derive(Clone, Copy)] +pub(crate) enum ProxyType { + Ref, + RefMut, + Val, + NonReflectVal, +} + +impl ProxyType { + pub fn to_ident_str(self) -> &'static str { + match self { + ProxyType::Ref => "LuaReflectRefProxy", + ProxyType::RefMut => "LuaReflectRefMutProxy", + ProxyType::Val => "LuaReflectValProxy", + ProxyType::NonReflectVal => "LuaValProxy", + } + } +} +/// Pretty prints types fully using the given import path finder or ADT's +struct TyPrinter<'a> { buffer: String, + path_finder: Box Cow<'static, str> + 'a>, + is_proxied_check: Box) -> bool + 'a>, + /// If true will wrap types in appropriate proxies instead of directly pringting the type + proxy_types: bool, } -impl TyPrinter { - pub fn new() -> Self { +impl<'a> TyPrinter<'a> { + pub fn new( + is_proxied_check: Box) -> bool + 'a>, + path_finder: Box Cow<'static, str> + 'a>, + proxy_types: bool, + ) -> Self { TyPrinter { buffer: String::new(), + is_proxied_check, + proxy_types, + path_finder, } } - pub fn print(mut self, path_finder: &ImportPathFinder, ty: Ty<'_>) -> String { - self.build_str(path_finder, ty); + + pub fn print(mut self, ty: Ty<'_>) -> String { + log::trace!("Printing type: {:#?}", ty); + self.print_ty(ty); self.buffer } - fn build_str(&mut self, path_finder: &ImportPathFinder, ty: Ty<'_>) { + fn print_args<'tcx, I: Iterator>>(&mut self, mut args: I) { + let mut next = args.next(); + if next.is_some() { + self.buffer.push('<'); + while let Some(arg) = next { + let ty = if let Some(ty) = arg.as_type() { + ty + } else if let Some(const_) = arg.as_const() { + const_.ty() + } else { + next = args.next(); + continue; + }; + self.print_ty(ty); + + next = args.next(); + if next.is_some() { + self.buffer.push_str(", "); + } + } + + self.buffer.push('>'); + } + } + + fn print_adt<'tcx, I: Iterator>>(&mut self, ty: AdtDef<'tcx>, args: I) { + log::trace!("Printing ADT: {:#?}", ty); + let did = ty.did(); + let import_path = (self.path_finder)(did); + self.buffer.push_str(&import_path); + self.print_args(args); + } + + fn print_ty(&mut self, ty: Ty<'_>) { + log::trace!("Printing type: {:#?}", ty); + match ty.kind() { - TyKind::Adt(adt_def, args) => { - let did = adt_def.did(); - let import_path = path_finder - .find_import_paths(did) - .first() - .unwrap() - .to_owned(); - self.buffer.push_str(&import_path); - if args.len() > 0 { - self.buffer.push('<'); - for (idx, a) in args.iter().enumerate() { - match a.as_type() { - Some(ty) => self.build_str(path_finder, ty), - None => _ = self.buffer.write_str(&a.to_string()), - } - if idx != args.len() - 1 { - self.buffer.push_str(", "); - } + TyKind::Bool => self.print_literal("bool"), + TyKind::Char => self.print_literal("char"), + TyKind::Str => self.print_literal("str"), + TyKind::Int(ty) => self.print_literal(ty.name_str()), + TyKind::Uint(ty) => self.print_literal(ty.name_str()), + TyKind::Float(ty) => self.print_literal(ty.name_str()), + TyKind::Adt(adt_ty, args) => { + if self.proxy_types { + self.print_proxied_ty(ty, ProxyType::Val); + } else { + self.print_adt(*adt_ty, args.iter()); + } + } + TyKind::Array(ty, const_) => { + self.buffer.push('['); + self.print_ty(*ty); + self.buffer.push(';'); + // shortcut, we won't encounter ADT's here just use native printer + self.buffer.push_str(&const_.to_string()); + self.buffer.push(']'); + } + TyKind::Slice(ty) => { + self.buffer.push('['); + self.print_ty(*ty); + self.buffer.push(']'); + } + TyKind::RawPtr(ptr) => { + self.buffer.push('*'); + if ptr.mutbl.is_mut() { + self.buffer.push_str("mut "); + } + self.print_ty(ptr.ty); + } + TyKind::Ref(_, ty, mut_) => { + if self.proxy_types { + let proxy_type = if mut_.is_mut() { + ProxyType::RefMut + } else { + ProxyType::Ref + }; + self.print_proxied_ty(*ty, proxy_type); + } else { + self.buffer.push('&'); + if mut_.is_mut() { + self.buffer.push_str("mut "); + } + self.print_ty(*ty); + } + } + TyKind::Tuple(tys) => { + self.buffer.push('('); + for (idx, ty) in tys.iter().enumerate() { + self.print_ty(ty); + if idx != tys.len() - 1 { + self.buffer.push(','); } - self.buffer.push('>'); } + self.buffer.push(')'); + } + TyKind::Alias(_, ty) => { + self.buffer.push_str(&(self.path_finder)(ty.def_id)); + self.print_args(ty.args.iter()); + } + // self is one I think + TyKind::Param(param) => self.print_literal(param.name.as_str()), + _ => { + warn!( + "Type outside the scope of the TyPrinter being printed: pretty=`{}` kind=`{:?}`", + ty, ty.kind() + ); + self.buffer.push_str(&ty.to_string()) } - _ => self.buffer.push_str(&ty.to_string()), } } + + /// prints a type but without making further proxies at this level + /// i.e. a &T will be printed as RefProxy instead of RefProxy> since the T will not be printed via print_ty but directly here + /// But only for ADT's, other types are printed as normal + fn print_proxied_ty(&mut self, ty: Ty<'_>, proxy_type: ProxyType) { + match ty.kind() { + TyKind::Adt(adt_ty, args) => { + if (self.is_proxied_check)(ty) { + self.print_literal_surround_content( + proxy_type.to_ident_str(), + '<', + '>', + |self_| { + self_.print_adt(*adt_ty, args.iter()); + }, + ); + } else { + self.print_adt(*adt_ty, args.iter()) + } + } + _ => self.print_ty(ty), + } + } + + fn print_literal_surround_content( + &mut self, + literal: &str, + start: char, + end: char, + f: F, + ) { + self.buffer.push_str(literal); + self.buffer.push(start); + f(self); + self.buffer.push(end); + } + + fn print_literal(&mut self, literal: &str) { + self.buffer.push_str(literal); + } } diff --git a/crates/bevy_api_gen/src/plugin.rs b/crates/bevy_api_gen/src/plugin.rs index b365458e..1e0d73a2 100644 --- a/crates/bevy_api_gen/src/plugin.rs +++ b/crates/bevy_api_gen/src/plugin.rs @@ -53,7 +53,9 @@ impl RustcPlugin for BevyAnalyzer { let mut callbacks = BevyAnalyzerCallbacks::new(plugin_args); let mut compiler = rustc_driver::RunCompiler::new(&compiler_args, &mut callbacks); compiler.set_file_loader(Some(Box::new(ModifyingFileLoader))); - compiler.run() + let out = compiler.run(); + log::trace!("Finished compiling with plugin"); + out } fn modify_cargo(&self, cmd: &mut std::process::Command, args: &Self::Args) { diff --git a/crates/bevy_api_gen/src/template.rs b/crates/bevy_api_gen/src/template.rs index ce8774e1..ddb9d029 100644 --- a/crates/bevy_api_gen/src/template.rs +++ b/crates/bevy_api_gen/src/template.rs @@ -111,17 +111,21 @@ pub(crate) struct Function { pub(crate) struct Arg { /// the name of the argument as in source code /// None if this is a receiver, in which case ty contains the ident - pub(crate) ident: Option, + pub(crate) ident: String, /// the type of argument /// i.e. `&Vec` pub(crate) ty: String, + /// The proxied type of argument for use in Unproxy and Proxy targetted code + /// i.e. AppropriateRefProxy instead of &MyTy for a reference + pub(crate) proxy_ty: String, pub(crate) reflection_strategy: ReflectionStrategy, } #[derive(Serialize)] pub(crate) struct Output { pub(crate) ty: String, + pub(crate) proxy_ty: String, pub(crate) reflection_strategy: ReflectionStrategy, } diff --git a/crates/bevy_api_gen/templates/field.tera b/crates/bevy_api_gen/templates/field.tera index bf9baae5..ea5fb145 100644 --- a/crates/bevy_api_gen/templates/field.tera +++ b/crates/bevy_api_gen/templates/field.tera @@ -1,6 +1,4 @@ -{%- if field.reflection_strategy == "Proxy" -%} - #[lua(output(proxy))] -{%- elif field.reflection_strategy == "Filtered" -%} +{%- if field.reflection_strategy == "Filtered" -%} #[lua(skip)] {%- endif -%} @@ -10,6 +8,6 @@ {% if field.reflection_strategy != "Reflection" -%} {{- field.ty -}} {%- else -%} -ReflectedValue +ReflectReference {%- endif -%} , diff --git a/crates/bevy_api_gen/templates/footer.tera b/crates/bevy_api_gen/templates/footer.tera index bdf763fc..87a76308 100644 --- a/crates/bevy_api_gen/templates/footer.tera +++ b/crates/bevy_api_gen/templates/footer.tera @@ -33,7 +33,7 @@ pub struct {{ "ScriptingPlugin" | prefix_cratename | convert_case(case="upper_ca impl bevy::app::Plugin for {{ "ScriptingPlugin" | prefix_cratename | convert_case(case="upper_camel")}} { fn build(&self, app: &mut bevy::prelude::App) { {% for item in items %} - app.register_foreign_lua_type::<{{ item.import_path }}>(); + app.register_proxy::<{{ item.import_path }}>(); {% endfor %} app.add_context_initializer::<()>({{ "ContextInitializer" | prefix_cratename | convert_case(case="snake") }}); app.add_documentation_fragment( diff --git a/crates/bevy_api_gen/templates/function.tera b/crates/bevy_api_gen/templates/function.tera index b8bc2637..970eebdf 100644 --- a/crates/bevy_api_gen/templates/function.tera +++ b/crates/bevy_api_gen/templates/function.tera @@ -54,16 +54,15 @@ metamethod="Eq", {%- for arg in function.args -%} --- - {%- if arg.ident and arg.reflection_strategy == "Proxy" -%} - #[proxy] - {%- endif -%} - {%- if arg.ident -%} - {{- arg.ident }} : {# -#} + {%- if arg.ident != "self" -%} + {{- arg.ident -}} + {%- else -%} + _{{- arg.ident -}} {%- endif -%} - {{- arg.ty -}} + : {{- arg.proxy_ty -}} {%- endfor -%} {%- endfilter -%} -) -> {{ function.output.ty -}}; +) -> {{ function.output.proxy_ty -}}; {%- endfilter %} "# \ No newline at end of file diff --git a/crates/bevy_api_gen/templates/header.tera b/crates/bevy_api_gen/templates/header.tera index c71af291..9d1e31ec 100644 --- a/crates/bevy_api_gen/templates/header.tera +++ b/crates/bevy_api_gen/templates/header.tera @@ -9,4 +9,10 @@ use super::{{crate}}::*; {% endfor %} -use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; \ No newline at end of file +use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation, bindings::ReflectReference}; + +{% if args.self_is_bms_lua %} +use crate::{bindings::proxy::{LuaReflectRefProxy,LuaReflectRefMutProxy,LuaReflectValProxy,LuaValProxy,IdentityProxy},RegisterLuaProxy}; +{% else %} +use bevy_mod_scripting::{lua::bindings::proxy::{LuaReflectRefProxy,LuaReflectRefMutProxy,LuaReflectValProxy,LuaValProxy,IdentityProxy}, RegisterLuaProxy}; +{% endif %} \ No newline at end of file diff --git a/crates/bevy_api_gen/templates/item.tera b/crates/bevy_api_gen/templates/item.tera index b11b90d0..43bb345e 100644 --- a/crates/bevy_api_gen/templates/item.tera +++ b/crates/bevy_api_gen/templates/item.tera @@ -3,13 +3,19 @@ {# for now #} {% endfor %} +{% if args.self_is_bms_lua %} +{% set bms_core_path="bevy_mod_scripting_core" %} +{% set bms_lua_path="crate" %} +{% else %} +{% set bms_core_path="bevy_mod_scripting::core" %} +{% set bms_lua_path="bevy_mod_scripting::lua" %} +{% endif %} + #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote="{{ item.import_path }}", -{% if args.self_is_bms_lua %} -bms_core_path="bevy_mod_scripting_core", -bms_lua_path="crate", -{% endif %} +bms_core_path="{{bms_core_path}}", +bms_lua_path="{{bms_lua_path}}", functions[ {%- filter separated(delimeter=",\n\t\t\t", split_at="---", ignore_first=true) -%} @@ -61,7 +67,7 @@ functions[ r#" {%- set mat_type = item.import_path | split(pat="::") | last -%} {%- set col_type = mat_type | replace(from="Mat", to="Vec")-%} - {{- macros::matrix_index(col_type=col_type,mat_type=mat_type)-}} + {{- macros::matrix_index(col_type=col_type,mat_type=mat_type,bms_core_path=bms_core_path)-}} "# {% endif %} {%- endfilter -%} @@ -76,7 +82,7 @@ functions[ {% set close_item = "}" %} {% endif %} -pub struct {{ item.ident | prefix_lua -}} {{ open_item }} +pub struct {{ item.ident -}} {{ open_item }} {% if not item.is_enum %} {% for field in item.variants[0].fields %} {% if field.reflection_strategy != "Filtered" %} diff --git a/crates/bevy_api_gen/templates/macros.tera b/crates/bevy_api_gen/templates/macros.tera index 0cd829e1..ef5b5783 100644 --- a/crates/bevy_api_gen/templates/macros.tera +++ b/crates/bevy_api_gen/templates/macros.tera @@ -1,39 +1,35 @@ {% macro vector_index(num_type) %} -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result<{{ num_type }},_> { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy<{{ num_type }}> { + _self[idx - 1] } {% endmacro vector_index %} {% macro vector_newindex(num_type) %} -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: {{ num_type }}) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: {{ num_type }}) -> () { + _self[idx - 1] = val } {% endmacro vector_newindex %} -{% macro matrix_index(col_type, mat_type) %} -#[lua(raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result<{{ col_type | prefix_lua }},_> { - Ok({{ col_type | prefix_lua }}::new_ref( - _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) +{% macro matrix_index(col_type, mat_type, bms_core_path) %} +#[lua(metamethod="Index")] +fn index(_self: IdentityProxy, idx: usize) -> IdentityProxy<{{ col_type | prefix_lua }}> { + let mut curr_ref = _self.0.clone(); + let def_ref = {{bms_core_path}}::bindings::DeferredReflection{ + get: std::sync::Arc::new(|ref_| Err(bevy::reflect::ReflectPathError::InvalidDowncast)), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(idx - 1)) + } else { + Err(bevy::reflect::ReflectPathError::InvalidDowncast) + } + }) + }; + curr_ref.reflect_path.push({{bms_core_path}}::bindings::ReflectionPathElem::new_deferred(def_ref)); + {{ col_type | prefix_lua }}(curr_ref) } {% endmacro matrix_index %} diff --git a/crates/bevy_mod_scripting_core/src/bindings.rs b/crates/bevy_mod_scripting_core/src/bindings.rs index f89ffedd..defdd2ac 100644 --- a/crates/bevy_mod_scripting_core/src/bindings.rs +++ b/crates/bevy_mod_scripting_core/src/bindings.rs @@ -27,12 +27,14 @@ use bevy::{ reflect::{ ParsedPath, Reflect, ReflectFromPtr, ReflectPath, ReflectPathError, TypeInfo, TypeRegistry, }, + utils::smallvec::SmallVec, }; use crate::{ allocator::{ReflectAllocation, ReflectAllocationId}, error::ReflectionError, prelude::ReflectAllocator, + proxy::{Proxy, Unproxy}, }; /// Describes kinds of base value we are accessing via reflection @@ -243,6 +245,48 @@ impl<'w> WorldAccessGuard<'w> { self.get_access(access_id) } + /// Call a function on a type which can be proxied, first by unproxying the input with world access, + /// then calling the function and finally proxying the output with the allocator. + pub fn proxy_call<'i, O: Proxy, T: Unproxy, F: Fn(T::Output<'_>) -> O::Input<'i>>( + &self, + mut proxied_input: T, + f: F, + ) -> Result { + let cell = self.as_unsafe_world_cell(); + let allocator_resource_id = cell + .components() + .resource_id::() + .expect("Reflect Allocator wasn't initialized"); + let type_registry_resource_id = cell + .components() + .resource_id::() + .expect("Type Registry wasn't initialized"); + let mut allocator_access = self + .get_access(allocator_resource_id.into()) + .expect("Deadlock while accessing allocator"); + let type_registry_access = self + .get_access(type_registry_resource_id.into()) + .expect("Deadlock while accessing type registry"); + let mut allocator = self + .get_resource_mut::(&mut allocator_access) + .unwrap() + .unwrap(); + let type_registry = self + .get_resource::(&type_registry_access) + .unwrap() + .unwrap(); + let type_registry = type_registry.read(); + let mut world_acceses = SmallVec::default(); + + proxied_input.collect_accesses(self, &mut world_acceses)?; + let input = unsafe { + proxied_input.unproxy_with_world(self, &world_acceses, &type_registry, &allocator)? + }; + let out = f(input); + + O::proxy_with_allocator(out, &mut allocator) + } + /// Get access to the given component, this is the only way to access a component/resource safely (in the context of the world access guard) pub fn get_component( &self, @@ -733,6 +777,29 @@ pub enum ReflectionPathElem { DeferredReflection(DeferredReflection), } +impl ReflectionPathElem { + pub fn new_reflection>(path: I) -> Self { + Self::Reflection(path.into()) + } + + pub fn new_deferred>(defref: I) -> Self { + Self::DeferredReflection(defref.into()) + } +} + +impl From<(A, B)> for DeferredReflection +where + A: Fn(&dyn Reflect) -> Result<&dyn Reflect, ReflectPathError<'static>> + Send + Sync, + B: Fn(&mut dyn Reflect) -> Result<&mut dyn Reflect, ReflectPathError<'static>> + Send + Sync, +{ + fn from((get, get_mut): (A, B)) -> Self { + Self { + get: Arc::new(get), + get_mut: Arc::new(get_mut), + } + } +} + impl<'a> ReflectPath<'a> for &'a ReflectionPathElem { fn reflect_element<'r>( self, @@ -758,8 +825,9 @@ impl<'a> ReflectPath<'a> for &'a ReflectionPathElem { /// A ReflectPath which can perform arbitrary operations on the root object to produce a sub-reference #[derive(Clone)] pub struct DeferredReflection { - get: Arc Result<&dyn Reflect, ReflectPathError<'static>> + Send + Sync>, - get_mut: Arc< + pub get: + Arc Result<&dyn Reflect, ReflectPathError<'static>> + Send + Sync>, + pub get_mut: Arc< dyn Fn(&mut dyn Reflect) -> Result<&mut dyn Reflect, ReflectPathError<'static>> + Send + Sync, diff --git a/crates/bevy_mod_scripting_core/src/error.rs b/crates/bevy_mod_scripting_core/src/error.rs index 07fdac3d..15debe9b 100644 --- a/crates/bevy_mod_scripting_core/src/error.rs +++ b/crates/bevy_mod_scripting_core/src/error.rs @@ -84,7 +84,11 @@ pub enum ReflectionError { InvalidBaseReference { base: String, reason: String }, #[error("Cannot safely access `{base}`. {reason}")] InsufficientAccess { base: String, reason: String }, - + #[error("Tried to access `{base:?}` with insufficient provenance. {reason}")] + InsufficientProvenance { + base: ReflectReference, + reason: String, + }, #[error("Cannot downcast reference: {reference:?} to: {to}")] CannotDowncast { reference: ReflectReference, diff --git a/crates/bevy_mod_scripting_core/src/proxy.rs b/crates/bevy_mod_scripting_core/src/proxy.rs index aa56119d..c665cef5 100644 --- a/crates/bevy_mod_scripting_core/src/proxy.rs +++ b/crates/bevy_mod_scripting_core/src/proxy.rs @@ -21,11 +21,11 @@ use crate::{ }; /// Inverse to [`Unproxy`], packages up a type into a proxy type. -pub trait Proxy<'a>: Sized { - type Input; +pub trait Proxy: Sized { + type Input<'a>; /// Proxies a type without access to the allocator, types which require access to the allocator will throw an error here - fn proxy(input: Self::Input) -> Result { + fn proxy<'a>(input: Self::Input<'a>) -> Result { Err(ReflectionError::InsufficientAccess { base: std::any::type_name::().to_owned(), reason: "Attempted to proxy a type that requires an allocator without providing it" @@ -34,8 +34,8 @@ pub trait Proxy<'a>: Sized { } /// Proxies a type with access to the allocator - fn proxy_with_allocator( - input: Self::Input, + fn proxy_with_allocator<'a>( + input: Self::Input<'a>, _allocator: &mut ReflectAllocator, ) -> Result { Self::proxy(input) @@ -47,10 +47,13 @@ pub trait Proxy<'a>: Sized { /// `RefProxy` and `RefMutProxy` are such 'meta-proxy' types. /// /// the [`Unproxy::Output`] type parameter is the type that this `proxy` will be converted to after unwrapping. -pub trait Unproxy<'w, 'o> { - type Output: 'o; +/// +pub trait Unproxy { + type Output<'o> + where + Self: 'o; - fn collect_accesses( + fn collect_accesses<'w>( &self, _guard: &WorldAccessGuard<'w>, _accesses: &mut SmallVec<[WorldAccessWrite<'w>; 1]>, @@ -64,9 +67,9 @@ pub trait Unproxy<'w, 'o> { /// Unproxies a proxy type into the represented type without world access /// This will fail on proxies which require world access to unproxy (for example those whose proxies are glorified [`ReflectReference`]'s ) - fn unproxy(&'o mut self) -> Result { + fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { Err(ReflectionError::InsufficientAccess { - base: std::any::type_name::().to_owned(), + base: std::any::type_name::>().to_owned(), reason: "Attempted to unproxy a type that requires world access without providing it" .to_owned(), }) @@ -75,13 +78,13 @@ pub trait Unproxy<'w, 'o> { /// Unproxies a proxy type into the represented type with world access /// # Safety /// - The caller must not use the accesses in the accesses list after the unproxy call at all, as implementors assume they have unique access to the accesses. - unsafe fn unproxy_with_world( + unsafe fn unproxy_with_world<'w, 'o>( &'o mut self, _guard: &WorldAccessGuard<'w>, _accesses: &'o [WorldAccessUnit<'w>], _type_registry: &TypeRegistry, _allocator: &'o ReflectAllocator, - ) -> Result { + ) -> Result, ReflectionError> { self.unproxy() } } @@ -128,37 +131,37 @@ impl ReflectRefMutProxy { } } -impl<'w, 'c, T: 'c, P: 'c> Unproxy<'w, 'c> for ValProxy +impl Unproxy for ValProxy where - T: From<&'c P>, + T: for<'l> From<&'l P>, { - type Output = T; + type Output<'o> = T where Self: 'o; - fn unproxy(&'c mut self) -> Result { + fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { Ok(T::from(&self.0)) } } -impl Proxy<'_> for ValProxy +impl Proxy for ValProxy where T: Into

, { - type Input = T; + type Input<'a> = T; - fn proxy(input: Self::Input) -> Result { + fn proxy<'a>(input: Self::Input<'a>) -> Result { Ok(ValProxy::new(input.into())) } } -impl Proxy<'_> for ReflectValProxy +impl Proxy for ReflectValProxy where T: Reflect, P: From, { - type Input = T; + type Input<'a> = T; - fn proxy_with_allocator( - input: Self::Input, + fn proxy_with_allocator<'a>( + input: Self::Input<'a>, allocator: &mut ReflectAllocator, ) -> Result { Ok(Self::new( @@ -167,20 +170,20 @@ where } } -impl<'w, 'c, T, P> Unproxy<'w, 'c> for ReflectValProxy +impl Unproxy for ReflectValProxy where P: AsRef, T: FromReflect, { - type Output = T; + type Output<'o> = T where Self: 'o; - unsafe fn unproxy_with_world( - &'c mut self, + unsafe fn unproxy_with_world<'w, 'o>( + &'o mut self, guard: &WorldAccessGuard<'w>, - _accesses: &'c [WorldAccessUnit<'w>], + _accesses: &'o [WorldAccessUnit<'w>], type_registry: &TypeRegistry, - allocator: &'c ReflectAllocator, - ) -> Result { + allocator: &'o ReflectAllocator, + ) -> Result, ReflectionError> { let reflect_ref: &ReflectReference = self.0.as_ref(); let access = reflect_ref.base.base_id.get_reflect_access_id(); let access = @@ -205,15 +208,15 @@ where } } -impl<'a, T, P> Proxy<'a> for ReflectRefProxy +impl Proxy for ReflectRefProxy where T: FromReflect, P: From, { - type Input = &'a T; + type Input<'a> = &'a T; - fn proxy_with_allocator( - input: Self::Input, + fn proxy_with_allocator<'a>( + input: Self::Input<'a>, allocator: &mut ReflectAllocator, ) -> Result { let inner = T::from_reflect(input).ok_or_else(|| ReflectionError::FromReflectFailure { @@ -225,14 +228,14 @@ where } } -impl<'w, 'c, T, P> Unproxy<'w, 'c> for ReflectRefProxy +impl Unproxy for ReflectRefProxy where P: AsRef, T: Reflect, { - type Output = &'c T; + type Output<'o> = &'o T where Self: 'o; - fn collect_accesses( + fn collect_accesses<'w>( &self, guard: &WorldAccessGuard<'w>, accesses: &mut SmallVec<[WorldAccessUnit<'w>; 1]>, @@ -249,13 +252,13 @@ where Ok(()) } - unsafe fn unproxy_with_world( - &'c mut self, + unsafe fn unproxy_with_world<'w, 'o>( + &'o mut self, guard: &WorldAccessGuard<'w>, - accesses: &'c [WorldAccessUnit<'w>], + accesses: &'o [WorldAccessUnit<'w>], type_registry: &TypeRegistry, - allocator: &'c ReflectAllocator, - ) -> Result { + allocator: &'o ReflectAllocator, + ) -> Result, ReflectionError> { let reflect_ref: &ReflectReference = self.0.as_ref(); let access = accesses .last() @@ -284,14 +287,14 @@ where } } -impl<'w, 'c, T, P> Unproxy<'w, 'c> for ReflectRefMutProxy +impl Unproxy for ReflectRefMutProxy where P: AsRef, T: Reflect, { - type Output = &'c mut T; + type Output<'o> = &'o mut T where Self: 'o; - fn collect_accesses( + fn collect_accesses<'w>( &self, guard: &WorldAccessGuard<'w>, accesses: &mut SmallVec<[WorldAccessUnit<'w>; 1]>, @@ -308,13 +311,13 @@ where Ok(()) } - unsafe fn unproxy_with_world( - &'c mut self, + unsafe fn unproxy_with_world<'w, 'o>( + &'o mut self, guard: &WorldAccessGuard<'w>, - accesses: &'c [WorldAccessUnit<'w>], + accesses: &'o [WorldAccessUnit<'w>], type_registry: &TypeRegistry, - allocator: &'c ReflectAllocator, - ) -> Result { + allocator: &'o ReflectAllocator, + ) -> Result, ReflectionError> { let reflect_ref: &ReflectReference = self.0.as_ref(); accesses .last() @@ -350,125 +353,146 @@ where } } -impl<'w, 'c, T: Unproxy<'w, 'c>> Unproxy<'w, 'c> for Vec { - type Output = Vec; +macro_rules! impl_unproxy_via_vec { + ($type:ty, $out_type:ty, ($($generics:tt)*)) => { + impl<'c, $($generics)*> Unproxy for $type { + type Output<'o> = $out_type where Self: 'o; - fn collect_accesses( - &self, - guard: &WorldAccessGuard<'w>, - accesses: &mut SmallVec<[WorldAccessUnit<'w>; 1]>, - ) -> Result<(), ReflectionError> { - for item in self { - item.collect_accesses(guard, accesses)?; - } - Ok(()) - } + fn collect_accesses<'w>( + &self, + guard: &WorldAccessGuard<'w>, + accesses: &mut SmallVec<[WorldAccessUnit<'w>; 1]>, + ) -> Result<(), ReflectionError> { + for item in self { + item.collect_accesses(guard, accesses)?; + } + Ok(()) + } - fn accesses_len(&self) -> usize { - self.iter().map(|item| item.accesses_len()).sum() - } + fn accesses_len(&self) -> usize { + self.iter().map(|item| item.accesses_len()).sum() + } - fn unproxy(&'c mut self) -> Result { - let mut out = Vec::with_capacity(self.len()); - for item in self { - let unproxied = item.unproxy()?; - out.push(unproxied); - } - Ok(out) - } + fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { + let mut out = Vec::with_capacity(self.len()); + for item in self { + let unproxied = item.unproxy()?; + out.push(unproxied); + } + Ok(out.try_into().map_err(|_| "something went wrong").unwrap()) + } - unsafe fn unproxy_with_world( - &'c mut self, - guard: &WorldAccessGuard<'w>, - accesses: &'c [WorldAccessUnit<'w>], - type_registry: &TypeRegistry, - allocator: &'c ReflectAllocator, - ) -> Result { - let mut out = Vec::with_capacity(self.len()); - let mut offset = 0; - for item in self { - let width = item.accesses_len(); - let unproxied = item.unproxy_with_world( - guard, - &accesses[offset..offset + width], - type_registry, - allocator, - )?; - out.push(unproxied); - offset += width; + unsafe fn unproxy_with_world<'w, 'o>( + &'o mut self, + guard: &WorldAccessGuard<'w>, + accesses: &'o [WorldAccessUnit<'w>], + type_registry: &TypeRegistry, + allocator: &'o ReflectAllocator, + ) -> Result, ReflectionError> { + let mut out = Vec::with_capacity(self.len()); + let mut offset = 0; + for item in self { + let width = item.accesses_len(); + let unproxied = item.unproxy_with_world( + guard, + &accesses[offset..offset + width], + type_registry, + allocator, + )?; + out.push(unproxied); + offset += width; + } + Ok(out.try_into().map_err(|_| "something went wrong").unwrap()) + } } - Ok(out) - } + }; } -impl<'a, T: Proxy<'a>> Proxy<'a> for Vec { - type Input = Vec; +macro_rules! impl_proxy_via_vec { + ($type:ty, $item_type:ty ,$in_type:ty, ($($generics:tt)*)) => { + impl<$($generics)*> Proxy for $type { + type Input<'i> = $in_type; - fn proxy(input: Self::Input) -> Result { - input.into_iter().map(T::proxy).collect() - } + fn proxy(input: Self::Input<'_>) -> Result { + let mut out = Vec::with_capacity(input.len()); + for item in input { + out.push(<$item_type as Proxy>::proxy(item)?); + } + Ok(out.try_into().map_err(|_| "something went wrong").unwrap()) + } - fn proxy_with_allocator( - input: Self::Input, - _allocator: &mut ReflectAllocator, - ) -> Result { - input - .into_iter() - .map(|i| T::proxy_with_allocator(i, _allocator)) - .collect() - } + fn proxy_with_allocator( + input: Self::Input<'_>, + _allocator: &mut ReflectAllocator, + ) -> Result { + let mut out = Vec::with_capacity(input.len()); + for item in input { + out.push(<$item_type as Proxy>::proxy_with_allocator(item, _allocator)?); + } + Ok(out.try_into().map_err(|_| "something went wrong").unwrap()) + } + } + }; } -impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for &T { - type Output = &'c T; +impl_unproxy_via_vec!(Vec, Vec>, (T: Unproxy)); +impl_proxy_via_vec!(Vec, T, Vec>, (T: Proxy)); +impl_unproxy_via_vec!([T; C], [T::Output<'o>; C], (T: Unproxy, const C: usize)); +impl_proxy_via_vec!([T; C],T,[T::Input<'i>; C],(T: Proxy, const C: usize)); +impl_unproxy_via_vec!(SmallVec<[T; C]>, SmallVec<[T::Output<'o>; C]>, (T: Unproxy, const C: usize)); +impl_proxy_via_vec!(SmallVec<[T; C]>, T, SmallVec<[T::Input<'i>; C]>, (T: Proxy, const C: usize)); + +// impl_proxy_unproxy_via_vec!(T, SmallVec, SmallVec<[T; C]>); +impl<'c, T: Unproxy + 'c> Unproxy for &'c T { + type Output<'o> = &'c T where Self: 'o; - fn unproxy(&'c mut self) -> Result { + fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { Ok(self) } } -impl<'a, T: Proxy<'a>> Proxy<'a> for &'a T { - type Input = &'a T; +impl<'s, T: Proxy> Proxy for &'s T { + type Input<'b> = &'s T; - fn proxy(input: Self::Input) -> Result { + fn proxy<'a>(input: Self::Input<'a>) -> Result { Ok(input) } - fn proxy_with_allocator( - input: Self::Input, + fn proxy_with_allocator<'a>( + input: Self::Input<'a>, _allocator: &mut ReflectAllocator, ) -> Result { Ok(input) } } -impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for &mut T { - type Output = &'c mut T; +impl Unproxy for &mut T { + type Output<'o> = &'o mut T where Self: 'o; - fn unproxy(&'c mut self) -> Result { + fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { Ok(self) } } -impl<'a, T: Proxy<'a>> Proxy<'a> for &'a mut T { - type Input = &'a mut T; +impl<'s, T: Proxy> Proxy for &'s mut T { + type Input<'a> = &'s mut T; - fn proxy(input: Self::Input) -> Result { + fn proxy<'a>(input: Self::Input<'a>) -> Result { Ok(input) } - fn proxy_with_allocator( - input: Self::Input, + fn proxy_with_allocator<'a>( + input: Self::Input<'a>, _allocator: &mut ReflectAllocator, ) -> Result { Ok(input) } } -impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for Option { - type Output = Option; +impl Unproxy for Option { + type Output<'o> = Option> where Self: 'o; - fn unproxy(&'c mut self) -> Result { + fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { if let Some(s) = self { let inner = s.unproxy()?; Ok(Some(inner)) @@ -477,13 +501,13 @@ impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for Option { } } - unsafe fn unproxy_with_world( - &'c mut self, + unsafe fn unproxy_with_world<'w, 'o>( + &'o mut self, guard: &WorldAccessGuard<'w>, - accesses: &'c [WorldAccessUnit<'w>], + accesses: &'o [WorldAccessUnit<'w>], type_registry: &TypeRegistry, - allocator: &'c ReflectAllocator, - ) -> Result { + allocator: &'o ReflectAllocator, + ) -> Result, ReflectionError> { if let Some(s) = self { let inner = s.unproxy_with_world(guard, accesses, type_registry, allocator)?; Ok(Some(inner)) @@ -492,7 +516,7 @@ impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for Option { } } - fn collect_accesses( + fn collect_accesses<'w>( &self, guard: &WorldAccessGuard<'w>, accesses: &mut SmallVec<[WorldAccessWrite<'w>; 1]>, @@ -507,15 +531,15 @@ impl<'w, 'c, T: Unproxy<'w, 'c> + 'c> Unproxy<'w, 'c> for Option { } } -impl<'a, T: Proxy<'a>> Proxy<'a> for Option { - type Input = Option; +impl Proxy for Option { + type Input<'a> = Option>; - fn proxy(input: Self::Input) -> Result { + fn proxy<'a>(input: Self::Input<'a>) -> Result { input.map(T::proxy).transpose() } - fn proxy_with_allocator( - input: Self::Input, + fn proxy_with_allocator<'a>( + input: Self::Input<'a>, _allocator: &mut ReflectAllocator, ) -> Result { input @@ -526,12 +550,12 @@ impl<'a, T: Proxy<'a>> Proxy<'a> for Option { macro_rules! impl_unproxy_by_move { ($($ty:ty),*) => { - $(impl<'w, 'c> Unproxy<'w, 'c> for $ty { - type Output = $ty; + $(impl Unproxy for $ty { + type Output<'o> = $ty; - fn unproxy( - &'c mut self - ) -> Result { + fn unproxy<'o>( + &'o mut self + ) -> Result, ReflectionError> { Ok(*self) } })* @@ -541,10 +565,10 @@ macro_rules! impl_unproxy_by_move { macro_rules! impl_proxy_by_move { ($($ty:ident),*) => { $( - impl Proxy<'_> for $ty { - type Input = Self; + impl Proxy for $ty { + type Input<'a> = Self; - fn proxy(input: Self::Input) -> Result { + fn proxy<'a>(input: Self::Input<'a>) -> Result { Ok(input) } } @@ -602,10 +626,10 @@ impl_unproxy_by_move!( macro_rules! impl_unproxy_by_clone { ($($ty:ty),*) => { - $(impl<'w, 'c> Unproxy<'w, 'c> for $ty { - type Output = $ty; + $(impl Unproxy for $ty { + type Output<'o> = $ty; - fn unproxy(&'c mut self) -> Result { + fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { Ok(self.clone()) } })* @@ -617,24 +641,24 @@ impl_proxy_by_move!(String); macro_rules! impl_tuple_unproxy_proxy { ($(($ty:ident, $idx:tt)),*) => { - impl <'a,$($ty : Proxy<'a>,)*> Proxy<'a> for ($($ty,)*) + impl <$($ty : Proxy,)*> Proxy for ($($ty,)*) { - type Input = ($($ty::Input,)*); + type Input<'a> = ($($ty::Input<'a>,)*); #[allow(clippy::unused_unit)] - fn proxy(_input: Self::Input) -> Result { + fn proxy<'a>(_input: Self::Input<'a>) -> Result { Ok(($($ty::proxy(_input.$idx)?,)*)) } - fn proxy_with_allocator(_input: Self::Input, _allocator: &mut ReflectAllocator) -> Result { + fn proxy_with_allocator<'a>(_input: Self::Input<'a>, _allocator: &mut ReflectAllocator) -> Result { Ok(($($ty::proxy_with_allocator(_input.$idx, _allocator)?,)*)) } } - impl<'w, 'c, $($ty: Unproxy<'w, 'c>),*> Unproxy<'w, 'c> for ($($ty,)*) { - type Output = ($($ty::Output,)*); + impl<$($ty: Unproxy),*> Unproxy for ($($ty,)*) { + type Output<'o> = ($($ty::Output<'o>,)*) where Self: 'o; - fn collect_accesses( + fn collect_accesses<'w>( &self, _guard: &WorldAccessGuard<'w>, _accesses: &mut SmallVec<[WorldAccessWrite<'w>; 1]>, @@ -649,20 +673,20 @@ macro_rules! impl_tuple_unproxy_proxy { _len } - fn unproxy(&'c mut self) -> Result { + fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { Ok(($( self.$idx.unproxy()? ,)*)) } #[allow(unused_assignments)] - unsafe fn unproxy_with_world( - &'c mut self, + unsafe fn unproxy_with_world<'w,'o>( + &'o mut self, _guard: &WorldAccessGuard<'w>, - _accesses: &'c [WorldAccessUnit<'w>], + _accesses: &'o [WorldAccessUnit<'w>], _type_registry: &TypeRegistry, - _allocator: &'c ReflectAllocator, - ) -> Result { + _allocator: &'o ReflectAllocator, + ) -> Result, ReflectionError> { let mut _offset = 0; Ok(($( @@ -771,9 +795,9 @@ mod test { let mut allocator = ReflectAllocator::default(); // test allocator version works as well - $($proxy_ty)*::proxy_with_allocator($original, &mut allocator).unwrap(); + <$($proxy_ty)* as Proxy>::proxy_with_allocator($original, &mut allocator).unwrap(); // test proxying works - let mut proxy = $($proxy_ty)*::proxy($original).unwrap(); + let mut proxy = <$($proxy_ty)* as Proxy>::proxy($original).unwrap(); proxy.collect_accesses(&world, &mut accesses).unwrap(); // test both unproxy methods work @@ -804,6 +828,11 @@ mod test { #[test] pub fn test_complex_types_proxy_is_inverse_of_unproxy() { + assert_proxy_invertible!([32; 4], [usize; 4]); + assert_proxy_invertible!( + core::array::from_fn::<_, 4, _>(|_| vec![Test("test")]), + [Vec::>; 4] + ); assert_proxy_invertible!(Vec::::default(), Vec::); assert_proxy_invertible!(Some(Test("test")), Option::>); assert_proxy_invertible!(None::, Option::>); diff --git a/crates/languages/bevy_mod_scripting_lua/Cargo.toml b/crates/languages/bevy_mod_scripting_lua/Cargo.toml index 86517184..a1125484 100644 --- a/crates/languages/bevy_mod_scripting_lua/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_lua/Cargo.toml @@ -51,3 +51,4 @@ tealr = { version = "0.9", features = [ parking_lot = "0.12.1" serde_json = "1.0.81" anyhow = "1.0.75" +smol_str = "0.2" diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs index a15b602a..221180d7 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs @@ -4,7 +4,16 @@ #![cfg_attr(rustfmt, rustfmt_skip)] use super::bevy_ecs::*; use super::bevy_reflect::*; -use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + IdentityProxy, + }, + RegisterLuaProxy, +}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::core::prelude::Name", @@ -12,14 +21,22 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &name::Name) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::core::prelude::Name; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -29,7 +46,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaName {} +pub struct Name {} #[derive(Default)] pub(crate) struct Globals; impl crate::tealr::mlu::ExportInstances for Globals { @@ -50,7 +67,7 @@ fn bevy_core_context_initializer( pub struct BevyCoreScriptingPlugin; impl bevy::app::Plugin for BevyCoreScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { - app.register_foreign_lua_type::(); + app.register_proxy::(); app.add_context_initializer::<()>(bevy_core_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs index a28e9594..e6c3afd9 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs @@ -3,7 +3,16 @@ #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] use super::bevy_reflect::*; -use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + IdentityProxy, + }, + RegisterLuaProxy, +}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::ecs::entity::Entity", @@ -12,7 +21,9 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::ecs::entity::Entity; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -27,7 +38,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// a component. #[lua()] - fn from_raw(index: u32) -> bevy::ecs::entity::Entity; + fn from_raw(index: u32) -> LuaReflectValProxy; "#, r#" @@ -37,7 +48,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// No particular structure is guaranteed for the returned bits. #[lua()] - fn to_bits(self) -> u64; + fn to_bits(_self: LuaReflectValProxy) -> u64; "#, r#" @@ -47,7 +58,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// This method will likely panic if given `u64` values that did not come from [`Entity::to_bits`]. #[lua()] - fn from_bits(bits: u64) -> bevy::ecs::entity::Entity; + fn from_bits(bits: u64) -> LuaReflectValProxy; "#, r#" @@ -57,7 +68,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// specific snapshot of the world, such as when serializing. #[lua()] - fn index(self) -> u32; + fn index(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -66,13 +77,19 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// given index has been reused (index, generation) pairs uniquely identify a given Entity. #[lua()] - fn generation(self) -> u32; + fn generation(_self: LuaReflectValProxy) -> u32; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &entity::Entity) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -82,7 +99,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaEntity {} +pub struct Entity {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::ecs::component::ComponentId", @@ -91,13 +108,21 @@ pub struct LuaEntity {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::ecs::component::ComponentId; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &component::ComponentId) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -106,20 +131,22 @@ pub struct LuaEntity {} /// Usually, this value is taken from a counter incremented for each type of component registered with the world. #[lua()] - fn new(index: usize) -> bevy::ecs::component::ComponentId; + fn new(index: usize) -> LuaReflectValProxy; "#, r#" /// Returns the index of the current component. #[lua()] - fn index(self) -> usize; + fn index(_self: LuaReflectValProxy) -> usize; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -129,7 +156,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaComponentId(); +pub struct ComponentId(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::ecs::component::Tick", @@ -137,35 +164,43 @@ pub struct LuaComponentId(); bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &component::Tick) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::ecs::component::Tick; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new [`Tick`] wrapping the given value. #[lua()] - fn new(tick: u32) -> bevy::ecs::component::Tick; + fn new(tick: u32) -> LuaReflectValProxy; "#, r#" /// Gets the value of this change tick. #[lua()] - fn get(self) -> u32; + fn get(_self: LuaReflectValProxy) -> u32; "#, r#" /// Sets the value of this change tick. #[lua()] - fn set(&mut self, tick: u32) -> (); + fn set(_self: LuaReflectRefMutProxy, tick: u32) -> (); "#, r#" @@ -174,18 +209,18 @@ pub struct LuaComponentId(); #[lua()] fn is_newer_than( - self, - #[proxy] - last_run: bevy::ecs::component::Tick, - #[proxy] - this_run: bevy::ecs::component::Tick, + _self: LuaReflectValProxy, + last_run: LuaReflectValProxy, + this_run: LuaReflectValProxy, ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -195,7 +230,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaTick {} +pub struct Tick {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::ecs::component::ComponentTicks", @@ -204,7 +239,9 @@ pub struct LuaTick {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::ecs::component::ComponentTicks; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -212,11 +249,9 @@ pub struct LuaTick {} #[lua()] fn is_added( - &self, - #[proxy] - last_run: bevy::ecs::component::Tick, - #[proxy] - this_run: bevy::ecs::component::Tick, + _self: LuaReflectRefProxy, + last_run: LuaReflectValProxy, + this_run: LuaReflectValProxy, ) -> bool; "#, @@ -225,11 +260,9 @@ pub struct LuaTick {} #[lua()] fn is_changed( - &self, - #[proxy] - last_run: bevy::ecs::component::Tick, - #[proxy] - this_run: bevy::ecs::component::Tick, + _self: LuaReflectRefProxy, + last_run: LuaReflectValProxy, + this_run: LuaReflectValProxy, ) -> bool; "#, @@ -237,14 +270,18 @@ pub struct LuaTick {} /// Returns the tick recording the time this component or resource was most recently changed. #[lua()] - fn last_changed_tick(&self) -> bevy::ecs::component::Tick; + fn last_changed_tick( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the tick recording the time this component or resource was added. #[lua()] - fn added_tick(&self) -> bevy::ecs::component::Tick; + fn added_tick( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -261,7 +298,10 @@ pub struct LuaTick {} /// ``` #[lua()] - fn set_changed(&mut self, #[proxy] change_tick: bevy::ecs::component::Tick) -> (); + fn set_changed( + _self: LuaReflectRefMutProxy, + change_tick: LuaReflectValProxy, + ) -> (); "#, r#" @@ -271,7 +311,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaComponentTicks {} +pub struct ComponentTicks {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::ecs::entity::EntityHash", @@ -280,11 +320,13 @@ pub struct LuaComponentTicks {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::ecs::entity::EntityHash; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#] )] -pub struct LuaEntityHash {} +pub struct EntityHash {} #[derive(Default)] pub(crate) struct Globals; impl crate::tealr::mlu::ExportInstances for Globals { @@ -314,11 +356,11 @@ fn bevy_ecs_context_initializer( pub struct BevyEcsScriptingPlugin; impl bevy::app::Plugin for BevyEcsScriptingPlugin { fn build(&self, app: &mut bevy::prelude::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_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); app.add_context_initializer::<()>(bevy_ecs_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs index d099d3fc..f5f05d58 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs @@ -5,7 +5,16 @@ use super::bevy_ecs::*; use super::bevy_reflect::*; use super::bevy_core::*; -use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + IdentityProxy, + }, + RegisterLuaProxy, +}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::hierarchy::prelude::Children", @@ -15,7 +24,11 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// Swaps the child at `a_index` with the child at `b_index`. #[lua()] - fn swap(&mut self, a_index: usize, b_index: usize) -> (); + fn swap( + _self: LuaReflectRefMutProxy, + a_index: usize, + b_index: usize, + ) -> (); "#, r#" @@ -25,7 +38,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaChildren(); +pub struct Children(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::hierarchy::prelude::Parent", @@ -33,21 +46,22 @@ pub struct LuaChildren(); bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &components::parent::Parent) -> bool; - -"#, - r#" -/// Gets the [`Entity`] ID of the parent. - - #[lua()] - fn get(&self) -> bevy::ecs::entity::Entity; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -57,7 +71,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaParent(); +pub struct Parent(); #[derive(Default)] pub(crate) struct Globals; impl crate::tealr::mlu::ExportInstances for Globals { @@ -78,8 +92,8 @@ fn bevy_hierarchy_context_initializer( pub struct BevyHierarchyScriptingPlugin; impl bevy::app::Plugin for BevyHierarchyScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); + app.register_proxy::(); + app.register_proxy::(); app.add_context_initializer::<()>(bevy_hierarchy_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs index 05a55fe4..d8f80021 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs @@ -4,7 +4,16 @@ #![cfg_attr(rustfmt, rustfmt_skip)] use super::bevy_ecs::*; use super::bevy_reflect::*; -use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + IdentityProxy, + }, + RegisterLuaProxy, +}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::Gamepad", @@ -14,19 +23,35 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// Creates a new [`Gamepad`]. #[lua()] - fn new(id: usize) -> bevy::input::gamepad::Gamepad; + fn new(id: usize) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::Gamepad; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -36,7 +61,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepad { +pub struct Gamepad { id: usize, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -47,19 +72,29 @@ pub struct LuaGamepad { functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::GamepadAxis; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &gamepad::GamepadAxis) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -76,11 +111,9 @@ pub struct LuaGamepad { #[lua()] fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - axis_type: bevy::input::gamepad::GamepadAxisType, - ) -> bevy::input::gamepad::GamepadAxis; + gamepad: LuaReflectValProxy, + axis_type: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -90,10 +123,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepadAxis { - #[lua(output(proxy))] +pub struct GamepadAxis { gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] axis_type: bevy::input::gamepad::GamepadAxisType, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -104,19 +135,29 @@ pub struct LuaGamepadAxis { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::GamepadAxisType; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &gamepad::GamepadAxisType) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -126,7 +167,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepadAxisType {} +pub struct GamepadAxisType {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadButton", @@ -146,29 +187,37 @@ pub struct LuaGamepadAxisType {} #[lua()] fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - button_type: bevy::input::gamepad::GamepadButtonType, - ) -> bevy::input::gamepad::GamepadButton; + gamepad: LuaReflectValProxy, + button_type: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &gamepad::GamepadButton) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::GamepadButton; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -178,10 +227,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepadButton { - #[lua(output(proxy))] +pub struct GamepadButton { gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] button_type: bevy::input::gamepad::GamepadButtonType, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -192,19 +239,29 @@ pub struct LuaGamepadButton { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &gamepad::GamepadButtonType) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonType; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -214,7 +271,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepadButtonType {} +pub struct GamepadButtonType {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::keyboard::KeyCode", @@ -223,19 +280,29 @@ pub struct LuaGamepadButtonType {} functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::keyboard::KeyCode; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &keyboard::KeyCode) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -245,7 +312,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaKeyCode {} +pub struct KeyCode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::mouse::MouseButton", @@ -254,19 +321,29 @@ pub struct LuaKeyCode {} functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::mouse::MouseButton; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &mouse::MouseButton) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -276,7 +353,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaMouseButton {} +pub struct MouseButton {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::touch::TouchInput", @@ -285,13 +362,21 @@ pub struct LuaMouseButton {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::touch::TouchInput; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &touch::TouchInput) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -301,14 +386,11 @@ fn index(&self) -> String { } "#] )] -pub struct LuaTouchInput { - #[lua(output(proxy))] +pub struct TouchInput { phase: bevy::input::touch::TouchPhase, - #[lua(output(proxy))] - position: bevy::math::Vec2, - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - force: ReflectedValue, + position: ReflectReference, + window: ReflectReference, + force: ReflectReference, id: u64, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -319,19 +401,29 @@ pub struct LuaTouchInput { functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::keyboard::Key; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &keyboard::Key) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -341,7 +433,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaKey {} +pub struct Key {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::keyboard::KeyboardInput", @@ -349,20 +441,30 @@ pub struct LuaKey {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &keyboard::KeyboardInput) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::keyboard::KeyboardInput; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -372,15 +474,11 @@ fn index(&self) -> String { } "#] )] -pub struct LuaKeyboardInput { - #[lua(output(proxy))] +pub struct KeyboardInput { key_code: bevy::input::keyboard::KeyCode, - #[lua(output(proxy))] logical_key: bevy::input::keyboard::Key, - #[lua(output(proxy))] state: bevy::input::ButtonState, - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, + window: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -390,19 +488,29 @@ pub struct LuaKeyboardInput { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &keyboard::NativeKey) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::keyboard::NativeKey; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -412,7 +520,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNativeKey {} +pub struct NativeKey {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::keyboard::NativeKeyCode", @@ -420,20 +528,30 @@ pub struct LuaNativeKey {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &keyboard::NativeKeyCode) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::keyboard::NativeKeyCode; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -443,7 +561,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNativeKeyCode {} +pub struct NativeKeyCode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::mouse::MouseButtonInput", @@ -451,20 +569,30 @@ pub struct LuaNativeKeyCode {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &mouse::MouseButtonInput) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::mouse::MouseButtonInput; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -474,13 +602,10 @@ fn index(&self) -> String { } "#] )] -pub struct LuaMouseButtonInput { - #[lua(output(proxy))] +pub struct MouseButtonInput { button: bevy::input::mouse::MouseButton, - #[lua(output(proxy))] state: bevy::input::ButtonState, - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, + window: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -489,14 +614,22 @@ pub struct LuaMouseButtonInput { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &mouse::MouseMotion) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::mouse::MouseMotion; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -506,9 +639,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaMouseMotion { - #[lua(output(proxy))] - delta: bevy::math::Vec2, +pub struct MouseMotion { + delta: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -517,20 +649,30 @@ pub struct LuaMouseMotion { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &mouse::MouseScrollUnit) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::mouse::MouseScrollUnit; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -540,7 +682,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaMouseScrollUnit {} +pub struct MouseScrollUnit {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::mouse::MouseWheel", @@ -549,13 +691,21 @@ pub struct LuaMouseScrollUnit {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::mouse::MouseWheel; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &mouse::MouseWheel) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -565,13 +715,11 @@ fn index(&self) -> String { } "#] )] -pub struct LuaMouseWheel { - #[lua(output(proxy))] +pub struct MouseWheel { unit: bevy::input::mouse::MouseScrollUnit, x: f32, y: f32, - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, + window: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -580,14 +728,22 @@ pub struct LuaMouseWheel { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &touch::ForceTouch) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::touch::ForceTouch; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -597,7 +753,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaForceTouch {} +pub struct ForceTouch {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::touch::TouchPhase", @@ -605,20 +761,30 @@ pub struct LuaForceTouch {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &touch::TouchPhase) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::touch::TouchPhase; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -628,7 +794,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaTouchPhase {} +pub struct TouchPhase {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::touchpad::TouchpadMagnify", @@ -636,14 +802,22 @@ pub struct LuaTouchPhase {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &touchpad::TouchpadMagnify) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::touchpad::TouchpadMagnify; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -653,7 +827,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaTouchpadMagnify(f32); +pub struct TouchpadMagnify(f32); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::touchpad::TouchpadRotate", @@ -661,14 +835,22 @@ pub struct LuaTouchpadMagnify(f32); bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &touchpad::TouchpadRotate) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::touchpad::TouchpadRotate; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -678,7 +860,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaTouchpadRotate(f32); +pub struct TouchpadRotate(f32); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::AxisSettings", @@ -688,7 +870,9 @@ pub struct LuaTouchpadRotate(f32); /// Get the value above which inputs will be rounded up to 1.0. #[lua()] - fn livezone_upperbound(&self) -> f32; + fn livezone_upperbound( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -698,14 +882,19 @@ pub struct LuaTouchpadRotate(f32); /// Returns the new value of `livezone_upperbound`. #[lua()] - fn set_livezone_upperbound(&mut self, value: f32) -> f32; + fn set_livezone_upperbound( + _self: LuaReflectRefMutProxy, + value: f32, + ) -> f32; "#, r#" /// Get the value below which positive inputs will be rounded down to 0.0. #[lua()] - fn deadzone_upperbound(&self) -> f32; + fn deadzone_upperbound( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -715,14 +904,19 @@ pub struct LuaTouchpadRotate(f32); /// Returns the new value of `deadzone_upperbound`. #[lua()] - fn set_deadzone_upperbound(&mut self, value: f32) -> f32; + fn set_deadzone_upperbound( + _self: LuaReflectRefMutProxy, + value: f32, + ) -> f32; "#, r#" /// Get the value below which negative inputs will be rounded down to -1.0. #[lua()] - fn livezone_lowerbound(&self) -> f32; + fn livezone_lowerbound( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -732,14 +926,19 @@ pub struct LuaTouchpadRotate(f32); /// Returns the new value of `livezone_lowerbound`. #[lua()] - fn set_livezone_lowerbound(&mut self, value: f32) -> f32; + fn set_livezone_lowerbound( + _self: LuaReflectRefMutProxy, + value: f32, + ) -> f32; "#, r#" /// Get the value above which inputs will be rounded up to 0.0. #[lua()] - fn deadzone_lowerbound(&self) -> f32; + fn deadzone_lowerbound( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -749,14 +948,17 @@ pub struct LuaTouchpadRotate(f32); /// Returns the new value of `deadzone_lowerbound`. #[lua()] - fn set_deadzone_lowerbound(&mut self, value: f32) -> f32; + fn set_deadzone_lowerbound( + _self: LuaReflectRefMutProxy, + value: f32, + ) -> f32; "#, r#" /// Get the minimum value by which input must change before the change is registered. #[lua()] - fn threshold(&self) -> f32; + fn threshold(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -765,14 +967,20 @@ pub struct LuaTouchpadRotate(f32); /// Returns the new value of threshold. #[lua()] - fn set_threshold(&mut self, value: f32) -> f32; + fn set_threshold( + _self: LuaReflectRefMutProxy, + value: f32, + ) -> f32; "#, r#" /// Clamps the `raw_value` according to the `AxisSettings`. #[lua()] - fn clamp(&self, new_value: f32) -> f32; + fn clamp( + _self: LuaReflectRefProxy, + new_value: f32, + ) -> f32; "#, r#" @@ -782,7 +990,7 @@ pub struct LuaTouchpadRotate(f32); #[lua()] fn filter( - &self, + _self: LuaReflectRefProxy, new_value: f32, old_value: std::option::Option, ) -> std::option::Option; @@ -791,13 +999,21 @@ pub struct LuaTouchpadRotate(f32); r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::AxisSettings; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &gamepad::AxisSettings) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -807,7 +1023,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaAxisSettings {} +pub struct AxisSettings {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::ButtonAxisSettings", @@ -816,7 +1032,9 @@ pub struct LuaAxisSettings {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::ButtonAxisSettings; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -826,7 +1044,7 @@ pub struct LuaAxisSettings {} #[lua()] fn filter( - &self, + _self: LuaReflectRefProxy, new_value: f32, old_value: std::option::Option, ) -> std::option::Option; @@ -839,7 +1057,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaButtonAxisSettings { +pub struct ButtonAxisSettings { high: f32, low: f32, threshold: f32, @@ -852,7 +1070,9 @@ pub struct LuaButtonAxisSettings { functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::ButtonSettings; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -860,7 +1080,10 @@ pub struct LuaButtonAxisSettings { /// A button is considered pressed if the `value` passed is greater than or equal to the press threshold. #[lua()] - fn is_pressed(&self, value: f32) -> bool; + fn is_pressed( + _self: LuaReflectRefProxy, + value: f32, + ) -> bool; "#, r#" @@ -868,14 +1091,19 @@ pub struct LuaButtonAxisSettings { /// A button is considered released if the `value` passed is lower than or equal to the release threshold. #[lua()] - fn is_released(&self, value: f32) -> bool; + fn is_released( + _self: LuaReflectRefProxy, + value: f32, + ) -> bool; "#, r#" /// Get the button input threshold above which the button is considered pressed. #[lua()] - fn press_threshold(&self) -> f32; + fn press_threshold( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -884,14 +1112,19 @@ pub struct LuaButtonAxisSettings { /// Returns the new value of the press threshold. #[lua()] - fn set_press_threshold(&mut self, value: f32) -> f32; + fn set_press_threshold( + _self: LuaReflectRefMutProxy, + value: f32, + ) -> f32; "#, r#" /// Get the button input threshold below which the button is considered released. #[lua()] - fn release_threshold(&self) -> f32; + fn release_threshold( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -900,7 +1133,10 @@ pub struct LuaButtonAxisSettings { /// Returns the new value of the release threshold. #[lua()] - fn set_release_threshold(&mut self, value: f32) -> f32; + fn set_release_threshold( + _self: LuaReflectRefMutProxy, + value: f32, + ) -> f32; "#, r#" @@ -910,7 +1146,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaButtonSettings {} +pub struct ButtonSettings {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadAxisChangedEvent", @@ -919,7 +1155,9 @@ pub struct LuaButtonSettings {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::GamepadAxisChangedEvent; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -927,18 +1165,22 @@ pub struct LuaButtonSettings {} #[lua()] fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - axis_type: bevy::input::gamepad::GamepadAxisType, + gamepad: LuaReflectValProxy, + axis_type: LuaReflectValProxy, value: f32, - ) -> bevy::input::gamepad::GamepadAxisChangedEvent; + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &gamepad::GamepadAxisChangedEvent) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -948,10 +1190,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepadAxisChangedEvent { - #[lua(output(proxy))] +pub struct GamepadAxisChangedEvent { gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] axis_type: bevy::input::gamepad::GamepadAxisType, value: f32, } @@ -965,24 +1205,30 @@ pub struct LuaGamepadAxisChangedEvent { #[lua()] fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - button_type: bevy::input::gamepad::GamepadButtonType, + gamepad: LuaReflectValProxy, + button_type: LuaReflectValProxy, value: f32, - ) -> bevy::input::gamepad::GamepadButtonChangedEvent; + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonChangedEvent; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &gamepad::GamepadButtonChangedEvent) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -992,10 +1238,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepadButtonChangedEvent { - #[lua(output(proxy))] +pub struct GamepadButtonChangedEvent { gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] button_type: bevy::input::gamepad::GamepadButtonType, value: f32, } @@ -1007,19 +1251,29 @@ pub struct LuaGamepadButtonChangedEvent { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &gamepad::GamepadButtonInput) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonInput; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1029,10 +1283,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepadButtonInput { - #[lua(output(proxy))] +pub struct GamepadButtonInput { button: bevy::input::gamepad::GamepadButton, - #[lua(output(proxy))] state: bevy::input::ButtonState, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -1042,14 +1294,22 @@ pub struct LuaGamepadButtonInput { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &gamepad::GamepadConnection) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::GamepadConnection; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1059,7 +1319,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepadConnection {} +pub struct GamepadConnection {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadConnectionEvent", @@ -1070,37 +1330,47 @@ pub struct LuaGamepadConnection {} #[lua()] fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - connection: bevy::input::gamepad::GamepadConnection, - ) -> bevy::input::gamepad::GamepadConnectionEvent; + gamepad: LuaReflectValProxy, + connection: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Is the gamepad connected? #[lua()] - fn connected(&self) -> bool; + fn connected( + _self: LuaReflectRefProxy, + ) -> bool; "#, r#" /// Is the gamepad disconnected? #[lua()] - fn disconnected(&self) -> bool; + fn disconnected( + _self: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &gamepad::GamepadConnectionEvent) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::GamepadConnectionEvent; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1110,10 +1380,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepadConnectionEvent { - #[lua(output(proxy))] +pub struct GamepadConnectionEvent { gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] connection: bevy::input::gamepad::GamepadConnection, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -1123,14 +1391,22 @@ pub struct LuaGamepadConnectionEvent { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &gamepad::GamepadEvent) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::GamepadEvent; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1140,7 +1416,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepadEvent {} +pub struct GamepadEvent {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadSettings", @@ -1153,16 +1429,13 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepadSettings { - #[lua(output(proxy))] +pub struct GamepadSettings { default_button_settings: bevy::input::gamepad::ButtonSettings, - #[lua(output(proxy))] default_axis_settings: bevy::input::gamepad::AxisSettings, - #[lua(output(proxy))] default_button_axis_settings: bevy::input::gamepad::ButtonAxisSettings, - button_settings: ReflectedValue, - axis_settings: ReflectedValue, - button_axis_settings: ReflectedValue, + button_settings: ReflectReference, + axis_settings: ReflectReference, + button_axis_settings: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -1173,25 +1446,35 @@ pub struct LuaGamepadSettings { /// Is this button pressed? #[lua()] - fn is_pressed(&self) -> bool; + fn is_pressed(_self: LuaReflectRefProxy) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &ButtonState) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::ButtonState; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1201,7 +1484,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaButtonState {} +pub struct ButtonState {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::input::gamepad::GamepadInfo", @@ -1209,20 +1492,30 @@ pub struct LuaButtonState {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &gamepad::GamepadInfo) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::input::gamepad::GamepadInfo; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -1232,7 +1525,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGamepadInfo { +pub struct GamepadInfo { name: std::string::String, } #[derive(Default)] @@ -1285,40 +1578,38 @@ fn bevy_input_context_initializer( pub struct BevyInputScriptingPlugin; impl bevy::app::Plugin for BevyInputScriptingPlugin { fn build(&self, app: &mut bevy::prelude::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::(); - 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::< - bevy::input::gamepad::GamepadButtonChangedEvent, - >(); - 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_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); app.add_context_initializer::<()>(bevy_input_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs index 9543f7b7..5f494521 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs @@ -2,7 +2,16 @@ #![allow(clippy::all)] #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] -use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + IdentityProxy, + }, + RegisterLuaProxy, +}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::utils::Duration", @@ -10,44 +19,63 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: u32) -> bevy::utils::Duration; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: u32) -> bevy::utils::Duration; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_utils::Duration) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::utils::Duration; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -65,7 +93,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn new(secs: u64, nanos: u32) -> bevy::utils::Duration; + fn new(secs: u64, nanos: u32) -> LuaReflectValProxy; "#, r#" @@ -79,7 +107,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn from_secs(secs: u64) -> bevy::utils::Duration; + fn from_secs(secs: u64) -> LuaReflectValProxy; "#, r#" @@ -93,7 +121,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn from_millis(millis: u64) -> bevy::utils::Duration; + fn from_millis(millis: u64) -> LuaReflectValProxy; "#, r#" @@ -107,7 +135,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn from_micros(micros: u64) -> bevy::utils::Duration; + fn from_micros(micros: u64) -> LuaReflectValProxy; "#, r#" @@ -121,7 +149,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn from_nanos(nanos: u64) -> bevy::utils::Duration; + fn from_nanos(nanos: u64) -> LuaReflectValProxy; "#, r#" @@ -139,7 +167,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn is_zero(&self) -> bool; + fn is_zero(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -159,7 +187,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// [`subsec_nanos`]: Duration::subsec_nanos #[lua()] - fn as_secs(&self) -> u64; + fn as_secs(_self: LuaReflectRefProxy) -> u64; "#, r#" @@ -176,7 +204,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn subsec_millis(&self) -> u32; + fn subsec_millis(_self: LuaReflectRefProxy) -> u32; "#, r#" @@ -193,7 +221,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn subsec_micros(&self) -> u32; + fn subsec_micros(_self: LuaReflectRefProxy) -> u32; "#, r#" @@ -210,7 +238,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn subsec_nanos(&self) -> u32; + fn subsec_nanos(_self: LuaReflectRefProxy) -> u32; "#, r#" @@ -223,7 +251,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn as_millis(&self) -> u128; + fn as_millis(_self: LuaReflectRefProxy) -> u128; "#, r#" @@ -236,7 +264,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn as_micros(&self) -> u128; + fn as_micros(_self: LuaReflectRefProxy) -> u128; "#, r#" @@ -249,7 +277,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn as_nanos(&self) -> u128; + fn as_nanos(_self: LuaReflectRefProxy) -> u128; "#, r#" @@ -265,10 +293,9 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; #[lua()] fn saturating_add( - self, - #[proxy] - rhs: bevy::utils::Duration, - ) -> bevy::utils::Duration; + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -283,10 +310,9 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; #[lua()] fn saturating_sub( - self, - #[proxy] - rhs: bevy::utils::Duration, - ) -> bevy::utils::Duration; + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -301,7 +327,10 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn saturating_mul(self, rhs: u32) -> bevy::utils::Duration; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" @@ -315,7 +344,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn as_secs_f64(&self) -> f64; + fn as_secs_f64(_self: LuaReflectRefProxy) -> f64; "#, r#" @@ -329,7 +358,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn as_secs_f32(&self) -> f32; + fn as_secs_f32(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -359,7 +388,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn from_secs_f64(secs: f64) -> bevy::utils::Duration; + fn from_secs_f64(secs: f64) -> LuaReflectValProxy; "#, r#" @@ -389,7 +418,7 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn from_secs_f32(secs: f32) -> bevy::utils::Duration; + fn from_secs_f32(secs: f32) -> LuaReflectValProxy; "#, r#" @@ -405,7 +434,10 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn mul_f64(self, rhs: f64) -> bevy::utils::Duration; + fn mul_f64( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -421,7 +453,10 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn mul_f32(self, rhs: f32) -> bevy::utils::Duration; + fn mul_f32( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -437,7 +472,10 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn div_f64(self, rhs: f64) -> bevy::utils::Duration; + fn div_f64( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -455,7 +493,10 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// ``` #[lua()] - fn div_f32(self, rhs: f32) -> bevy::utils::Duration; + fn div_f32( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -465,7 +506,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaDuration {} +pub struct Duration {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::utils::Instant", @@ -476,32 +517,45 @@ pub struct LuaDuration {} /// This function may panic if the resulting point in time cannot be represented by the /// underlying data structure. See [`Instant::checked_add`] for a version without panic. - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_utils::Instant) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::utils::Instant; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -513,7 +567,7 @@ pub struct LuaDuration {} /// ``` #[lua()] - fn now() -> bevy::utils::Instant; + fn now() -> LuaReflectValProxy; "#, r#" @@ -537,10 +591,9 @@ pub struct LuaDuration {} #[lua()] fn duration_since( - &self, - #[proxy] - earlier: bevy::utils::Instant, - ) -> bevy::utils::Duration; + _self: LuaReflectRefProxy, + earlier: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -559,10 +612,9 @@ pub struct LuaDuration {} #[lua()] fn saturating_duration_since( - &self, - #[proxy] - earlier: bevy::utils::Instant, - ) -> bevy::utils::Duration; + _self: LuaReflectRefProxy, + earlier: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -583,7 +635,9 @@ pub struct LuaDuration {} /// ``` #[lua()] - fn elapsed(&self) -> bevy::utils::Duration; + fn elapsed( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -595,8 +649,11 @@ pub struct LuaDuration {} /// See [Monotonicity]. /// [Monotonicity]: Instant#monotonicity - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] other: bevy::utils::Instant) -> bevy::utils::Duration; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -606,7 +663,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaInstant(); +pub struct Instant(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroI128", @@ -615,7 +672,9 @@ pub struct LuaInstant(); functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::num::NonZeroI128; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -625,14 +684,14 @@ pub struct LuaInstant(); /// The value must not be zero. #[lua()] - unsafe fn new_unchecked(n: i128) -> std::num::NonZeroI128; + unsafe fn new_unchecked(n: i128) -> LuaReflectValProxy; "#, r#" /// Returns the value as a primitive type. #[lua()] - fn get(self) -> i128; + fn get(_self: LuaReflectValProxy) -> i128; "#, r#" @@ -646,7 +705,7 @@ pub struct LuaInstant(); /// ``` #[lua()] - fn leading_zeros(self) -> u32; + fn leading_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -661,7 +720,7 @@ pub struct LuaInstant(); /// ``` #[lua()] - fn trailing_zeros(self) -> u32; + fn trailing_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -682,7 +741,9 @@ pub struct LuaInstant(); /// ``` #[lua()] - fn abs(self) -> std::num::NonZeroI128; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -707,7 +768,9 @@ pub struct LuaInstant(); /// ``` #[lua()] - fn saturating_abs(self) -> std::num::NonZeroI128; + fn saturating_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -731,7 +794,9 @@ pub struct LuaInstant(); /// ``` #[lua()] - fn wrapping_abs(self) -> std::num::NonZeroI128; + fn wrapping_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -756,7 +821,9 @@ pub struct LuaInstant(); /// ``` #[lua()] - fn unsigned_abs(self) -> std::num::NonZeroU128; + fn unsigned_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -776,7 +843,7 @@ pub struct LuaInstant(); /// ``` #[lua()] - fn is_positive(self) -> bool; + fn is_positive(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -796,7 +863,7 @@ pub struct LuaInstant(); /// ``` #[lua()] - fn is_negative(self) -> bool; + fn is_negative(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -822,7 +889,9 @@ pub struct LuaInstant(); /// ``` #[lua()] - fn saturating_neg(self) -> std::num::NonZeroI128; + fn saturating_neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -845,7 +914,9 @@ pub struct LuaInstant(); /// ``` #[lua()] - fn wrapping_neg(self) -> std::num::NonZeroI128; + fn wrapping_neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -867,10 +938,9 @@ pub struct LuaInstant(); #[lua()] fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroI128, - ) -> std::num::NonZeroI128; + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -891,25 +961,35 @@ pub struct LuaInstant(); /// ``` #[lua()] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI128; + fn saturating_pow( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::num::NonZeroI128) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> std::num::NonZeroI128; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -919,7 +999,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNonZeroI128(); +pub struct NonZeroI128(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroI16", @@ -927,20 +1007,27 @@ pub struct LuaNonZeroI128(); bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::num::NonZeroI16) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::num::NonZeroI16; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -950,14 +1037,14 @@ pub struct LuaNonZeroI128(); /// The value must not be zero. #[lua()] - unsafe fn new_unchecked(n: i16) -> std::num::NonZeroI16; + unsafe fn new_unchecked(n: i16) -> LuaReflectValProxy; "#, r#" /// Returns the value as a primitive type. #[lua()] - fn get(self) -> i16; + fn get(_self: LuaReflectValProxy) -> i16; "#, r#" @@ -971,7 +1058,7 @@ pub struct LuaNonZeroI128(); /// ``` #[lua()] - fn leading_zeros(self) -> u32; + fn leading_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -986,7 +1073,7 @@ pub struct LuaNonZeroI128(); /// ``` #[lua()] - fn trailing_zeros(self) -> u32; + fn trailing_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -1007,7 +1094,9 @@ pub struct LuaNonZeroI128(); /// ``` #[lua()] - fn abs(self) -> std::num::NonZeroI16; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1032,7 +1121,9 @@ pub struct LuaNonZeroI128(); /// ``` #[lua()] - fn saturating_abs(self) -> std::num::NonZeroI16; + fn saturating_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1056,7 +1147,9 @@ pub struct LuaNonZeroI128(); /// ``` #[lua()] - fn wrapping_abs(self) -> std::num::NonZeroI16; + fn wrapping_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1081,7 +1174,9 @@ pub struct LuaNonZeroI128(); /// ``` #[lua()] - fn unsigned_abs(self) -> std::num::NonZeroU16; + fn unsigned_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1101,7 +1196,7 @@ pub struct LuaNonZeroI128(); /// ``` #[lua()] - fn is_positive(self) -> bool; + fn is_positive(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -1121,7 +1216,7 @@ pub struct LuaNonZeroI128(); /// ``` #[lua()] - fn is_negative(self) -> bool; + fn is_negative(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -1147,7 +1242,9 @@ pub struct LuaNonZeroI128(); /// ``` #[lua()] - fn saturating_neg(self) -> std::num::NonZeroI16; + fn saturating_neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1170,7 +1267,9 @@ pub struct LuaNonZeroI128(); /// ``` #[lua()] - fn wrapping_neg(self) -> std::num::NonZeroI16; + fn wrapping_neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1192,10 +1291,9 @@ pub struct LuaNonZeroI128(); #[lua()] fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroI16, - ) -> std::num::NonZeroI16; + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1216,13 +1314,18 @@ pub struct LuaNonZeroI128(); /// ``` #[lua()] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI16; + fn saturating_pow( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> std::num::NonZeroI16; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1232,7 +1335,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNonZeroI16(); +pub struct NonZeroI16(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroI32", @@ -1241,7 +1344,9 @@ pub struct LuaNonZeroI16(); functions[r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> std::num::NonZeroI32; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1251,14 +1356,14 @@ pub struct LuaNonZeroI16(); /// The value must not be zero. #[lua()] - unsafe fn new_unchecked(n: i32) -> std::num::NonZeroI32; + unsafe fn new_unchecked(n: i32) -> LuaReflectValProxy; "#, r#" /// Returns the value as a primitive type. #[lua()] - fn get(self) -> i32; + fn get(_self: LuaReflectValProxy) -> i32; "#, r#" @@ -1272,7 +1377,7 @@ pub struct LuaNonZeroI16(); /// ``` #[lua()] - fn leading_zeros(self) -> u32; + fn leading_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -1287,7 +1392,7 @@ pub struct LuaNonZeroI16(); /// ``` #[lua()] - fn trailing_zeros(self) -> u32; + fn trailing_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -1308,7 +1413,9 @@ pub struct LuaNonZeroI16(); /// ``` #[lua()] - fn abs(self) -> std::num::NonZeroI32; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1333,7 +1440,9 @@ pub struct LuaNonZeroI16(); /// ``` #[lua()] - fn saturating_abs(self) -> std::num::NonZeroI32; + fn saturating_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1357,7 +1466,9 @@ pub struct LuaNonZeroI16(); /// ``` #[lua()] - fn wrapping_abs(self) -> std::num::NonZeroI32; + fn wrapping_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1382,7 +1493,9 @@ pub struct LuaNonZeroI16(); /// ``` #[lua()] - fn unsigned_abs(self) -> std::num::NonZeroU32; + fn unsigned_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1402,7 +1515,7 @@ pub struct LuaNonZeroI16(); /// ``` #[lua()] - fn is_positive(self) -> bool; + fn is_positive(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -1422,7 +1535,7 @@ pub struct LuaNonZeroI16(); /// ``` #[lua()] - fn is_negative(self) -> bool; + fn is_negative(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -1448,7 +1561,9 @@ pub struct LuaNonZeroI16(); /// ``` #[lua()] - fn saturating_neg(self) -> std::num::NonZeroI32; + fn saturating_neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1471,7 +1586,9 @@ pub struct LuaNonZeroI16(); /// ``` #[lua()] - fn wrapping_neg(self) -> std::num::NonZeroI32; + fn wrapping_neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1493,10 +1610,9 @@ pub struct LuaNonZeroI16(); #[lua()] fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroI32, - ) -> std::num::NonZeroI32; + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1517,25 +1633,35 @@ pub struct LuaNonZeroI16(); /// ``` #[lua()] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI32; + fn saturating_pow( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::num::NonZeroI32; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::num::NonZeroI32) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -1545,7 +1671,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNonZeroI32(); +pub struct NonZeroI32(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroI64", @@ -1558,14 +1684,14 @@ pub struct LuaNonZeroI32(); /// The value must not be zero. #[lua()] - unsafe fn new_unchecked(n: i64) -> std::num::NonZeroI64; + unsafe fn new_unchecked(n: i64) -> LuaReflectValProxy; "#, r#" /// Returns the value as a primitive type. #[lua()] - fn get(self) -> i64; + fn get(_self: LuaReflectValProxy) -> i64; "#, r#" @@ -1579,7 +1705,7 @@ pub struct LuaNonZeroI32(); /// ``` #[lua()] - fn leading_zeros(self) -> u32; + fn leading_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -1594,7 +1720,7 @@ pub struct LuaNonZeroI32(); /// ``` #[lua()] - fn trailing_zeros(self) -> u32; + fn trailing_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -1615,7 +1741,9 @@ pub struct LuaNonZeroI32(); /// ``` #[lua()] - fn abs(self) -> std::num::NonZeroI64; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1640,7 +1768,9 @@ pub struct LuaNonZeroI32(); /// ``` #[lua()] - fn saturating_abs(self) -> std::num::NonZeroI64; + fn saturating_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1664,7 +1794,9 @@ pub struct LuaNonZeroI32(); /// ``` #[lua()] - fn wrapping_abs(self) -> std::num::NonZeroI64; + fn wrapping_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1689,7 +1821,9 @@ pub struct LuaNonZeroI32(); /// ``` #[lua()] - fn unsigned_abs(self) -> std::num::NonZeroU64; + fn unsigned_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1709,7 +1843,7 @@ pub struct LuaNonZeroI32(); /// ``` #[lua()] - fn is_positive(self) -> bool; + fn is_positive(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -1729,7 +1863,7 @@ pub struct LuaNonZeroI32(); /// ``` #[lua()] - fn is_negative(self) -> bool; + fn is_negative(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -1755,7 +1889,9 @@ pub struct LuaNonZeroI32(); /// ``` #[lua()] - fn saturating_neg(self) -> std::num::NonZeroI64; + fn saturating_neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1778,7 +1914,9 @@ pub struct LuaNonZeroI32(); /// ``` #[lua()] - fn wrapping_neg(self) -> std::num::NonZeroI64; + fn wrapping_neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1800,10 +1938,9 @@ pub struct LuaNonZeroI32(); #[lua()] fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroI64, - ) -> std::num::NonZeroI64; + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1824,31 +1961,43 @@ pub struct LuaNonZeroI32(); /// ``` #[lua()] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI64; + fn saturating_pow( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> std::num::NonZeroI64; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::num::NonZeroI64) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::num::NonZeroI64; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -1858,7 +2007,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNonZeroI64(); +pub struct NonZeroI64(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroI8", @@ -1867,25 +2016,32 @@ pub struct LuaNonZeroI64(); functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> std::num::NonZeroI8; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::num::NonZeroI8) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::num::NonZeroI8; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1895,14 +2051,14 @@ pub struct LuaNonZeroI64(); /// The value must not be zero. #[lua()] - unsafe fn new_unchecked(n: i8) -> std::num::NonZeroI8; + unsafe fn new_unchecked(n: i8) -> LuaReflectValProxy; "#, r#" /// Returns the value as a primitive type. #[lua()] - fn get(self) -> i8; + fn get(_self: LuaReflectValProxy) -> i8; "#, r#" @@ -1916,7 +2072,7 @@ pub struct LuaNonZeroI64(); /// ``` #[lua()] - fn leading_zeros(self) -> u32; + fn leading_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -1931,7 +2087,7 @@ pub struct LuaNonZeroI64(); /// ``` #[lua()] - fn trailing_zeros(self) -> u32; + fn trailing_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -1952,7 +2108,9 @@ pub struct LuaNonZeroI64(); /// ``` #[lua()] - fn abs(self) -> std::num::NonZeroI8; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1977,7 +2135,9 @@ pub struct LuaNonZeroI64(); /// ``` #[lua()] - fn saturating_abs(self) -> std::num::NonZeroI8; + fn saturating_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2001,7 +2161,9 @@ pub struct LuaNonZeroI64(); /// ``` #[lua()] - fn wrapping_abs(self) -> std::num::NonZeroI8; + fn wrapping_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2026,7 +2188,9 @@ pub struct LuaNonZeroI64(); /// ``` #[lua()] - fn unsigned_abs(self) -> std::num::NonZeroU8; + fn unsigned_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2046,7 +2210,7 @@ pub struct LuaNonZeroI64(); /// ``` #[lua()] - fn is_positive(self) -> bool; + fn is_positive(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -2066,7 +2230,7 @@ pub struct LuaNonZeroI64(); /// ``` #[lua()] - fn is_negative(self) -> bool; + fn is_negative(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -2092,7 +2256,9 @@ pub struct LuaNonZeroI64(); /// ``` #[lua()] - fn saturating_neg(self) -> std::num::NonZeroI8; + fn saturating_neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2115,7 +2281,9 @@ pub struct LuaNonZeroI64(); /// ``` #[lua()] - fn wrapping_neg(self) -> std::num::NonZeroI8; + fn wrapping_neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2136,7 +2304,10 @@ pub struct LuaNonZeroI64(); /// ``` #[lua()] - fn saturating_mul(self, #[proxy] other: std::num::NonZeroI8) -> std::num::NonZeroI8; + fn saturating_mul( + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2157,7 +2328,10 @@ pub struct LuaNonZeroI64(); /// ``` #[lua()] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI8; + fn saturating_pow( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" @@ -2167,7 +2341,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNonZeroI8(); +pub struct NonZeroI8(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroU128", @@ -2176,19 +2350,26 @@ pub struct LuaNonZeroI8(); functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::num::NonZeroU128; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::num::NonZeroU128) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -2198,14 +2379,14 @@ pub struct LuaNonZeroI8(); /// The value must not be zero. #[lua()] - unsafe fn new_unchecked(n: u128) -> std::num::NonZeroU128; + unsafe fn new_unchecked(n: u128) -> LuaReflectValProxy; "#, r#" /// Returns the value as a primitive type. #[lua()] - fn get(self) -> u128; + fn get(_self: LuaReflectValProxy) -> u128; "#, r#" @@ -2219,7 +2400,7 @@ pub struct LuaNonZeroI8(); /// ``` #[lua()] - fn leading_zeros(self) -> u32; + fn leading_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2234,7 +2415,7 @@ pub struct LuaNonZeroI8(); /// ``` #[lua()] - fn trailing_zeros(self) -> u32; + fn trailing_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2255,7 +2436,10 @@ pub struct LuaNonZeroI8(); /// ``` #[lua()] - fn saturating_add(self, other: u128) -> std::num::NonZeroU128; + fn saturating_add( + _self: LuaReflectValProxy, + other: u128, + ) -> LuaReflectValProxy; "#, r#" @@ -2273,7 +2457,7 @@ pub struct LuaNonZeroI8(); /// ``` #[lua()] - fn ilog2(self) -> u32; + fn ilog2(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2291,7 +2475,7 @@ pub struct LuaNonZeroI8(); /// ``` #[lua()] - fn ilog10(self) -> u32; + fn ilog10(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2308,7 +2492,7 @@ pub struct LuaNonZeroI8(); /// ``` #[lua()] - fn is_power_of_two(self) -> bool; + fn is_power_of_two(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -2330,10 +2514,9 @@ pub struct LuaNonZeroI8(); #[lua()] fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroU128, - ) -> std::num::NonZeroU128; + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2354,7 +2537,10 @@ pub struct LuaNonZeroI8(); /// ``` #[lua()] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU128; + fn saturating_pow( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" @@ -2364,7 +2550,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNonZeroU128(); +pub struct NonZeroU128(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroU16", @@ -2377,14 +2563,14 @@ pub struct LuaNonZeroU128(); /// The value must not be zero. #[lua()] - unsafe fn new_unchecked(n: u16) -> std::num::NonZeroU16; + unsafe fn new_unchecked(n: u16) -> LuaReflectValProxy; "#, r#" /// Returns the value as a primitive type. #[lua()] - fn get(self) -> u16; + fn get(_self: LuaReflectValProxy) -> u16; "#, r#" @@ -2398,7 +2584,7 @@ pub struct LuaNonZeroU128(); /// ``` #[lua()] - fn leading_zeros(self) -> u32; + fn leading_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2413,7 +2599,7 @@ pub struct LuaNonZeroU128(); /// ``` #[lua()] - fn trailing_zeros(self) -> u32; + fn trailing_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2434,7 +2620,10 @@ pub struct LuaNonZeroU128(); /// ``` #[lua()] - fn saturating_add(self, other: u16) -> std::num::NonZeroU16; + fn saturating_add( + _self: LuaReflectValProxy, + other: u16, + ) -> LuaReflectValProxy; "#, r#" @@ -2452,7 +2641,7 @@ pub struct LuaNonZeroU128(); /// ``` #[lua()] - fn ilog2(self) -> u32; + fn ilog2(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2470,7 +2659,7 @@ pub struct LuaNonZeroU128(); /// ``` #[lua()] - fn ilog10(self) -> u32; + fn ilog10(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2487,7 +2676,7 @@ pub struct LuaNonZeroU128(); /// ``` #[lua()] - fn is_power_of_two(self) -> bool; + fn is_power_of_two(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -2509,10 +2698,9 @@ pub struct LuaNonZeroU128(); #[lua()] fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroU16, - ) -> std::num::NonZeroU16; + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2533,25 +2721,35 @@ pub struct LuaNonZeroU128(); /// ``` #[lua()] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU16; + fn saturating_pow( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::num::NonZeroU16) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::num::NonZeroU16; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2561,7 +2759,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNonZeroU16(); +pub struct NonZeroU16(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroU32", @@ -2569,14 +2767,19 @@ pub struct LuaNonZeroU16(); bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::num::NonZeroU32) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -2586,14 +2789,14 @@ pub struct LuaNonZeroU16(); /// The value must not be zero. #[lua()] - unsafe fn new_unchecked(n: u32) -> std::num::NonZeroU32; + unsafe fn new_unchecked(n: u32) -> LuaReflectValProxy; "#, r#" /// Returns the value as a primitive type. #[lua()] - fn get(self) -> u32; + fn get(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2607,7 +2810,7 @@ pub struct LuaNonZeroU16(); /// ``` #[lua()] - fn leading_zeros(self) -> u32; + fn leading_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2622,7 +2825,7 @@ pub struct LuaNonZeroU16(); /// ``` #[lua()] - fn trailing_zeros(self) -> u32; + fn trailing_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2643,7 +2846,10 @@ pub struct LuaNonZeroU16(); /// ``` #[lua()] - fn saturating_add(self, other: u32) -> std::num::NonZeroU32; + fn saturating_add( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" @@ -2661,7 +2867,7 @@ pub struct LuaNonZeroU16(); /// ``` #[lua()] - fn ilog2(self) -> u32; + fn ilog2(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2679,7 +2885,7 @@ pub struct LuaNonZeroU16(); /// ``` #[lua()] - fn ilog10(self) -> u32; + fn ilog10(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2696,7 +2902,7 @@ pub struct LuaNonZeroU16(); /// ``` #[lua()] - fn is_power_of_two(self) -> bool; + fn is_power_of_two(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -2718,10 +2924,9 @@ pub struct LuaNonZeroU16(); #[lua()] fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroU32, - ) -> std::num::NonZeroU32; + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2742,13 +2947,18 @@ pub struct LuaNonZeroU16(); /// ``` #[lua()] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU32; + fn saturating_pow( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::num::NonZeroU32; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2758,7 +2968,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNonZeroU32(); +pub struct NonZeroU32(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroU64", @@ -2766,8 +2976,11 @@ pub struct LuaNonZeroU32(); bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::num::NonZeroU64) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -2777,14 +2990,14 @@ pub struct LuaNonZeroU32(); /// The value must not be zero. #[lua()] - unsafe fn new_unchecked(n: u64) -> std::num::NonZeroU64; + unsafe fn new_unchecked(n: u64) -> LuaReflectValProxy; "#, r#" /// Returns the value as a primitive type. #[lua()] - fn get(self) -> u64; + fn get(_self: LuaReflectValProxy) -> u64; "#, r#" @@ -2798,7 +3011,7 @@ pub struct LuaNonZeroU32(); /// ``` #[lua()] - fn leading_zeros(self) -> u32; + fn leading_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2813,7 +3026,7 @@ pub struct LuaNonZeroU32(); /// ``` #[lua()] - fn trailing_zeros(self) -> u32; + fn trailing_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2834,7 +3047,10 @@ pub struct LuaNonZeroU32(); /// ``` #[lua()] - fn saturating_add(self, other: u64) -> std::num::NonZeroU64; + fn saturating_add( + _self: LuaReflectValProxy, + other: u64, + ) -> LuaReflectValProxy; "#, r#" @@ -2852,7 +3068,7 @@ pub struct LuaNonZeroU32(); /// ``` #[lua()] - fn ilog2(self) -> u32; + fn ilog2(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2870,7 +3086,7 @@ pub struct LuaNonZeroU32(); /// ``` #[lua()] - fn ilog10(self) -> u32; + fn ilog10(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -2887,7 +3103,7 @@ pub struct LuaNonZeroU32(); /// ``` #[lua()] - fn is_power_of_two(self) -> bool; + fn is_power_of_two(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -2909,10 +3125,9 @@ pub struct LuaNonZeroU32(); #[lua()] fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroU64, - ) -> std::num::NonZeroU64; + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2933,19 +3148,26 @@ pub struct LuaNonZeroU32(); /// ``` #[lua()] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU64; + fn saturating_pow( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::num::NonZeroU64; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -2955,7 +3177,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNonZeroU64(); +pub struct NonZeroU64(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroU8", @@ -2964,13 +3186,15 @@ pub struct LuaNonZeroU64(); functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::num::NonZeroU8; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -2980,14 +3204,14 @@ pub struct LuaNonZeroU64(); /// The value must not be zero. #[lua()] - unsafe fn new_unchecked(n: u8) -> std::num::NonZeroU8; + unsafe fn new_unchecked(n: u8) -> LuaReflectValProxy; "#, r#" /// Returns the value as a primitive type. #[lua()] - fn get(self) -> u8; + fn get(_self: LuaReflectValProxy) -> u8; "#, r#" @@ -3001,7 +3225,7 @@ pub struct LuaNonZeroU64(); /// ``` #[lua()] - fn leading_zeros(self) -> u32; + fn leading_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -3016,7 +3240,7 @@ pub struct LuaNonZeroU64(); /// ``` #[lua()] - fn trailing_zeros(self) -> u32; + fn trailing_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -3037,7 +3261,10 @@ pub struct LuaNonZeroU64(); /// ``` #[lua()] - fn saturating_add(self, other: u8) -> std::num::NonZeroU8; + fn saturating_add( + _self: LuaReflectValProxy, + other: u8, + ) -> LuaReflectValProxy; "#, r#" @@ -3055,7 +3282,7 @@ pub struct LuaNonZeroU64(); /// ``` #[lua()] - fn ilog2(self) -> u32; + fn ilog2(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -3073,7 +3300,7 @@ pub struct LuaNonZeroU64(); /// ``` #[lua()] - fn ilog10(self) -> u32; + fn ilog10(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -3090,7 +3317,7 @@ pub struct LuaNonZeroU64(); /// ``` #[lua()] - fn is_power_of_two(self) -> bool; + fn is_power_of_two(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -3111,7 +3338,10 @@ pub struct LuaNonZeroU64(); /// ``` #[lua()] - fn saturating_mul(self, #[proxy] other: std::num::NonZeroU8) -> std::num::NonZeroU8; + fn saturating_mul( + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3132,13 +3362,19 @@ pub struct LuaNonZeroU64(); /// ``` #[lua()] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU8; + fn saturating_pow( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::num::NonZeroU8) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -3148,7 +3384,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNonZeroU8(); +pub struct NonZeroU8(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroUsize", @@ -3157,7 +3393,9 @@ pub struct LuaNonZeroU8(); functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -3167,14 +3405,14 @@ pub struct LuaNonZeroU8(); /// The value must not be zero. #[lua()] - unsafe fn new_unchecked(n: usize) -> std::num::NonZeroUsize; + unsafe fn new_unchecked(n: usize) -> LuaReflectValProxy; "#, r#" /// Returns the value as a primitive type. #[lua()] - fn get(self) -> usize; + fn get(_self: LuaReflectValProxy) -> usize; "#, r#" @@ -3188,7 +3426,7 @@ pub struct LuaNonZeroU8(); /// ``` #[lua()] - fn leading_zeros(self) -> u32; + fn leading_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -3203,7 +3441,7 @@ pub struct LuaNonZeroU8(); /// ``` #[lua()] - fn trailing_zeros(self) -> u32; + fn trailing_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -3224,7 +3462,10 @@ pub struct LuaNonZeroU8(); /// ``` #[lua()] - fn saturating_add(self, other: usize) -> std::num::NonZeroUsize; + fn saturating_add( + _self: LuaReflectValProxy, + other: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -3242,7 +3483,7 @@ pub struct LuaNonZeroU8(); /// ``` #[lua()] - fn ilog2(self) -> u32; + fn ilog2(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -3260,7 +3501,7 @@ pub struct LuaNonZeroU8(); /// ``` #[lua()] - fn ilog10(self) -> u32; + fn ilog10(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -3277,7 +3518,7 @@ pub struct LuaNonZeroU8(); /// ``` #[lua()] - fn is_power_of_two(self) -> bool; + fn is_power_of_two(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -3299,10 +3540,9 @@ pub struct LuaNonZeroU8(); #[lua()] fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroUsize, - ) -> std::num::NonZeroUsize; + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3323,19 +3563,27 @@ pub struct LuaNonZeroU8(); /// ``` #[lua()] - fn saturating_pow(self, other: u32) -> std::num::NonZeroUsize; + fn saturating_pow( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::num::NonZeroUsize) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::num::NonZeroUsize; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3345,7 +3593,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNonZeroUsize(); +pub struct NonZeroUsize(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::path::PathBuf", @@ -3353,20 +3601,28 @@ pub struct LuaNonZeroUsize(); bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::path::PathBuf) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::path::PathBuf; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone_from(&mut self, #[proxy] source: &std::path::PathBuf) -> (); + fn clone_from( + _self: LuaReflectRefMutProxy, + source: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -3378,7 +3634,7 @@ pub struct LuaNonZeroUsize(); /// ``` #[lua()] - fn new() -> std::path::PathBuf; + fn new() -> LuaReflectValProxy; "#, r#" @@ -3396,7 +3652,7 @@ pub struct LuaNonZeroUsize(); /// [`with_capacity`]: OsString::with_capacity #[lua()] - fn with_capacity(capacity: usize) -> std::path::PathBuf; + fn with_capacity(capacity: usize) -> LuaReflectValProxy; "#, r#" @@ -3415,7 +3671,7 @@ pub struct LuaNonZeroUsize(); /// ``` #[lua()] - fn pop(&mut self) -> bool; + fn pop(_self: LuaReflectRefMutProxy) -> bool; "#, r#" @@ -3423,7 +3679,7 @@ pub struct LuaNonZeroUsize(); /// [`capacity`]: OsString::capacity #[lua()] - fn capacity(&self) -> usize; + fn capacity(_self: LuaReflectRefProxy) -> usize; "#, r#" @@ -3431,7 +3687,7 @@ pub struct LuaNonZeroUsize(); /// [`clear`]: OsString::clear #[lua()] - fn clear(&mut self) -> (); + fn clear(_self: LuaReflectRefMutProxy) -> (); "#, r#" @@ -3439,7 +3695,10 @@ pub struct LuaNonZeroUsize(); /// [`reserve`]: OsString::reserve #[lua()] - fn reserve(&mut self, additional: usize) -> (); + fn reserve( + _self: LuaReflectRefMutProxy, + additional: usize, + ) -> (); "#, r#" @@ -3447,7 +3706,10 @@ pub struct LuaNonZeroUsize(); /// [`reserve_exact`]: OsString::reserve_exact #[lua()] - fn reserve_exact(&mut self, additional: usize) -> (); + fn reserve_exact( + _self: LuaReflectRefMutProxy, + additional: usize, + ) -> (); "#, r#" @@ -3455,7 +3717,7 @@ pub struct LuaNonZeroUsize(); /// [`shrink_to_fit`]: OsString::shrink_to_fit #[lua()] - fn shrink_to_fit(&mut self) -> (); + fn shrink_to_fit(_self: LuaReflectRefMutProxy) -> (); "#, r#" @@ -3463,7 +3725,10 @@ pub struct LuaNonZeroUsize(); /// [`shrink_to`]: OsString::shrink_to #[lua()] - fn shrink_to(&mut self, min_capacity: usize) -> (); + fn shrink_to( + _self: LuaReflectRefMutProxy, + min_capacity: usize, + ) -> (); "#, r#" @@ -3473,7 +3738,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaPathBuf {} +pub struct PathBuf {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::ops::RangeFull", @@ -3482,19 +3747,24 @@ pub struct LuaPathBuf {} functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::ops::RangeFull; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::ops::RangeFull) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" @@ -3504,7 +3774,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaRangeFull {} +pub struct RangeFull {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::Quat", @@ -3513,18 +3783,23 @@ pub struct LuaRangeFull {} functions[r#" /// Rotates the [`Direction3d`] using a [`Quat`]. - #[lua(as_trait = "std::ops::Mul", composite = "mul")] + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + )] fn mul( - self, - #[proxy] - direction: bevy::math::primitives::Direction3d, - ) -> bevy::math::primitives::Direction3d; + _self: LuaReflectValProxy, + direction: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3532,8 +3807,11 @@ pub struct LuaRangeFull {} /// # Panics /// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3544,14 +3822,19 @@ pub struct LuaRangeFull {} /// # Panics /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::Quat; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3560,30 +3843,42 @@ pub struct LuaRangeFull {} /// Note that addition is not the same as combining the rotations represented by the /// two quaternions! That corresponds to multiplication. - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Subtracts the `rhs` quaternion from `self`. /// The difference is not guaranteed to be normalized. - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::Quat) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" /// Divides a quaternion by a scalar value. /// The quotient is not guaranteed to be normalized. - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: f32) -> bevy::math::Quat; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -3596,7 +3891,7 @@ pub struct LuaRangeFull {} /// provide normalized input or to normalized the resulting quaternion. #[lua()] - fn from_xyzw(x: f32, y: f32, z: f32, w: f32) -> bevy::math::Quat; + fn from_xyzw(x: f32, y: f32, z: f32, w: f32) -> LuaReflectValProxy; "#, r#" @@ -3606,7 +3901,7 @@ pub struct LuaRangeFull {} /// provide normalized input or to normalized the resulting quaternion. #[lua()] - fn from_array(a: [f32; 4]) -> bevy::math::Quat; + fn from_array(a: [f32; 4]) -> LuaReflectValProxy; "#, r#" @@ -3616,7 +3911,9 @@ pub struct LuaRangeFull {} /// provide normalized input or to normalized the resulting quaternion. #[lua()] - fn from_vec4(#[proxy] v: bevy::math::Vec4) -> bevy::math::Quat; + fn from_vec4( + v: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3626,7 +3923,10 @@ pub struct LuaRangeFull {} /// Will panic if `axis` is not normalized when `glam_assert` is enabled. #[lua()] - fn from_axis_angle(#[proxy] axis: bevy::math::Vec3, angle: f32) -> bevy::math::Quat; + fn from_axis_angle( + axis: LuaReflectValProxy, + angle: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -3634,28 +3934,30 @@ pub struct LuaRangeFull {} /// `from_scaled_axis(Vec3::ZERO)` results in the identity quaternion. #[lua()] - fn from_scaled_axis(#[proxy] v: bevy::math::Vec3) -> bevy::math::Quat; + fn from_scaled_axis( + v: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from the `angle` (in radians) around the x axis. #[lua()] - fn from_rotation_x(angle: f32) -> bevy::math::Quat; + fn from_rotation_x(angle: f32) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from the `angle` (in radians) around the y axis. #[lua()] - fn from_rotation_y(angle: f32) -> bevy::math::Quat; + fn from_rotation_y(angle: f32) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from the `angle` (in radians) around the z axis. #[lua()] - fn from_rotation_z(angle: f32) -> bevy::math::Quat; + fn from_rotation_z(angle: f32) -> LuaReflectValProxy; "#, r#" @@ -3663,33 +3965,38 @@ pub struct LuaRangeFull {} #[lua()] fn from_euler( - #[proxy] - euler: bevy::math::EulerRot, + euler: LuaReflectValProxy, a: f32, b: f32, c: f32, - ) -> bevy::math::Quat; + ) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from a 3x3 rotation matrix. #[lua()] - fn from_mat3(#[proxy] mat: &glam::Mat3) -> bevy::math::Quat; + fn from_mat3( + mat: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from a 3x3 SIMD aligned rotation matrix. #[lua()] - fn from_mat3a(#[proxy] mat: &glam::Mat3A) -> bevy::math::Quat; + fn from_mat3a( + mat: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. #[lua()] - fn from_mat4(#[proxy] mat: &glam::Mat4) -> bevy::math::Quat; + fn from_mat4( + mat: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3704,11 +4011,9 @@ pub struct LuaRangeFull {} #[lua()] fn from_rotation_arc( - #[proxy] - from: bevy::math::Vec3, - #[proxy] - to: bevy::math::Vec3, - ) -> bevy::math::Quat; + from: LuaReflectValProxy, + to: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3723,11 +4028,9 @@ pub struct LuaRangeFull {} #[lua()] fn from_rotation_arc_colinear( - #[proxy] - from: bevy::math::Vec3, - #[proxy] - to: bevy::math::Vec3, - ) -> bevy::math::Quat; + from: LuaReflectValProxy, + to: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3742,39 +4045,44 @@ pub struct LuaRangeFull {} #[lua()] fn from_rotation_arc_2d( - #[proxy] - from: bevy::math::Vec2, - #[proxy] - to: bevy::math::Vec2, - ) -> bevy::math::Quat; + from: LuaReflectValProxy, + to: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the rotation axis scaled by the rotation in radians. #[lua()] - fn to_scaled_axis(self) -> bevy::math::Vec3; + fn to_scaled_axis( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the rotation angles for the given euler rotation sequence. #[lua()] - fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f32, f32, f32); + fn to_euler( + _self: LuaReflectValProxy, + euler: LuaReflectValProxy, + ) -> (f32, f32, f32); "#, r#" /// `[x, y, z, w]` #[lua()] - fn to_array(&self) -> [f32; 4]; + fn to_array(_self: LuaReflectRefProxy) -> [f32; 4]; "#, r#" /// Returns the vector part of the quaternion. #[lua()] - fn xyz(self) -> bevy::math::Vec3; + fn xyz( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3782,7 +4090,9 @@ pub struct LuaRangeFull {} /// conjugate is also the inverse. #[lua()] - fn conjugate(self) -> bevy::math::Quat; + fn conjugate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3794,7 +4104,9 @@ pub struct LuaRangeFull {} /// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua()] - fn inverse(self) -> bevy::math::Quat; + fn inverse( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3802,14 +4114,17 @@ pub struct LuaRangeFull {} /// equal to the cosine of the angle between two quaternion rotations. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::Quat) -> f32; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Computes the length of `self`. #[lua()] - fn length(self) -> f32; + fn length(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -3818,7 +4133,7 @@ pub struct LuaRangeFull {} /// root operation. #[lua()] - fn length_squared(self) -> f32; + fn length_squared(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -3826,7 +4141,7 @@ pub struct LuaRangeFull {} /// For valid results, `self` must _not_ be of length zero. #[lua()] - fn length_recip(self) -> f32; + fn length_recip(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -3836,7 +4151,9 @@ pub struct LuaRangeFull {} /// Will panic if `self` is zero length when `glam_assert` is enabled. #[lua()] - fn normalize(self) -> bevy::math::Quat; + fn normalize( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3844,13 +4161,13 @@ pub struct LuaRangeFull {} /// If any element is either `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(self) -> bool; + fn is_finite(_self: LuaReflectValProxy) -> bool; "#, r#" #[lua()] - fn is_nan(self) -> bool; + fn is_nan(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -3858,13 +4175,13 @@ pub struct LuaRangeFull {} /// Uses a precision threshold of `1e-6`. #[lua()] - fn is_normalized(self) -> bool; + fn is_normalized(_self: LuaReflectValProxy) -> bool; "#, r#" #[lua()] - fn is_near_identity(self) -> bool; + fn is_near_identity(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -3875,7 +4192,10 @@ pub struct LuaRangeFull {} /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. #[lua()] - fn angle_between(self, #[proxy] rhs: bevy::math::Quat) -> f32; + fn angle_between( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" @@ -3888,7 +4208,11 @@ pub struct LuaRangeFull {} /// [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: bevy::math::Quat, max_abs_diff: f32) -> bool; + fn abs_diff_eq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f32, + ) -> bool; "#, r#" @@ -3900,7 +4224,11 @@ pub struct LuaRangeFull {} /// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. #[lua()] - fn lerp(self, #[proxy] end: bevy::math::Quat, s: f32) -> bevy::math::Quat; + fn lerp( + _self: LuaReflectValProxy, + end: LuaReflectValProxy, + s: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -3912,7 +4240,11 @@ pub struct LuaRangeFull {} /// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. #[lua()] - fn slerp(self, #[proxy] end: bevy::math::Quat, s: f32) -> bevy::math::Quat; + fn slerp( + _self: LuaReflectValProxy, + end: LuaReflectValProxy, + s: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -3921,7 +4253,10 @@ pub struct LuaRangeFull {} /// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua()] - fn mul_vec3(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn mul_vec3( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3932,47 +4267,64 @@ pub struct LuaRangeFull {} /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. #[lua()] - fn mul_quat(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + fn mul_quat( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. #[lua()] - fn from_affine3(#[proxy] a: &glam::Affine3A) -> bevy::math::Quat; + fn from_affine3( + a: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies a quaternion and a 3D vector, returning the rotated vector. #[lua()] - fn mul_vec3a(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn mul_vec3a( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua()] - fn as_dquat(self) -> bevy::math::DQuat; + fn as_dquat( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua()] - fn as_f64(self) -> bevy::math::DQuat; + fn as_f64( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies a quaternion by a scalar value. /// The product is not guaranteed to be normalized. - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f32) -> bevy::math::Quat; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::Quat; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -3982,7 +4334,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaQuat(); +pub struct Quat(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::Vec3", @@ -3990,70 +4342,95 @@ pub struct LuaQuat(); bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::Vec3; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f32) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: f32) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: f32) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::Vec3; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3; + fn new(x: f32, y: f32, z: f32) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: f32) -> bevy::math::Vec3; + fn splat(v: f32) -> LuaReflectValProxy; "#, r#" @@ -4064,34 +4441,34 @@ pub struct LuaQuat(); #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec3, - #[proxy] - if_true: bevy::math::Vec3, - #[proxy] - if_false: bevy::math::Vec3, - ) -> bevy::math::Vec3; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [f32; 3]) -> bevy::math::Vec3; + fn from_array(a: [f32; 3]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z]` #[lua()] - fn to_array(&self) -> [f32; 3]; + fn to_array(_self: LuaReflectRefProxy) -> [f32; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. #[lua()] - fn extend(self, w: f32) -> bevy::math::Vec4; + fn extend( + _self: LuaReflectValProxy, + w: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -4099,28 +4476,39 @@ pub struct LuaQuat(); /// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. #[lua()] - fn truncate(self) -> bevy::math::Vec2; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::Vec3) -> f32; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the cross product of `self` and `rhs`. #[lua()] - fn cross(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn cross( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4128,7 +4516,10 @@ pub struct LuaQuat(); /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4136,7 +4527,10 @@ pub struct LuaQuat(); /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4147,12 +4541,10 @@ pub struct LuaQuat(); #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::Vec3, - #[proxy] - max: bevy::math::Vec3, - ) -> bevy::math::Vec3; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4160,7 +4552,7 @@ pub struct LuaQuat(); /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> f32; + fn min_element(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -4168,7 +4560,7 @@ pub struct LuaQuat(); /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> f32; + fn max_element(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -4178,7 +4570,10 @@ pub struct LuaQuat(); /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4188,7 +4583,10 @@ pub struct LuaQuat(); /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4198,7 +4596,10 @@ pub struct LuaQuat(); /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4208,7 +4609,10 @@ pub struct LuaQuat(); /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4218,7 +4622,10 @@ pub struct LuaQuat(); /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4228,14 +4635,19 @@ pub struct LuaQuat(); /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::Vec3; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4245,14 +4657,19 @@ pub struct LuaQuat(); /// - `NAN` if the number is `NAN` #[lua()] - fn signum(self) -> bevy::math::Vec3; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. #[lua()] - fn copysign(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn copysign( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4261,7 +4678,7 @@ pub struct LuaQuat(); /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -4269,14 +4686,14 @@ pub struct LuaQuat(); /// `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(self) -> bool; + fn is_finite(_self: LuaReflectValProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(self) -> bool; + fn is_nan(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -4284,14 +4701,16 @@ pub struct LuaQuat(); /// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. #[lua()] - fn is_nan_mask(self) -> bevy::math::BVec3; + fn is_nan_mask( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the length of `self`. #[lua()] - fn length(self) -> f32; + fn length(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -4299,7 +4718,7 @@ pub struct LuaQuat(); /// This is faster than `length()` as it avoids a square root operation. #[lua()] - fn length_squared(self) -> f32; + fn length_squared(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -4307,28 +4726,37 @@ pub struct LuaQuat(); /// For valid results, `self` must _not_ be of length zero. #[lua()] - fn length_recip(self) -> f32; + fn length_recip(_self: LuaReflectValProxy) -> f32; "#, r#" /// Computes the Euclidean distance between two points in space. #[lua()] - fn distance(self, #[proxy] rhs: bevy::math::Vec3) -> f32; + fn distance( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::Vec3) -> f32; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4336,7 +4764,10 @@ pub struct LuaQuat(); /// [Euclidean division]: f32::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4347,7 +4778,9 @@ pub struct LuaQuat(); /// Will panic if `self` is zero length when `glam_assert` is enabled. #[lua()] - fn normalize(self) -> bevy::math::Vec3; + fn normalize( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4357,7 +4790,9 @@ pub struct LuaQuat(); /// See also [`Self::try_normalize()`]. #[lua()] - fn normalize_or_zero(self) -> bevy::math::Vec3; + fn normalize_or_zero( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4365,7 +4800,7 @@ pub struct LuaQuat(); /// Uses a precision threshold of `1e-6`. #[lua()] - fn is_normalized(self) -> bool; + fn is_normalized(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -4375,7 +4810,10 @@ pub struct LuaQuat(); /// Will panic if `rhs` is zero length when `glam_assert` is enabled. #[lua()] - fn project_onto(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn project_onto( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4387,7 +4825,10 @@ pub struct LuaQuat(); /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. #[lua()] - fn reject_from(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn reject_from( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4397,7 +4838,10 @@ pub struct LuaQuat(); /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua()] - fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn project_onto_normalized( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4409,7 +4853,10 @@ pub struct LuaQuat(); /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua()] - fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn reject_from_normalized( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4417,7 +4864,9 @@ pub struct LuaQuat(); /// Round half-way cases away from 0.0. #[lua()] - fn round(self) -> bevy::math::Vec3; + fn round( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4425,7 +4874,9 @@ pub struct LuaQuat(); /// element of `self`. #[lua()] - fn floor(self) -> bevy::math::Vec3; + fn floor( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4433,7 +4884,9 @@ pub struct LuaQuat(); /// each element of `self`. #[lua()] - fn ceil(self) -> bevy::math::Vec3; + fn ceil( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4441,7 +4894,9 @@ pub struct LuaQuat(); /// always truncated towards zero. #[lua()] - fn trunc(self) -> bevy::math::Vec3; + fn trunc( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4450,7 +4905,9 @@ pub struct LuaQuat(); /// Note that this is fast but not precise for large numbers. #[lua()] - fn fract(self) -> bevy::math::Vec3; + fn fract( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4458,21 +4915,28 @@ pub struct LuaQuat(); /// `self`. #[lua()] - fn exp(self) -> bevy::math::Vec3; + fn exp( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. #[lua()] - fn powf(self, n: f32) -> bevy::math::Vec3; + fn powf( + _self: LuaReflectValProxy, + n: f32, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. #[lua()] - fn recip(self) -> bevy::math::Vec3; + fn recip( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4482,7 +4946,11 @@ pub struct LuaQuat(); /// extrapolated. #[lua()] - fn lerp(self, #[proxy] rhs: bevy::math::Vec3, s: f32) -> bevy::math::Vec3; + fn lerp( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + s: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -4495,7 +4963,11 @@ pub struct LuaQuat(); /// [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: bevy::math::Vec3, max_abs_diff: f32) -> bool; + fn abs_diff_eq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f32, + ) -> bool; "#, r#" @@ -4504,21 +4976,31 @@ pub struct LuaQuat(); /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua()] - fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3; + fn clamp_length( + _self: LuaReflectValProxy, + min: f32, + max: f32, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no more than `max` #[lua()] - fn clamp_length_max(self, max: f32) -> bevy::math::Vec3; + fn clamp_length_max( + _self: LuaReflectValProxy, + max: f32, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no less than `min` #[lua()] - fn clamp_length_min(self, min: f32) -> bevy::math::Vec3; + fn clamp_length_min( + _self: LuaReflectValProxy, + min: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -4531,12 +5013,10 @@ pub struct LuaQuat(); #[lua()] fn mul_add( - self, - #[proxy] - a: bevy::math::Vec3, - #[proxy] - b: bevy::math::Vec3, - ) -> bevy::math::Vec3; + _self: LuaReflectValProxy, + a: LuaReflectValProxy, + b: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4544,7 +5024,10 @@ pub struct LuaQuat(); /// The inputs do not need to be unit vectors however they must be non-zero. #[lua()] - fn angle_between(self, #[proxy] rhs: bevy::math::Vec3) -> f32; + fn angle_between( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" @@ -4554,7 +5037,9 @@ pub struct LuaQuat(); /// [`Self::any_orthonormal_vector()`] instead. #[lua()] - fn any_orthogonal_vector(&self) -> bevy::math::Vec3; + fn any_orthogonal_vector( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4564,66 +5049,90 @@ pub struct LuaQuat(); /// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua()] - fn any_orthonormal_vector(&self) -> bevy::math::Vec3; + fn any_orthonormal_vector( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec3(&self) -> bevy::math::DVec3; + fn as_dvec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec3(&self) -> bevy::math::IVec3; + fn as_ivec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec3(&self) -> bevy::math::UVec3; + fn as_uvec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; + fn as_i64vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; + fn as_u64vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: f32) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: f32) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::Vec3) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -4633,19 +5142,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f32) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaVec3 { +pub struct Vec3 { x: f32, y: f32, z: f32, @@ -4657,88 +5166,120 @@ pub struct LuaVec3 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: i32) -> bevy::math::IVec2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: i32) -> bevy::math::IVec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::IVec2) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: i32) -> bevy::math::IVec2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::IVec2; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: i32) -> bevy::math::IVec2; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: i32, y: i32) -> bevy::math::IVec2; + fn new(x: i32, y: i32) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: i32) -> bevy::math::IVec2; + fn splat(v: i32) -> LuaReflectValProxy; "#, r#" @@ -4749,48 +5290,54 @@ pub struct LuaVec3 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec2, - #[proxy] - if_true: bevy::math::IVec2, - #[proxy] - if_false: bevy::math::IVec2, - ) -> bevy::math::IVec2; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [i32; 2]) -> bevy::math::IVec2; + fn from_array(a: [i32; 2]) -> LuaReflectValProxy; "#, r#" /// `[x, y]` #[lua()] - fn to_array(&self) -> [i32; 2]; + fn to_array(_self: LuaReflectRefProxy) -> [i32; 2]; "#, r#" /// Creates a 3D vector from `self` and the given `z` value. #[lua()] - fn extend(self, z: i32) -> bevy::math::IVec3; + fn extend( + _self: LuaReflectValProxy, + z: i32, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::IVec2) -> i32; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4798,7 +5345,10 @@ pub struct LuaVec3 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4806,7 +5356,10 @@ pub struct LuaVec3 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4817,12 +5370,10 @@ pub struct LuaVec3 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::IVec2, - #[proxy] - max: bevy::math::IVec2, - ) -> bevy::math::IVec2; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4830,7 +5381,7 @@ pub struct LuaVec3 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> i32; + fn min_element(_self: LuaReflectValProxy) -> i32; "#, r#" @@ -4838,7 +5389,7 @@ pub struct LuaVec3 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> i32; + fn max_element(_self: LuaReflectValProxy) -> i32; "#, r#" @@ -4848,7 +5399,10 @@ pub struct LuaVec3 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4858,7 +5412,10 @@ pub struct LuaVec3 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4868,7 +5425,10 @@ pub struct LuaVec3 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4878,7 +5438,10 @@ pub struct LuaVec3 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4888,7 +5451,10 @@ pub struct LuaVec3 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4898,14 +5464,19 @@ pub struct LuaVec3 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::IVec2; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4915,7 +5486,9 @@ pub struct LuaVec3 { /// - `-1` if the number is negative #[lua()] - fn signum(self) -> bevy::math::IVec2; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4924,21 +5497,24 @@ pub struct LuaVec3 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" /// Computes the squared length of `self`. #[lua()] - fn length_squared(self) -> i32; + fn length_squared(_self: LuaReflectValProxy) -> i32; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::IVec2) -> i32; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i32; "#, r#" @@ -4947,7 +5523,10 @@ pub struct LuaVec3 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4957,14 +5536,19 @@ pub struct LuaVec3 { /// [Euclidean division]: i32::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector that is equal to `self` rotated by 90 degrees. #[lua()] - fn perp(self) -> bevy::math::IVec2; + fn perp( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -4972,7 +5556,10 @@ pub struct LuaVec3 { /// Also known as the wedge product, 2D cross product, and determinant. #[lua()] - fn perp_dot(self, #[proxy] rhs: bevy::math::IVec2) -> i32; + fn perp_dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i32; "#, r#" @@ -4981,42 +5568,55 @@ pub struct LuaVec3 { /// it will be like a rotation with a multiplication by `self`'s length. #[lua()] - fn rotate(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn rotate( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec2(&self) -> bevy::math::Vec2; + fn as_vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec2(&self) -> bevy::math::DVec2; + fn as_dvec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec2(&self) -> bevy::math::UVec2; + fn as_uvec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; + fn as_i64vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; + fn as_u64vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5024,7 +5624,10 @@ pub struct LuaVec3 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua()] - fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn wrapping_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5032,7 +5635,10 @@ pub struct LuaVec3 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua()] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn wrapping_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5040,7 +5646,10 @@ pub struct LuaVec3 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua()] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn wrapping_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5048,7 +5657,10 @@ pub struct LuaVec3 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua()] - fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn wrapping_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5056,7 +5668,10 @@ pub struct LuaVec3 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua()] - fn saturating_add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn saturating_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5064,7 +5679,10 @@ pub struct LuaVec3 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua()] - fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn saturating_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5072,7 +5690,10 @@ pub struct LuaVec3 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua()] - fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5080,19 +5701,27 @@ pub struct LuaVec3 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua()] - fn saturating_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn saturating_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: i32) -> bevy::math::IVec2; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::IVec2; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5102,19 +5731,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: i32) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaIVec2 { +pub struct IVec2 { x: i32, y: i32, } @@ -5125,34 +5754,43 @@ pub struct LuaIVec2 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: i32) -> bevy::math::IVec3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: i32, y: i32, z: i32) -> bevy::math::IVec3; + fn new(x: i32, y: i32, z: i32) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: i32) -> bevy::math::IVec3; + fn splat(v: i32) -> LuaReflectValProxy; "#, r#" @@ -5163,34 +5801,34 @@ pub struct LuaIVec2 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec3, - #[proxy] - if_true: bevy::math::IVec3, - #[proxy] - if_false: bevy::math::IVec3, - ) -> bevy::math::IVec3; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [i32; 3]) -> bevy::math::IVec3; + fn from_array(a: [i32; 3]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z]` #[lua()] - fn to_array(&self) -> [i32; 3]; + fn to_array(_self: LuaReflectRefProxy) -> [i32; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. #[lua()] - fn extend(self, w: i32) -> bevy::math::IVec4; + fn extend( + _self: LuaReflectValProxy, + w: i32, + ) -> LuaReflectValProxy; "#, r#" @@ -5198,28 +5836,39 @@ pub struct LuaIVec2 { /// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. #[lua()] - fn truncate(self) -> bevy::math::IVec2; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::IVec3) -> i32; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the cross product of `self` and `rhs`. #[lua()] - fn cross(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn cross( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5227,7 +5876,10 @@ pub struct LuaIVec2 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5235,7 +5887,10 @@ pub struct LuaIVec2 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5246,12 +5901,10 @@ pub struct LuaIVec2 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::IVec3, - #[proxy] - max: bevy::math::IVec3, - ) -> bevy::math::IVec3; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5259,7 +5912,7 @@ pub struct LuaIVec2 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> i32; + fn min_element(_self: LuaReflectValProxy) -> i32; "#, r#" @@ -5267,7 +5920,7 @@ pub struct LuaIVec2 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> i32; + fn max_element(_self: LuaReflectValProxy) -> i32; "#, r#" @@ -5277,7 +5930,10 @@ pub struct LuaIVec2 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5287,7 +5943,10 @@ pub struct LuaIVec2 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5297,7 +5956,10 @@ pub struct LuaIVec2 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5307,7 +5969,10 @@ pub struct LuaIVec2 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5317,7 +5982,10 @@ pub struct LuaIVec2 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5327,14 +5995,19 @@ pub struct LuaIVec2 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::IVec3; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5344,7 +6017,9 @@ pub struct LuaIVec2 { /// - `-1` if the number is negative #[lua()] - fn signum(self) -> bevy::math::IVec3; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5353,21 +6028,24 @@ pub struct LuaIVec2 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" /// Computes the squared length of `self`. #[lua()] - fn length_squared(self) -> i32; + fn length_squared(_self: LuaReflectValProxy) -> i32; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::IVec3) -> i32; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i32; "#, r#" @@ -5376,7 +6054,10 @@ pub struct LuaIVec2 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5386,49 +6067,64 @@ pub struct LuaIVec2 { /// [Euclidean division]: i32::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec3(&self) -> bevy::math::Vec3; + fn as_vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec3a(&self) -> bevy::math::Vec3A; + fn as_vec3a( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec3(&self) -> bevy::math::DVec3; + fn as_dvec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec3(&self) -> bevy::math::UVec3; + fn as_uvec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; + fn as_i64vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; + fn as_u64vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5436,7 +6132,10 @@ pub struct LuaIVec2 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua()] - fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn wrapping_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5444,7 +6143,10 @@ pub struct LuaIVec2 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua()] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn wrapping_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5452,7 +6154,10 @@ pub struct LuaIVec2 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua()] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn wrapping_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5460,7 +6165,10 @@ pub struct LuaIVec2 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua()] - fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn wrapping_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5468,7 +6176,10 @@ pub struct LuaIVec2 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua()] - fn saturating_add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn saturating_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5476,7 +6187,10 @@ pub struct LuaIVec2 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua()] - fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn saturating_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5484,7 +6198,10 @@ pub struct LuaIVec2 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua()] - fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5492,73 +6209,104 @@ pub struct LuaIVec2 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua()] - fn saturating_div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn saturating_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::IVec3; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::IVec3; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: i32) -> bevy::math::IVec3; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: i32) -> bevy::math::IVec3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: i32) -> bevy::math::IVec3; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: i32) -> bevy::math::IVec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::IVec3) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" @@ -5568,19 +6316,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: i32) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaIVec3 { +pub struct IVec3 { x: i32, y: i32, z: i32, @@ -5593,39 +6341,47 @@ pub struct LuaIVec3 { functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::IVec4; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: i32) -> bevy::math::IVec4; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" /// Creates a new vector. #[lua()] - fn new(x: i32, y: i32, z: i32, w: i32) -> bevy::math::IVec4; + fn new(x: i32, y: i32, z: i32, w: i32) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: i32) -> bevy::math::IVec4; + fn splat(v: i32) -> LuaReflectValProxy; "#, r#" @@ -5636,27 +6392,24 @@ pub struct LuaIVec3 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec4, - #[proxy] - if_true: bevy::math::IVec4, - #[proxy] - if_false: bevy::math::IVec4, - ) -> bevy::math::IVec4; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [i32; 4]) -> bevy::math::IVec4; + fn from_array(a: [i32; 4]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z, w]` #[lua()] - fn to_array(&self) -> [i32; 4]; + fn to_array(_self: LuaReflectRefProxy) -> [i32; 4]; "#, r#" @@ -5664,21 +6417,29 @@ pub struct LuaIVec3 { /// Truncation to [`IVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. #[lua()] - fn truncate(self) -> bevy::math::IVec3; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::IVec4) -> i32; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5686,7 +6447,10 @@ pub struct LuaIVec3 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5694,7 +6458,10 @@ pub struct LuaIVec3 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5705,12 +6472,10 @@ pub struct LuaIVec3 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::IVec4, - #[proxy] - max: bevy::math::IVec4, - ) -> bevy::math::IVec4; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5718,7 +6483,7 @@ pub struct LuaIVec3 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> i32; + fn min_element(_self: LuaReflectValProxy) -> i32; "#, r#" @@ -5726,7 +6491,7 @@ pub struct LuaIVec3 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> i32; + fn max_element(_self: LuaReflectValProxy) -> i32; "#, r#" @@ -5736,7 +6501,10 @@ pub struct LuaIVec3 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5746,7 +6514,10 @@ pub struct LuaIVec3 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5756,7 +6527,10 @@ pub struct LuaIVec3 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5766,7 +6540,10 @@ pub struct LuaIVec3 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5776,7 +6553,10 @@ pub struct LuaIVec3 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5786,14 +6566,19 @@ pub struct LuaIVec3 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::IVec4; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5803,7 +6588,9 @@ pub struct LuaIVec3 { /// - `-1` if the number is negative #[lua()] - fn signum(self) -> bevy::math::IVec4; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5812,21 +6599,24 @@ pub struct LuaIVec3 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" /// Computes the squared length of `self`. #[lua()] - fn length_squared(self) -> i32; + fn length_squared(_self: LuaReflectValProxy) -> i32; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::IVec4) -> i32; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i32; "#, r#" @@ -5835,7 +6625,10 @@ pub struct LuaIVec3 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5845,42 +6638,55 @@ pub struct LuaIVec3 { /// [Euclidean division]: i32::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec4(&self) -> bevy::math::Vec4; + fn as_vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec4(&self) -> bevy::math::DVec4; + fn as_dvec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec4(&self) -> bevy::math::UVec4; + fn as_uvec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; + fn as_i64vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; + fn as_u64vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5888,7 +6694,10 @@ pub struct LuaIVec3 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua()] - fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn wrapping_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5896,7 +6705,10 @@ pub struct LuaIVec3 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua()] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn wrapping_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5904,7 +6716,10 @@ pub struct LuaIVec3 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua()] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn wrapping_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5912,7 +6727,10 @@ pub struct LuaIVec3 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua()] - fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn wrapping_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5920,7 +6738,10 @@ pub struct LuaIVec3 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua()] - fn saturating_add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn saturating_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5928,7 +6749,10 @@ pub struct LuaIVec3 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua()] - fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn saturating_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5936,7 +6760,10 @@ pub struct LuaIVec3 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua()] - fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -5944,67 +6771,99 @@ pub struct LuaIVec3 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua()] - fn saturating_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn saturating_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::IVec4) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: i32) -> bevy::math::IVec4; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: i32) -> bevy::math::IVec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: i32) -> bevy::math::IVec4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::IVec4; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: i32) -> bevy::math::IVec4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: i32, + ) -> LuaReflectValProxy; "#, r#" @@ -6014,19 +6873,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: i32) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaIVec4 { +pub struct IVec4 { x: i32, y: i32, z: i32, @@ -6039,100 +6898,137 @@ pub struct LuaIVec4 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: i64) -> bevy::math::I64Vec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::I64Vec2; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: i64) -> bevy::math::I64Vec2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: i64) -> bevy::math::I64Vec2; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: i64) -> bevy::math::I64Vec2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::I64Vec2) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: i64) -> bevy::math::I64Vec2; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::I64Vec2; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: i64, y: i64) -> bevy::math::I64Vec2; + fn new(x: i64, y: i64) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: i64) -> bevy::math::I64Vec2; + fn splat(v: i64) -> LuaReflectValProxy; "#, r#" @@ -6143,48 +7039,54 @@ pub struct LuaIVec4 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec2, - #[proxy] - if_true: bevy::math::I64Vec2, - #[proxy] - if_false: bevy::math::I64Vec2, - ) -> bevy::math::I64Vec2; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [i64; 2]) -> bevy::math::I64Vec2; + fn from_array(a: [i64; 2]) -> LuaReflectValProxy; "#, r#" /// `[x, y]` #[lua()] - fn to_array(&self) -> [i64; 2]; + fn to_array(_self: LuaReflectRefProxy) -> [i64; 2]; "#, r#" /// Creates a 3D vector from `self` and the given `z` value. #[lua()] - fn extend(self, z: i64) -> bevy::math::I64Vec3; + fn extend( + _self: LuaReflectValProxy, + z: i64, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6192,7 +7094,10 @@ pub struct LuaIVec4 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6200,7 +7105,10 @@ pub struct LuaIVec4 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6211,12 +7119,10 @@ pub struct LuaIVec4 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::I64Vec2, - #[proxy] - max: bevy::math::I64Vec2, - ) -> bevy::math::I64Vec2; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6224,7 +7130,7 @@ pub struct LuaIVec4 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> i64; + fn min_element(_self: LuaReflectValProxy) -> i64; "#, r#" @@ -6232,7 +7138,7 @@ pub struct LuaIVec4 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> i64; + fn max_element(_self: LuaReflectValProxy) -> i64; "#, r#" @@ -6242,7 +7148,10 @@ pub struct LuaIVec4 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6252,7 +7161,10 @@ pub struct LuaIVec4 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6262,7 +7174,10 @@ pub struct LuaIVec4 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6272,7 +7187,10 @@ pub struct LuaIVec4 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6282,7 +7200,10 @@ pub struct LuaIVec4 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6292,14 +7213,19 @@ pub struct LuaIVec4 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::I64Vec2; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6309,7 +7235,9 @@ pub struct LuaIVec4 { /// - `-1` if the number is negative #[lua()] - fn signum(self) -> bevy::math::I64Vec2; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6318,21 +7246,24 @@ pub struct LuaIVec4 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" /// Computes the squared length of `self`. #[lua()] - fn length_squared(self) -> i64; + fn length_squared(_self: LuaReflectValProxy) -> i64; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i64; "#, r#" @@ -6341,7 +7272,10 @@ pub struct LuaIVec4 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6351,14 +7285,19 @@ pub struct LuaIVec4 { /// [Euclidean division]: i64::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector that is equal to `self` rotated by 90 degrees. #[lua()] - fn perp(self) -> bevy::math::I64Vec2; + fn perp( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6366,7 +7305,10 @@ pub struct LuaIVec4 { /// Also known as the wedge product, 2D cross product, and determinant. #[lua()] - fn perp_dot(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; + fn perp_dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i64; "#, r#" @@ -6375,42 +7317,55 @@ pub struct LuaIVec4 { /// it will be like a rotation with a multiplication by `self`'s length. #[lua()] - fn rotate(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn rotate( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec2(&self) -> bevy::math::Vec2; + fn as_vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec2(&self) -> bevy::math::DVec2; + fn as_dvec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec2(&self) -> bevy::math::IVec2; + fn as_ivec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec2(&self) -> bevy::math::UVec2; + fn as_uvec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; + fn as_u64vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6418,7 +7373,10 @@ pub struct LuaIVec4 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua()] - fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn wrapping_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6426,7 +7384,10 @@ pub struct LuaIVec4 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua()] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn wrapping_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6434,7 +7395,10 @@ pub struct LuaIVec4 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua()] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn wrapping_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6442,7 +7406,10 @@ pub struct LuaIVec4 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua()] - fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn wrapping_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6450,7 +7417,10 @@ pub struct LuaIVec4 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua()] - fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn saturating_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6458,7 +7428,10 @@ pub struct LuaIVec4 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua()] - fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn saturating_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6466,7 +7439,10 @@ pub struct LuaIVec4 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua()] - fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6474,7 +7450,10 @@ pub struct LuaIVec4 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua()] - fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn saturating_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6484,7 +7463,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaI64Vec2 { +pub struct I64Vec2 { x: i64, y: i64, } @@ -6495,40 +7474,49 @@ pub struct LuaI64Vec2 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: i64) -> bevy::math::I64Vec3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: i64) -> bevy::math::I64Vec3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: i64, y: i64, z: i64) -> bevy::math::I64Vec3; + fn new(x: i64, y: i64, z: i64) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: i64) -> bevy::math::I64Vec3; + fn splat(v: i64) -> LuaReflectValProxy; "#, r#" @@ -6539,34 +7527,34 @@ pub struct LuaI64Vec2 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec3, - #[proxy] - if_true: bevy::math::I64Vec3, - #[proxy] - if_false: bevy::math::I64Vec3, - ) -> bevy::math::I64Vec3; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [i64; 3]) -> bevy::math::I64Vec3; + fn from_array(a: [i64; 3]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z]` #[lua()] - fn to_array(&self) -> [i64; 3]; + fn to_array(_self: LuaReflectRefProxy) -> [i64; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. #[lua()] - fn extend(self, w: i64) -> bevy::math::I64Vec4; + fn extend( + _self: LuaReflectValProxy, + w: i64, + ) -> LuaReflectValProxy; "#, r#" @@ -6574,28 +7562,39 @@ pub struct LuaI64Vec2 { /// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. #[lua()] - fn truncate(self) -> bevy::math::I64Vec2; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::I64Vec3) -> i64; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the cross product of `self` and `rhs`. #[lua()] - fn cross(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn cross( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6603,7 +7602,10 @@ pub struct LuaI64Vec2 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6611,7 +7613,10 @@ pub struct LuaI64Vec2 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6622,12 +7627,10 @@ pub struct LuaI64Vec2 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::I64Vec3, - #[proxy] - max: bevy::math::I64Vec3, - ) -> bevy::math::I64Vec3; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6635,7 +7638,7 @@ pub struct LuaI64Vec2 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> i64; + fn min_element(_self: LuaReflectValProxy) -> i64; "#, r#" @@ -6643,7 +7646,7 @@ pub struct LuaI64Vec2 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> i64; + fn max_element(_self: LuaReflectValProxy) -> i64; "#, r#" @@ -6653,7 +7656,10 @@ pub struct LuaI64Vec2 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6663,7 +7669,10 @@ pub struct LuaI64Vec2 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6673,7 +7682,10 @@ pub struct LuaI64Vec2 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6683,7 +7695,10 @@ pub struct LuaI64Vec2 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6693,7 +7708,10 @@ pub struct LuaI64Vec2 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6703,14 +7721,19 @@ pub struct LuaI64Vec2 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::I64Vec3; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6720,7 +7743,9 @@ pub struct LuaI64Vec2 { /// - `-1` if the number is negative #[lua()] - fn signum(self) -> bevy::math::I64Vec3; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6729,21 +7754,24 @@ pub struct LuaI64Vec2 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" /// Computes the squared length of `self`. #[lua()] - fn length_squared(self) -> i64; + fn length_squared(_self: LuaReflectValProxy) -> i64; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec3) -> i64; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i64; "#, r#" @@ -6752,7 +7780,10 @@ pub struct LuaI64Vec2 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6762,49 +7793,64 @@ pub struct LuaI64Vec2 { /// [Euclidean division]: i64::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec3(&self) -> bevy::math::Vec3; + fn as_vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec3a(&self) -> bevy::math::Vec3A; + fn as_vec3a( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec3(&self) -> bevy::math::DVec3; + fn as_dvec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec3(&self) -> bevy::math::IVec3; + fn as_ivec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec3(&self) -> bevy::math::UVec3; + fn as_uvec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; + fn as_u64vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6812,7 +7858,10 @@ pub struct LuaI64Vec2 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua()] - fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn wrapping_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6820,7 +7869,10 @@ pub struct LuaI64Vec2 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua()] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn wrapping_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6828,7 +7880,10 @@ pub struct LuaI64Vec2 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua()] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn wrapping_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6836,7 +7891,10 @@ pub struct LuaI64Vec2 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua()] - fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn wrapping_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6844,7 +7902,10 @@ pub struct LuaI64Vec2 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua()] - fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn saturating_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6852,7 +7913,10 @@ pub struct LuaI64Vec2 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua()] - fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn saturating_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6860,7 +7924,10 @@ pub struct LuaI64Vec2 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua()] - fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6868,67 +7935,98 @@ pub struct LuaI64Vec2 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua()] - fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn saturating_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: i64) -> bevy::math::I64Vec3; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: i64) -> bevy::math::I64Vec3; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::I64Vec3; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::I64Vec3) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::I64Vec3; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: i64) -> bevy::math::I64Vec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -6938,7 +8036,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaI64Vec3 { +pub struct I64Vec3 { x: i64, y: i64, z: i64, @@ -6951,39 +8049,48 @@ pub struct LuaI64Vec3 { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: i64) -> bevy::math::I64Vec4; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: i64, y: i64, z: i64, w: i64) -> bevy::math::I64Vec4; + fn new(x: i64, y: i64, z: i64, w: i64) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: i64) -> bevy::math::I64Vec4; + fn splat(v: i64) -> LuaReflectValProxy; "#, r#" @@ -6994,27 +8101,24 @@ pub struct LuaI64Vec3 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec4, - #[proxy] - if_true: bevy::math::I64Vec4, - #[proxy] - if_false: bevy::math::I64Vec4, - ) -> bevy::math::I64Vec4; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [i64; 4]) -> bevy::math::I64Vec4; + fn from_array(a: [i64; 4]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z, w]` #[lua()] - fn to_array(&self) -> [i64; 4]; + fn to_array(_self: LuaReflectRefProxy) -> [i64; 4]; "#, r#" @@ -7022,21 +8126,29 @@ pub struct LuaI64Vec3 { /// Truncation to [`I64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. #[lua()] - fn truncate(self) -> bevy::math::I64Vec3; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::I64Vec4) -> i64; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7044,7 +8156,10 @@ pub struct LuaI64Vec3 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7052,7 +8167,10 @@ pub struct LuaI64Vec3 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7063,12 +8181,10 @@ pub struct LuaI64Vec3 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::I64Vec4, - #[proxy] - max: bevy::math::I64Vec4, - ) -> bevy::math::I64Vec4; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7076,7 +8192,7 @@ pub struct LuaI64Vec3 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> i64; + fn min_element(_self: LuaReflectValProxy) -> i64; "#, r#" @@ -7084,7 +8200,7 @@ pub struct LuaI64Vec3 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> i64; + fn max_element(_self: LuaReflectValProxy) -> i64; "#, r#" @@ -7094,7 +8210,10 @@ pub struct LuaI64Vec3 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7104,7 +8223,10 @@ pub struct LuaI64Vec3 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7114,7 +8236,10 @@ pub struct LuaI64Vec3 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7124,7 +8249,10 @@ pub struct LuaI64Vec3 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7134,7 +8262,10 @@ pub struct LuaI64Vec3 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7144,14 +8275,19 @@ pub struct LuaI64Vec3 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::I64Vec4; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7161,7 +8297,9 @@ pub struct LuaI64Vec3 { /// - `-1` if the number is negative #[lua()] - fn signum(self) -> bevy::math::I64Vec4; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7170,21 +8308,24 @@ pub struct LuaI64Vec3 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" /// Computes the squared length of `self`. #[lua()] - fn length_squared(self) -> i64; + fn length_squared(_self: LuaReflectValProxy) -> i64; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec4) -> i64; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> i64; "#, r#" @@ -7193,7 +8334,10 @@ pub struct LuaI64Vec3 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7203,42 +8347,55 @@ pub struct LuaI64Vec3 { /// [Euclidean division]: i64::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec4(&self) -> bevy::math::Vec4; + fn as_vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec4(&self) -> bevy::math::DVec4; + fn as_dvec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec4(&self) -> bevy::math::IVec4; + fn as_ivec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec4(&self) -> bevy::math::UVec4; + fn as_uvec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; + fn as_u64vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7246,7 +8403,10 @@ pub struct LuaI64Vec3 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua()] - fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn wrapping_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7254,7 +8414,10 @@ pub struct LuaI64Vec3 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua()] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn wrapping_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7262,7 +8425,10 @@ pub struct LuaI64Vec3 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua()] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn wrapping_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7270,7 +8436,10 @@ pub struct LuaI64Vec3 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua()] - fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn wrapping_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7278,7 +8447,10 @@ pub struct LuaI64Vec3 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua()] - fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn saturating_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7286,7 +8458,10 @@ pub struct LuaI64Vec3 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua()] - fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn saturating_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7294,7 +8469,10 @@ pub struct LuaI64Vec3 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua()] - fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7302,67 +8480,98 @@ pub struct LuaI64Vec3 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua()] - fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn saturating_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: i64) -> bevy::math::I64Vec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::I64Vec4; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::I64Vec4) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::I64Vec4; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: i64) -> bevy::math::I64Vec4; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: i64) -> bevy::math::I64Vec4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: i64) -> bevy::math::I64Vec4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: i64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7372,7 +8581,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaI64Vec4 { +pub struct I64Vec4 { x: i64, y: i64, z: i64, @@ -7385,94 +8594,129 @@ pub struct LuaI64Vec4 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: u32) -> bevy::math::UVec2; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: u32) -> bevy::math::UVec2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::UVec2) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::UVec2; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: u32) -> bevy::math::UVec2; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: u32) -> bevy::math::UVec2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: u32) -> bevy::math::UVec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: u32, y: u32) -> bevy::math::UVec2; + fn new(x: u32, y: u32) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: u32) -> bevy::math::UVec2; + fn splat(v: u32) -> LuaReflectValProxy; "#, r#" @@ -7483,48 +8727,54 @@ pub struct LuaI64Vec4 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec2, - #[proxy] - if_true: bevy::math::UVec2, - #[proxy] - if_false: bevy::math::UVec2, - ) -> bevy::math::UVec2; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [u32; 2]) -> bevy::math::UVec2; + fn from_array(a: [u32; 2]) -> LuaReflectValProxy; "#, r#" /// `[x, y]` #[lua()] - fn to_array(&self) -> [u32; 2]; + fn to_array(_self: LuaReflectRefProxy) -> [u32; 2]; "#, r#" /// Creates a 3D vector from `self` and the given `z` value. #[lua()] - fn extend(self, z: u32) -> bevy::math::UVec3; + fn extend( + _self: LuaReflectValProxy, + z: u32, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::UVec2) -> u32; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> u32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7532,7 +8782,10 @@ pub struct LuaI64Vec4 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7540,7 +8793,10 @@ pub struct LuaI64Vec4 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7551,12 +8807,10 @@ pub struct LuaI64Vec4 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::UVec2, - #[proxy] - max: bevy::math::UVec2, - ) -> bevy::math::UVec2; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7564,7 +8818,7 @@ pub struct LuaI64Vec4 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> u32; + fn min_element(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -7572,7 +8826,7 @@ pub struct LuaI64Vec4 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> u32; + fn max_element(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -7582,7 +8836,10 @@ pub struct LuaI64Vec4 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7592,7 +8849,10 @@ pub struct LuaI64Vec4 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7602,7 +8862,10 @@ pub struct LuaI64Vec4 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7612,7 +8875,10 @@ pub struct LuaI64Vec4 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7622,7 +8888,10 @@ pub struct LuaI64Vec4 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7632,49 +8901,62 @@ pub struct LuaI64Vec4 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the squared length of `self`. #[lua()] - fn length_squared(self) -> u32; + fn length_squared(_self: LuaReflectValProxy) -> u32; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec2(&self) -> bevy::math::Vec2; + fn as_vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec2(&self) -> bevy::math::DVec2; + fn as_dvec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec2(&self) -> bevy::math::IVec2; + fn as_ivec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; + fn as_i64vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; + fn as_u64vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7682,7 +8964,10 @@ pub struct LuaI64Vec4 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua()] - fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn wrapping_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7690,7 +8975,10 @@ pub struct LuaI64Vec4 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua()] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn wrapping_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7698,7 +8986,10 @@ pub struct LuaI64Vec4 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua()] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn wrapping_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7706,7 +8997,10 @@ pub struct LuaI64Vec4 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua()] - fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn wrapping_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7714,7 +9008,10 @@ pub struct LuaI64Vec4 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua()] - fn saturating_add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn saturating_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7722,7 +9019,10 @@ pub struct LuaI64Vec4 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua()] - fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn saturating_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7730,7 +9030,10 @@ pub struct LuaI64Vec4 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua()] - fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7738,7 +9041,10 @@ pub struct LuaI64Vec4 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua()] - fn saturating_div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn saturating_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7748,19 +9054,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: u32) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaUVec2 { +pub struct UVec2 { x: u32, y: u32, } @@ -7771,52 +9077,70 @@ pub struct LuaUVec2 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: u32) -> bevy::math::UVec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: u32) -> bevy::math::UVec3; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: u32) -> bevy::math::UVec3; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: u32, y: u32, z: u32) -> bevy::math::UVec3; + fn new(x: u32, y: u32, z: u32) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: u32) -> bevy::math::UVec3; + fn splat(v: u32) -> LuaReflectValProxy; "#, r#" @@ -7827,34 +9151,34 @@ pub struct LuaUVec2 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec3, - #[proxy] - if_true: bevy::math::UVec3, - #[proxy] - if_false: bevy::math::UVec3, - ) -> bevy::math::UVec3; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [u32; 3]) -> bevy::math::UVec3; + fn from_array(a: [u32; 3]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z]` #[lua()] - fn to_array(&self) -> [u32; 3]; + fn to_array(_self: LuaReflectRefProxy) -> [u32; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. #[lua()] - fn extend(self, w: u32) -> bevy::math::UVec4; + fn extend( + _self: LuaReflectValProxy, + w: u32, + ) -> LuaReflectValProxy; "#, r#" @@ -7862,28 +9186,39 @@ pub struct LuaUVec2 { /// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. #[lua()] - fn truncate(self) -> bevy::math::UVec2; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::UVec3) -> u32; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> u32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the cross product of `self` and `rhs`. #[lua()] - fn cross(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn cross( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7891,7 +9226,10 @@ pub struct LuaUVec2 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7899,7 +9237,10 @@ pub struct LuaUVec2 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7910,12 +9251,10 @@ pub struct LuaUVec2 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::UVec3, - #[proxy] - max: bevy::math::UVec3, - ) -> bevy::math::UVec3; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7923,7 +9262,7 @@ pub struct LuaUVec2 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> u32; + fn min_element(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -7931,7 +9270,7 @@ pub struct LuaUVec2 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> u32; + fn max_element(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -7941,7 +9280,10 @@ pub struct LuaUVec2 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7951,7 +9293,10 @@ pub struct LuaUVec2 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7961,7 +9306,10 @@ pub struct LuaUVec2 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7971,7 +9319,10 @@ pub struct LuaUVec2 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7981,7 +9332,10 @@ pub struct LuaUVec2 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -7991,56 +9345,71 @@ pub struct LuaUVec2 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the squared length of `self`. #[lua()] - fn length_squared(self) -> u32; + fn length_squared(_self: LuaReflectValProxy) -> u32; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec3(&self) -> bevy::math::Vec3; + fn as_vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec3a(&self) -> bevy::math::Vec3A; + fn as_vec3a( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec3(&self) -> bevy::math::DVec3; + fn as_dvec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec3(&self) -> bevy::math::IVec3; + fn as_ivec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; + fn as_i64vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; + fn as_u64vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8048,7 +9417,10 @@ pub struct LuaUVec2 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua()] - fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn wrapping_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8056,7 +9428,10 @@ pub struct LuaUVec2 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua()] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn wrapping_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8064,7 +9439,10 @@ pub struct LuaUVec2 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua()] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn wrapping_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8072,7 +9450,10 @@ pub struct LuaUVec2 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua()] - fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn wrapping_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8080,7 +9461,10 @@ pub struct LuaUVec2 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua()] - fn saturating_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn saturating_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8088,7 +9472,10 @@ pub struct LuaUVec2 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua()] - fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn saturating_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8096,7 +9483,10 @@ pub struct LuaUVec2 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua()] - fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8104,49 +9494,69 @@ pub struct LuaUVec2 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua()] - fn saturating_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn saturating_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::UVec3) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: u32) -> bevy::math::UVec3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::UVec3; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: u32) -> bevy::math::UVec3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" @@ -8156,19 +9566,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: u32) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaUVec3 { +pub struct UVec3 { x: u32, y: u32, z: u32, @@ -8180,58 +9590,76 @@ pub struct LuaUVec3 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: u32) -> bevy::math::UVec4; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: u32) -> bevy::math::UVec4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: u32) -> bevy::math::UVec4; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: u32, y: u32, z: u32, w: u32) -> bevy::math::UVec4; + fn new(x: u32, y: u32, z: u32, w: u32) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: u32) -> bevy::math::UVec4; + fn splat(v: u32) -> LuaReflectValProxy; "#, r#" @@ -8242,27 +9670,24 @@ pub struct LuaUVec3 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec4, - #[proxy] - if_true: bevy::math::UVec4, - #[proxy] - if_false: bevy::math::UVec4, - ) -> bevy::math::UVec4; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [u32; 4]) -> bevy::math::UVec4; + fn from_array(a: [u32; 4]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z, w]` #[lua()] - fn to_array(&self) -> [u32; 4]; + fn to_array(_self: LuaReflectRefProxy) -> [u32; 4]; "#, r#" @@ -8270,21 +9695,29 @@ pub struct LuaUVec3 { /// Truncation to [`UVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. #[lua()] - fn truncate(self) -> bevy::math::UVec3; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::UVec4) -> u32; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> u32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8292,7 +9725,10 @@ pub struct LuaUVec3 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8300,7 +9736,10 @@ pub struct LuaUVec3 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8311,12 +9750,10 @@ pub struct LuaUVec3 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::UVec4, - #[proxy] - max: bevy::math::UVec4, - ) -> bevy::math::UVec4; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8324,7 +9761,7 @@ pub struct LuaUVec3 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> u32; + fn min_element(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -8332,7 +9769,7 @@ pub struct LuaUVec3 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> u32; + fn max_element(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -8342,7 +9779,10 @@ pub struct LuaUVec3 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8352,7 +9792,10 @@ pub struct LuaUVec3 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8362,7 +9805,10 @@ pub struct LuaUVec3 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8372,7 +9818,10 @@ pub struct LuaUVec3 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8382,7 +9831,10 @@ pub struct LuaUVec3 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8392,49 +9844,62 @@ pub struct LuaUVec3 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the squared length of `self`. #[lua()] - fn length_squared(self) -> u32; + fn length_squared(_self: LuaReflectValProxy) -> u32; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec4(&self) -> bevy::math::Vec4; + fn as_vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec4(&self) -> bevy::math::DVec4; + fn as_dvec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec4(&self) -> bevy::math::IVec4; + fn as_ivec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; + fn as_i64vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; + fn as_u64vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8442,7 +9907,10 @@ pub struct LuaUVec3 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua()] - fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn wrapping_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8450,7 +9918,10 @@ pub struct LuaUVec3 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua()] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn wrapping_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8458,7 +9929,10 @@ pub struct LuaUVec3 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua()] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn wrapping_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8466,7 +9940,10 @@ pub struct LuaUVec3 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua()] - fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn wrapping_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8474,7 +9951,10 @@ pub struct LuaUVec3 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua()] - fn saturating_add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn saturating_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8482,7 +9962,10 @@ pub struct LuaUVec3 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua()] - fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn saturating_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8490,7 +9973,10 @@ pub struct LuaUVec3 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua()] - fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8498,43 +9984,63 @@ pub struct LuaUVec3 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua()] - fn saturating_div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn saturating_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::UVec4) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: u32) -> bevy::math::UVec4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::UVec4; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: u32) -> bevy::math::UVec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: u32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8544,19 +10050,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: u32) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaUVec4 { +pub struct UVec4 { x: u32, y: u32, z: u32, @@ -8569,22 +10075,25 @@ pub struct LuaUVec4 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: u64) -> bevy::math::U64Vec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: u64, y: u64) -> bevy::math::U64Vec2; + fn new(x: u64, y: u64) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: u64) -> bevy::math::U64Vec2; + fn splat(v: u64) -> LuaReflectValProxy; "#, r#" @@ -8595,48 +10104,54 @@ pub struct LuaUVec4 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec2, - #[proxy] - if_true: bevy::math::U64Vec2, - #[proxy] - if_false: bevy::math::U64Vec2, - ) -> bevy::math::U64Vec2; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [u64; 2]) -> bevy::math::U64Vec2; + fn from_array(a: [u64; 2]) -> LuaReflectValProxy; "#, r#" /// `[x, y]` #[lua()] - fn to_array(&self) -> [u64; 2]; + fn to_array(_self: LuaReflectRefProxy) -> [u64; 2]; "#, r#" /// Creates a 3D vector from `self` and the given `z` value. #[lua()] - fn extend(self, z: u64) -> bevy::math::U64Vec3; + fn extend( + _self: LuaReflectValProxy, + z: u64, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::U64Vec2) -> u64; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> u64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8644,7 +10159,10 @@ pub struct LuaUVec4 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8652,7 +10170,10 @@ pub struct LuaUVec4 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8663,12 +10184,10 @@ pub struct LuaUVec4 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::U64Vec2, - #[proxy] - max: bevy::math::U64Vec2, - ) -> bevy::math::U64Vec2; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8676,7 +10195,7 @@ pub struct LuaUVec4 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> u64; + fn min_element(_self: LuaReflectValProxy) -> u64; "#, r#" @@ -8684,7 +10203,7 @@ pub struct LuaUVec4 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> u64; + fn max_element(_self: LuaReflectValProxy) -> u64; "#, r#" @@ -8694,7 +10213,10 @@ pub struct LuaUVec4 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8704,7 +10226,10 @@ pub struct LuaUVec4 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8714,7 +10239,10 @@ pub struct LuaUVec4 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8724,7 +10252,10 @@ pub struct LuaUVec4 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8734,7 +10265,10 @@ pub struct LuaUVec4 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8744,49 +10278,62 @@ pub struct LuaUVec4 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the squared length of `self`. #[lua()] - fn length_squared(self) -> u64; + fn length_squared(_self: LuaReflectValProxy) -> u64; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec2(&self) -> bevy::math::Vec2; + fn as_vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec2(&self) -> bevy::math::DVec2; + fn as_dvec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec2(&self) -> bevy::math::IVec2; + fn as_ivec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec2(&self) -> bevy::math::UVec2; + fn as_uvec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; + fn as_i64vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8794,7 +10341,10 @@ pub struct LuaUVec4 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua()] - fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn wrapping_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8802,7 +10352,10 @@ pub struct LuaUVec4 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua()] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn wrapping_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8810,7 +10363,10 @@ pub struct LuaUVec4 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua()] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn wrapping_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8818,7 +10374,10 @@ pub struct LuaUVec4 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua()] - fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn wrapping_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8826,7 +10385,10 @@ pub struct LuaUVec4 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua()] - fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn saturating_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8834,7 +10396,10 @@ pub struct LuaUVec4 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua()] - fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn saturating_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8842,7 +10407,10 @@ pub struct LuaUVec4 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua()] - fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -8850,79 +10418,114 @@ pub struct LuaUVec4 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua()] - fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn saturating_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: u64) -> bevy::math::U64Vec2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: u64) -> bevy::math::U64Vec2; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::U64Vec2; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::U64Vec2) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: u64) -> bevy::math::U64Vec2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: u64) -> bevy::math::U64Vec2; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" @@ -8932,7 +10535,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaU64Vec2 { +pub struct U64Vec2 { x: u64, y: u64, } @@ -8943,22 +10546,25 @@ pub struct LuaU64Vec2 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: u64) -> bevy::math::U64Vec3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: u64, y: u64, z: u64) -> bevy::math::U64Vec3; + fn new(x: u64, y: u64, z: u64) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: u64) -> bevy::math::U64Vec3; + fn splat(v: u64) -> LuaReflectValProxy; "#, r#" @@ -8969,34 +10575,34 @@ pub struct LuaU64Vec2 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec3, - #[proxy] - if_true: bevy::math::U64Vec3, - #[proxy] - if_false: bevy::math::U64Vec3, - ) -> bevy::math::U64Vec3; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [u64; 3]) -> bevy::math::U64Vec3; + fn from_array(a: [u64; 3]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z]` #[lua()] - fn to_array(&self) -> [u64; 3]; + fn to_array(_self: LuaReflectRefProxy) -> [u64; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. #[lua()] - fn extend(self, w: u64) -> bevy::math::U64Vec4; + fn extend( + _self: LuaReflectValProxy, + w: u64, + ) -> LuaReflectValProxy; "#, r#" @@ -9004,28 +10610,39 @@ pub struct LuaU64Vec2 { /// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. #[lua()] - fn truncate(self) -> bevy::math::U64Vec2; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::U64Vec3) -> u64; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> u64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the cross product of `self` and `rhs`. #[lua()] - fn cross(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn cross( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9033,7 +10650,10 @@ pub struct LuaU64Vec2 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9041,7 +10661,10 @@ pub struct LuaU64Vec2 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9052,12 +10675,10 @@ pub struct LuaU64Vec2 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::U64Vec3, - #[proxy] - max: bevy::math::U64Vec3, - ) -> bevy::math::U64Vec3; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9065,7 +10686,7 @@ pub struct LuaU64Vec2 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> u64; + fn min_element(_self: LuaReflectValProxy) -> u64; "#, r#" @@ -9073,7 +10694,7 @@ pub struct LuaU64Vec2 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> u64; + fn max_element(_self: LuaReflectValProxy) -> u64; "#, r#" @@ -9083,7 +10704,10 @@ pub struct LuaU64Vec2 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9093,7 +10717,10 @@ pub struct LuaU64Vec2 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9103,7 +10730,10 @@ pub struct LuaU64Vec2 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9113,7 +10743,10 @@ pub struct LuaU64Vec2 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9123,7 +10756,10 @@ pub struct LuaU64Vec2 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9133,56 +10769,71 @@ pub struct LuaU64Vec2 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the squared length of `self`. #[lua()] - fn length_squared(self) -> u64; + fn length_squared(_self: LuaReflectValProxy) -> u64; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec3(&self) -> bevy::math::Vec3; + fn as_vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec3a(&self) -> bevy::math::Vec3A; + fn as_vec3a( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec3(&self) -> bevy::math::DVec3; + fn as_dvec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec3(&self) -> bevy::math::IVec3; + fn as_ivec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec3(&self) -> bevy::math::UVec3; + fn as_uvec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; + fn as_i64vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9190,7 +10841,10 @@ pub struct LuaU64Vec2 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua()] - fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn wrapping_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9198,7 +10852,10 @@ pub struct LuaU64Vec2 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua()] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn wrapping_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9206,7 +10863,10 @@ pub struct LuaU64Vec2 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua()] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn wrapping_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9214,7 +10874,10 @@ pub struct LuaU64Vec2 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua()] - fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn wrapping_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9222,7 +10885,10 @@ pub struct LuaU64Vec2 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua()] - fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn saturating_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9230,7 +10896,10 @@ pub struct LuaU64Vec2 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua()] - fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn saturating_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9238,7 +10907,10 @@ pub struct LuaU64Vec2 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua()] - fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9246,79 +10918,114 @@ pub struct LuaU64Vec2 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua()] - fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn saturating_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: u64) -> bevy::math::U64Vec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::U64Vec3; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: u64) -> bevy::math::U64Vec3; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: u64) -> bevy::math::U64Vec3; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::U64Vec3) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: u64) -> bevy::math::U64Vec3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9328,7 +11035,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaU64Vec3 { +pub struct U64Vec3 { x: u64, y: u64, z: u64, @@ -9342,14 +11049,14 @@ pub struct LuaU64Vec3 { /// Creates a new vector. #[lua()] - fn new(x: u64, y: u64, z: u64, w: u64) -> bevy::math::U64Vec4; + fn new(x: u64, y: u64, z: u64, w: u64) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: u64) -> bevy::math::U64Vec4; + fn splat(v: u64) -> LuaReflectValProxy; "#, r#" @@ -9360,27 +11067,24 @@ pub struct LuaU64Vec3 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec4, - #[proxy] - if_true: bevy::math::U64Vec4, - #[proxy] - if_false: bevy::math::U64Vec4, - ) -> bevy::math::U64Vec4; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [u64; 4]) -> bevy::math::U64Vec4; + fn from_array(a: [u64; 4]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z, w]` #[lua()] - fn to_array(&self) -> [u64; 4]; + fn to_array(_self: LuaReflectRefProxy) -> [u64; 4]; "#, r#" @@ -9388,21 +11092,29 @@ pub struct LuaU64Vec3 { /// Truncation to [`U64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. #[lua()] - fn truncate(self) -> bevy::math::U64Vec3; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::U64Vec4) -> u64; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> u64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9410,7 +11122,10 @@ pub struct LuaU64Vec3 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9418,7 +11133,10 @@ pub struct LuaU64Vec3 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9429,12 +11147,10 @@ pub struct LuaU64Vec3 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::U64Vec4, - #[proxy] - max: bevy::math::U64Vec4, - ) -> bevy::math::U64Vec4; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9442,7 +11158,7 @@ pub struct LuaU64Vec3 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> u64; + fn min_element(_self: LuaReflectValProxy) -> u64; "#, r#" @@ -9450,7 +11166,7 @@ pub struct LuaU64Vec3 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> u64; + fn max_element(_self: LuaReflectValProxy) -> u64; "#, r#" @@ -9460,7 +11176,10 @@ pub struct LuaU64Vec3 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9470,7 +11189,10 @@ pub struct LuaU64Vec3 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9480,7 +11202,10 @@ pub struct LuaU64Vec3 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9490,7 +11215,10 @@ pub struct LuaU64Vec3 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9500,7 +11228,10 @@ pub struct LuaU64Vec3 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9510,49 +11241,62 @@ pub struct LuaU64Vec3 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the squared length of `self`. #[lua()] - fn length_squared(self) -> u64; + fn length_squared(_self: LuaReflectValProxy) -> u64; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec4(&self) -> bevy::math::Vec4; + fn as_vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec4(&self) -> bevy::math::DVec4; + fn as_dvec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec4(&self) -> bevy::math::IVec4; + fn as_ivec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec4(&self) -> bevy::math::UVec4; + fn as_uvec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; + fn as_i64vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9560,7 +11304,10 @@ pub struct LuaU64Vec3 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua()] - fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn wrapping_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9568,7 +11315,10 @@ pub struct LuaU64Vec3 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua()] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn wrapping_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9576,7 +11326,10 @@ pub struct LuaU64Vec3 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua()] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn wrapping_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9584,7 +11337,10 @@ pub struct LuaU64Vec3 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua()] - fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn wrapping_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9592,7 +11348,10 @@ pub struct LuaU64Vec3 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua()] - fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn saturating_add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9600,7 +11359,10 @@ pub struct LuaU64Vec3 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua()] - fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn saturating_sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9608,7 +11370,10 @@ pub struct LuaU64Vec3 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua()] - fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn saturating_mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9616,85 +11381,123 @@ pub struct LuaU64Vec3 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua()] - fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn saturating_div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: u64) -> bevy::math::U64Vec4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: u64) -> bevy::math::U64Vec4; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: u64) -> bevy::math::U64Vec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: u64) -> bevy::math::U64Vec4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::U64Vec4) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: u64) -> bevy::math::U64Vec4; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: u64, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::U64Vec4; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9704,7 +11507,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaU64Vec4 { +pub struct U64Vec4 { x: u64, y: u64, z: u64, @@ -9717,82 +11520,114 @@ pub struct LuaU64Vec4 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: f32) -> bevy::math::Vec2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: f32) -> bevy::math::Vec2; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: f32) -> bevy::math::Vec2; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::Vec2; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::Vec2) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f32) -> bevy::math::Vec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: f32, y: f32) -> bevy::math::Vec2; + fn new(x: f32, y: f32) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: f32) -> bevy::math::Vec2; + fn splat(v: f32) -> LuaReflectValProxy; "#, r#" @@ -9803,48 +11638,54 @@ pub struct LuaU64Vec4 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec2, - #[proxy] - if_true: bevy::math::Vec2, - #[proxy] - if_false: bevy::math::Vec2, - ) -> bevy::math::Vec2; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [f32; 2]) -> bevy::math::Vec2; + fn from_array(a: [f32; 2]) -> LuaReflectValProxy; "#, r#" /// `[x, y]` #[lua()] - fn to_array(&self) -> [f32; 2]; + fn to_array(_self: LuaReflectRefProxy) -> [f32; 2]; "#, r#" /// Creates a 3D vector from `self` and the given `z` value. #[lua()] - fn extend(self, z: f32) -> bevy::math::Vec3; + fn extend( + _self: LuaReflectValProxy, + z: f32, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9852,7 +11693,10 @@ pub struct LuaU64Vec4 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9860,7 +11704,10 @@ pub struct LuaU64Vec4 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9871,12 +11718,10 @@ pub struct LuaU64Vec4 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::Vec2, - #[proxy] - max: bevy::math::Vec2, - ) -> bevy::math::Vec2; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9884,7 +11729,7 @@ pub struct LuaU64Vec4 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> f32; + fn min_element(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -9892,7 +11737,7 @@ pub struct LuaU64Vec4 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> f32; + fn max_element(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -9902,7 +11747,10 @@ pub struct LuaU64Vec4 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9912,7 +11760,10 @@ pub struct LuaU64Vec4 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9922,7 +11773,10 @@ pub struct LuaU64Vec4 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9932,7 +11786,10 @@ pub struct LuaU64Vec4 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9942,7 +11799,10 @@ pub struct LuaU64Vec4 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9952,14 +11812,19 @@ pub struct LuaU64Vec4 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::Vec2; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9969,14 +11834,19 @@ pub struct LuaU64Vec4 { /// - `NAN` if the number is `NAN` #[lua()] - fn signum(self) -> bevy::math::Vec2; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. #[lua()] - fn copysign(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn copysign( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -9985,7 +11855,7 @@ pub struct LuaU64Vec4 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -9993,14 +11863,14 @@ pub struct LuaU64Vec4 { /// `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(self) -> bool; + fn is_finite(_self: LuaReflectValProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(self) -> bool; + fn is_nan(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -10008,14 +11878,16 @@ pub struct LuaU64Vec4 { /// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. #[lua()] - fn is_nan_mask(self) -> bevy::math::BVec2; + fn is_nan_mask( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the length of `self`. #[lua()] - fn length(self) -> f32; + fn length(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -10023,7 +11895,7 @@ pub struct LuaU64Vec4 { /// This is faster than `length()` as it avoids a square root operation. #[lua()] - fn length_squared(self) -> f32; + fn length_squared(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -10031,28 +11903,37 @@ pub struct LuaU64Vec4 { /// For valid results, `self` must _not_ be of length zero. #[lua()] - fn length_recip(self) -> f32; + fn length_recip(_self: LuaReflectValProxy) -> f32; "#, r#" /// Computes the Euclidean distance between two points in space. #[lua()] - fn distance(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + fn distance( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10060,7 +11941,10 @@ pub struct LuaU64Vec4 { /// [Euclidean division]: f32::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10071,7 +11955,9 @@ pub struct LuaU64Vec4 { /// Will panic if `self` is zero length when `glam_assert` is enabled. #[lua()] - fn normalize(self) -> bevy::math::Vec2; + fn normalize( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10081,7 +11967,9 @@ pub struct LuaU64Vec4 { /// See also [`Self::try_normalize()`]. #[lua()] - fn normalize_or_zero(self) -> bevy::math::Vec2; + fn normalize_or_zero( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10089,7 +11977,7 @@ pub struct LuaU64Vec4 { /// Uses a precision threshold of `1e-6`. #[lua()] - fn is_normalized(self) -> bool; + fn is_normalized(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -10099,7 +11987,10 @@ pub struct LuaU64Vec4 { /// Will panic if `rhs` is zero length when `glam_assert` is enabled. #[lua()] - fn project_onto(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn project_onto( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10111,7 +12002,10 @@ pub struct LuaU64Vec4 { /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. #[lua()] - fn reject_from(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn reject_from( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10121,7 +12015,10 @@ pub struct LuaU64Vec4 { /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua()] - fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn project_onto_normalized( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10133,7 +12030,10 @@ pub struct LuaU64Vec4 { /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua()] - fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn reject_from_normalized( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10141,7 +12041,9 @@ pub struct LuaU64Vec4 { /// Round half-way cases away from 0.0. #[lua()] - fn round(self) -> bevy::math::Vec2; + fn round( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10149,7 +12051,9 @@ pub struct LuaU64Vec4 { /// element of `self`. #[lua()] - fn floor(self) -> bevy::math::Vec2; + fn floor( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10157,7 +12061,9 @@ pub struct LuaU64Vec4 { /// each element of `self`. #[lua()] - fn ceil(self) -> bevy::math::Vec2; + fn ceil( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10165,7 +12071,9 @@ pub struct LuaU64Vec4 { /// always truncated towards zero. #[lua()] - fn trunc(self) -> bevy::math::Vec2; + fn trunc( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10174,7 +12082,9 @@ pub struct LuaU64Vec4 { /// Note that this is fast but not precise for large numbers. #[lua()] - fn fract(self) -> bevy::math::Vec2; + fn fract( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10182,21 +12092,28 @@ pub struct LuaU64Vec4 { /// `self`. #[lua()] - fn exp(self) -> bevy::math::Vec2; + fn exp( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. #[lua()] - fn powf(self, n: f32) -> bevy::math::Vec2; + fn powf( + _self: LuaReflectValProxy, + n: f32, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. #[lua()] - fn recip(self) -> bevy::math::Vec2; + fn recip( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10206,7 +12123,11 @@ pub struct LuaU64Vec4 { /// extrapolated. #[lua()] - fn lerp(self, #[proxy] rhs: bevy::math::Vec2, s: f32) -> bevy::math::Vec2; + fn lerp( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + s: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -10219,7 +12140,11 @@ pub struct LuaU64Vec4 { /// [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: bevy::math::Vec2, max_abs_diff: f32) -> bool; + fn abs_diff_eq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f32, + ) -> bool; "#, r#" @@ -10228,21 +12153,31 @@ pub struct LuaU64Vec4 { /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua()] - fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec2; + fn clamp_length( + _self: LuaReflectValProxy, + min: f32, + max: f32, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no more than `max` #[lua()] - fn clamp_length_max(self, max: f32) -> bevy::math::Vec2; + fn clamp_length_max( + _self: LuaReflectValProxy, + max: f32, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no less than `min` #[lua()] - fn clamp_length_min(self, min: f32) -> bevy::math::Vec2; + fn clamp_length_min( + _self: LuaReflectValProxy, + min: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -10255,12 +12190,10 @@ pub struct LuaU64Vec4 { #[lua()] fn mul_add( - self, - #[proxy] - a: bevy::math::Vec2, - #[proxy] - b: bevy::math::Vec2, - ) -> bevy::math::Vec2; + _self: LuaReflectValProxy, + a: LuaReflectValProxy, + b: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10270,7 +12203,7 @@ pub struct LuaU64Vec4 { /// and rotate [`Vec2::Y`] around it returning `-Vec2::Y`. #[lua()] - fn from_angle(angle: f32) -> bevy::math::Vec2; + fn from_angle(angle: f32) -> LuaReflectValProxy; "#, r#" @@ -10278,7 +12211,7 @@ pub struct LuaU64Vec4 { /// The input does not need to be a unit vector however it must be non-zero. #[lua()] - fn to_angle(self) -> f32; + fn to_angle(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -10286,14 +12219,19 @@ pub struct LuaU64Vec4 { /// The inputs do not need to be unit vectors however they must be non-zero. #[lua()] - fn angle_between(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + fn angle_between( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Returns a vector that is equal to `self` rotated by 90 degrees. #[lua()] - fn perp(self) -> bevy::math::Vec2; + fn perp( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10301,7 +12239,10 @@ pub struct LuaU64Vec4 { /// Also known as the wedge product, 2D cross product, and determinant. #[lua()] - fn perp_dot(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + fn perp_dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" @@ -10310,54 +12251,72 @@ pub struct LuaU64Vec4 { /// it will be like a rotation with a multiplication by `self`'s length. #[lua()] - fn rotate(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn rotate( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec2(&self) -> bevy::math::DVec2; + fn as_dvec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec2(&self) -> bevy::math::IVec2; + fn as_ivec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec2(&self) -> bevy::math::UVec2; + fn as_uvec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; + fn as_i64vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; + fn as_u64vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: f32) -> bevy::math::Vec2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::Vec2; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10367,19 +12326,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f32) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaVec2 { +pub struct Vec2 { x: f32, y: f32, } @@ -10390,40 +12349,52 @@ pub struct LuaVec2 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: f32) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::Vec3A) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: f32) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3A; + fn new(x: f32, y: f32, z: f32) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: f32) -> bevy::math::Vec3A; + fn splat(v: f32) -> LuaReflectValProxy; "#, r#" @@ -10434,34 +12405,34 @@ pub struct LuaVec2 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec3A, - #[proxy] - if_true: bevy::math::Vec3A, - #[proxy] - if_false: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [f32; 3]) -> bevy::math::Vec3A; + fn from_array(a: [f32; 3]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z]` #[lua()] - fn to_array(&self) -> [f32; 3]; + fn to_array(_self: LuaReflectRefProxy) -> [f32; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. #[lua()] - fn extend(self, w: f32) -> bevy::math::Vec4; + fn extend( + _self: LuaReflectValProxy, + w: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -10469,28 +12440,39 @@ pub struct LuaVec2 { /// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. #[lua()] - fn truncate(self) -> bevy::math::Vec2; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the cross product of `self` and `rhs`. #[lua()] - fn cross(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn cross( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10498,7 +12480,10 @@ pub struct LuaVec2 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10506,7 +12491,10 @@ pub struct LuaVec2 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10517,12 +12505,10 @@ pub struct LuaVec2 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::Vec3A, - #[proxy] - max: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10530,7 +12516,7 @@ pub struct LuaVec2 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> f32; + fn min_element(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -10538,7 +12524,7 @@ pub struct LuaVec2 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> f32; + fn max_element(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -10548,7 +12534,10 @@ pub struct LuaVec2 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10558,7 +12547,10 @@ pub struct LuaVec2 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10568,7 +12560,10 @@ pub struct LuaVec2 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10578,7 +12573,10 @@ pub struct LuaVec2 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10588,7 +12586,10 @@ pub struct LuaVec2 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10598,14 +12599,19 @@ pub struct LuaVec2 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::Vec3A; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10615,14 +12621,19 @@ pub struct LuaVec2 { /// - `NAN` if the number is `NAN` #[lua()] - fn signum(self) -> bevy::math::Vec3A; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. #[lua()] - fn copysign(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn copysign( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10631,7 +12642,7 @@ pub struct LuaVec2 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -10639,14 +12650,14 @@ pub struct LuaVec2 { /// `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(self) -> bool; + fn is_finite(_self: LuaReflectValProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(self) -> bool; + fn is_nan(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -10654,14 +12665,16 @@ pub struct LuaVec2 { /// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. #[lua()] - fn is_nan_mask(self) -> bevy::math::BVec3A; + fn is_nan_mask( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the length of `self`. #[lua()] - fn length(self) -> f32; + fn length(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -10669,7 +12682,7 @@ pub struct LuaVec2 { /// This is faster than `length()` as it avoids a square root operation. #[lua()] - fn length_squared(self) -> f32; + fn length_squared(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -10677,28 +12690,37 @@ pub struct LuaVec2 { /// For valid results, `self` must _not_ be of length zero. #[lua()] - fn length_recip(self) -> f32; + fn length_recip(_self: LuaReflectValProxy) -> f32; "#, r#" /// Computes the Euclidean distance between two points in space. #[lua()] - fn distance(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; + fn distance( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10706,7 +12728,10 @@ pub struct LuaVec2 { /// [Euclidean division]: f32::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10717,7 +12742,9 @@ pub struct LuaVec2 { /// Will panic if `self` is zero length when `glam_assert` is enabled. #[lua()] - fn normalize(self) -> bevy::math::Vec3A; + fn normalize( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10727,7 +12754,9 @@ pub struct LuaVec2 { /// See also [`Self::try_normalize()`]. #[lua()] - fn normalize_or_zero(self) -> bevy::math::Vec3A; + fn normalize_or_zero( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10735,7 +12764,7 @@ pub struct LuaVec2 { /// Uses a precision threshold of `1e-6`. #[lua()] - fn is_normalized(self) -> bool; + fn is_normalized(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -10745,7 +12774,10 @@ pub struct LuaVec2 { /// Will panic if `rhs` is zero length when `glam_assert` is enabled. #[lua()] - fn project_onto(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn project_onto( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10757,7 +12789,10 @@ pub struct LuaVec2 { /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. #[lua()] - fn reject_from(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn reject_from( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10768,10 +12803,9 @@ pub struct LuaVec2 { #[lua()] fn project_onto_normalized( - self, - #[proxy] - rhs: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10784,10 +12818,9 @@ pub struct LuaVec2 { #[lua()] fn reject_from_normalized( - self, - #[proxy] - rhs: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10795,7 +12828,9 @@ pub struct LuaVec2 { /// Round half-way cases away from 0.0. #[lua()] - fn round(self) -> bevy::math::Vec3A; + fn round( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10803,7 +12838,9 @@ pub struct LuaVec2 { /// element of `self`. #[lua()] - fn floor(self) -> bevy::math::Vec3A; + fn floor( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10811,7 +12848,9 @@ pub struct LuaVec2 { /// each element of `self`. #[lua()] - fn ceil(self) -> bevy::math::Vec3A; + fn ceil( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10819,7 +12858,9 @@ pub struct LuaVec2 { /// always truncated towards zero. #[lua()] - fn trunc(self) -> bevy::math::Vec3A; + fn trunc( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10828,7 +12869,9 @@ pub struct LuaVec2 { /// Note that this is fast but not precise for large numbers. #[lua()] - fn fract(self) -> bevy::math::Vec3A; + fn fract( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10836,21 +12879,28 @@ pub struct LuaVec2 { /// `self`. #[lua()] - fn exp(self) -> bevy::math::Vec3A; + fn exp( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. #[lua()] - fn powf(self, n: f32) -> bevy::math::Vec3A; + fn powf( + _self: LuaReflectValProxy, + n: f32, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. #[lua()] - fn recip(self) -> bevy::math::Vec3A; + fn recip( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10860,7 +12910,11 @@ pub struct LuaVec2 { /// extrapolated. #[lua()] - fn lerp(self, #[proxy] rhs: bevy::math::Vec3A, s: f32) -> bevy::math::Vec3A; + fn lerp( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + s: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -10873,7 +12927,11 @@ pub struct LuaVec2 { /// [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: bevy::math::Vec3A, max_abs_diff: f32) -> bool; + fn abs_diff_eq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f32, + ) -> bool; "#, r#" @@ -10882,21 +12940,31 @@ pub struct LuaVec2 { /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua()] - fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3A; + fn clamp_length( + _self: LuaReflectValProxy, + min: f32, + max: f32, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no more than `max` #[lua()] - fn clamp_length_max(self, max: f32) -> bevy::math::Vec3A; + fn clamp_length_max( + _self: LuaReflectValProxy, + max: f32, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no less than `min` #[lua()] - fn clamp_length_min(self, min: f32) -> bevy::math::Vec3A; + fn clamp_length_min( + _self: LuaReflectValProxy, + min: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -10909,12 +12977,10 @@ pub struct LuaVec2 { #[lua()] fn mul_add( - self, - #[proxy] - a: bevy::math::Vec3A, - #[proxy] - b: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; + _self: LuaReflectValProxy, + a: LuaReflectValProxy, + b: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10922,7 +12988,10 @@ pub struct LuaVec2 { /// The inputs do not need to be unit vectors however they must be non-zero. #[lua()] - fn angle_between(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; + fn angle_between( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" @@ -10932,7 +13001,9 @@ pub struct LuaVec2 { /// [`Self::any_orthonormal_vector()`] instead. #[lua()] - fn any_orthogonal_vector(&self) -> bevy::math::Vec3A; + fn any_orthogonal_vector( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -10942,96 +13013,133 @@ pub struct LuaVec2 { /// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua()] - fn any_orthonormal_vector(&self) -> bevy::math::Vec3A; + fn any_orthonormal_vector( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec3(&self) -> bevy::math::DVec3; + fn as_dvec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec3(&self) -> bevy::math::IVec3; + fn as_ivec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec3(&self) -> bevy::math::UVec3; + fn as_uvec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; + fn as_i64vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; + fn as_u64vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: f32) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: f32) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f32) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::Vec3A; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::Vec3A; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11041,19 +13149,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f32) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaVec3A(); +pub struct Vec3A(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::Vec4", @@ -11061,40 +13169,51 @@ pub struct LuaVec3A(); bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::Vec4) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::Vec4; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: f32, y: f32, z: f32, w: f32) -> bevy::math::Vec4; + fn new(x: f32, y: f32, z: f32, w: f32) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: f32) -> bevy::math::Vec4; + fn splat(v: f32) -> LuaReflectValProxy; "#, r#" @@ -11105,27 +13224,24 @@ pub struct LuaVec3A(); #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec4A, - #[proxy] - if_true: bevy::math::Vec4, - #[proxy] - if_false: bevy::math::Vec4, - ) -> bevy::math::Vec4; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [f32; 4]) -> bevy::math::Vec4; + fn from_array(a: [f32; 4]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z, w]` #[lua()] - fn to_array(&self) -> [f32; 4]; + fn to_array(_self: LuaReflectRefProxy) -> [f32; 4]; "#, r#" @@ -11134,21 +13250,29 @@ pub struct LuaVec3A(); /// To truncate to [`Vec3A`] use [`Vec3A::from()`]. #[lua()] - fn truncate(self) -> bevy::math::Vec3; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::Vec4) -> f32; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11156,7 +13280,10 @@ pub struct LuaVec3A(); /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11164,7 +13291,10 @@ pub struct LuaVec3A(); /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11175,12 +13305,10 @@ pub struct LuaVec3A(); #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::Vec4, - #[proxy] - max: bevy::math::Vec4, - ) -> bevy::math::Vec4; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11188,7 +13316,7 @@ pub struct LuaVec3A(); /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> f32; + fn min_element(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -11196,7 +13324,7 @@ pub struct LuaVec3A(); /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> f32; + fn max_element(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -11206,7 +13334,10 @@ pub struct LuaVec3A(); /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11216,7 +13347,10 @@ pub struct LuaVec3A(); /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11226,7 +13360,10 @@ pub struct LuaVec3A(); /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11236,7 +13373,10 @@ pub struct LuaVec3A(); /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11246,7 +13386,10 @@ pub struct LuaVec3A(); /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11256,14 +13399,19 @@ pub struct LuaVec3A(); /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::Vec4; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11273,14 +13421,19 @@ pub struct LuaVec3A(); /// - `NAN` if the number is `NAN` #[lua()] - fn signum(self) -> bevy::math::Vec4; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. #[lua()] - fn copysign(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn copysign( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11289,7 +13442,7 @@ pub struct LuaVec3A(); /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -11297,14 +13450,14 @@ pub struct LuaVec3A(); /// `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(self) -> bool; + fn is_finite(_self: LuaReflectValProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(self) -> bool; + fn is_nan(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -11312,14 +13465,16 @@ pub struct LuaVec3A(); /// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. #[lua()] - fn is_nan_mask(self) -> bevy::math::BVec4A; + fn is_nan_mask( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the length of `self`. #[lua()] - fn length(self) -> f32; + fn length(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -11327,7 +13482,7 @@ pub struct LuaVec3A(); /// This is faster than `length()` as it avoids a square root operation. #[lua()] - fn length_squared(self) -> f32; + fn length_squared(_self: LuaReflectValProxy) -> f32; "#, r#" @@ -11335,28 +13490,37 @@ pub struct LuaVec3A(); /// For valid results, `self` must _not_ be of length zero. #[lua()] - fn length_recip(self) -> f32; + fn length_recip(_self: LuaReflectValProxy) -> f32; "#, r#" /// Computes the Euclidean distance between two points in space. #[lua()] - fn distance(self, #[proxy] rhs: bevy::math::Vec4) -> f32; + fn distance( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::Vec4) -> f32; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f32; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11364,7 +13528,10 @@ pub struct LuaVec3A(); /// [Euclidean division]: f32::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11375,7 +13542,9 @@ pub struct LuaVec3A(); /// Will panic if `self` is zero length when `glam_assert` is enabled. #[lua()] - fn normalize(self) -> bevy::math::Vec4; + fn normalize( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11385,7 +13554,9 @@ pub struct LuaVec3A(); /// See also [`Self::try_normalize()`]. #[lua()] - fn normalize_or_zero(self) -> bevy::math::Vec4; + fn normalize_or_zero( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11393,7 +13564,7 @@ pub struct LuaVec3A(); /// Uses a precision threshold of `1e-6`. #[lua()] - fn is_normalized(self) -> bool; + fn is_normalized(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -11403,7 +13574,10 @@ pub struct LuaVec3A(); /// Will panic if `rhs` is zero length when `glam_assert` is enabled. #[lua()] - fn project_onto(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn project_onto( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11415,7 +13589,10 @@ pub struct LuaVec3A(); /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. #[lua()] - fn reject_from(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn reject_from( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11425,7 +13602,10 @@ pub struct LuaVec3A(); /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua()] - fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn project_onto_normalized( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11437,7 +13617,10 @@ pub struct LuaVec3A(); /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua()] - fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn reject_from_normalized( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11445,7 +13628,9 @@ pub struct LuaVec3A(); /// Round half-way cases away from 0.0. #[lua()] - fn round(self) -> bevy::math::Vec4; + fn round( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11453,7 +13638,9 @@ pub struct LuaVec3A(); /// element of `self`. #[lua()] - fn floor(self) -> bevy::math::Vec4; + fn floor( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11461,7 +13648,9 @@ pub struct LuaVec3A(); /// each element of `self`. #[lua()] - fn ceil(self) -> bevy::math::Vec4; + fn ceil( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11469,7 +13658,9 @@ pub struct LuaVec3A(); /// always truncated towards zero. #[lua()] - fn trunc(self) -> bevy::math::Vec4; + fn trunc( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11478,7 +13669,9 @@ pub struct LuaVec3A(); /// Note that this is fast but not precise for large numbers. #[lua()] - fn fract(self) -> bevy::math::Vec4; + fn fract( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11486,21 +13679,28 @@ pub struct LuaVec3A(); /// `self`. #[lua()] - fn exp(self) -> bevy::math::Vec4; + fn exp( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. #[lua()] - fn powf(self, n: f32) -> bevy::math::Vec4; + fn powf( + _self: LuaReflectValProxy, + n: f32, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. #[lua()] - fn recip(self) -> bevy::math::Vec4; + fn recip( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11510,7 +13710,11 @@ pub struct LuaVec3A(); /// extrapolated. #[lua()] - fn lerp(self, #[proxy] rhs: bevy::math::Vec4, s: f32) -> bevy::math::Vec4; + fn lerp( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + s: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -11523,7 +13727,11 @@ pub struct LuaVec3A(); /// [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: bevy::math::Vec4, max_abs_diff: f32) -> bool; + fn abs_diff_eq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f32, + ) -> bool; "#, r#" @@ -11532,21 +13740,31 @@ pub struct LuaVec3A(); /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua()] - fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec4; + fn clamp_length( + _self: LuaReflectValProxy, + min: f32, + max: f32, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no more than `max` #[lua()] - fn clamp_length_max(self, max: f32) -> bevy::math::Vec4; + fn clamp_length_max( + _self: LuaReflectValProxy, + max: f32, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no less than `min` #[lua()] - fn clamp_length_min(self, min: f32) -> bevy::math::Vec4; + fn clamp_length_min( + _self: LuaReflectValProxy, + min: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -11559,101 +13777,135 @@ pub struct LuaVec3A(); #[lua()] fn mul_add( - self, - #[proxy] - a: bevy::math::Vec4, - #[proxy] - b: bevy::math::Vec4, - ) -> bevy::math::Vec4; + _self: LuaReflectValProxy, + a: LuaReflectValProxy, + b: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f64`. #[lua()] - fn as_dvec4(&self) -> bevy::math::DVec4; + fn as_dvec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec4(&self) -> bevy::math::IVec4; + fn as_ivec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec4(&self) -> bevy::math::UVec4; + fn as_uvec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; + fn as_i64vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; + fn as_u64vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: f32) -> bevy::math::Vec4; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f32) -> bevy::math::Vec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: f32) -> bevy::math::Vec4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: f32) -> bevy::math::Vec4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::Vec4; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: f32) -> bevy::math::Vec4; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -11663,19 +13915,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f32) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaVec4(); +pub struct Vec4(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::BVec2", @@ -11684,21 +13936,23 @@ pub struct LuaVec4(); functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::BVec2; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector mask. #[lua()] - fn new(x: bool, y: bool) -> bevy::math::BVec2; + fn new(x: bool, y: bool) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: bool) -> bevy::math::BVec2; + fn splat(v: bool) -> LuaReflectValProxy; "#, r#" @@ -11707,21 +13961,21 @@ pub struct LuaVec4(); /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn bitmask(self) -> u32; + fn bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" /// Returns true if any of the elements are true, false otherwise. #[lua()] - fn any(self) -> bool; + fn any(_self: LuaReflectValProxy) -> bool; "#, r#" /// Returns true if all the elements are true, false otherwise. #[lua()] - fn all(self) -> bool; + fn all(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -11729,7 +13983,7 @@ pub struct LuaVec4(); /// Panics if `index` is greater than 1. #[lua()] - fn test(&self, index: usize) -> bool; + fn test(_self: LuaReflectRefProxy, index: usize) -> bool; "#, r#" @@ -11737,19 +13991,26 @@ pub struct LuaVec4(); /// Panics if `index` is greater than 1. #[lua()] - fn set(&mut self, index: usize, value: bool) -> (); + fn set( + _self: LuaReflectRefMutProxy, + index: usize, + value: bool, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::BVec2) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" @@ -11759,7 +14020,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaBVec2 { +pub struct BVec2 { x: bool, y: bool, } @@ -11771,21 +14032,21 @@ pub struct LuaBVec2 { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" /// Creates a new vector mask. #[lua()] - fn new(x: bool, y: bool, z: bool) -> bevy::math::BVec3; + fn new(x: bool, y: bool, z: bool) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: bool) -> bevy::math::BVec3; + fn splat(v: bool) -> LuaReflectValProxy; "#, r#" @@ -11794,21 +14055,21 @@ pub struct LuaBVec2 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn bitmask(self) -> u32; + fn bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" /// Returns true if any of the elements are true, false otherwise. #[lua()] - fn any(self) -> bool; + fn any(_self: LuaReflectValProxy) -> bool; "#, r#" /// Returns true if all the elements are true, false otherwise. #[lua()] - fn all(self) -> bool; + fn all(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -11816,7 +14077,7 @@ pub struct LuaBVec2 { /// Panics if `index` is greater than 2. #[lua()] - fn test(&self, index: usize) -> bool; + fn test(_self: LuaReflectRefProxy, index: usize) -> bool; "#, r#" @@ -11824,19 +14085,28 @@ pub struct LuaBVec2 { /// Panics if `index` is greater than 2. #[lua()] - fn set(&mut self, index: usize, value: bool) -> (); + fn set( + _self: LuaReflectRefMutProxy, + index: usize, + value: bool, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::BVec3) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::BVec3; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -11846,7 +14116,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaBVec3 { +pub struct BVec3 { x: bool, y: bool, z: bool, @@ -11858,34 +14128,39 @@ pub struct LuaBVec3 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::BVec4) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::BVec4; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" /// Creates a new vector mask. #[lua()] - fn new(x: bool, y: bool, z: bool, w: bool) -> bevy::math::BVec4; + fn new(x: bool, y: bool, z: bool, w: bool) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: bool) -> bevy::math::BVec4; + fn splat(v: bool) -> LuaReflectValProxy; "#, r#" @@ -11894,21 +14169,21 @@ pub struct LuaBVec3 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn bitmask(self) -> u32; + fn bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" /// Returns true if any of the elements are true, false otherwise. #[lua()] - fn any(self) -> bool; + fn any(_self: LuaReflectValProxy) -> bool; "#, r#" /// Returns true if all the elements are true, false otherwise. #[lua()] - fn all(self) -> bool; + fn all(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -11916,7 +14191,7 @@ pub struct LuaBVec3 { /// Panics if `index` is greater than 3. #[lua()] - fn test(&self, index: usize) -> bool; + fn test(_self: LuaReflectRefProxy, index: usize) -> bool; "#, r#" @@ -11924,7 +14199,11 @@ pub struct LuaBVec3 { /// Panics if `index` is greater than 3. #[lua()] - fn set(&mut self, index: usize, value: bool) -> (); + fn set( + _self: LuaReflectRefMutProxy, + index: usize, + value: bool, + ) -> (); "#, r#" @@ -11934,7 +14213,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaBVec4 { +pub struct BVec4 { x: bool, y: bool, z: bool, @@ -11947,76 +14226,105 @@ pub struct LuaBVec4 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: f64) -> bevy::math::DVec2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: f64) -> bevy::math::DVec2; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: f64) -> bevy::math::DVec2; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::DVec2; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: f64) -> bevy::math::DVec2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: f64, y: f64) -> bevy::math::DVec2; + fn new(x: f64, y: f64) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: f64) -> bevy::math::DVec2; + fn splat(v: f64) -> LuaReflectValProxy; "#, r#" @@ -12027,48 +14335,54 @@ pub struct LuaBVec4 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec2, - #[proxy] - if_true: bevy::math::DVec2, - #[proxy] - if_false: bevy::math::DVec2, - ) -> bevy::math::DVec2; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [f64; 2]) -> bevy::math::DVec2; + fn from_array(a: [f64; 2]) -> LuaReflectValProxy; "#, r#" /// `[x, y]` #[lua()] - fn to_array(&self) -> [f64; 2]; + fn to_array(_self: LuaReflectRefProxy) -> [f64; 2]; "#, r#" /// Creates a 3D vector from `self` and the given `z` value. #[lua()] - fn extend(self, z: f64) -> bevy::math::DVec3; + fn extend( + _self: LuaReflectValProxy, + z: f64, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12076,7 +14390,10 @@ pub struct LuaBVec4 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12084,7 +14401,10 @@ pub struct LuaBVec4 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12095,12 +14415,10 @@ pub struct LuaBVec4 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::DVec2, - #[proxy] - max: bevy::math::DVec2, - ) -> bevy::math::DVec2; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12108,7 +14426,7 @@ pub struct LuaBVec4 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> f64; + fn min_element(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -12116,7 +14434,7 @@ pub struct LuaBVec4 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> f64; + fn max_element(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -12126,7 +14444,10 @@ pub struct LuaBVec4 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12136,7 +14457,10 @@ pub struct LuaBVec4 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12146,7 +14470,10 @@ pub struct LuaBVec4 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12156,7 +14483,10 @@ pub struct LuaBVec4 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12166,7 +14496,10 @@ pub struct LuaBVec4 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12176,14 +14509,19 @@ pub struct LuaBVec4 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::DVec2; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12193,14 +14531,19 @@ pub struct LuaBVec4 { /// - `NAN` if the number is `NAN` #[lua()] - fn signum(self) -> bevy::math::DVec2; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. #[lua()] - fn copysign(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn copysign( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12209,7 +14552,7 @@ pub struct LuaBVec4 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -12217,14 +14560,14 @@ pub struct LuaBVec4 { /// `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(self) -> bool; + fn is_finite(_self: LuaReflectValProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(self) -> bool; + fn is_nan(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -12232,14 +14575,16 @@ pub struct LuaBVec4 { /// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. #[lua()] - fn is_nan_mask(self) -> bevy::math::BVec2; + fn is_nan_mask( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the length of `self`. #[lua()] - fn length(self) -> f64; + fn length(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -12247,7 +14592,7 @@ pub struct LuaBVec4 { /// This is faster than `length()` as it avoids a square root operation. #[lua()] - fn length_squared(self) -> f64; + fn length_squared(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -12255,28 +14600,37 @@ pub struct LuaBVec4 { /// For valid results, `self` must _not_ be of length zero. #[lua()] - fn length_recip(self) -> f64; + fn length_recip(_self: LuaReflectValProxy) -> f64; "#, r#" /// Computes the Euclidean distance between two points in space. #[lua()] - fn distance(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + fn distance( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12284,7 +14638,10 @@ pub struct LuaBVec4 { /// [Euclidean division]: f64::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12295,7 +14652,9 @@ pub struct LuaBVec4 { /// Will panic if `self` is zero length when `glam_assert` is enabled. #[lua()] - fn normalize(self) -> bevy::math::DVec2; + fn normalize( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12305,7 +14664,9 @@ pub struct LuaBVec4 { /// See also [`Self::try_normalize()`]. #[lua()] - fn normalize_or_zero(self) -> bevy::math::DVec2; + fn normalize_or_zero( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12313,7 +14674,7 @@ pub struct LuaBVec4 { /// Uses a precision threshold of `1e-6`. #[lua()] - fn is_normalized(self) -> bool; + fn is_normalized(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -12323,7 +14684,10 @@ pub struct LuaBVec4 { /// Will panic if `rhs` is zero length when `glam_assert` is enabled. #[lua()] - fn project_onto(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn project_onto( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12335,7 +14699,10 @@ pub struct LuaBVec4 { /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. #[lua()] - fn reject_from(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn reject_from( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12346,10 +14713,9 @@ pub struct LuaBVec4 { #[lua()] fn project_onto_normalized( - self, - #[proxy] - rhs: bevy::math::DVec2, - ) -> bevy::math::DVec2; + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12362,10 +14728,9 @@ pub struct LuaBVec4 { #[lua()] fn reject_from_normalized( - self, - #[proxy] - rhs: bevy::math::DVec2, - ) -> bevy::math::DVec2; + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12373,7 +14738,9 @@ pub struct LuaBVec4 { /// Round half-way cases away from 0.0. #[lua()] - fn round(self) -> bevy::math::DVec2; + fn round( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12381,7 +14748,9 @@ pub struct LuaBVec4 { /// element of `self`. #[lua()] - fn floor(self) -> bevy::math::DVec2; + fn floor( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12389,7 +14758,9 @@ pub struct LuaBVec4 { /// each element of `self`. #[lua()] - fn ceil(self) -> bevy::math::DVec2; + fn ceil( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12397,7 +14768,9 @@ pub struct LuaBVec4 { /// always truncated towards zero. #[lua()] - fn trunc(self) -> bevy::math::DVec2; + fn trunc( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12406,7 +14779,9 @@ pub struct LuaBVec4 { /// Note that this is fast but not precise for large numbers. #[lua()] - fn fract(self) -> bevy::math::DVec2; + fn fract( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12414,21 +14789,28 @@ pub struct LuaBVec4 { /// `self`. #[lua()] - fn exp(self) -> bevy::math::DVec2; + fn exp( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. #[lua()] - fn powf(self, n: f64) -> bevy::math::DVec2; + fn powf( + _self: LuaReflectValProxy, + n: f64, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. #[lua()] - fn recip(self) -> bevy::math::DVec2; + fn recip( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12438,7 +14820,11 @@ pub struct LuaBVec4 { /// extrapolated. #[lua()] - fn lerp(self, #[proxy] rhs: bevy::math::DVec2, s: f64) -> bevy::math::DVec2; + fn lerp( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + s: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -12451,7 +14837,11 @@ pub struct LuaBVec4 { /// [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: bevy::math::DVec2, max_abs_diff: f64) -> bool; + fn abs_diff_eq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f64, + ) -> bool; "#, r#" @@ -12460,21 +14850,31 @@ pub struct LuaBVec4 { /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua()] - fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec2; + fn clamp_length( + _self: LuaReflectValProxy, + min: f64, + max: f64, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no more than `max` #[lua()] - fn clamp_length_max(self, max: f64) -> bevy::math::DVec2; + fn clamp_length_max( + _self: LuaReflectValProxy, + max: f64, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no less than `min` #[lua()] - fn clamp_length_min(self, min: f64) -> bevy::math::DVec2; + fn clamp_length_min( + _self: LuaReflectValProxy, + min: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -12487,12 +14887,10 @@ pub struct LuaBVec4 { #[lua()] fn mul_add( - self, - #[proxy] - a: bevy::math::DVec2, - #[proxy] - b: bevy::math::DVec2, - ) -> bevy::math::DVec2; + _self: LuaReflectValProxy, + a: LuaReflectValProxy, + b: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12502,7 +14900,7 @@ pub struct LuaBVec4 { /// and rotate [`DVec2::Y`] around it returning `-DVec2::Y`. #[lua()] - fn from_angle(angle: f64) -> bevy::math::DVec2; + fn from_angle(angle: f64) -> LuaReflectValProxy; "#, r#" @@ -12510,7 +14908,7 @@ pub struct LuaBVec4 { /// The input does not need to be a unit vector however it must be non-zero. #[lua()] - fn to_angle(self) -> f64; + fn to_angle(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -12518,14 +14916,19 @@ pub struct LuaBVec4 { /// The inputs do not need to be unit vectors however they must be non-zero. #[lua()] - fn angle_between(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + fn angle_between( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" /// Returns a vector that is equal to `self` rotated by 90 degrees. #[lua()] - fn perp(self) -> bevy::math::DVec2; + fn perp( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12533,7 +14936,10 @@ pub struct LuaBVec4 { /// Also known as the wedge product, 2D cross product, and determinant. #[lua()] - fn perp_dot(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + fn perp_dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" @@ -12542,60 +14948,81 @@ pub struct LuaBVec4 { /// it will be like a rotation with a multiplication by `self`'s length. #[lua()] - fn rotate(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn rotate( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec2(&self) -> bevy::math::Vec2; + fn as_vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec2(&self) -> bevy::math::IVec2; + fn as_ivec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec2(&self) -> bevy::math::UVec2; + fn as_uvec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; + fn as_i64vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; + fn as_u64vec2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f64) -> bevy::math::DVec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::DVec2) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::DVec2; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12605,19 +15032,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f64) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaDVec2 { +pub struct DVec2 { x: f64, y: f64, } @@ -12629,21 +15056,23 @@ pub struct LuaDVec2 { functions[r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::DVec3; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: f64, y: f64, z: f64) -> bevy::math::DVec3; + fn new(x: f64, y: f64, z: f64) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: f64) -> bevy::math::DVec3; + fn splat(v: f64) -> LuaReflectValProxy; "#, r#" @@ -12654,34 +15083,34 @@ pub struct LuaDVec2 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec3, - #[proxy] - if_true: bevy::math::DVec3, - #[proxy] - if_false: bevy::math::DVec3, - ) -> bevy::math::DVec3; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [f64; 3]) -> bevy::math::DVec3; + fn from_array(a: [f64; 3]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z]` #[lua()] - fn to_array(&self) -> [f64; 3]; + fn to_array(_self: LuaReflectRefProxy) -> [f64; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. #[lua()] - fn extend(self, w: f64) -> bevy::math::DVec4; + fn extend( + _self: LuaReflectValProxy, + w: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -12689,28 +15118,39 @@ pub struct LuaDVec2 { /// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. #[lua()] - fn truncate(self) -> bevy::math::DVec2; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::DVec3) -> f64; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the cross product of `self` and `rhs`. #[lua()] - fn cross(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn cross( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12718,7 +15158,10 @@ pub struct LuaDVec2 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12726,7 +15169,10 @@ pub struct LuaDVec2 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12737,12 +15183,10 @@ pub struct LuaDVec2 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::DVec3, - #[proxy] - max: bevy::math::DVec3, - ) -> bevy::math::DVec3; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12750,7 +15194,7 @@ pub struct LuaDVec2 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> f64; + fn min_element(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -12758,7 +15202,7 @@ pub struct LuaDVec2 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> f64; + fn max_element(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -12768,7 +15212,10 @@ pub struct LuaDVec2 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12778,7 +15225,10 @@ pub struct LuaDVec2 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12788,7 +15238,10 @@ pub struct LuaDVec2 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12798,7 +15251,10 @@ pub struct LuaDVec2 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12808,7 +15264,10 @@ pub struct LuaDVec2 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12818,14 +15277,19 @@ pub struct LuaDVec2 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::DVec3; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12835,14 +15299,19 @@ pub struct LuaDVec2 { /// - `NAN` if the number is `NAN` #[lua()] - fn signum(self) -> bevy::math::DVec3; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. #[lua()] - fn copysign(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn copysign( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12851,7 +15320,7 @@ pub struct LuaDVec2 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -12859,14 +15328,14 @@ pub struct LuaDVec2 { /// `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(self) -> bool; + fn is_finite(_self: LuaReflectValProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(self) -> bool; + fn is_nan(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -12874,14 +15343,16 @@ pub struct LuaDVec2 { /// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. #[lua()] - fn is_nan_mask(self) -> bevy::math::BVec3; + fn is_nan_mask( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the length of `self`. #[lua()] - fn length(self) -> f64; + fn length(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -12889,7 +15360,7 @@ pub struct LuaDVec2 { /// This is faster than `length()` as it avoids a square root operation. #[lua()] - fn length_squared(self) -> f64; + fn length_squared(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -12897,28 +15368,37 @@ pub struct LuaDVec2 { /// For valid results, `self` must _not_ be of length zero. #[lua()] - fn length_recip(self) -> f64; + fn length_recip(_self: LuaReflectValProxy) -> f64; "#, r#" /// Computes the Euclidean distance between two points in space. #[lua()] - fn distance(self, #[proxy] rhs: bevy::math::DVec3) -> f64; + fn distance( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::DVec3) -> f64; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12926,7 +15406,10 @@ pub struct LuaDVec2 { /// [Euclidean division]: f64::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12937,7 +15420,9 @@ pub struct LuaDVec2 { /// Will panic if `self` is zero length when `glam_assert` is enabled. #[lua()] - fn normalize(self) -> bevy::math::DVec3; + fn normalize( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12947,7 +15432,9 @@ pub struct LuaDVec2 { /// See also [`Self::try_normalize()`]. #[lua()] - fn normalize_or_zero(self) -> bevy::math::DVec3; + fn normalize_or_zero( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12955,7 +15442,7 @@ pub struct LuaDVec2 { /// Uses a precision threshold of `1e-6`. #[lua()] - fn is_normalized(self) -> bool; + fn is_normalized(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -12965,7 +15452,10 @@ pub struct LuaDVec2 { /// Will panic if `rhs` is zero length when `glam_assert` is enabled. #[lua()] - fn project_onto(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn project_onto( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12977,7 +15467,10 @@ pub struct LuaDVec2 { /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. #[lua()] - fn reject_from(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn reject_from( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -12988,10 +15481,9 @@ pub struct LuaDVec2 { #[lua()] fn project_onto_normalized( - self, - #[proxy] - rhs: bevy::math::DVec3, - ) -> bevy::math::DVec3; + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13004,10 +15496,9 @@ pub struct LuaDVec2 { #[lua()] fn reject_from_normalized( - self, - #[proxy] - rhs: bevy::math::DVec3, - ) -> bevy::math::DVec3; + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13015,7 +15506,9 @@ pub struct LuaDVec2 { /// Round half-way cases away from 0.0. #[lua()] - fn round(self) -> bevy::math::DVec3; + fn round( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13023,7 +15516,9 @@ pub struct LuaDVec2 { /// element of `self`. #[lua()] - fn floor(self) -> bevy::math::DVec3; + fn floor( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13031,7 +15526,9 @@ pub struct LuaDVec2 { /// each element of `self`. #[lua()] - fn ceil(self) -> bevy::math::DVec3; + fn ceil( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13039,7 +15536,9 @@ pub struct LuaDVec2 { /// always truncated towards zero. #[lua()] - fn trunc(self) -> bevy::math::DVec3; + fn trunc( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13048,7 +15547,9 @@ pub struct LuaDVec2 { /// Note that this is fast but not precise for large numbers. #[lua()] - fn fract(self) -> bevy::math::DVec3; + fn fract( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13056,21 +15557,28 @@ pub struct LuaDVec2 { /// `self`. #[lua()] - fn exp(self) -> bevy::math::DVec3; + fn exp( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. #[lua()] - fn powf(self, n: f64) -> bevy::math::DVec3; + fn powf( + _self: LuaReflectValProxy, + n: f64, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. #[lua()] - fn recip(self) -> bevy::math::DVec3; + fn recip( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13080,7 +15588,11 @@ pub struct LuaDVec2 { /// extrapolated. #[lua()] - fn lerp(self, #[proxy] rhs: bevy::math::DVec3, s: f64) -> bevy::math::DVec3; + fn lerp( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + s: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -13093,7 +15605,11 @@ pub struct LuaDVec2 { /// [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: bevy::math::DVec3, max_abs_diff: f64) -> bool; + fn abs_diff_eq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f64, + ) -> bool; "#, r#" @@ -13102,21 +15618,31 @@ pub struct LuaDVec2 { /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua()] - fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec3; + fn clamp_length( + _self: LuaReflectValProxy, + min: f64, + max: f64, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no more than `max` #[lua()] - fn clamp_length_max(self, max: f64) -> bevy::math::DVec3; + fn clamp_length_max( + _self: LuaReflectValProxy, + max: f64, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no less than `min` #[lua()] - fn clamp_length_min(self, min: f64) -> bevy::math::DVec3; + fn clamp_length_min( + _self: LuaReflectValProxy, + min: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -13129,12 +15655,10 @@ pub struct LuaDVec2 { #[lua()] fn mul_add( - self, - #[proxy] - a: bevy::math::DVec3, - #[proxy] - b: bevy::math::DVec3, - ) -> bevy::math::DVec3; + _self: LuaReflectValProxy, + a: LuaReflectValProxy, + b: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13142,7 +15666,10 @@ pub struct LuaDVec2 { /// The inputs do not need to be unit vectors however they must be non-zero. #[lua()] - fn angle_between(self, #[proxy] rhs: bevy::math::DVec3) -> f64; + fn angle_between( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" @@ -13152,7 +15679,9 @@ pub struct LuaDVec2 { /// [`Self::any_orthonormal_vector()`] instead. #[lua()] - fn any_orthogonal_vector(&self) -> bevy::math::DVec3; + fn any_orthogonal_vector( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13162,121 +15691,170 @@ pub struct LuaDVec2 { /// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua()] - fn any_orthonormal_vector(&self) -> bevy::math::DVec3; + fn any_orthonormal_vector( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec3(&self) -> bevy::math::Vec3; + fn as_vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec3a(&self) -> bevy::math::Vec3A; + fn as_vec3a( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec3(&self) -> bevy::math::IVec3; + fn as_ivec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec3(&self) -> bevy::math::UVec3; + fn as_uvec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; + fn as_i64vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; + fn as_u64vec3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::DVec3) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f64) -> bevy::math::DVec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: f64) -> bevy::math::DVec3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: f64) -> bevy::math::DVec3; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: f64) -> bevy::math::DVec3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::DVec3; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: f64) -> bevy::math::DVec3; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13286,19 +15864,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f64) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaDVec3 { +pub struct DVec3 { x: f64, y: f64, z: f64, @@ -13310,82 +15888,113 @@ pub struct LuaDVec3 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, rhs: f64) -> bevy::math::DVec4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, rhs: f64) -> bevy::math::DVec4; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f64) -> bevy::math::DVec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, rhs: f64) -> bevy::math::DVec4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::DVec4) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::DVec4; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Rem", composite = "rem")] - fn rem(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + #[lua(as_trait = "std::ops::Rem::", composite = "rem")] + fn rem( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::DVec4; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector. #[lua()] - fn new(x: f64, y: f64, z: f64, w: f64) -> bevy::math::DVec4; + fn new(x: f64, y: f64, z: f64, w: f64) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: f64) -> bevy::math::DVec4; + fn splat(v: f64) -> LuaReflectValProxy; "#, r#" @@ -13396,27 +16005,24 @@ pub struct LuaDVec3 { #[lua()] fn select( - #[proxy] - mask: bevy::math::BVec4, - #[proxy] - if_true: bevy::math::DVec4, - #[proxy] - if_false: bevy::math::DVec4, - ) -> bevy::math::DVec4; + mask: LuaReflectValProxy, + if_true: LuaReflectValProxy, + if_false: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector from an array. #[lua()] - fn from_array(a: [f64; 4]) -> bevy::math::DVec4; + fn from_array(a: [f64; 4]) -> LuaReflectValProxy; "#, r#" /// `[x, y, z, w]` #[lua()] - fn to_array(&self) -> [f64; 4]; + fn to_array(_self: LuaReflectRefProxy) -> [f64; 4]; "#, r#" @@ -13424,21 +16030,29 @@ pub struct LuaDVec3 { /// Truncation to [`DVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. #[lua()] - fn truncate(self) -> bevy::math::DVec3; + fn truncate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::DVec4) -> f64; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" /// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua()] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn dot_into_vec( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13446,7 +16060,10 @@ pub struct LuaDVec3 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua()] - fn min(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn min( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13454,7 +16071,10 @@ pub struct LuaDVec3 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua()] - fn max(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn max( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13465,12 +16085,10 @@ pub struct LuaDVec3 { #[lua()] fn clamp( - self, - #[proxy] - min: bevy::math::DVec4, - #[proxy] - max: bevy::math::DVec4, - ) -> bevy::math::DVec4; + _self: LuaReflectValProxy, + min: LuaReflectValProxy, + max: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13478,7 +16096,7 @@ pub struct LuaDVec3 { /// In other words this computes `min(x, y, ..)`. #[lua()] - fn min_element(self) -> f64; + fn min_element(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -13486,7 +16104,7 @@ pub struct LuaDVec3 { /// In other words this computes `max(x, y, ..)`. #[lua()] - fn max_element(self) -> f64; + fn max_element(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -13496,7 +16114,10 @@ pub struct LuaDVec3 { /// elements. #[lua()] - fn cmpeq(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + fn cmpeq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13506,7 +16127,10 @@ pub struct LuaDVec3 { /// elements. #[lua()] - fn cmpne(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + fn cmpne( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13516,7 +16140,10 @@ pub struct LuaDVec3 { /// elements. #[lua()] - fn cmpge(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + fn cmpge( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13526,7 +16153,10 @@ pub struct LuaDVec3 { /// elements. #[lua()] - fn cmpgt(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + fn cmpgt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13536,7 +16166,10 @@ pub struct LuaDVec3 { /// elements. #[lua()] - fn cmple(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + fn cmple( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13546,14 +16179,19 @@ pub struct LuaDVec3 { /// elements. #[lua()] - fn cmplt(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + fn cmplt( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua()] - fn abs(self) -> bevy::math::DVec4; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13563,14 +16201,19 @@ pub struct LuaDVec3 { /// - `NAN` if the number is `NAN` #[lua()] - fn signum(self) -> bevy::math::DVec4; + fn signum( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. #[lua()] - fn copysign(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn copysign( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13579,7 +16222,7 @@ pub struct LuaDVec3 { /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn is_negative_bitmask(self) -> u32; + fn is_negative_bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -13587,14 +16230,14 @@ pub struct LuaDVec3 { /// `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(self) -> bool; + fn is_finite(_self: LuaReflectValProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(self) -> bool; + fn is_nan(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -13602,14 +16245,16 @@ pub struct LuaDVec3 { /// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. #[lua()] - fn is_nan_mask(self) -> bevy::math::BVec4; + fn is_nan_mask( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Computes the length of `self`. #[lua()] - fn length(self) -> f64; + fn length(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -13617,7 +16262,7 @@ pub struct LuaDVec3 { /// This is faster than `length()` as it avoids a square root operation. #[lua()] - fn length_squared(self) -> f64; + fn length_squared(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -13625,28 +16270,37 @@ pub struct LuaDVec3 { /// For valid results, `self` must _not_ be of length zero. #[lua()] - fn length_recip(self) -> f64; + fn length_recip(_self: LuaReflectValProxy) -> f64; "#, r#" /// Computes the Euclidean distance between two points in space. #[lua()] - fn distance(self, #[proxy] rhs: bevy::math::DVec4) -> f64; + fn distance( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua()] - fn distance_squared(self, #[proxy] rhs: bevy::math::DVec4) -> f64; + fn distance_squared( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. #[lua()] - fn div_euclid(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn div_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13654,7 +16308,10 @@ pub struct LuaDVec3 { /// [Euclidean division]: f64::rem_euclid #[lua()] - fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn rem_euclid( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13665,7 +16322,9 @@ pub struct LuaDVec3 { /// Will panic if `self` is zero length when `glam_assert` is enabled. #[lua()] - fn normalize(self) -> bevy::math::DVec4; + fn normalize( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13675,7 +16334,9 @@ pub struct LuaDVec3 { /// See also [`Self::try_normalize()`]. #[lua()] - fn normalize_or_zero(self) -> bevy::math::DVec4; + fn normalize_or_zero( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13683,7 +16344,7 @@ pub struct LuaDVec3 { /// Uses a precision threshold of `1e-6`. #[lua()] - fn is_normalized(self) -> bool; + fn is_normalized(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -13693,7 +16354,10 @@ pub struct LuaDVec3 { /// Will panic if `rhs` is zero length when `glam_assert` is enabled. #[lua()] - fn project_onto(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn project_onto( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13705,7 +16369,10 @@ pub struct LuaDVec3 { /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. #[lua()] - fn reject_from(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn reject_from( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13716,10 +16383,9 @@ pub struct LuaDVec3 { #[lua()] fn project_onto_normalized( - self, - #[proxy] - rhs: bevy::math::DVec4, - ) -> bevy::math::DVec4; + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13732,10 +16398,9 @@ pub struct LuaDVec3 { #[lua()] fn reject_from_normalized( - self, - #[proxy] - rhs: bevy::math::DVec4, - ) -> bevy::math::DVec4; + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13743,7 +16408,9 @@ pub struct LuaDVec3 { /// Round half-way cases away from 0.0. #[lua()] - fn round(self) -> bevy::math::DVec4; + fn round( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13751,7 +16418,9 @@ pub struct LuaDVec3 { /// element of `self`. #[lua()] - fn floor(self) -> bevy::math::DVec4; + fn floor( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13759,7 +16428,9 @@ pub struct LuaDVec3 { /// each element of `self`. #[lua()] - fn ceil(self) -> bevy::math::DVec4; + fn ceil( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13767,7 +16438,9 @@ pub struct LuaDVec3 { /// always truncated towards zero. #[lua()] - fn trunc(self) -> bevy::math::DVec4; + fn trunc( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13776,7 +16449,9 @@ pub struct LuaDVec3 { /// Note that this is fast but not precise for large numbers. #[lua()] - fn fract(self) -> bevy::math::DVec4; + fn fract( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13784,21 +16459,28 @@ pub struct LuaDVec3 { /// `self`. #[lua()] - fn exp(self) -> bevy::math::DVec4; + fn exp( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. #[lua()] - fn powf(self, n: f64) -> bevy::math::DVec4; + fn powf( + _self: LuaReflectValProxy, + n: f64, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. #[lua()] - fn recip(self) -> bevy::math::DVec4; + fn recip( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13808,7 +16490,11 @@ pub struct LuaDVec3 { /// extrapolated. #[lua()] - fn lerp(self, #[proxy] rhs: bevy::math::DVec4, s: f64) -> bevy::math::DVec4; + fn lerp( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + s: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -13821,7 +16507,11 @@ pub struct LuaDVec3 { /// [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: bevy::math::DVec4, max_abs_diff: f64) -> bool; + fn abs_diff_eq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f64, + ) -> bool; "#, r#" @@ -13830,21 +16520,31 @@ pub struct LuaDVec3 { /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua()] - fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec4; + fn clamp_length( + _self: LuaReflectValProxy, + min: f64, + max: f64, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no more than `max` #[lua()] - fn clamp_length_max(self, max: f64) -> bevy::math::DVec4; + fn clamp_length_max( + _self: LuaReflectValProxy, + max: f64, + ) -> LuaReflectValProxy; "#, r#" /// Returns a vector with a length no less than `min` #[lua()] - fn clamp_length_min(self, min: f64) -> bevy::math::DVec4; + fn clamp_length_min( + _self: LuaReflectValProxy, + min: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -13857,59 +16557,73 @@ pub struct LuaDVec3 { #[lua()] fn mul_add( - self, - #[proxy] - a: bevy::math::DVec4, - #[proxy] - b: bevy::math::DVec4, - ) -> bevy::math::DVec4; + _self: LuaReflectValProxy, + a: LuaReflectValProxy, + b: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `f32`. #[lua()] - fn as_vec4(&self) -> bevy::math::Vec4; + fn as_vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i32`. #[lua()] - fn as_ivec4(&self) -> bevy::math::IVec4; + fn as_ivec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u32`. #[lua()] - fn as_uvec4(&self) -> bevy::math::UVec4; + fn as_uvec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `i64`. #[lua()] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; + fn as_i64vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Casts all elements of `self` to `u64`. #[lua()] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; + fn as_u64vec4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: f64) -> bevy::math::DVec4; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -13919,19 +16633,19 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(_self.inner()?[*idx]) +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> IdentityProxy { + _self[idx - 1] } "#, r#" -#[lua(raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - _self.val_mut(|s| Ok(s[*idx] = val))? +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f64) -> () { + _self[idx - 1] = val } "#] )] -pub struct LuaDVec4 { +pub struct DVec4 { x: f64, y: f64, z: f64, @@ -13944,14 +16658,20 @@ pub struct LuaDVec4 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13959,11 +16679,9 @@ pub struct LuaDVec4 { #[lua()] fn from_cols( - #[proxy] - x_axis: bevy::math::Vec2, - #[proxy] - y_axis: bevy::math::Vec2, - ) -> bevy::math::Mat2; + x_axis: LuaReflectValProxy, + y_axis: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13971,7 +16689,7 @@ pub struct LuaDVec4 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array(&self) -> [f32; 4]; + fn to_cols_array(_self: LuaReflectRefProxy) -> [f32; 4]; "#, r#" @@ -13979,14 +16697,16 @@ pub struct LuaDVec4 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array_2d(&self) -> [[f32; 2]; 2]; + fn to_cols_array_2d(_self: LuaReflectRefProxy) -> [[f32; 2]; 2]; "#, r#" /// Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. #[lua()] - fn from_diagonal(#[proxy] diagonal: bevy::math::Vec2) -> bevy::math::Mat2; + fn from_diagonal( + diagonal: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -13995,31 +16715,34 @@ pub struct LuaDVec4 { #[lua()] fn from_scale_angle( - #[proxy] - scale: bevy::math::Vec2, + scale: LuaReflectValProxy, angle: f32, - ) -> bevy::math::Mat2; + ) -> LuaReflectValProxy; "#, r#" /// Creates a 2x2 matrix containing a rotation of `angle` (in radians). #[lua()] - fn from_angle(angle: f32) -> bevy::math::Mat2; + fn from_angle(angle: f32) -> LuaReflectValProxy; "#, r#" /// Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. #[lua()] - fn from_mat3(#[proxy] m: bevy::math::Mat3) -> bevy::math::Mat2; + fn from_mat3( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. #[lua()] - fn from_mat3a(#[proxy] m: bevy::math::Mat3A) -> bevy::math::Mat2; + fn from_mat3a( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14028,7 +16751,10 @@ pub struct LuaDVec4 { /// Panics if `index` is greater than 1. #[lua()] - fn col(&self, index: usize) -> bevy::math::Vec2; + fn col( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -14037,7 +16763,10 @@ pub struct LuaDVec4 { /// Panics if `index` is greater than 1. #[lua()] - fn row(&self, index: usize) -> bevy::math::Vec2; + fn row( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -14045,28 +16774,30 @@ pub struct LuaDVec4 { /// If any element is either `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(&self) -> bool; + fn is_finite(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(&self) -> bool; + fn is_nan(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns the transpose of `self`. #[lua()] - fn transpose(&self) -> bevy::math::Mat2; + fn transpose( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the determinant of `self`. #[lua()] - fn determinant(&self) -> f32; + fn determinant(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -14076,42 +16807,59 @@ pub struct LuaDVec4 { /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. #[lua()] - fn inverse(&self) -> bevy::math::Mat2; + fn inverse( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms a 2D vector. #[lua()] - fn mul_vec2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn mul_vec2( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies two 2x2 matrices. #[lua()] - fn mul_mat2(&self, #[proxy] rhs: &glam::Mat2) -> bevy::math::Mat2; + fn mul_mat2( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Adds two 2x2 matrices. #[lua()] - fn add_mat2(&self, #[proxy] rhs: &glam::Mat2) -> bevy::math::Mat2; + fn add_mat2( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Subtracts two 2x2 matrices. #[lua()] - fn sub_mat2(&self, #[proxy] rhs: &glam::Mat2) -> bevy::math::Mat2; + fn sub_mat2( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies a 2x2 matrix by a scalar. #[lua()] - fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat2; + fn mul_scalar( + _self: LuaReflectRefProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -14124,49 +16872,71 @@ pub struct LuaDVec4 { /// [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: bevy::math::Mat2, max_abs_diff: f32) -> bool; + fn abs_diff_eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f32, + ) -> bool; "#, r#" #[lua()] - fn as_dmat2(&self) -> bevy::math::DMat2; + fn as_dmat2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::Mat2; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::Mat2; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f32) -> bevy::math::Mat2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::Mat2) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -14176,31 +16946,27 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaVec2::new_ref( - _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) +#[lua(metamethod="Index")] +fn index(_self: IdentityProxy, idx: usize) -> IdentityProxy { + let mut curr_ref = _self.0.clone(); + let def_ref = bevy_mod_scripting_core::bindings::DeferredReflection{ + get: std::sync::Arc::new(|ref_| Err(bevy::reflect::ReflectPathError::InvalidDowncast)), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(idx - 1)) + } else { + Err(bevy::reflect::ReflectPathError::InvalidDowncast) + } + }) + }; + curr_ref.reflect_path.push(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_deferred(def_ref)); + LuaVec2(curr_ref) } "#] )] -pub struct LuaMat2(); +pub struct Mat2(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::Mat3", @@ -14209,43 +16975,62 @@ pub struct LuaMat2(); functions[r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::Mat3; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::Mat3; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f32) -> bevy::math::Mat3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14253,13 +17038,10 @@ pub struct LuaMat2(); #[lua()] fn from_cols( - #[proxy] - x_axis: bevy::math::Vec3, - #[proxy] - y_axis: bevy::math::Vec3, - #[proxy] - z_axis: bevy::math::Vec3, - ) -> bevy::math::Mat3; + x_axis: LuaReflectValProxy, + y_axis: LuaReflectValProxy, + z_axis: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14267,7 +17049,7 @@ pub struct LuaMat2(); /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array(&self) -> [f32; 9]; + fn to_cols_array(_self: LuaReflectRefProxy) -> [f32; 9]; "#, r#" @@ -14275,21 +17057,25 @@ pub struct LuaMat2(); /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array_2d(&self) -> [[f32; 3]; 3]; + fn to_cols_array_2d(_self: LuaReflectRefProxy) -> [[f32; 3]; 3]; "#, r#" /// Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. #[lua()] - fn from_diagonal(#[proxy] diagonal: bevy::math::Vec3) -> bevy::math::Mat3; + fn from_diagonal( + diagonal: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. #[lua()] - fn from_mat4(#[proxy] m: bevy::math::Mat4) -> bevy::math::Mat3; + fn from_mat4( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14298,7 +17084,9 @@ pub struct LuaMat2(); /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. #[lua()] - fn from_quat(#[proxy] rotation: bevy::math::Quat) -> bevy::math::Mat3; + fn from_quat( + rotation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14308,7 +17096,10 @@ pub struct LuaMat2(); /// Will panic if `axis` is not normalized when `glam_assert` is enabled. #[lua()] - fn from_axis_angle(#[proxy] axis: bevy::math::Vec3, angle: f32) -> bevy::math::Mat3; + fn from_axis_angle( + axis: LuaReflectValProxy, + angle: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -14317,33 +17108,32 @@ pub struct LuaMat2(); #[lua()] fn from_euler( - #[proxy] - order: bevy::math::EulerRot, + order: LuaReflectValProxy, a: f32, b: f32, c: f32, - ) -> bevy::math::Mat3; + ) -> LuaReflectValProxy; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. #[lua()] - fn from_rotation_x(angle: f32) -> bevy::math::Mat3; + fn from_rotation_x(angle: f32) -> LuaReflectValProxy; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the y axis. #[lua()] - fn from_rotation_y(angle: f32) -> bevy::math::Mat3; + fn from_rotation_y(angle: f32) -> LuaReflectValProxy; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the z axis. #[lua()] - fn from_rotation_z(angle: f32) -> bevy::math::Mat3; + fn from_rotation_z(angle: f32) -> LuaReflectValProxy; "#, r#" @@ -14352,7 +17142,9 @@ pub struct LuaMat2(); /// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. #[lua()] - fn from_translation(#[proxy] translation: bevy::math::Vec2) -> bevy::math::Mat3; + fn from_translation( + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14362,7 +17154,7 @@ pub struct LuaMat2(); /// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. #[lua()] - fn from_angle(angle: f32) -> bevy::math::Mat3; + fn from_angle(angle: f32) -> LuaReflectValProxy; "#, r#" @@ -14373,12 +17165,10 @@ pub struct LuaMat2(); #[lua()] fn from_scale_angle_translation( - #[proxy] - scale: bevy::math::Vec2, + scale: LuaReflectValProxy, angle: f32, - #[proxy] - translation: bevy::math::Vec2, - ) -> bevy::math::Mat3; + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14389,7 +17179,9 @@ pub struct LuaMat2(); /// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. #[lua()] - fn from_scale(#[proxy] scale: bevy::math::Vec2) -> bevy::math::Mat3; + fn from_scale( + scale: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14398,7 +17190,9 @@ pub struct LuaMat2(); /// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. #[lua()] - fn from_mat2(#[proxy] m: bevy::math::Mat2) -> bevy::math::Mat3; + fn from_mat2( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14407,7 +17201,10 @@ pub struct LuaMat2(); /// Panics if `index` is greater than 2. #[lua()] - fn col(&self, index: usize) -> bevy::math::Vec3; + fn col( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -14416,7 +17213,10 @@ pub struct LuaMat2(); /// Panics if `index` is greater than 2. #[lua()] - fn row(&self, index: usize) -> bevy::math::Vec3; + fn row( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -14424,28 +17224,30 @@ pub struct LuaMat2(); /// If any element is either `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(&self) -> bool; + fn is_finite(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(&self) -> bool; + fn is_nan(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns the transpose of `self`. #[lua()] - fn transpose(&self) -> bevy::math::Mat3; + fn transpose( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the determinant of `self`. #[lua()] - fn determinant(&self) -> f32; + fn determinant(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -14455,7 +17257,9 @@ pub struct LuaMat2(); /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. #[lua()] - fn inverse(&self) -> bevy::math::Mat3; + fn inverse( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14466,7 +17270,10 @@ pub struct LuaMat2(); /// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. #[lua()] - fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn transform_point2( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14477,49 +17284,70 @@ pub struct LuaMat2(); /// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. #[lua()] - fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn transform_vector2( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms a 3D vector. #[lua()] - fn mul_vec3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn mul_vec3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms a [`Vec3A`]. #[lua()] - fn mul_vec3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn mul_vec3a( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies two 3x3 matrices. #[lua()] - fn mul_mat3(&self, #[proxy] rhs: &glam::Mat3) -> bevy::math::Mat3; + fn mul_mat3( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Adds two 3x3 matrices. #[lua()] - fn add_mat3(&self, #[proxy] rhs: &glam::Mat3) -> bevy::math::Mat3; + fn add_mat3( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Subtracts two 3x3 matrices. #[lua()] - fn sub_mat3(&self, #[proxy] rhs: &glam::Mat3) -> bevy::math::Mat3; + fn sub_mat3( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies a 3x3 matrix by a scalar. #[lua()] - fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat3; + fn mul_scalar( + _self: LuaReflectRefProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -14532,31 +17360,46 @@ pub struct LuaMat2(); /// [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: bevy::math::Mat3, max_abs_diff: f32) -> bool; + fn abs_diff_eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f32, + ) -> bool; "#, r#" #[lua()] - fn as_dmat3(&self) -> bevy::math::DMat3; + fn as_dmat3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::Mat3) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14566,36 +17409,29 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaVec3::new_ref( - _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) +#[lua(metamethod="Index")] +fn index(_self: IdentityProxy, idx: usize) -> IdentityProxy { + let mut curr_ref = _self.0.clone(); + let def_ref = bevy_mod_scripting_core::bindings::DeferredReflection{ + get: std::sync::Arc::new(|ref_| Err(bevy::reflect::ReflectPathError::InvalidDowncast)), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(idx - 1)) + } else { + Err(bevy::reflect::ReflectPathError::InvalidDowncast) + } + }) + }; + curr_ref.reflect_path.push(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_deferred(def_ref)); + LuaVec3(curr_ref) } "#] )] -pub struct LuaMat3 { - #[lua(output(proxy))] +pub struct Mat3 { x_axis: bevy::math::Vec3, - #[lua(output(proxy))] y_axis: bevy::math::Vec3, - #[lua(output(proxy))] z_axis: bevy::math::Vec3, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -14605,44 +17441,64 @@ pub struct LuaMat3 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3A; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f32) -> bevy::math::Mat3A; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::Mat3A; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14650,13 +17506,10 @@ pub struct LuaMat3 { #[lua()] fn from_cols( - #[proxy] - x_axis: bevy::math::Vec3A, - #[proxy] - y_axis: bevy::math::Vec3A, - #[proxy] - z_axis: bevy::math::Vec3A, - ) -> bevy::math::Mat3A; + x_axis: LuaReflectValProxy, + y_axis: LuaReflectValProxy, + z_axis: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14664,7 +17517,7 @@ pub struct LuaMat3 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array(&self) -> [f32; 9]; + fn to_cols_array(_self: LuaReflectRefProxy) -> [f32; 9]; "#, r#" @@ -14672,21 +17525,25 @@ pub struct LuaMat3 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array_2d(&self) -> [[f32; 3]; 3]; + fn to_cols_array_2d(_self: LuaReflectRefProxy) -> [[f32; 3]; 3]; "#, r#" /// Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. #[lua()] - fn from_diagonal(#[proxy] diagonal: bevy::math::Vec3) -> bevy::math::Mat3A; + fn from_diagonal( + diagonal: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. #[lua()] - fn from_mat4(#[proxy] m: bevy::math::Mat4) -> bevy::math::Mat3A; + fn from_mat4( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14695,7 +17552,9 @@ pub struct LuaMat3 { /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. #[lua()] - fn from_quat(#[proxy] rotation: bevy::math::Quat) -> bevy::math::Mat3A; + fn from_quat( + rotation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14705,7 +17564,10 @@ pub struct LuaMat3 { /// Will panic if `axis` is not normalized when `glam_assert` is enabled. #[lua()] - fn from_axis_angle(#[proxy] axis: bevy::math::Vec3, angle: f32) -> bevy::math::Mat3A; + fn from_axis_angle( + axis: LuaReflectValProxy, + angle: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -14714,33 +17576,32 @@ pub struct LuaMat3 { #[lua()] fn from_euler( - #[proxy] - order: bevy::math::EulerRot, + order: LuaReflectValProxy, a: f32, b: f32, c: f32, - ) -> bevy::math::Mat3A; + ) -> LuaReflectValProxy; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. #[lua()] - fn from_rotation_x(angle: f32) -> bevy::math::Mat3A; + fn from_rotation_x(angle: f32) -> LuaReflectValProxy; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the y axis. #[lua()] - fn from_rotation_y(angle: f32) -> bevy::math::Mat3A; + fn from_rotation_y(angle: f32) -> LuaReflectValProxy; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the z axis. #[lua()] - fn from_rotation_z(angle: f32) -> bevy::math::Mat3A; + fn from_rotation_z(angle: f32) -> LuaReflectValProxy; "#, r#" @@ -14749,7 +17610,9 @@ pub struct LuaMat3 { /// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. #[lua()] - fn from_translation(#[proxy] translation: bevy::math::Vec2) -> bevy::math::Mat3A; + fn from_translation( + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14759,7 +17622,7 @@ pub struct LuaMat3 { /// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. #[lua()] - fn from_angle(angle: f32) -> bevy::math::Mat3A; + fn from_angle(angle: f32) -> LuaReflectValProxy; "#, r#" @@ -14770,12 +17633,10 @@ pub struct LuaMat3 { #[lua()] fn from_scale_angle_translation( - #[proxy] - scale: bevy::math::Vec2, + scale: LuaReflectValProxy, angle: f32, - #[proxy] - translation: bevy::math::Vec2, - ) -> bevy::math::Mat3A; + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14786,7 +17647,9 @@ pub struct LuaMat3 { /// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. #[lua()] - fn from_scale(#[proxy] scale: bevy::math::Vec2) -> bevy::math::Mat3A; + fn from_scale( + scale: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14795,7 +17658,9 @@ pub struct LuaMat3 { /// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. #[lua()] - fn from_mat2(#[proxy] m: bevy::math::Mat2) -> bevy::math::Mat3A; + fn from_mat2( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14804,7 +17669,10 @@ pub struct LuaMat3 { /// Panics if `index` is greater than 2. #[lua()] - fn col(&self, index: usize) -> bevy::math::Vec3A; + fn col( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -14813,7 +17681,10 @@ pub struct LuaMat3 { /// Panics if `index` is greater than 2. #[lua()] - fn row(&self, index: usize) -> bevy::math::Vec3A; + fn row( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -14821,28 +17692,30 @@ pub struct LuaMat3 { /// If any element is either `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(&self) -> bool; + fn is_finite(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(&self) -> bool; + fn is_nan(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns the transpose of `self`. #[lua()] - fn transpose(&self) -> bevy::math::Mat3A; + fn transpose( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the determinant of `self`. #[lua()] - fn determinant(&self) -> f32; + fn determinant(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -14852,7 +17725,9 @@ pub struct LuaMat3 { /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. #[lua()] - fn inverse(&self) -> bevy::math::Mat3A; + fn inverse( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14863,7 +17738,10 @@ pub struct LuaMat3 { /// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. #[lua()] - fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn transform_point2( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -14874,49 +17752,70 @@ pub struct LuaMat3 { /// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. #[lua()] - fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn transform_vector2( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms a 3D vector. #[lua()] - fn mul_vec3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn mul_vec3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms a [`Vec3A`]. #[lua()] - fn mul_vec3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn mul_vec3a( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies two 3x3 matrices. #[lua()] - fn mul_mat3(&self, #[proxy] rhs: &glam::Mat3A) -> bevy::math::Mat3A; + fn mul_mat3( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Adds two 3x3 matrices. #[lua()] - fn add_mat3(&self, #[proxy] rhs: &glam::Mat3A) -> bevy::math::Mat3A; + fn add_mat3( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Subtracts two 3x3 matrices. #[lua()] - fn sub_mat3(&self, #[proxy] rhs: &glam::Mat3A) -> bevy::math::Mat3A; + fn sub_mat3( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies a 3x3 matrix by a scalar. #[lua()] - fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat3A; + fn mul_scalar( + _self: LuaReflectRefProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -14929,31 +17828,45 @@ pub struct LuaMat3 { /// [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: bevy::math::Mat3A, max_abs_diff: f32) -> bool; + fn abs_diff_eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f32, + ) -> bool; "#, r#" #[lua()] - fn as_dmat3(&self) -> bevy::math::DMat3; + fn as_dmat3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::Mat3A; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::Mat3A) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -14963,36 +17876,29 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaVec3A::new_ref( - _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) +#[lua(metamethod="Index")] +fn index(_self: IdentityProxy, idx: usize) -> IdentityProxy { + let mut curr_ref = _self.0.clone(); + let def_ref = bevy_mod_scripting_core::bindings::DeferredReflection{ + get: std::sync::Arc::new(|ref_| Err(bevy::reflect::ReflectPathError::InvalidDowncast)), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(idx - 1)) + } else { + Err(bevy::reflect::ReflectPathError::InvalidDowncast) + } + }) + }; + curr_ref.reflect_path.push(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_deferred(def_ref)); + LuaVec3A(curr_ref) } "#] )] -pub struct LuaMat3A { - #[lua(output(proxy))] +pub struct Mat3A { x_axis: bevy::math::Vec3A, - #[lua(output(proxy))] y_axis: bevy::math::Vec3A, - #[lua(output(proxy))] z_axis: bevy::math::Vec3A, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -15003,55 +17909,80 @@ pub struct LuaMat3A { functions[r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::Mat4; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f32) -> bevy::math::Mat4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::Mat4) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Mat4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::Mat4; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15059,15 +17990,11 @@ pub struct LuaMat3A { #[lua()] fn from_cols( - #[proxy] - x_axis: bevy::math::Vec4, - #[proxy] - y_axis: bevy::math::Vec4, - #[proxy] - z_axis: bevy::math::Vec4, - #[proxy] - w_axis: bevy::math::Vec4, - ) -> bevy::math::Mat4; + x_axis: LuaReflectValProxy, + y_axis: LuaReflectValProxy, + z_axis: LuaReflectValProxy, + w_axis: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15075,7 +18002,7 @@ pub struct LuaMat3A { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array(&self) -> [f32; 16]; + fn to_cols_array(_self: LuaReflectRefProxy) -> [f32; 16]; "#, r#" @@ -15083,14 +18010,16 @@ pub struct LuaMat3A { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array_2d(&self) -> [[f32; 4]; 4]; + fn to_cols_array_2d(_self: LuaReflectRefProxy) -> [[f32; 4]; 4]; "#, r#" /// Creates a 4x4 matrix with its diagonal set to `diagonal` and all other entries set to 0. #[lua()] - fn from_diagonal(#[proxy] diagonal: bevy::math::Vec4) -> bevy::math::Mat4; + fn from_diagonal( + diagonal: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15103,13 +18032,10 @@ pub struct LuaMat3A { #[lua()] fn from_scale_rotation_translation( - #[proxy] - scale: bevy::math::Vec3, - #[proxy] - rotation: bevy::math::Quat, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Mat4; + scale: LuaReflectValProxy, + rotation: LuaReflectValProxy, + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15121,11 +18047,9 @@ pub struct LuaMat3A { #[lua()] fn from_rotation_translation( - #[proxy] - rotation: bevy::math::Quat, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Mat4; + rotation: LuaReflectValProxy, + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15136,7 +18060,9 @@ pub struct LuaMat3A { /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. #[lua()] - fn from_quat(#[proxy] rotation: bevy::math::Quat) -> bevy::math::Mat4; + fn from_quat( + rotation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15146,7 +18072,9 @@ pub struct LuaMat3A { /// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. #[lua()] - fn from_mat3(#[proxy] m: bevy::math::Mat3) -> bevy::math::Mat4; + fn from_mat3( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15156,7 +18084,9 @@ pub struct LuaMat3A { /// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. #[lua()] - fn from_mat3a(#[proxy] m: bevy::math::Mat3A) -> bevy::math::Mat4; + fn from_mat3a( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15165,7 +18095,9 @@ pub struct LuaMat3A { /// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. #[lua()] - fn from_translation(#[proxy] translation: bevy::math::Vec3) -> bevy::math::Mat4; + fn from_translation( + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15177,7 +18109,10 @@ pub struct LuaMat3A { /// Will panic if `axis` is not normalized when `glam_assert` is enabled. #[lua()] - fn from_axis_angle(#[proxy] axis: bevy::math::Vec3, angle: f32) -> bevy::math::Mat4; + fn from_axis_angle( + axis: LuaReflectValProxy, + angle: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -15188,12 +18123,11 @@ pub struct LuaMat3A { #[lua()] fn from_euler( - #[proxy] - order: bevy::math::EulerRot, + order: LuaReflectValProxy, a: f32, b: f32, c: f32, - ) -> bevy::math::Mat4; + ) -> LuaReflectValProxy; "#, r#" @@ -15203,7 +18137,7 @@ pub struct LuaMat3A { /// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. #[lua()] - fn from_rotation_x(angle: f32) -> bevy::math::Mat4; + fn from_rotation_x(angle: f32) -> LuaReflectValProxy; "#, r#" @@ -15213,7 +18147,7 @@ pub struct LuaMat3A { /// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. #[lua()] - fn from_rotation_y(angle: f32) -> bevy::math::Mat4; + fn from_rotation_y(angle: f32) -> LuaReflectValProxy; "#, r#" @@ -15223,7 +18157,7 @@ pub struct LuaMat3A { /// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. #[lua()] - fn from_rotation_z(angle: f32) -> bevy::math::Mat4; + fn from_rotation_z(angle: f32) -> LuaReflectValProxy; "#, r#" @@ -15234,7 +18168,9 @@ pub struct LuaMat3A { /// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. #[lua()] - fn from_scale(#[proxy] scale: bevy::math::Vec3) -> bevy::math::Mat4; + fn from_scale( + scale: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15243,7 +18179,10 @@ pub struct LuaMat3A { /// Panics if `index` is greater than 3. #[lua()] - fn col(&self, index: usize) -> bevy::math::Vec4; + fn col( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -15252,7 +18191,10 @@ pub struct LuaMat3A { /// Panics if `index` is greater than 3. #[lua()] - fn row(&self, index: usize) -> bevy::math::Vec4; + fn row( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -15260,28 +18202,30 @@ pub struct LuaMat3A { /// If any element is either `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(&self) -> bool; + fn is_finite(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(&self) -> bool; + fn is_nan(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns the transpose of `self`. #[lua()] - fn transpose(&self) -> bevy::math::Mat4; + fn transpose( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the determinant of `self`. #[lua()] - fn determinant(&self) -> f32; + fn determinant(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -15291,7 +18235,9 @@ pub struct LuaMat3A { /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. #[lua()] - fn inverse(&self) -> bevy::math::Mat4; + fn inverse( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15301,13 +18247,10 @@ pub struct LuaMat3A { #[lua()] fn look_to_lh( - #[proxy] - eye: bevy::math::Vec3, - #[proxy] - dir: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Mat4; + eye: LuaReflectValProxy, + dir: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15317,13 +18260,10 @@ pub struct LuaMat3A { #[lua()] fn look_to_rh( - #[proxy] - eye: bevy::math::Vec3, - #[proxy] - dir: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Mat4; + eye: LuaReflectValProxy, + dir: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15335,13 +18275,10 @@ pub struct LuaMat3A { #[lua()] fn look_at_lh( - #[proxy] - eye: bevy::math::Vec3, - #[proxy] - center: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Mat4; + eye: LuaReflectValProxy, + center: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15353,13 +18290,10 @@ pub struct LuaMat3A { #[lua()] fn look_at_rh( - #[proxy] - eye: bevy::math::Vec3, - #[proxy] - center: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Mat4; + eye: LuaReflectValProxy, + center: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15373,7 +18307,7 @@ pub struct LuaMat3A { aspect_ratio: f32, z_near: f32, z_far: f32, - ) -> bevy::math::Mat4; + ) -> LuaReflectValProxy; "#, r#" @@ -15388,7 +18322,7 @@ pub struct LuaMat3A { aspect_ratio: f32, z_near: f32, z_far: f32, - ) -> bevy::math::Mat4; + ) -> LuaReflectValProxy; "#, r#" @@ -15403,7 +18337,7 @@ pub struct LuaMat3A { aspect_ratio: f32, z_near: f32, z_far: f32, - ) -> bevy::math::Mat4; + ) -> LuaReflectValProxy; "#, r#" @@ -15416,7 +18350,7 @@ pub struct LuaMat3A { fov_y_radians: f32, aspect_ratio: f32, z_near: f32, - ) -> bevy::math::Mat4; + ) -> LuaReflectValProxy; "#, r#" @@ -15429,7 +18363,7 @@ pub struct LuaMat3A { fov_y_radians: f32, aspect_ratio: f32, z_near: f32, - ) -> bevy::math::Mat4; + ) -> LuaReflectValProxy; "#, r#" @@ -15441,7 +18375,7 @@ pub struct LuaMat3A { fov_y_radians: f32, aspect_ratio: f32, z_near: f32, - ) -> bevy::math::Mat4; + ) -> LuaReflectValProxy; "#, r#" @@ -15453,7 +18387,7 @@ pub struct LuaMat3A { fov_y_radians: f32, aspect_ratio: f32, z_near: f32, - ) -> bevy::math::Mat4; + ) -> LuaReflectValProxy; "#, r#" @@ -15470,7 +18404,7 @@ pub struct LuaMat3A { top: f32, near: f32, far: f32, - ) -> bevy::math::Mat4; + ) -> LuaReflectValProxy; "#, r#" @@ -15484,7 +18418,7 @@ pub struct LuaMat3A { top: f32, near: f32, far: f32, - ) -> bevy::math::Mat4; + ) -> LuaReflectValProxy; "#, r#" @@ -15498,7 +18432,7 @@ pub struct LuaMat3A { top: f32, near: f32, far: f32, - ) -> bevy::math::Mat4; + ) -> LuaReflectValProxy; "#, r#" @@ -15508,7 +18442,10 @@ pub struct LuaMat3A { /// This method assumes that `self` contains a projective transform. #[lua()] - fn project_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn project_point3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15522,7 +18459,10 @@ pub struct LuaMat3A { /// Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. #[lua()] - fn transform_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn transform_point3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15534,7 +18474,10 @@ pub struct LuaMat3A { /// Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. #[lua()] - fn transform_vector3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn transform_vector3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15542,7 +18485,10 @@ pub struct LuaMat3A { /// This is the equivalent of multiplying the [`Vec3A`] as a 4D vector where `w` is `1.0`. #[lua()] - fn transform_point3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn transform_point3a( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15550,42 +18496,60 @@ pub struct LuaMat3A { /// This is the equivalent of multiplying the [`Vec3A`] as a 4D vector where `w` is `0.0`. #[lua()] - fn transform_vector3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn transform_vector3a( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms a 4D vector. #[lua()] - fn mul_vec4(&self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn mul_vec4( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies two 4x4 matrices. #[lua()] - fn mul_mat4(&self, #[proxy] rhs: &glam::Mat4) -> bevy::math::Mat4; + fn mul_mat4( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Adds two 4x4 matrices. #[lua()] - fn add_mat4(&self, #[proxy] rhs: &glam::Mat4) -> bevy::math::Mat4; + fn add_mat4( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Subtracts two 4x4 matrices. #[lua()] - fn sub_mat4(&self, #[proxy] rhs: &glam::Mat4) -> bevy::math::Mat4; + fn sub_mat4( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies a 4x4 matrix by a scalar. #[lua()] - fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat4; + fn mul_scalar( + _self: LuaReflectRefProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -15598,13 +18562,19 @@ pub struct LuaMat3A { /// [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: bevy::math::Mat4, max_abs_diff: f32) -> bool; + fn abs_diff_eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f32, + ) -> bool; "#, r#" #[lua()] - fn as_dmat4(&self) -> bevy::math::DMat4; + fn as_dmat4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15614,38 +18584,30 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaVec4::new_ref( - _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) +#[lua(metamethod="Index")] +fn index(_self: IdentityProxy, idx: usize) -> IdentityProxy { + let mut curr_ref = _self.0.clone(); + let def_ref = bevy_mod_scripting_core::bindings::DeferredReflection{ + get: std::sync::Arc::new(|ref_| Err(bevy::reflect::ReflectPathError::InvalidDowncast)), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(idx - 1)) + } else { + Err(bevy::reflect::ReflectPathError::InvalidDowncast) + } + }) + }; + curr_ref.reflect_path.push(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_deferred(def_ref)); + LuaVec4(curr_ref) } "#] )] -pub struct LuaMat4 { - #[lua(output(proxy))] +pub struct Mat4 { x_axis: bevy::math::Vec4, - #[lua(output(proxy))] y_axis: bevy::math::Vec4, - #[lua(output(proxy))] z_axis: bevy::math::Vec4, - #[lua(output(proxy))] w_axis: bevy::math::Vec4, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -15655,32 +18617,45 @@ pub struct LuaMat4 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::DMat2; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::DMat2; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::DMat2) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -15688,11 +18663,9 @@ pub struct LuaMat4 { #[lua()] fn from_cols( - #[proxy] - x_axis: bevy::math::DVec2, - #[proxy] - y_axis: bevy::math::DVec2, - ) -> bevy::math::DMat2; + x_axis: LuaReflectValProxy, + y_axis: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15700,7 +18673,7 @@ pub struct LuaMat4 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array(&self) -> [f64; 4]; + fn to_cols_array(_self: LuaReflectRefProxy) -> [f64; 4]; "#, r#" @@ -15708,14 +18681,16 @@ pub struct LuaMat4 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array_2d(&self) -> [[f64; 2]; 2]; + fn to_cols_array_2d(_self: LuaReflectRefProxy) -> [[f64; 2]; 2]; "#, r#" /// Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. #[lua()] - fn from_diagonal(#[proxy] diagonal: bevy::math::DVec2) -> bevy::math::DMat2; + fn from_diagonal( + diagonal: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15724,24 +18699,25 @@ pub struct LuaMat4 { #[lua()] fn from_scale_angle( - #[proxy] - scale: bevy::math::DVec2, + scale: LuaReflectValProxy, angle: f64, - ) -> bevy::math::DMat2; + ) -> LuaReflectValProxy; "#, r#" /// Creates a 2x2 matrix containing a rotation of `angle` (in radians). #[lua()] - fn from_angle(angle: f64) -> bevy::math::DMat2; + fn from_angle(angle: f64) -> LuaReflectValProxy; "#, r#" /// Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. #[lua()] - fn from_mat3(#[proxy] m: bevy::math::DMat3) -> bevy::math::DMat2; + fn from_mat3( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15750,7 +18726,10 @@ pub struct LuaMat4 { /// Panics if `index` is greater than 1. #[lua()] - fn col(&self, index: usize) -> bevy::math::DVec2; + fn col( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -15759,7 +18738,10 @@ pub struct LuaMat4 { /// Panics if `index` is greater than 1. #[lua()] - fn row(&self, index: usize) -> bevy::math::DVec2; + fn row( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -15767,28 +18749,30 @@ pub struct LuaMat4 { /// If any element is either `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(&self) -> bool; + fn is_finite(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(&self) -> bool; + fn is_nan(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns the transpose of `self`. #[lua()] - fn transpose(&self) -> bevy::math::DMat2; + fn transpose( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the determinant of `self`. #[lua()] - fn determinant(&self) -> f64; + fn determinant(_self: LuaReflectRefProxy) -> f64; "#, r#" @@ -15798,42 +18782,59 @@ pub struct LuaMat4 { /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. #[lua()] - fn inverse(&self) -> bevy::math::DMat2; + fn inverse( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms a 2D vector. #[lua()] - fn mul_vec2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn mul_vec2( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies two 2x2 matrices. #[lua()] - fn mul_mat2(&self, #[proxy] rhs: &glam::DMat2) -> bevy::math::DMat2; + fn mul_mat2( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Adds two 2x2 matrices. #[lua()] - fn add_mat2(&self, #[proxy] rhs: &glam::DMat2) -> bevy::math::DMat2; + fn add_mat2( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Subtracts two 2x2 matrices. #[lua()] - fn sub_mat2(&self, #[proxy] rhs: &glam::DMat2) -> bevy::math::DMat2; + fn sub_mat2( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies a 2x2 matrix by a scalar. #[lua()] - fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat2; + fn mul_scalar( + _self: LuaReflectRefProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -15846,31 +18847,46 @@ pub struct LuaMat4 { /// [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: bevy::math::DMat2, max_abs_diff: f64) -> bool; + fn abs_diff_eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f64, + ) -> bool; "#, r#" #[lua()] - fn as_mat2(&self) -> bevy::math::Mat2; + fn as_mat2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f64) -> bevy::math::DMat2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15880,34 +18896,28 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaDVec2::new_ref( - _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) +#[lua(metamethod="Index")] +fn index(_self: IdentityProxy, idx: usize) -> IdentityProxy { + let mut curr_ref = _self.0.clone(); + let def_ref = bevy_mod_scripting_core::bindings::DeferredReflection{ + get: std::sync::Arc::new(|ref_| Err(bevy::reflect::ReflectPathError::InvalidDowncast)), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(idx - 1)) + } else { + Err(bevy::reflect::ReflectPathError::InvalidDowncast) + } + }) + }; + curr_ref.reflect_path.push(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_deferred(def_ref)); + LuaDVec2(curr_ref) } "#] )] -pub struct LuaDMat2 { - #[lua(output(proxy))] +pub struct DMat2 { x_axis: bevy::math::DVec2, - #[lua(output(proxy))] y_axis: bevy::math::DVec2, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -15917,8 +18927,11 @@ pub struct LuaDMat2 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15926,13 +18939,10 @@ pub struct LuaDMat2 { #[lua()] fn from_cols( - #[proxy] - x_axis: bevy::math::DVec3, - #[proxy] - y_axis: bevy::math::DVec3, - #[proxy] - z_axis: bevy::math::DVec3, - ) -> bevy::math::DMat3; + x_axis: LuaReflectValProxy, + y_axis: LuaReflectValProxy, + z_axis: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15940,7 +18950,7 @@ pub struct LuaDMat2 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array(&self) -> [f64; 9]; + fn to_cols_array(_self: LuaReflectRefProxy) -> [f64; 9]; "#, r#" @@ -15948,21 +18958,25 @@ pub struct LuaDMat2 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array_2d(&self) -> [[f64; 3]; 3]; + fn to_cols_array_2d(_self: LuaReflectRefProxy) -> [[f64; 3]; 3]; "#, r#" /// Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. #[lua()] - fn from_diagonal(#[proxy] diagonal: bevy::math::DVec3) -> bevy::math::DMat3; + fn from_diagonal( + diagonal: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. #[lua()] - fn from_mat4(#[proxy] m: bevy::math::DMat4) -> bevy::math::DMat3; + fn from_mat4( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15971,7 +18985,9 @@ pub struct LuaDMat2 { /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. #[lua()] - fn from_quat(#[proxy] rotation: bevy::math::DQuat) -> bevy::math::DMat3; + fn from_quat( + rotation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -15982,10 +18998,9 @@ pub struct LuaDMat2 { #[lua()] fn from_axis_angle( - #[proxy] - axis: bevy::math::DVec3, + axis: LuaReflectValProxy, angle: f64, - ) -> bevy::math::DMat3; + ) -> LuaReflectValProxy; "#, r#" @@ -15994,33 +19009,32 @@ pub struct LuaDMat2 { #[lua()] fn from_euler( - #[proxy] - order: bevy::math::EulerRot, + order: LuaReflectValProxy, a: f64, b: f64, c: f64, - ) -> bevy::math::DMat3; + ) -> LuaReflectValProxy; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. #[lua()] - fn from_rotation_x(angle: f64) -> bevy::math::DMat3; + fn from_rotation_x(angle: f64) -> LuaReflectValProxy; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the y axis. #[lua()] - fn from_rotation_y(angle: f64) -> bevy::math::DMat3; + fn from_rotation_y(angle: f64) -> LuaReflectValProxy; "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the z axis. #[lua()] - fn from_rotation_z(angle: f64) -> bevy::math::DMat3; + fn from_rotation_z(angle: f64) -> LuaReflectValProxy; "#, r#" @@ -16029,7 +19043,9 @@ pub struct LuaDMat2 { /// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. #[lua()] - fn from_translation(#[proxy] translation: bevy::math::DVec2) -> bevy::math::DMat3; + fn from_translation( + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16039,7 +19055,7 @@ pub struct LuaDMat2 { /// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. #[lua()] - fn from_angle(angle: f64) -> bevy::math::DMat3; + fn from_angle(angle: f64) -> LuaReflectValProxy; "#, r#" @@ -16050,12 +19066,10 @@ pub struct LuaDMat2 { #[lua()] fn from_scale_angle_translation( - #[proxy] - scale: bevy::math::DVec2, + scale: LuaReflectValProxy, angle: f64, - #[proxy] - translation: bevy::math::DVec2, - ) -> bevy::math::DMat3; + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16066,7 +19080,9 @@ pub struct LuaDMat2 { /// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. #[lua()] - fn from_scale(#[proxy] scale: bevy::math::DVec2) -> bevy::math::DMat3; + fn from_scale( + scale: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16075,7 +19091,9 @@ pub struct LuaDMat2 { /// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. #[lua()] - fn from_mat2(#[proxy] m: bevy::math::DMat2) -> bevy::math::DMat3; + fn from_mat2( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16084,7 +19102,10 @@ pub struct LuaDMat2 { /// Panics if `index` is greater than 2. #[lua()] - fn col(&self, index: usize) -> bevy::math::DVec3; + fn col( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -16093,7 +19114,10 @@ pub struct LuaDMat2 { /// Panics if `index` is greater than 2. #[lua()] - fn row(&self, index: usize) -> bevy::math::DVec3; + fn row( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -16101,28 +19125,30 @@ pub struct LuaDMat2 { /// If any element is either `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(&self) -> bool; + fn is_finite(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(&self) -> bool; + fn is_nan(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns the transpose of `self`. #[lua()] - fn transpose(&self) -> bevy::math::DMat3; + fn transpose( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the determinant of `self`. #[lua()] - fn determinant(&self) -> f64; + fn determinant(_self: LuaReflectRefProxy) -> f64; "#, r#" @@ -16132,7 +19158,9 @@ pub struct LuaDMat2 { /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. #[lua()] - fn inverse(&self) -> bevy::math::DMat3; + fn inverse( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16143,7 +19171,10 @@ pub struct LuaDMat2 { /// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. #[lua()] - fn transform_point2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn transform_point2( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16154,42 +19185,60 @@ pub struct LuaDMat2 { /// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. #[lua()] - fn transform_vector2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn transform_vector2( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms a 3D vector. #[lua()] - fn mul_vec3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn mul_vec3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies two 3x3 matrices. #[lua()] - fn mul_mat3(&self, #[proxy] rhs: &glam::DMat3) -> bevy::math::DMat3; + fn mul_mat3( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Adds two 3x3 matrices. #[lua()] - fn add_mat3(&self, #[proxy] rhs: &glam::DMat3) -> bevy::math::DMat3; + fn add_mat3( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Subtracts two 3x3 matrices. #[lua()] - fn sub_mat3(&self, #[proxy] rhs: &glam::DMat3) -> bevy::math::DMat3; + fn sub_mat3( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies a 3x3 matrix by a scalar. #[lua()] - fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat3; + fn mul_scalar( + _self: LuaReflectRefProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -16202,61 +19251,89 @@ pub struct LuaDMat2 { /// [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: bevy::math::DMat3, max_abs_diff: f64) -> bool; + fn abs_diff_eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f64, + ) -> bool; "#, r#" #[lua()] - fn as_mat3(&self) -> bevy::math::Mat3; + fn as_mat3( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::DMat3; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f64) -> bevy::math::DMat3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::DMat3; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DMat3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::DMat3) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -16266,36 +19343,29 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaDVec3::new_ref( - _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) +#[lua(metamethod="Index")] +fn index(_self: IdentityProxy, idx: usize) -> IdentityProxy { + let mut curr_ref = _self.0.clone(); + let def_ref = bevy_mod_scripting_core::bindings::DeferredReflection{ + get: std::sync::Arc::new(|ref_| Err(bevy::reflect::ReflectPathError::InvalidDowncast)), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(idx - 1)) + } else { + Err(bevy::reflect::ReflectPathError::InvalidDowncast) + } + }) + }; + curr_ref.reflect_path.push(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_deferred(def_ref)); + LuaDVec3(curr_ref) } "#] )] -pub struct LuaDMat3 { - #[lua(output(proxy))] +pub struct DMat3 { x_axis: bevy::math::DVec3, - #[lua(output(proxy))] y_axis: bevy::math::DVec3, - #[lua(output(proxy))] z_axis: bevy::math::DVec3, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -16305,38 +19375,55 @@ pub struct LuaDMat3 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DMat4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::DMat4; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16344,15 +19431,11 @@ pub struct LuaDMat3 { #[lua()] fn from_cols( - #[proxy] - x_axis: bevy::math::DVec4, - #[proxy] - y_axis: bevy::math::DVec4, - #[proxy] - z_axis: bevy::math::DVec4, - #[proxy] - w_axis: bevy::math::DVec4, - ) -> bevy::math::DMat4; + x_axis: LuaReflectValProxy, + y_axis: LuaReflectValProxy, + z_axis: LuaReflectValProxy, + w_axis: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16360,7 +19443,7 @@ pub struct LuaDMat3 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array(&self) -> [f64; 16]; + fn to_cols_array(_self: LuaReflectRefProxy) -> [f64; 16]; "#, r#" @@ -16368,14 +19451,16 @@ pub struct LuaDMat3 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array_2d(&self) -> [[f64; 4]; 4]; + fn to_cols_array_2d(_self: LuaReflectRefProxy) -> [[f64; 4]; 4]; "#, r#" /// Creates a 4x4 matrix with its diagonal set to `diagonal` and all other entries set to 0. #[lua()] - fn from_diagonal(#[proxy] diagonal: bevy::math::DVec4) -> bevy::math::DMat4; + fn from_diagonal( + diagonal: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16388,13 +19473,10 @@ pub struct LuaDMat3 { #[lua()] fn from_scale_rotation_translation( - #[proxy] - scale: bevy::math::DVec3, - #[proxy] - rotation: bevy::math::DQuat, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DMat4; + scale: LuaReflectValProxy, + rotation: LuaReflectValProxy, + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16406,11 +19488,9 @@ pub struct LuaDMat3 { #[lua()] fn from_rotation_translation( - #[proxy] - rotation: bevy::math::DQuat, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DMat4; + rotation: LuaReflectValProxy, + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16421,7 +19501,9 @@ pub struct LuaDMat3 { /// Will panic if `rotation` is not normalized when `glam_assert` is enabled. #[lua()] - fn from_quat(#[proxy] rotation: bevy::math::DQuat) -> bevy::math::DMat4; + fn from_quat( + rotation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16431,7 +19513,9 @@ pub struct LuaDMat3 { /// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. #[lua()] - fn from_mat3(#[proxy] m: bevy::math::DMat3) -> bevy::math::DMat4; + fn from_mat3( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16440,7 +19524,9 @@ pub struct LuaDMat3 { /// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. #[lua()] - fn from_translation(#[proxy] translation: bevy::math::DVec3) -> bevy::math::DMat4; + fn from_translation( + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16453,10 +19539,9 @@ pub struct LuaDMat3 { #[lua()] fn from_axis_angle( - #[proxy] - axis: bevy::math::DVec3, + axis: LuaReflectValProxy, angle: f64, - ) -> bevy::math::DMat4; + ) -> LuaReflectValProxy; "#, r#" @@ -16467,12 +19552,11 @@ pub struct LuaDMat3 { #[lua()] fn from_euler( - #[proxy] - order: bevy::math::EulerRot, + order: LuaReflectValProxy, a: f64, b: f64, c: f64, - ) -> bevy::math::DMat4; + ) -> LuaReflectValProxy; "#, r#" @@ -16482,7 +19566,7 @@ pub struct LuaDMat3 { /// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. #[lua()] - fn from_rotation_x(angle: f64) -> bevy::math::DMat4; + fn from_rotation_x(angle: f64) -> LuaReflectValProxy; "#, r#" @@ -16492,7 +19576,7 @@ pub struct LuaDMat3 { /// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. #[lua()] - fn from_rotation_y(angle: f64) -> bevy::math::DMat4; + fn from_rotation_y(angle: f64) -> LuaReflectValProxy; "#, r#" @@ -16502,7 +19586,7 @@ pub struct LuaDMat3 { /// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. #[lua()] - fn from_rotation_z(angle: f64) -> bevy::math::DMat4; + fn from_rotation_z(angle: f64) -> LuaReflectValProxy; "#, r#" @@ -16513,7 +19597,9 @@ pub struct LuaDMat3 { /// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. #[lua()] - fn from_scale(#[proxy] scale: bevy::math::DVec3) -> bevy::math::DMat4; + fn from_scale( + scale: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16522,7 +19608,10 @@ pub struct LuaDMat3 { /// Panics if `index` is greater than 3. #[lua()] - fn col(&self, index: usize) -> bevy::math::DVec4; + fn col( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -16531,7 +19620,10 @@ pub struct LuaDMat3 { /// Panics if `index` is greater than 3. #[lua()] - fn row(&self, index: usize) -> bevy::math::DVec4; + fn row( + _self: LuaReflectRefProxy, + index: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -16539,28 +19631,30 @@ pub struct LuaDMat3 { /// If any element is either `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(&self) -> bool; + fn is_finite(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(&self) -> bool; + fn is_nan(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns the transpose of `self`. #[lua()] - fn transpose(&self) -> bevy::math::DMat4; + fn transpose( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the determinant of `self`. #[lua()] - fn determinant(&self) -> f64; + fn determinant(_self: LuaReflectRefProxy) -> f64; "#, r#" @@ -16570,7 +19664,9 @@ pub struct LuaDMat3 { /// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. #[lua()] - fn inverse(&self) -> bevy::math::DMat4; + fn inverse( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16580,13 +19676,10 @@ pub struct LuaDMat3 { #[lua()] fn look_to_lh( - #[proxy] - eye: bevy::math::DVec3, - #[proxy] - dir: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DMat4; + eye: LuaReflectValProxy, + dir: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16596,13 +19689,10 @@ pub struct LuaDMat3 { #[lua()] fn look_to_rh( - #[proxy] - eye: bevy::math::DVec3, - #[proxy] - dir: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DMat4; + eye: LuaReflectValProxy, + dir: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16614,13 +19704,10 @@ pub struct LuaDMat3 { #[lua()] fn look_at_lh( - #[proxy] - eye: bevy::math::DVec3, - #[proxy] - center: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DMat4; + eye: LuaReflectValProxy, + center: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16632,13 +19719,10 @@ pub struct LuaDMat3 { #[lua()] fn look_at_rh( - #[proxy] - eye: bevy::math::DVec3, - #[proxy] - center: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DMat4; + eye: LuaReflectValProxy, + center: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16652,7 +19736,7 @@ pub struct LuaDMat3 { aspect_ratio: f64, z_near: f64, z_far: f64, - ) -> bevy::math::DMat4; + ) -> LuaReflectValProxy; "#, r#" @@ -16667,7 +19751,7 @@ pub struct LuaDMat3 { aspect_ratio: f64, z_near: f64, z_far: f64, - ) -> bevy::math::DMat4; + ) -> LuaReflectValProxy; "#, r#" @@ -16682,7 +19766,7 @@ pub struct LuaDMat3 { aspect_ratio: f64, z_near: f64, z_far: f64, - ) -> bevy::math::DMat4; + ) -> LuaReflectValProxy; "#, r#" @@ -16695,7 +19779,7 @@ pub struct LuaDMat3 { fov_y_radians: f64, aspect_ratio: f64, z_near: f64, - ) -> bevy::math::DMat4; + ) -> LuaReflectValProxy; "#, r#" @@ -16708,7 +19792,7 @@ pub struct LuaDMat3 { fov_y_radians: f64, aspect_ratio: f64, z_near: f64, - ) -> bevy::math::DMat4; + ) -> LuaReflectValProxy; "#, r#" @@ -16720,7 +19804,7 @@ pub struct LuaDMat3 { fov_y_radians: f64, aspect_ratio: f64, z_near: f64, - ) -> bevy::math::DMat4; + ) -> LuaReflectValProxy; "#, r#" @@ -16732,7 +19816,7 @@ pub struct LuaDMat3 { fov_y_radians: f64, aspect_ratio: f64, z_near: f64, - ) -> bevy::math::DMat4; + ) -> LuaReflectValProxy; "#, r#" @@ -16749,7 +19833,7 @@ pub struct LuaDMat3 { top: f64, near: f64, far: f64, - ) -> bevy::math::DMat4; + ) -> LuaReflectValProxy; "#, r#" @@ -16763,7 +19847,7 @@ pub struct LuaDMat3 { top: f64, near: f64, far: f64, - ) -> bevy::math::DMat4; + ) -> LuaReflectValProxy; "#, r#" @@ -16777,7 +19861,7 @@ pub struct LuaDMat3 { top: f64, near: f64, far: f64, - ) -> bevy::math::DMat4; + ) -> LuaReflectValProxy; "#, r#" @@ -16787,7 +19871,10 @@ pub struct LuaDMat3 { /// This method assumes that `self` contains a projective transform. #[lua()] - fn project_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn project_point3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16801,7 +19888,10 @@ pub struct LuaDMat3 { /// Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. #[lua()] - fn transform_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn transform_point3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16813,42 +19903,60 @@ pub struct LuaDMat3 { /// Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. #[lua()] - fn transform_vector3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn transform_vector3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms a 4D vector. #[lua()] - fn mul_vec4(&self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn mul_vec4( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies two 4x4 matrices. #[lua()] - fn mul_mat4(&self, #[proxy] rhs: &glam::DMat4) -> bevy::math::DMat4; + fn mul_mat4( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Adds two 4x4 matrices. #[lua()] - fn add_mat4(&self, #[proxy] rhs: &glam::DMat4) -> bevy::math::DMat4; + fn add_mat4( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Subtracts two 4x4 matrices. #[lua()] - fn sub_mat4(&self, #[proxy] rhs: &glam::DMat4) -> bevy::math::DMat4; + fn sub_mat4( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies a 4x4 matrix by a scalar. #[lua()] - fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat4; + fn mul_scalar( + _self: LuaReflectRefProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -16861,31 +19969,45 @@ pub struct LuaDMat3 { /// [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: bevy::math::DMat4, max_abs_diff: f64) -> bool; + fn abs_diff_eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f64, + ) -> bool; "#, r#" #[lua()] - fn as_mat4(&self) -> bevy::math::Mat4; + fn as_mat4( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::DMat4) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f64) -> bevy::math::DMat4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::DMat4; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -16895,38 +20017,30 @@ fn index(&self) -> String { } "#, r#" -#[lua(raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaDVec4::new_ref( - _self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) +#[lua(metamethod="Index")] +fn index(_self: IdentityProxy, idx: usize) -> IdentityProxy { + let mut curr_ref = _self.0.clone(); + let def_ref = bevy_mod_scripting_core::bindings::DeferredReflection{ + get: std::sync::Arc::new(|ref_| Err(bevy::reflect::ReflectPathError::InvalidDowncast)), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(idx - 1)) + } else { + Err(bevy::reflect::ReflectPathError::InvalidDowncast) + } + }) + }; + curr_ref.reflect_path.push(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_deferred(def_ref)); + LuaDVec4(curr_ref) } "#] )] -pub struct LuaDMat4 { - #[lua(output(proxy))] +pub struct DMat4 { x_axis: bevy::math::DVec4, - #[lua(output(proxy))] y_axis: bevy::math::DVec4, - #[lua(output(proxy))] z_axis: bevy::math::DVec4, - #[lua(output(proxy))] w_axis: bevy::math::DVec4, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -16939,20 +20053,17 @@ pub struct LuaDMat4 { #[lua()] fn from_cols( - #[proxy] - x_axis: bevy::math::Vec2, - #[proxy] - y_axis: bevy::math::Vec2, - #[proxy] - z_axis: bevy::math::Vec2, - ) -> bevy::math::Affine2; + x_axis: LuaReflectValProxy, + y_axis: LuaReflectValProxy, + z_axis: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a `[f32; 6]` array storing data in column major order. #[lua()] - fn to_cols_array(&self) -> [f32; 6]; + fn to_cols_array(_self: LuaReflectRefProxy) -> [f32; 6]; "#, r#" @@ -16961,7 +20072,7 @@ pub struct LuaDMat4 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array_2d(&self) -> [[f32; 2]; 3]; + fn to_cols_array_2d(_self: LuaReflectRefProxy) -> [[f32; 2]; 3]; "#, r#" @@ -16969,28 +20080,34 @@ pub struct LuaDMat4 { /// Note that if any scale is zero the transform will be non-invertible. #[lua()] - fn from_scale(#[proxy] scale: bevy::math::Vec2) -> bevy::math::Affine2; + fn from_scale( + scale: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates an affine transform from the given rotation `angle`. #[lua()] - fn from_angle(angle: f32) -> bevy::math::Affine2; + fn from_angle(angle: f32) -> LuaReflectValProxy; "#, r#" /// Creates an affine transformation from the given 2D `translation`. #[lua()] - fn from_translation(#[proxy] translation: bevy::math::Vec2) -> bevy::math::Affine2; + fn from_translation( + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) #[lua()] - fn from_mat2(#[proxy] matrix2: bevy::math::Mat2) -> bevy::math::Affine2; + fn from_mat2( + matrix2: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17001,11 +20118,9 @@ pub struct LuaDMat4 { #[lua()] fn from_mat2_translation( - #[proxy] - matrix2: bevy::math::Mat2, - #[proxy] - translation: bevy::math::Vec2, - ) -> bevy::math::Affine2; + matrix2: LuaReflectValProxy, + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17016,12 +20131,10 @@ pub struct LuaDMat4 { #[lua()] fn from_scale_angle_translation( - #[proxy] - scale: bevy::math::Vec2, + scale: LuaReflectValProxy, angle: f32, - #[proxy] - translation: bevy::math::Vec2, - ) -> bevy::math::Affine2; + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17032,30 +20145,36 @@ pub struct LuaDMat4 { #[lua()] fn from_angle_translation( angle: f32, - #[proxy] - translation: bevy::math::Vec2, - ) -> bevy::math::Affine2; + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// The given `Mat3` must be an affine transform, #[lua()] - fn from_mat3(#[proxy] m: bevy::math::Mat3) -> bevy::math::Affine2; + fn from_mat3( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// The given [`Mat3A`] must be an affine transform, #[lua()] - fn from_mat3a(#[proxy] m: bevy::math::Mat3A) -> bevy::math::Affine2; + fn from_mat3a( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms the given 2D point, applying shear, scale, rotation and translation. #[lua()] - fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn transform_point2( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17064,7 +20183,10 @@ pub struct LuaDMat4 { /// To also apply translation, use [`Self::transform_point2()`] instead. #[lua()] - fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn transform_vector2( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17073,14 +20195,14 @@ pub struct LuaDMat4 { /// `false`. #[lua()] - fn is_finite(&self) -> bool; + fn is_finite(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(&self) -> bool; + fn is_nan(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -17093,7 +20215,11 @@ pub struct LuaDMat4 { /// [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: bevy::math::Affine2, max_abs_diff: f32) -> bool; + fn abs_diff_eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f32, + ) -> bool; "#, r#" @@ -17101,37 +20227,53 @@ pub struct LuaDMat4 { /// Note that if the transform is not invertible the result will be invalid. #[lua()] - fn inverse(&self) -> bevy::math::Affine2; + fn inverse( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::Affine2; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Affine2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::Affine2) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17141,10 +20283,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaAffine2 { - #[lua(output(proxy))] +pub struct Affine2 { matrix2: bevy::math::Mat2, - #[lua(output(proxy))] translation: bevy::math::Vec2, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -17154,26 +20294,37 @@ pub struct LuaAffine2 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Affine3A; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::Affine3A; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::Affine3A) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17181,22 +20332,18 @@ pub struct LuaAffine2 { #[lua()] fn from_cols( - #[proxy] - x_axis: bevy::math::Vec3A, - #[proxy] - y_axis: bevy::math::Vec3A, - #[proxy] - z_axis: bevy::math::Vec3A, - #[proxy] - w_axis: bevy::math::Vec3A, - ) -> bevy::math::Affine3A; + x_axis: LuaReflectValProxy, + y_axis: LuaReflectValProxy, + z_axis: LuaReflectValProxy, + w_axis: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a `[f32; 12]` array storing data in column major order. #[lua()] - fn to_cols_array(&self) -> [f32; 12]; + fn to_cols_array(_self: LuaReflectRefProxy) -> [f32; 12]; "#, r#" @@ -17205,7 +20352,9 @@ pub struct LuaAffine2 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array_2d(&self) -> [[f32; 3]; 4]; + fn to_cols_array_2d( + _self: LuaReflectRefProxy, + ) -> [[f32; 3]; 4]; "#, r#" @@ -17213,14 +20362,18 @@ pub struct LuaAffine2 { /// Note that if any scale is zero the transform will be non-invertible. #[lua()] - fn from_scale(#[proxy] scale: bevy::math::Vec3) -> bevy::math::Affine3A; + fn from_scale( + scale: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates an affine transform from the given `rotation` quaternion. #[lua()] - fn from_quat(#[proxy] rotation: bevy::math::Quat) -> bevy::math::Affine3A; + fn from_quat( + rotation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17229,10 +20382,9 @@ pub struct LuaAffine2 { #[lua()] fn from_axis_angle( - #[proxy] - axis: bevy::math::Vec3, + axis: LuaReflectValProxy, angle: f32, - ) -> bevy::math::Affine3A; + ) -> LuaReflectValProxy; "#, r#" @@ -17240,7 +20392,7 @@ pub struct LuaAffine2 { /// `angle` (in radians). #[lua()] - fn from_rotation_x(angle: f32) -> bevy::math::Affine3A; + fn from_rotation_x(angle: f32) -> LuaReflectValProxy; "#, r#" @@ -17248,7 +20400,7 @@ pub struct LuaAffine2 { /// `angle` (in radians). #[lua()] - fn from_rotation_y(angle: f32) -> bevy::math::Affine3A; + fn from_rotation_y(angle: f32) -> LuaReflectValProxy; "#, r#" @@ -17256,14 +20408,16 @@ pub struct LuaAffine2 { /// `angle` (in radians). #[lua()] - fn from_rotation_z(angle: f32) -> bevy::math::Affine3A; + fn from_rotation_z(angle: f32) -> LuaReflectValProxy; "#, r#" /// Creates an affine transformation from the given 3D `translation`. #[lua()] - fn from_translation(#[proxy] translation: bevy::math::Vec3) -> bevy::math::Affine3A; + fn from_translation( + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17271,7 +20425,9 @@ pub struct LuaAffine2 { /// rotation) #[lua()] - fn from_mat3(#[proxy] mat3: bevy::math::Mat3) -> bevy::math::Affine3A; + fn from_mat3( + mat3: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17281,11 +20437,9 @@ pub struct LuaAffine2 { #[lua()] fn from_mat3_translation( - #[proxy] - mat3: bevy::math::Mat3, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Affine3A; + mat3: LuaReflectValProxy, + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17296,13 +20450,10 @@ pub struct LuaAffine2 { #[lua()] fn from_scale_rotation_translation( - #[proxy] - scale: bevy::math::Vec3, - #[proxy] - rotation: bevy::math::Quat, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Affine3A; + scale: LuaReflectValProxy, + rotation: LuaReflectValProxy, + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17311,11 +20462,9 @@ pub struct LuaAffine2 { #[lua()] fn from_rotation_translation( - #[proxy] - rotation: bevy::math::Quat, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Affine3A; + rotation: LuaReflectValProxy, + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17323,7 +20472,9 @@ pub struct LuaAffine2 { /// i.e. contain no perspective transform. #[lua()] - fn from_mat4(#[proxy] m: bevy::math::Mat4) -> bevy::math::Affine3A; + fn from_mat4( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17333,13 +20484,10 @@ pub struct LuaAffine2 { #[lua()] fn look_to_lh( - #[proxy] - eye: bevy::math::Vec3, - #[proxy] - dir: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Affine3A; + eye: LuaReflectValProxy, + dir: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17349,13 +20497,10 @@ pub struct LuaAffine2 { #[lua()] fn look_to_rh( - #[proxy] - eye: bevy::math::Vec3, - #[proxy] - dir: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Affine3A; + eye: LuaReflectValProxy, + dir: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17367,13 +20512,10 @@ pub struct LuaAffine2 { #[lua()] fn look_at_lh( - #[proxy] - eye: bevy::math::Vec3, - #[proxy] - center: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Affine3A; + eye: LuaReflectValProxy, + center: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17385,20 +20527,20 @@ pub struct LuaAffine2 { #[lua()] fn look_at_rh( - #[proxy] - eye: bevy::math::Vec3, - #[proxy] - center: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Affine3A; + eye: LuaReflectValProxy, + center: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms the given 3D points, applying shear, scale, rotation and translation. #[lua()] - fn transform_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn transform_point3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17407,14 +20549,20 @@ pub struct LuaAffine2 { /// To also apply translation, use [`Self::transform_point3()`] instead. #[lua()] - fn transform_vector3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn transform_vector3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms the given [`Vec3A`], applying shear, scale, rotation and translation. #[lua()] - fn transform_point3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn transform_point3a( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17423,7 +20571,10 @@ pub struct LuaAffine2 { /// To also apply translation, use [`Self::transform_point3a()`] instead. #[lua()] - fn transform_vector3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn transform_vector3a( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17432,14 +20583,14 @@ pub struct LuaAffine2 { /// `false`. #[lua()] - fn is_finite(&self) -> bool; + fn is_finite(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(&self) -> bool; + fn is_nan(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -17452,7 +20603,11 @@ pub struct LuaAffine2 { /// [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: bevy::math::Affine3A, max_abs_diff: f32) -> bool; + fn abs_diff_eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f32, + ) -> bool; "#, r#" @@ -17460,7 +20615,9 @@ pub struct LuaAffine2 { /// Note that if the transform is not invertible the result will be invalid. #[lua()] - fn inverse(&self) -> bevy::math::Affine3A; + fn inverse( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17470,10 +20627,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaAffine3A { - #[lua(output(proxy))] +pub struct Affine3A { matrix3: bevy::math::Mat3A, - #[lua(output(proxy))] translation: bevy::math::Vec3A, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -17483,14 +20638,20 @@ pub struct LuaAffine3A { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::DAffine2) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -17498,20 +20659,17 @@ pub struct LuaAffine3A { #[lua()] fn from_cols( - #[proxy] - x_axis: bevy::math::DVec2, - #[proxy] - y_axis: bevy::math::DVec2, - #[proxy] - z_axis: bevy::math::DVec2, - ) -> bevy::math::DAffine2; + x_axis: LuaReflectValProxy, + y_axis: LuaReflectValProxy, + z_axis: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a `[f64; 6]` array storing data in column major order. #[lua()] - fn to_cols_array(&self) -> [f64; 6]; + fn to_cols_array(_self: LuaReflectRefProxy) -> [f64; 6]; "#, r#" @@ -17520,7 +20678,9 @@ pub struct LuaAffine3A { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array_2d(&self) -> [[f64; 2]; 3]; + fn to_cols_array_2d( + _self: LuaReflectRefProxy, + ) -> [[f64; 2]; 3]; "#, r#" @@ -17528,28 +20688,34 @@ pub struct LuaAffine3A { /// Note that if any scale is zero the transform will be non-invertible. #[lua()] - fn from_scale(#[proxy] scale: bevy::math::DVec2) -> bevy::math::DAffine2; + fn from_scale( + scale: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates an affine transform from the given rotation `angle`. #[lua()] - fn from_angle(angle: f64) -> bevy::math::DAffine2; + fn from_angle(angle: f64) -> LuaReflectValProxy; "#, r#" /// Creates an affine transformation from the given 2D `translation`. #[lua()] - fn from_translation(#[proxy] translation: bevy::math::DVec2) -> bevy::math::DAffine2; + fn from_translation( + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) #[lua()] - fn from_mat2(#[proxy] matrix2: bevy::math::DMat2) -> bevy::math::DAffine2; + fn from_mat2( + matrix2: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17560,11 +20726,9 @@ pub struct LuaAffine3A { #[lua()] fn from_mat2_translation( - #[proxy] - matrix2: bevy::math::DMat2, - #[proxy] - translation: bevy::math::DVec2, - ) -> bevy::math::DAffine2; + matrix2: LuaReflectValProxy, + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17575,12 +20739,10 @@ pub struct LuaAffine3A { #[lua()] fn from_scale_angle_translation( - #[proxy] - scale: bevy::math::DVec2, + scale: LuaReflectValProxy, angle: f64, - #[proxy] - translation: bevy::math::DVec2, - ) -> bevy::math::DAffine2; + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17591,23 +20753,27 @@ pub struct LuaAffine3A { #[lua()] fn from_angle_translation( angle: f64, - #[proxy] - translation: bevy::math::DVec2, - ) -> bevy::math::DAffine2; + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// The given `DMat3` must be an affine transform, #[lua()] - fn from_mat3(#[proxy] m: bevy::math::DMat3) -> bevy::math::DAffine2; + fn from_mat3( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms the given 2D point, applying shear, scale, rotation and translation. #[lua()] - fn transform_point2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn transform_point2( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17616,7 +20782,10 @@ pub struct LuaAffine3A { /// To also apply translation, use [`Self::transform_point2()`] instead. #[lua()] - fn transform_vector2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn transform_vector2( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17625,14 +20794,14 @@ pub struct LuaAffine3A { /// `false`. #[lua()] - fn is_finite(&self) -> bool; + fn is_finite(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(&self) -> bool; + fn is_nan(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -17645,7 +20814,11 @@ pub struct LuaAffine3A { /// [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: bevy::math::DAffine2, max_abs_diff: f64) -> bool; + fn abs_diff_eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f64, + ) -> bool; "#, r#" @@ -17653,19 +20826,26 @@ pub struct LuaAffine3A { /// Note that if the transform is not invertible the result will be invalid. #[lua()] - fn inverse(&self) -> bevy::math::DAffine2; + fn inverse( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::DAffine2; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DAffine2; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17675,10 +20855,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaDAffine2 { - #[lua(output(proxy))] +pub struct DAffine2 { matrix2: bevy::math::DMat2, - #[lua(output(proxy))] translation: bevy::math::DVec2, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -17688,14 +20866,19 @@ pub struct LuaDAffine2 { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::DAffine3; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17703,22 +20886,18 @@ pub struct LuaDAffine2 { #[lua()] fn from_cols( - #[proxy] - x_axis: bevy::math::DVec3, - #[proxy] - y_axis: bevy::math::DVec3, - #[proxy] - z_axis: bevy::math::DVec3, - #[proxy] - w_axis: bevy::math::DVec3, - ) -> bevy::math::DAffine3; + x_axis: LuaReflectValProxy, + y_axis: LuaReflectValProxy, + z_axis: LuaReflectValProxy, + w_axis: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a `[f64; 12]` array storing data in column major order. #[lua()] - fn to_cols_array(&self) -> [f64; 12]; + fn to_cols_array(_self: LuaReflectRefProxy) -> [f64; 12]; "#, r#" @@ -17727,7 +20906,9 @@ pub struct LuaDAffine2 { /// If you require data in row major order `transpose` the matrix first. #[lua()] - fn to_cols_array_2d(&self) -> [[f64; 3]; 4]; + fn to_cols_array_2d( + _self: LuaReflectRefProxy, + ) -> [[f64; 3]; 4]; "#, r#" @@ -17735,14 +20916,18 @@ pub struct LuaDAffine2 { /// Note that if any scale is zero the transform will be non-invertible. #[lua()] - fn from_scale(#[proxy] scale: bevy::math::DVec3) -> bevy::math::DAffine3; + fn from_scale( + scale: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates an affine transform from the given `rotation` quaternion. #[lua()] - fn from_quat(#[proxy] rotation: bevy::math::DQuat) -> bevy::math::DAffine3; + fn from_quat( + rotation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17751,10 +20936,9 @@ pub struct LuaDAffine2 { #[lua()] fn from_axis_angle( - #[proxy] - axis: bevy::math::DVec3, + axis: LuaReflectValProxy, angle: f64, - ) -> bevy::math::DAffine3; + ) -> LuaReflectValProxy; "#, r#" @@ -17762,7 +20946,7 @@ pub struct LuaDAffine2 { /// `angle` (in radians). #[lua()] - fn from_rotation_x(angle: f64) -> bevy::math::DAffine3; + fn from_rotation_x(angle: f64) -> LuaReflectValProxy; "#, r#" @@ -17770,7 +20954,7 @@ pub struct LuaDAffine2 { /// `angle` (in radians). #[lua()] - fn from_rotation_y(angle: f64) -> bevy::math::DAffine3; + fn from_rotation_y(angle: f64) -> LuaReflectValProxy; "#, r#" @@ -17778,14 +20962,16 @@ pub struct LuaDAffine2 { /// `angle` (in radians). #[lua()] - fn from_rotation_z(angle: f64) -> bevy::math::DAffine3; + fn from_rotation_z(angle: f64) -> LuaReflectValProxy; "#, r#" /// Creates an affine transformation from the given 3D `translation`. #[lua()] - fn from_translation(#[proxy] translation: bevy::math::DVec3) -> bevy::math::DAffine3; + fn from_translation( + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17793,7 +20979,9 @@ pub struct LuaDAffine2 { /// rotation) #[lua()] - fn from_mat3(#[proxy] mat3: bevy::math::DMat3) -> bevy::math::DAffine3; + fn from_mat3( + mat3: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17803,11 +20991,9 @@ pub struct LuaDAffine2 { #[lua()] fn from_mat3_translation( - #[proxy] - mat3: bevy::math::DMat3, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DAffine3; + mat3: LuaReflectValProxy, + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17818,13 +21004,10 @@ pub struct LuaDAffine2 { #[lua()] fn from_scale_rotation_translation( - #[proxy] - scale: bevy::math::DVec3, - #[proxy] - rotation: bevy::math::DQuat, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DAffine3; + scale: LuaReflectValProxy, + rotation: LuaReflectValProxy, + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17833,11 +21016,9 @@ pub struct LuaDAffine2 { #[lua()] fn from_rotation_translation( - #[proxy] - rotation: bevy::math::DQuat, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DAffine3; + rotation: LuaReflectValProxy, + translation: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17845,7 +21026,9 @@ pub struct LuaDAffine2 { /// i.e. contain no perspective transform. #[lua()] - fn from_mat4(#[proxy] m: bevy::math::DMat4) -> bevy::math::DAffine3; + fn from_mat4( + m: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17855,13 +21038,10 @@ pub struct LuaDAffine2 { #[lua()] fn look_to_lh( - #[proxy] - eye: bevy::math::DVec3, - #[proxy] - dir: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DAffine3; + eye: LuaReflectValProxy, + dir: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17871,13 +21051,10 @@ pub struct LuaDAffine2 { #[lua()] fn look_to_rh( - #[proxy] - eye: bevy::math::DVec3, - #[proxy] - dir: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DAffine3; + eye: LuaReflectValProxy, + dir: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17889,13 +21066,10 @@ pub struct LuaDAffine2 { #[lua()] fn look_at_lh( - #[proxy] - eye: bevy::math::DVec3, - #[proxy] - center: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DAffine3; + eye: LuaReflectValProxy, + center: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17907,20 +21081,20 @@ pub struct LuaDAffine2 { #[lua()] fn look_at_rh( - #[proxy] - eye: bevy::math::DVec3, - #[proxy] - center: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DAffine3; + eye: LuaReflectValProxy, + center: LuaReflectValProxy, + up: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Transforms the given 3D points, applying shear, scale, rotation and translation. #[lua()] - fn transform_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn transform_point3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17929,7 +21103,10 @@ pub struct LuaDAffine2 { /// To also apply translation, use [`Self::transform_point3()`] instead. #[lua()] - fn transform_vector3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn transform_vector3( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -17938,14 +21115,14 @@ pub struct LuaDAffine2 { /// `false`. #[lua()] - fn is_finite(&self) -> bool; + fn is_finite(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Returns `true` if any elements are `NaN`. #[lua()] - fn is_nan(&self) -> bool; + fn is_nan(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -17958,7 +21135,11 @@ pub struct LuaDAffine2 { /// [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: bevy::math::DAffine3, max_abs_diff: f64) -> bool; + fn abs_diff_eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f64, + ) -> bool; "#, r#" @@ -17966,19 +21147,27 @@ pub struct LuaDAffine2 { /// Note that if the transform is not invertible the result will be invalid. #[lua()] - fn inverse(&self) -> bevy::math::DAffine3; + fn inverse( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DAffine3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::DAffine3) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -17988,10 +21177,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaDAffine3 { - #[lua(output(proxy))] +pub struct DAffine3 { matrix3: bevy::math::DMat3, - #[lua(output(proxy))] translation: bevy::math::DVec3, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -18005,34 +21192,47 @@ pub struct LuaDAffine3 { /// Note that addition is not the same as combining the rotations represented by the /// two quaternions! That corresponds to multiplication. - #[lua(as_trait = "std::ops::Add", composite = "add")] - fn add(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + #[lua(as_trait = "std::ops::Add::", composite = "add")] + fn add( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::DQuat; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::DQuat) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::DQuat; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Divides a quaternion by a scalar value. /// The quotient is not guaranteed to be normalized. - #[lua(as_trait = "std::ops::Div", composite = "div")] - fn div(self, rhs: f64) -> bevy::math::DQuat; + #[lua(as_trait = "std::ops::Div::", composite = "div")] + fn div( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -18043,24 +21243,33 @@ pub struct LuaDAffine3 { /// # Panics /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Subtracts the `rhs` quaternion from `self`. /// The difference is not guaranteed to be normalized. - #[lua(as_trait = "std::ops::Sub", composite = "sub")] - fn sub(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + #[lua(as_trait = "std::ops::Sub::", composite = "sub")] + fn sub( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Multiplies a quaternion by a scalar value. /// The product is not guaranteed to be normalized. - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f64) -> bevy::math::DQuat; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -18068,8 +21277,11 @@ pub struct LuaDAffine3 { /// # Panics /// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18082,7 +21294,12 @@ pub struct LuaDAffine3 { /// provide normalized input or to normalized the resulting quaternion. #[lua()] - fn from_xyzw(x: f64, y: f64, z: f64, w: f64) -> bevy::math::DQuat; + fn from_xyzw( + x: f64, + y: f64, + z: f64, + w: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -18092,7 +21309,7 @@ pub struct LuaDAffine3 { /// provide normalized input or to normalized the resulting quaternion. #[lua()] - fn from_array(a: [f64; 4]) -> bevy::math::DQuat; + fn from_array(a: [f64; 4]) -> LuaReflectValProxy; "#, r#" @@ -18102,7 +21319,9 @@ pub struct LuaDAffine3 { /// provide normalized input or to normalized the resulting quaternion. #[lua()] - fn from_vec4(#[proxy] v: bevy::math::DVec4) -> bevy::math::DQuat; + fn from_vec4( + v: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18113,10 +21332,9 @@ pub struct LuaDAffine3 { #[lua()] fn from_axis_angle( - #[proxy] - axis: bevy::math::DVec3, + axis: LuaReflectValProxy, angle: f64, - ) -> bevy::math::DQuat; + ) -> LuaReflectValProxy; "#, r#" @@ -18124,28 +21342,30 @@ pub struct LuaDAffine3 { /// `from_scaled_axis(Vec3::ZERO)` results in the identity quaternion. #[lua()] - fn from_scaled_axis(#[proxy] v: bevy::math::DVec3) -> bevy::math::DQuat; + fn from_scaled_axis( + v: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from the `angle` (in radians) around the x axis. #[lua()] - fn from_rotation_x(angle: f64) -> bevy::math::DQuat; + fn from_rotation_x(angle: f64) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from the `angle` (in radians) around the y axis. #[lua()] - fn from_rotation_y(angle: f64) -> bevy::math::DQuat; + fn from_rotation_y(angle: f64) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from the `angle` (in radians) around the z axis. #[lua()] - fn from_rotation_z(angle: f64) -> bevy::math::DQuat; + fn from_rotation_z(angle: f64) -> LuaReflectValProxy; "#, r#" @@ -18153,26 +21373,29 @@ pub struct LuaDAffine3 { #[lua()] fn from_euler( - #[proxy] - euler: bevy::math::EulerRot, + euler: LuaReflectValProxy, a: f64, b: f64, c: f64, - ) -> bevy::math::DQuat; + ) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from a 3x3 rotation matrix. #[lua()] - fn from_mat3(#[proxy] mat: &glam::DMat3) -> bevy::math::DQuat; + fn from_mat3( + mat: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. #[lua()] - fn from_mat4(#[proxy] mat: &glam::DMat4) -> bevy::math::DQuat; + fn from_mat4( + mat: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18187,11 +21410,9 @@ pub struct LuaDAffine3 { #[lua()] fn from_rotation_arc( - #[proxy] - from: bevy::math::DVec3, - #[proxy] - to: bevy::math::DVec3, - ) -> bevy::math::DQuat; + from: LuaReflectValProxy, + to: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18206,11 +21427,9 @@ pub struct LuaDAffine3 { #[lua()] fn from_rotation_arc_colinear( - #[proxy] - from: bevy::math::DVec3, - #[proxy] - to: bevy::math::DVec3, - ) -> bevy::math::DQuat; + from: LuaReflectValProxy, + to: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18225,39 +21444,44 @@ pub struct LuaDAffine3 { #[lua()] fn from_rotation_arc_2d( - #[proxy] - from: bevy::math::DVec2, - #[proxy] - to: bevy::math::DVec2, - ) -> bevy::math::DQuat; + from: LuaReflectValProxy, + to: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the rotation axis scaled by the rotation in radians. #[lua()] - fn to_scaled_axis(self) -> bevy::math::DVec3; + fn to_scaled_axis( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the rotation angles for the given euler rotation sequence. #[lua()] - fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f64, f64, f64); + fn to_euler( + _self: LuaReflectValProxy, + euler: LuaReflectValProxy, + ) -> (f64, f64, f64); "#, r#" /// `[x, y, z, w]` #[lua()] - fn to_array(&self) -> [f64; 4]; + fn to_array(_self: LuaReflectRefProxy) -> [f64; 4]; "#, r#" /// Returns the vector part of the quaternion. #[lua()] - fn xyz(self) -> bevy::math::DVec3; + fn xyz( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18265,7 +21489,9 @@ pub struct LuaDAffine3 { /// conjugate is also the inverse. #[lua()] - fn conjugate(self) -> bevy::math::DQuat; + fn conjugate( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18277,7 +21503,9 @@ pub struct LuaDAffine3 { /// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua()] - fn inverse(self) -> bevy::math::DQuat; + fn inverse( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18285,14 +21513,17 @@ pub struct LuaDAffine3 { /// equal to the cosine of the angle between two quaternion rotations. #[lua()] - fn dot(self, #[proxy] rhs: bevy::math::DQuat) -> f64; + fn dot( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" /// Computes the length of `self`. #[lua()] - fn length(self) -> f64; + fn length(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -18301,7 +21532,7 @@ pub struct LuaDAffine3 { /// root operation. #[lua()] - fn length_squared(self) -> f64; + fn length_squared(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -18309,7 +21540,7 @@ pub struct LuaDAffine3 { /// For valid results, `self` must _not_ be of length zero. #[lua()] - fn length_recip(self) -> f64; + fn length_recip(_self: LuaReflectValProxy) -> f64; "#, r#" @@ -18319,7 +21550,9 @@ pub struct LuaDAffine3 { /// Will panic if `self` is zero length when `glam_assert` is enabled. #[lua()] - fn normalize(self) -> bevy::math::DQuat; + fn normalize( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18327,13 +21560,13 @@ pub struct LuaDAffine3 { /// If any element is either `NaN`, positive or negative infinity, this will return `false`. #[lua()] - fn is_finite(self) -> bool; + fn is_finite(_self: LuaReflectValProxy) -> bool; "#, r#" #[lua()] - fn is_nan(self) -> bool; + fn is_nan(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -18341,13 +21574,13 @@ pub struct LuaDAffine3 { /// Uses a precision threshold of `1e-6`. #[lua()] - fn is_normalized(self) -> bool; + fn is_normalized(_self: LuaReflectValProxy) -> bool; "#, r#" #[lua()] - fn is_near_identity(self) -> bool; + fn is_near_identity(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -18358,7 +21591,10 @@ pub struct LuaDAffine3 { /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. #[lua()] - fn angle_between(self, #[proxy] rhs: bevy::math::DQuat) -> f64; + fn angle_between( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> f64; "#, r#" @@ -18371,7 +21607,11 @@ pub struct LuaDAffine3 { /// [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: bevy::math::DQuat, max_abs_diff: f64) -> bool; + fn abs_diff_eq( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + max_abs_diff: f64, + ) -> bool; "#, r#" @@ -18383,7 +21623,11 @@ pub struct LuaDAffine3 { /// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. #[lua()] - fn lerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; + fn lerp( + _self: LuaReflectValProxy, + end: LuaReflectValProxy, + s: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -18395,7 +21639,11 @@ pub struct LuaDAffine3 { /// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. #[lua()] - fn slerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; + fn slerp( + _self: LuaReflectValProxy, + end: LuaReflectValProxy, + s: f64, + ) -> LuaReflectValProxy; "#, r#" @@ -18404,7 +21652,10 @@ pub struct LuaDAffine3 { /// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua()] - fn mul_vec3(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn mul_vec3( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18415,26 +21666,35 @@ pub struct LuaDAffine3 { /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. #[lua()] - fn mul_quat(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + fn mul_quat( + _self: LuaReflectValProxy, + rhs: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. #[lua()] - fn from_affine3(#[proxy] a: &glam::DAffine3) -> bevy::math::DQuat; + fn from_affine3( + a: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua()] - fn as_quat(self) -> bevy::math::Quat; + fn as_quat( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua()] - fn as_f32(self) -> bevy::math::Quat; + fn as_f32( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18444,7 +21704,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaDQuat { +pub struct DQuat { x: f64, y: f64, z: f64, @@ -18457,20 +21717,27 @@ pub struct LuaDQuat { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &glam::EulerRot) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::EulerRot; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18480,7 +21747,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaEulerRot {} +pub struct EulerRot {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::BVec3A", @@ -18489,21 +21756,23 @@ pub struct LuaEulerRot {} functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::BVec3A; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector mask. #[lua()] - fn new(x: bool, y: bool, z: bool) -> bevy::math::BVec3A; + fn new(x: bool, y: bool, z: bool) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: bool) -> bevy::math::BVec3A; + fn splat(v: bool) -> LuaReflectValProxy; "#, r#" @@ -18512,21 +21781,21 @@ pub struct LuaEulerRot {} /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn bitmask(self) -> u32; + fn bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" /// Returns true if any of the elements are true, false otherwise. #[lua()] - fn any(self) -> bool; + fn any(_self: LuaReflectValProxy) -> bool; "#, r#" /// Returns true if all the elements are true, false otherwise. #[lua()] - fn all(self) -> bool; + fn all(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -18534,7 +21803,7 @@ pub struct LuaEulerRot {} /// Panics if `index` is greater than 2. #[lua()] - fn test(&self, index: usize) -> bool; + fn test(_self: LuaReflectRefProxy, index: usize) -> bool; "#, r#" @@ -18542,13 +21811,20 @@ pub struct LuaEulerRot {} /// Panics if `index` is greater than 2. #[lua()] - fn set(&mut self, index: usize, value: bool) -> (); + fn set( + _self: LuaReflectRefMutProxy, + index: usize, + value: bool, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::BVec3A) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -18558,7 +21834,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaBVec3A(); +pub struct BVec3A(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::BVec4A", @@ -18567,21 +21843,23 @@ pub struct LuaBVec3A(); functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::BVec4A; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new vector mask. #[lua()] - fn new(x: bool, y: bool, z: bool, w: bool) -> bevy::math::BVec4A; + fn new(x: bool, y: bool, z: bool, w: bool) -> LuaReflectValProxy; "#, r#" /// Creates a vector with all elements set to `v`. #[lua()] - fn splat(v: bool) -> bevy::math::BVec4A; + fn splat(v: bool) -> LuaReflectValProxy; "#, r#" @@ -18590,21 +21868,21 @@ pub struct LuaBVec3A(); /// into the first lowest bit, element `y` into the second, etc. #[lua()] - fn bitmask(self) -> u32; + fn bitmask(_self: LuaReflectValProxy) -> u32; "#, r#" /// Returns true if any of the elements are true, false otherwise. #[lua()] - fn any(self) -> bool; + fn any(_self: LuaReflectValProxy) -> bool; "#, r#" /// Returns true if all the elements are true, false otherwise. #[lua()] - fn all(self) -> bool; + fn all(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -18612,7 +21890,7 @@ pub struct LuaBVec3A(); /// Panics if `index` is greater than 3. #[lua()] - fn test(&self, index: usize) -> bool; + fn test(_self: LuaReflectRefProxy, index: usize) -> bool; "#, r#" @@ -18620,13 +21898,20 @@ pub struct LuaBVec3A(); /// Panics if `index` is greater than 3. #[lua()] - fn set(&mut self, index: usize, value: bool) -> (); + fn set( + _self: LuaReflectRefMutProxy, + index: usize, + value: bool, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] rhs: &glam::BVec4A) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + rhs: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -18636,7 +21921,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaBVec4A(); +pub struct BVec4A(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Direction2d", @@ -18649,27 +21934,36 @@ pub struct LuaBVec4A(); #[lua()] fn new_unchecked( - #[proxy] - value: bevy::math::Vec2, - ) -> bevy::math::primitives::Direction2d; + value: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction2d) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Direction2d; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::primitives::Direction2d; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18679,7 +21973,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaDirection2d(); +pub struct Direction2d(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Circle", @@ -18688,41 +21982,49 @@ pub struct LuaDirection2d(); functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Circle; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Circle) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" /// Create a new [`Circle`] from a `radius` #[lua()] - fn new(radius: f32) -> bevy::math::primitives::Circle; + fn new(radius: f32) -> LuaReflectValProxy; "#, r#" /// Get the diameter of the circle #[lua()] - fn diameter(&self) -> f32; + fn diameter(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the area of the circle #[lua()] - fn area(&self) -> f32; + fn area(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the perimeter or circumference of the circle #[lua()] - fn perimeter(&self) -> f32; + fn perimeter(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -18731,7 +22033,10 @@ pub struct LuaDirection2d(); /// Otherwise, it will be inside the circle and returned as is. #[lua()] - fn closest_point(&self, #[proxy] point: bevy::math::Vec2) -> bevy::math::Vec2; + fn closest_point( + _self: LuaReflectRefProxy, + point: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18741,7 +22046,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCircle { +pub struct Circle { radius: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -18752,13 +22057,21 @@ pub struct LuaCircle { functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Ellipse; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Ellipse) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -18766,7 +22079,10 @@ pub struct LuaCircle { /// This corresponds to the two perpendicular radii defining the ellipse. #[lua()] - fn new(half_width: f32, half_height: f32) -> bevy::math::primitives::Ellipse; + fn new( + half_width: f32, + half_height: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -18774,28 +22090,30 @@ pub struct LuaCircle { /// `size.x` is the diameter along the X axis, and `size.y` is the diameter along the Y axis. #[lua()] - fn from_size(#[proxy] size: bevy::math::Vec2) -> bevy::math::primitives::Ellipse; + fn from_size( + size: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns the length of the semi-major axis. This corresponds to the longest radius of the ellipse. #[lua()] - fn semi_major(self) -> f32; + fn semi_major(_self: LuaReflectValProxy) -> f32; "#, r#" /// Returns the length of the semi-minor axis. This corresponds to the shortest radius of the ellipse. #[lua()] - fn semi_minor(self) -> f32; + fn semi_minor(_self: LuaReflectValProxy) -> f32; "#, r#" /// Get the area of the ellipse #[lua()] - fn area(&self) -> f32; + fn area(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -18805,8 +22123,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaEllipse { - #[lua(output(proxy))] +pub struct Ellipse { half_size: bevy::math::Vec2, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -18816,8 +22133,14 @@ pub struct LuaEllipse { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Plane2d) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -18826,13 +22149,17 @@ pub struct LuaEllipse { /// Panics if the given `normal` is zero (or very close to zero), or non-finite. #[lua()] - fn new(#[proxy] normal: bevy::math::Vec2) -> bevy::math::primitives::Plane2d; + fn new( + normal: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Plane2d; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18842,8 +22169,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaPlane2d { - #[lua(output(proxy))] +pub struct Plane2d { normal: bevy::math::primitives::Direction2d, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -18853,14 +22179,22 @@ pub struct LuaPlane2d { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Line2d) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Line2d; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18870,8 +22204,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaLine2d { - #[lua(output(proxy))] +pub struct Line2d { direction: bevy::math::primitives::Direction2d, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -18884,36 +22217,47 @@ pub struct LuaLine2d { #[lua()] fn new( - #[proxy] - direction: bevy::math::primitives::Direction2d, + direction: LuaReflectValProxy, length: f32, - ) -> bevy::math::primitives::Segment2d; + ) -> LuaReflectValProxy; "#, r#" /// Get the position of the first point on the line segment #[lua()] - fn point1(&self) -> bevy::math::Vec2; + fn point1( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Get the position of the second point on the line segment #[lua()] - fn point2(&self) -> bevy::math::Vec2; + fn point2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Segment2d; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Segment2d) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -18923,8 +22267,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaSegment2d { - #[lua(output(proxy))] +pub struct Segment2d { direction: bevy::math::primitives::Direction2d, half_length: f32, } @@ -18936,7 +22279,9 @@ pub struct LuaSegment2d { functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Triangle2d; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -18944,27 +22289,24 @@ pub struct LuaSegment2d { #[lua()] fn new( - #[proxy] - a: bevy::math::Vec2, - #[proxy] - b: bevy::math::Vec2, - #[proxy] - c: bevy::math::Vec2, - ) -> bevy::math::primitives::Triangle2d; + a: LuaReflectValProxy, + b: LuaReflectValProxy, + c: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Get the area of the triangle #[lua()] - fn area(&self) -> f32; + fn area(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the perimeter of the triangle #[lua()] - fn perimeter(&self) -> f32; + fn perimeter(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -18972,13 +22314,19 @@ pub struct LuaSegment2d { /// by swapping the second and third vertices #[lua()] - fn reverse(&mut self) -> (); + fn reverse(_self: LuaReflectRefMutProxy) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Triangle2d) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -18988,8 +22336,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaTriangle2d { - vertices: ReflectedValue, +pub struct Triangle2d { + vertices: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -19000,14 +22348,19 @@ pub struct LuaTriangle2d { /// Create a new `Rectangle` from a full width and height #[lua()] - fn new(width: f32, height: f32) -> bevy::math::primitives::Rectangle; + fn new( + width: f32, + height: f32, + ) -> LuaReflectValProxy; "#, r#" /// Create a new `Rectangle` from a given full size #[lua()] - fn from_size(#[proxy] size: bevy::math::Vec2) -> bevy::math::primitives::Rectangle; + fn from_size( + size: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19015,32 +22368,32 @@ pub struct LuaTriangle2d { #[lua()] fn from_corners( - #[proxy] - point1: bevy::math::Vec2, - #[proxy] - point2: bevy::math::Vec2, - ) -> bevy::math::primitives::Rectangle; + point1: LuaReflectValProxy, + point2: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Get the size of the rectangle #[lua()] - fn size(&self) -> bevy::math::Vec2; + fn size( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Get the area of the rectangle #[lua()] - fn area(&self) -> f32; + fn area(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the perimeter of the rectangle #[lua()] - fn perimeter(&self) -> f32; + fn perimeter(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -19049,19 +22402,30 @@ pub struct LuaTriangle2d { /// Otherwise, it will be inside the rectangle and returned as is. #[lua()] - fn closest_point(&self, #[proxy] point: bevy::math::Vec2) -> bevy::math::Vec2; + fn closest_point( + _self: LuaReflectRefProxy, + point: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Rectangle) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Rectangle; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19071,8 +22435,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaRectangle { - #[lua(output(proxy))] +pub struct Rectangle { half_size: bevy::math::Vec2, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -19083,13 +22446,21 @@ pub struct LuaRectangle { functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::RegularPolygon; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::RegularPolygon) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -19099,7 +22470,10 @@ pub struct LuaRectangle { /// Panics if `circumradius` is non-positive #[lua()] - fn new(circumradius: f32, sides: usize) -> bevy::math::primitives::RegularPolygon; + fn new( + circumradius: f32, + sides: usize, + ) -> LuaReflectValProxy; "#, r#" @@ -19107,7 +22481,9 @@ pub struct LuaRectangle { /// of the regular polygon lie #[lua()] - fn circumradius(&self) -> f32; + fn circumradius( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -19116,21 +22492,25 @@ pub struct LuaRectangle { /// be drawn within the polygon #[lua()] - fn inradius(&self) -> f32; + fn inradius( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" /// Get the length of one side of the regular polygon #[lua()] - fn side_length(&self) -> f32; + fn side_length( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" /// Get the area of the regular polygon #[lua()] - fn area(&self) -> f32; + fn area(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -19138,7 +22518,9 @@ pub struct LuaRectangle { /// This is the sum of its sides #[lua()] - fn perimeter(&self) -> f32; + fn perimeter( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -19147,7 +22529,9 @@ pub struct LuaRectangle { /// within the angle being in the interior of the polygon #[lua()] - fn internal_angle_degrees(&self) -> f32; + fn internal_angle_degrees( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -19156,7 +22540,9 @@ pub struct LuaRectangle { /// within the angle being in the interior of the polygon #[lua()] - fn internal_angle_radians(&self) -> f32; + fn internal_angle_radians( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -19165,7 +22551,9 @@ pub struct LuaRectangle { /// within the angle being in the exterior of the polygon #[lua()] - fn external_angle_degrees(&self) -> f32; + fn external_angle_degrees( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -19174,7 +22562,9 @@ pub struct LuaRectangle { /// within the angle being in the exterior of the polygon #[lua()] - fn external_angle_radians(&self) -> f32; + fn external_angle_radians( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -19184,8 +22574,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaRegularPolygon { - #[lua(output(proxy))] +pub struct RegularPolygon { circumcircle: bevy::math::primitives::Circle, sides: usize, } @@ -19196,21 +22585,32 @@ pub struct LuaRegularPolygon { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule2d) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" /// Create a new `Capsule2d` from a radius and length #[lua()] - fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule2d; + fn new( + radius: f32, + length: f32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Capsule2d; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19220,7 +22620,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCapsule2d { +pub struct Capsule2d { radius: f32, half_length: f32, } @@ -19231,20 +22631,31 @@ pub struct LuaCapsule2d { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction3d) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, rhs: f32) -> bevy::math::Vec3; + #[lua(as_trait = "std::ops::Mul::", composite = "mul")] + fn mul( + _self: LuaReflectValProxy, + rhs: f32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Direction3d; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19254,15 +22665,16 @@ pub struct LuaCapsule2d { #[lua()] fn new_unchecked( - #[proxy] - value: bevy::math::Vec3, - ) -> bevy::math::primitives::Direction3d; + value: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> bevy::math::primitives::Direction3d; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19272,7 +22684,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaDirection3d(); +pub struct Direction3d(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::math::primitives::Sphere", @@ -19281,35 +22693,37 @@ pub struct LuaDirection3d(); functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Sphere; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Create a new [`Sphere`] from a `radius` #[lua()] - fn new(radius: f32) -> bevy::math::primitives::Sphere; + fn new(radius: f32) -> LuaReflectValProxy; "#, r#" /// Get the diameter of the sphere #[lua()] - fn diameter(&self) -> f32; + fn diameter(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the surface area of the sphere #[lua()] - fn area(&self) -> f32; + fn area(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the volume of the sphere #[lua()] - fn volume(&self) -> f32; + fn volume(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -19318,13 +22732,22 @@ pub struct LuaDirection3d(); /// Otherwise, it will be inside the sphere and returned as is. #[lua()] - fn closest_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; + fn closest_point( + _self: LuaReflectRefProxy, + point: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Sphere) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -19334,7 +22757,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaSphere { +pub struct Sphere { radius: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -19345,7 +22768,9 @@ pub struct LuaSphere { functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Plane3d; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19354,13 +22779,21 @@ pub struct LuaSphere { /// Panics if the given `normal` is zero (or very close to zero), or non-finite. #[lua()] - fn new(#[proxy] normal: bevy::math::Vec3) -> bevy::math::primitives::Plane3d; + fn new( + normal: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Plane3d) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -19370,8 +22803,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaPlane3d { - #[lua(output(proxy))] +pub struct Plane3d { normal: bevy::math::primitives::Direction3d, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -19382,13 +22814,21 @@ pub struct LuaPlane3d { functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Line3d; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Line3d) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -19398,8 +22838,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaLine3d { - #[lua(output(proxy))] +pub struct Line3d { direction: bevy::math::primitives::Direction3d, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -19412,36 +22851,47 @@ pub struct LuaLine3d { #[lua()] fn new( - #[proxy] - direction: bevy::math::primitives::Direction3d, + direction: LuaReflectValProxy, length: f32, - ) -> bevy::math::primitives::Segment3d; + ) -> LuaReflectValProxy; "#, r#" /// Get the position of the first point on the line segment #[lua()] - fn point1(&self) -> bevy::math::Vec3; + fn point1( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Get the position of the second point on the line segment #[lua()] - fn point2(&self) -> bevy::math::Vec3; + fn point2( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Segment3d; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Segment3d) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -19451,8 +22901,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaSegment3d { - #[lua(output(proxy))] +pub struct Segment3d { direction: bevy::math::primitives::Direction3d, half_length: f32, } @@ -19464,7 +22913,9 @@ pub struct LuaSegment3d { functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Cuboid; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19475,14 +22926,16 @@ pub struct LuaSegment3d { x_length: f32, y_length: f32, z_length: f32, - ) -> bevy::math::primitives::Cuboid; + ) -> LuaReflectValProxy; "#, r#" /// Create a new `Cuboid` from a given full size #[lua()] - fn from_size(#[proxy] size: bevy::math::Vec3) -> bevy::math::primitives::Cuboid; + fn from_size( + size: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19490,32 +22943,32 @@ pub struct LuaSegment3d { #[lua()] fn from_corners( - #[proxy] - point1: bevy::math::Vec3, - #[proxy] - point2: bevy::math::Vec3, - ) -> bevy::math::primitives::Cuboid; + point1: LuaReflectValProxy, + point2: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Get the size of the cuboid #[lua()] - fn size(&self) -> bevy::math::Vec3; + fn size( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Get the surface area of the cuboid #[lua()] - fn area(&self) -> f32; + fn area(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the volume of the cuboid #[lua()] - fn volume(&self) -> f32; + fn volume(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -19524,13 +22977,22 @@ pub struct LuaSegment3d { /// Otherwise, it will be inside the cuboid and returned as is. #[lua()] - fn closest_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; + fn closest_point( + _self: LuaReflectRefProxy, + point: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Cuboid) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -19540,8 +23002,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCuboid { - #[lua(output(proxy))] +pub struct Cuboid { half_size: bevy::math::Vec3, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -19552,27 +23013,40 @@ pub struct LuaCuboid { functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Cylinder; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Cylinder) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" /// Create a new `Cylinder` from a radius and full height #[lua()] - fn new(radius: f32, height: f32) -> bevy::math::primitives::Cylinder; + fn new( + radius: f32, + height: f32, + ) -> LuaReflectValProxy; "#, r#" /// Get the base of the cylinder as a [`Circle`] #[lua()] - fn base(&self) -> bevy::math::primitives::Circle; + fn base( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19580,28 +23054,28 @@ pub struct LuaCuboid { /// also known as the lateral area #[lua()] - fn lateral_area(&self) -> f32; + fn lateral_area(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the surface area of one base of the cylinder #[lua()] - fn base_area(&self) -> f32; + fn base_area(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the total surface area of the cylinder #[lua()] - fn area(&self) -> f32; + fn area(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the volume of the cylinder #[lua()] - fn volume(&self) -> f32; + fn volume(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -19611,7 +23085,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCylinder { +pub struct Cylinder { radius: f32, half_height: f32, } @@ -19623,14 +23097,19 @@ pub struct LuaCylinder { functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Capsule3d; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Create a new `Capsule3d` from a radius and length #[lua()] - fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule3d; + fn new( + radius: f32, + length: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -19638,27 +23117,35 @@ pub struct LuaCylinder { /// of the capsule as a [`Cylinder`] #[lua()] - fn to_cylinder(&self) -> bevy::math::primitives::Cylinder; + fn to_cylinder( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Get the surface area of the capsule #[lua()] - fn area(&self) -> f32; + fn area(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the volume of the capsule #[lua()] - fn volume(&self) -> f32; + fn volume(_self: LuaReflectRefProxy) -> f32; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule3d) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -19668,7 +23155,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCapsule3d { +pub struct Capsule3d { radius: f32, half_length: f32, } @@ -19680,14 +23167,18 @@ pub struct LuaCapsule3d { functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Cone; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Get the base of the cone as a [`Circle`] #[lua()] - fn base(&self) -> bevy::math::primitives::Circle; + fn base( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19695,7 +23186,7 @@ pub struct LuaCapsule3d { /// connecting a point on the base to the apex #[lua()] - fn slant_height(&self) -> f32; + fn slant_height(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -19703,34 +23194,40 @@ pub struct LuaCapsule3d { /// also known as the lateral area #[lua()] - fn lateral_area(&self) -> f32; + fn lateral_area(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the surface area of the base of the cone #[lua()] - fn base_area(&self) -> f32; + fn base_area(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the total surface area of the cone #[lua()] - fn area(&self) -> f32; + fn area(_self: LuaReflectRefProxy) -> f32; "#, r#" /// Get the volume of the cone #[lua()] - fn volume(&self) -> f32; + fn volume(_self: LuaReflectRefProxy) -> f32; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Cone) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -19740,7 +23237,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCone { +pub struct Cone { radius: f32, height: f32, } @@ -19752,13 +23249,21 @@ pub struct LuaCone { functions[r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::ConicalFrustum; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::ConicalFrustum) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -19768,7 +23273,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaConicalFrustum { +pub struct ConicalFrustum { radius_top: f32, radius_bottom: f32, height: f32, @@ -19784,7 +23289,10 @@ pub struct LuaConicalFrustum { /// is the radius of the entire object #[lua()] - fn new(inner_radius: f32, outer_radius: f32) -> bevy::math::primitives::Torus; + fn new( + inner_radius: f32, + outer_radius: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -19793,7 +23301,7 @@ pub struct LuaConicalFrustum { /// or `major_radius - minor_radius` #[lua()] - fn inner_radius(&self) -> f32; + fn inner_radius(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -19802,7 +23310,7 @@ pub struct LuaConicalFrustum { /// or `major_radius + minor_radius` #[lua()] - fn outer_radius(&self) -> f32; + fn outer_radius(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -19810,7 +23318,7 @@ pub struct LuaConicalFrustum { /// the expected result when the torus has a ring and isn't self-intersecting #[lua()] - fn area(&self) -> f32; + fn area(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -19818,19 +23326,27 @@ pub struct LuaConicalFrustum { /// the expected result when the torus has a ring and isn't self-intersecting #[lua()] - fn volume(&self) -> f32; + fn volume(_self: LuaReflectRefProxy) -> f32; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::primitives::Torus; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Torus) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -19840,7 +23356,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaTorus { +pub struct Torus { minor_radius: f32, major_radius: f32, } @@ -19861,7 +23377,7 @@ pub struct LuaTorus { /// ``` #[lua()] - fn new(x0: i32, y0: i32, x1: i32, y1: i32) -> bevy::math::IRect; + fn new(x0: i32, y0: i32, x1: i32, y1: i32) -> LuaReflectValProxy; "#, r#" @@ -19879,11 +23395,9 @@ pub struct LuaTorus { #[lua()] fn from_corners( - #[proxy] - p0: bevy::math::IVec2, - #[proxy] - p1: bevy::math::IVec2, - ) -> bevy::math::IRect; + p0: LuaReflectValProxy, + p1: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19902,11 +23416,9 @@ pub struct LuaTorus { #[lua()] fn from_center_size( - #[proxy] - origin: bevy::math::IVec2, - #[proxy] - size: bevy::math::IVec2, - ) -> bevy::math::IRect; + origin: LuaReflectValProxy, + size: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19923,11 +23435,9 @@ pub struct LuaTorus { #[lua()] fn from_center_half_size( - #[proxy] - origin: bevy::math::IVec2, - #[proxy] - half_size: bevy::math::IVec2, - ) -> bevy::math::IRect; + origin: LuaReflectValProxy, + half_size: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19940,7 +23450,7 @@ pub struct LuaTorus { /// ``` #[lua()] - fn is_empty(&self) -> bool; + fn is_empty(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -19953,7 +23463,7 @@ pub struct LuaTorus { /// ``` #[lua()] - fn width(&self) -> i32; + fn width(_self: LuaReflectRefProxy) -> i32; "#, r#" @@ -19966,7 +23476,7 @@ pub struct LuaTorus { /// ``` #[lua()] - fn height(&self) -> i32; + fn height(_self: LuaReflectRefProxy) -> i32; "#, r#" @@ -19979,7 +23489,9 @@ pub struct LuaTorus { /// ``` #[lua()] - fn size(&self) -> bevy::math::IVec2; + fn size( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -19994,7 +23506,9 @@ pub struct LuaTorus { /// ``` #[lua()] - fn half_size(&self) -> bevy::math::IVec2; + fn half_size( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20009,7 +23523,9 @@ pub struct LuaTorus { /// ``` #[lua()] - fn center(&self) -> bevy::math::IVec2; + fn center( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20024,7 +23540,10 @@ pub struct LuaTorus { /// ``` #[lua()] - fn contains(&self, #[proxy] point: bevy::math::IVec2) -> bool; + fn contains( + _self: LuaReflectRefProxy, + point: LuaReflectValProxy, + ) -> bool; "#, r#" @@ -20041,7 +23560,10 @@ pub struct LuaTorus { /// ``` #[lua()] - fn union(&self, #[proxy] other: bevy::math::IRect) -> bevy::math::IRect; + fn union( + _self: LuaReflectRefProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20058,7 +23580,10 @@ pub struct LuaTorus { /// ``` #[lua()] - fn union_point(&self, #[proxy] other: bevy::math::IVec2) -> bevy::math::IRect; + fn union_point( + _self: LuaReflectRefProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20077,7 +23602,10 @@ pub struct LuaTorus { /// ``` #[lua()] - fn intersect(&self, #[proxy] other: bevy::math::IRect) -> bevy::math::IRect; + fn intersect( + _self: LuaReflectRefProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20099,39 +23627,51 @@ pub struct LuaTorus { /// ``` #[lua()] - fn inset(&self, inset: i32) -> bevy::math::IRect; + fn inset( + _self: LuaReflectRefProxy, + inset: i32, + ) -> LuaReflectValProxy; "#, r#" /// Returns self as [`Rect`] (f32) #[lua()] - fn as_rect(&self) -> bevy::math::Rect; + fn as_rect( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns self as [`URect`] (u32) #[lua()] - fn as_urect(&self) -> bevy::math::URect; + fn as_urect( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::IRect; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::IRect) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" @@ -20141,10 +23681,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaIRect { - #[lua(output(proxy))] +pub struct IRect { min: bevy::math::IVec2, - #[lua(output(proxy))] max: bevy::math::IVec2, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -20164,7 +23702,7 @@ pub struct LuaIRect { /// ``` #[lua()] - fn new(x0: f32, y0: f32, x1: f32, y1: f32) -> bevy::math::Rect; + fn new(x0: f32, y0: f32, x1: f32, y1: f32) -> LuaReflectValProxy; "#, r#" @@ -20182,11 +23720,9 @@ pub struct LuaIRect { #[lua()] fn from_corners( - #[proxy] - p0: bevy::math::Vec2, - #[proxy] - p1: bevy::math::Vec2, - ) -> bevy::math::Rect; + p0: LuaReflectValProxy, + p1: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20203,11 +23739,9 @@ pub struct LuaIRect { #[lua()] fn from_center_size( - #[proxy] - origin: bevy::math::Vec2, - #[proxy] - size: bevy::math::Vec2, - ) -> bevy::math::Rect; + origin: LuaReflectValProxy, + size: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20224,11 +23758,9 @@ pub struct LuaIRect { #[lua()] fn from_center_half_size( - #[proxy] - origin: bevy::math::Vec2, - #[proxy] - half_size: bevy::math::Vec2, - ) -> bevy::math::Rect; + origin: LuaReflectValProxy, + half_size: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20241,7 +23773,7 @@ pub struct LuaIRect { /// ``` #[lua()] - fn is_empty(&self) -> bool; + fn is_empty(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -20254,7 +23786,7 @@ pub struct LuaIRect { /// ``` #[lua()] - fn width(&self) -> f32; + fn width(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -20267,7 +23799,7 @@ pub struct LuaIRect { /// ``` #[lua()] - fn height(&self) -> f32; + fn height(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -20280,7 +23812,9 @@ pub struct LuaIRect { /// ``` #[lua()] - fn size(&self) -> bevy::math::Vec2; + fn size( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20293,7 +23827,9 @@ pub struct LuaIRect { /// ``` #[lua()] - fn half_size(&self) -> bevy::math::Vec2; + fn half_size( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20306,7 +23842,9 @@ pub struct LuaIRect { /// ``` #[lua()] - fn center(&self) -> bevy::math::Vec2; + fn center( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20321,7 +23859,10 @@ pub struct LuaIRect { /// ``` #[lua()] - fn contains(&self, #[proxy] point: bevy::math::Vec2) -> bool; + fn contains( + _self: LuaReflectRefProxy, + point: LuaReflectValProxy, + ) -> bool; "#, r#" @@ -20338,7 +23879,10 @@ pub struct LuaIRect { /// ``` #[lua()] - fn union(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; + fn union( + _self: LuaReflectRefProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20355,7 +23899,10 @@ pub struct LuaIRect { /// ``` #[lua()] - fn union_point(&self, #[proxy] other: bevy::math::Vec2) -> bevy::math::Rect; + fn union_point( + _self: LuaReflectRefProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20374,7 +23921,10 @@ pub struct LuaIRect { /// ``` #[lua()] - fn intersect(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; + fn intersect( + _self: LuaReflectRefProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20396,7 +23946,10 @@ pub struct LuaIRect { /// ``` #[lua()] - fn inset(&self, inset: f32) -> bevy::math::Rect; + fn inset( + _self: LuaReflectRefProxy, + inset: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -20415,33 +23968,45 @@ pub struct LuaIRect { /// ``` #[lua()] - fn normalize(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; + fn normalize( + _self: LuaReflectRefProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns self as [`IRect`] (i32) #[lua()] - fn as_irect(&self) -> bevy::math::IRect; + fn as_irect( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns self as [`URect`] (u32) #[lua()] - fn as_urect(&self) -> bevy::math::URect; + fn as_urect( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::Rect) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::Rect; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20451,10 +24016,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaRect { - #[lua(output(proxy))] +pub struct Rect { min: bevy::math::Vec2, - #[lua(output(proxy))] max: bevy::math::Vec2, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -20465,19 +24028,24 @@ pub struct LuaRect { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_math::URect) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::math::URect; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20492,7 +24060,7 @@ pub struct LuaRect { /// ``` #[lua()] - fn new(x0: u32, y0: u32, x1: u32, y1: u32) -> bevy::math::URect; + fn new(x0: u32, y0: u32, x1: u32, y1: u32) -> LuaReflectValProxy; "#, r#" @@ -20510,11 +24078,9 @@ pub struct LuaRect { #[lua()] fn from_corners( - #[proxy] - p0: bevy::math::UVec2, - #[proxy] - p1: bevy::math::UVec2, - ) -> bevy::math::URect; + p0: LuaReflectValProxy, + p1: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20533,11 +24099,9 @@ pub struct LuaRect { #[lua()] fn from_center_size( - #[proxy] - origin: bevy::math::UVec2, - #[proxy] - size: bevy::math::UVec2, - ) -> bevy::math::URect; + origin: LuaReflectValProxy, + size: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20554,11 +24118,9 @@ pub struct LuaRect { #[lua()] fn from_center_half_size( - #[proxy] - origin: bevy::math::UVec2, - #[proxy] - half_size: bevy::math::UVec2, - ) -> bevy::math::URect; + origin: LuaReflectValProxy, + half_size: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20571,7 +24133,7 @@ pub struct LuaRect { /// ``` #[lua()] - fn is_empty(&self) -> bool; + fn is_empty(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -20584,7 +24146,7 @@ pub struct LuaRect { /// ``` #[lua()] - fn width(&self) -> u32; + fn width(_self: LuaReflectRefProxy) -> u32; "#, r#" @@ -20597,7 +24159,7 @@ pub struct LuaRect { /// ``` #[lua()] - fn height(&self) -> u32; + fn height(_self: LuaReflectRefProxy) -> u32; "#, r#" @@ -20610,7 +24172,9 @@ pub struct LuaRect { /// ``` #[lua()] - fn size(&self) -> bevy::math::UVec2; + fn size( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20625,7 +24189,9 @@ pub struct LuaRect { /// ``` #[lua()] - fn half_size(&self) -> bevy::math::UVec2; + fn half_size( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20640,7 +24206,9 @@ pub struct LuaRect { /// ``` #[lua()] - fn center(&self) -> bevy::math::UVec2; + fn center( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20655,7 +24223,10 @@ pub struct LuaRect { /// ``` #[lua()] - fn contains(&self, #[proxy] point: bevy::math::UVec2) -> bool; + fn contains( + _self: LuaReflectRefProxy, + point: LuaReflectValProxy, + ) -> bool; "#, r#" @@ -20672,7 +24243,10 @@ pub struct LuaRect { /// ``` #[lua()] - fn union(&self, #[proxy] other: bevy::math::URect) -> bevy::math::URect; + fn union( + _self: LuaReflectRefProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20689,7 +24263,10 @@ pub struct LuaRect { /// ``` #[lua()] - fn union_point(&self, #[proxy] other: bevy::math::UVec2) -> bevy::math::URect; + fn union_point( + _self: LuaReflectRefProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20708,7 +24285,10 @@ pub struct LuaRect { /// ``` #[lua()] - fn intersect(&self, #[proxy] other: bevy::math::URect) -> bevy::math::URect; + fn intersect( + _self: LuaReflectRefProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20730,21 +24310,28 @@ pub struct LuaRect { /// ``` #[lua()] - fn inset(&self, inset: i32) -> bevy::math::URect; + fn inset( + _self: LuaReflectRefProxy, + inset: i32, + ) -> LuaReflectValProxy; "#, r#" /// Returns self as [`Rect`] (f32) #[lua()] - fn as_rect(&self) -> bevy::math::Rect; + fn as_rect( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Returns self as [`IRect`] (i32) #[lua()] - fn as_irect(&self) -> bevy::math::IRect; + fn as_irect( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20754,10 +24341,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaURect { - #[lua(output(proxy))] +pub struct URect { min: bevy::math::UVec2, - #[lua(output(proxy))] max: bevy::math::UVec2, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -20768,37 +24353,42 @@ pub struct LuaURect { functions[r#" #[lua()] - fn to_string(&self) -> std::string::String; + fn to_string(_self: LuaReflectRefProxy) -> std::string::String; "#, r#" #[lua()] - fn len(&self) -> usize; + fn len(_self: LuaReflectRefProxy) -> usize; "#, r#" #[lua()] - fn is_empty(&self) -> bool; + fn is_empty(_self: LuaReflectRefProxy) -> bool; "#, r#" #[lua()] - fn is_heap_allocated(&self) -> bool; + fn is_heap_allocated(_self: LuaReflectRefProxy) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &smol_str::SmolStr) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> smol_str::SmolStr; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20808,7 +24398,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaSmolStr(); +pub struct SmolStr(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "std::num::NonZeroIsize", @@ -20816,14 +24406,19 @@ pub struct LuaSmolStr(); bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &std::num::NonZeroIsize) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -20833,14 +24428,14 @@ pub struct LuaSmolStr(); /// The value must not be zero. #[lua()] - unsafe fn new_unchecked(n: isize) -> std::num::NonZeroIsize; + unsafe fn new_unchecked(n: isize) -> LuaReflectValProxy; "#, r#" /// Returns the value as a primitive type. #[lua()] - fn get(self) -> isize; + fn get(_self: LuaReflectValProxy) -> isize; "#, r#" @@ -20854,7 +24449,7 @@ pub struct LuaSmolStr(); /// ``` #[lua()] - fn leading_zeros(self) -> u32; + fn leading_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -20869,7 +24464,7 @@ pub struct LuaSmolStr(); /// ``` #[lua()] - fn trailing_zeros(self) -> u32; + fn trailing_zeros(_self: LuaReflectValProxy) -> u32; "#, r#" @@ -20890,7 +24485,9 @@ pub struct LuaSmolStr(); /// ``` #[lua()] - fn abs(self) -> std::num::NonZeroIsize; + fn abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20915,7 +24512,9 @@ pub struct LuaSmolStr(); /// ``` #[lua()] - fn saturating_abs(self) -> std::num::NonZeroIsize; + fn saturating_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20939,7 +24538,9 @@ pub struct LuaSmolStr(); /// ``` #[lua()] - fn wrapping_abs(self) -> std::num::NonZeroIsize; + fn wrapping_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20964,7 +24565,9 @@ pub struct LuaSmolStr(); /// ``` #[lua()] - fn unsigned_abs(self) -> std::num::NonZeroUsize; + fn unsigned_abs( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -20984,7 +24587,7 @@ pub struct LuaSmolStr(); /// ``` #[lua()] - fn is_positive(self) -> bool; + fn is_positive(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -21004,7 +24607,7 @@ pub struct LuaSmolStr(); /// ``` #[lua()] - fn is_negative(self) -> bool; + fn is_negative(_self: LuaReflectValProxy) -> bool; "#, r#" @@ -21030,7 +24633,9 @@ pub struct LuaSmolStr(); /// ``` #[lua()] - fn saturating_neg(self) -> std::num::NonZeroIsize; + fn saturating_neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -21053,7 +24658,9 @@ pub struct LuaSmolStr(); /// ``` #[lua()] - fn wrapping_neg(self) -> std::num::NonZeroIsize; + fn wrapping_neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -21075,10 +24682,9 @@ pub struct LuaSmolStr(); #[lua()] fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroIsize, - ) -> std::num::NonZeroIsize; + _self: LuaReflectValProxy, + other: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -21099,19 +24705,26 @@ pub struct LuaSmolStr(); /// ``` #[lua()] - fn saturating_pow(self, other: u32) -> std::num::NonZeroIsize; + fn saturating_pow( + _self: LuaReflectValProxy, + other: u32, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> std::num::NonZeroIsize; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::ops::Neg", composite = "neg")] - fn neg(self) -> std::num::NonZeroIsize; + fn neg( + _self: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -21121,7 +24734,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNonZeroIsize(); +pub struct NonZeroIsize(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::utils::Uuid", @@ -21150,25 +24763,30 @@ pub struct LuaNonZeroIsize(); /// [from_random_bytes]: struct.Builder.html#method.from_random_bytes #[lua()] - fn new_v4() -> bevy::utils::Uuid; + fn new_v4() -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &bevy_utils::Uuid) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq(_self: LuaReflectRefProxy) -> (); "#, r#" #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] - fn clone(&self) -> bevy::utils::Uuid; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -21189,7 +24807,7 @@ pub struct LuaNonZeroIsize(); /// * [Version in RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.3) #[lua()] - fn get_version_num(&self) -> usize; + fn get_version_num(_self: LuaReflectRefProxy) -> usize; "#, r#" @@ -21209,7 +24827,7 @@ pub struct LuaNonZeroIsize(); /// ``` #[lua()] - fn as_u128(&self) -> u128; + fn as_u128(_self: LuaReflectRefProxy) -> u128; "#, r#" @@ -21235,7 +24853,7 @@ pub struct LuaNonZeroIsize(); /// ``` #[lua()] - fn to_u128_le(&self) -> u128; + fn to_u128_le(_self: LuaReflectRefProxy) -> u128; "#, r#" @@ -21257,7 +24875,7 @@ pub struct LuaNonZeroIsize(); /// ``` #[lua()] - fn as_u64_pair(&self) -> (u64, u64); + fn as_u64_pair(_self: LuaReflectRefProxy) -> (u64, u64); "#, r#" @@ -21276,7 +24894,7 @@ pub struct LuaNonZeroIsize(); /// ``` #[lua()] - fn into_bytes(self) -> [u8; 16]; + fn into_bytes(_self: LuaReflectValProxy) -> [u8; 16]; "#, r#" @@ -21301,21 +24919,21 @@ pub struct LuaNonZeroIsize(); /// ``` #[lua()] - fn to_bytes_le(&self) -> [u8; 16]; + fn to_bytes_le(_self: LuaReflectRefProxy) -> [u8; 16]; "#, r#" /// Tests if the UUID is nil (all zeros). #[lua()] - fn is_nil(&self) -> bool; + fn is_nil(_self: LuaReflectRefProxy) -> bool; "#, r#" /// Tests if the UUID is max (all ones). #[lua()] - fn is_max(&self) -> bool; + fn is_max(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -21362,7 +24980,7 @@ pub struct LuaNonZeroIsize(); /// ``` #[lua()] - fn nil() -> bevy::utils::Uuid; + fn nil() -> LuaReflectValProxy; "#, r#" @@ -21383,7 +25001,7 @@ pub struct LuaNonZeroIsize(); /// ``` #[lua()] - fn max() -> bevy::utils::Uuid; + fn max() -> LuaReflectValProxy; "#, r#" @@ -21401,7 +25019,7 @@ pub struct LuaNonZeroIsize(); /// ``` #[lua()] - fn from_u128(v: u128) -> bevy::utils::Uuid; + fn from_u128(v: u128) -> LuaReflectValProxy; "#, r#" @@ -21423,7 +25041,7 @@ pub struct LuaNonZeroIsize(); /// ``` #[lua()] - fn from_u128_le(v: u128) -> bevy::utils::Uuid; + fn from_u128_le(v: u128) -> LuaReflectValProxy; "#, r#" @@ -21442,7 +25060,10 @@ pub struct LuaNonZeroIsize(); /// ``` #[lua()] - fn from_u64_pair(high_bits: u64, low_bits: u64) -> bevy::utils::Uuid; + fn from_u64_pair( + high_bits: u64, + low_bits: u64, + ) -> LuaReflectValProxy; "#, r#" @@ -21468,7 +25089,7 @@ pub struct LuaNonZeroIsize(); /// ``` #[lua()] - fn from_bytes(bytes: [u8; 16]) -> bevy::utils::Uuid; + fn from_bytes(bytes: [u8; 16]) -> LuaReflectValProxy; "#, r#" @@ -21495,7 +25116,7 @@ pub struct LuaNonZeroIsize(); /// ``` #[lua()] - fn from_bytes_le(b: [u8; 16]) -> bevy::utils::Uuid; + fn from_bytes_le(b: [u8; 16]) -> LuaReflectValProxy; "#, r#" @@ -21505,7 +25126,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaUuid(); +pub struct Uuid(); #[derive(Default)] pub(crate) struct Globals; impl crate::tealr::mlu::ExportInstances for Globals { @@ -21786,86 +25407,86 @@ fn bevy_reflect_context_initializer( pub struct BevyReflectScriptingPlugin; impl bevy::app::Plugin for BevyReflectScriptingPlugin { fn build(&self, app: &mut bevy::prelude::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::(); - 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::(); - 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::(); - 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::(); - 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::(); - 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_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); app.add_context_initializer::<()>(bevy_reflect_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs index c9c2d9b3..e116c354 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs @@ -4,7 +4,16 @@ #![cfg_attr(rustfmt, rustfmt_skip)] use super::bevy_ecs::*; use super::bevy_reflect::*; -use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + IdentityProxy, + }, + RegisterLuaProxy, +}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::time::prelude::Fixed", @@ -13,7 +22,9 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::time::prelude::Fixed; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -23,7 +34,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaFixed {} +pub struct Fixed {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::time::prelude::Real", @@ -32,7 +43,9 @@ pub struct LuaFixed {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::time::prelude::Real; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -42,7 +55,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaReal {} +pub struct Real {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::time::prelude::Timer", @@ -51,20 +64,9 @@ pub struct LuaReal {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::time::prelude::Timer; - -"#, - r#" -/// Creates a new timer with a given duration. -/// See also [`Timer::from_seconds`](Timer::from_seconds). - - #[lua()] - fn new( - #[proxy] - duration: bevy::utils::Duration, - #[proxy] - mode: bevy::time::prelude::TimerMode, - ) -> bevy::time::prelude::Timer; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -78,9 +80,8 @@ pub struct LuaReal {} #[lua()] fn from_seconds( duration: f32, - #[proxy] - mode: bevy::time::prelude::TimerMode, - ) -> bevy::time::prelude::Timer; + mode: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -105,7 +106,7 @@ pub struct LuaReal {} /// ``` #[lua()] - fn finished(&self) -> bool; + fn finished(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -122,24 +123,7 @@ pub struct LuaReal {} /// ``` #[lua()] - fn just_finished(&self) -> bool; - -"#, - r#" -/// Returns the time elapsed on the timer. Guaranteed to be between 0.0 and `duration`. -/// Will only equal `duration` when the timer is finished and non repeating. -/// See also [`Stopwatch::elapsed`](Stopwatch::elapsed). -/// # Examples -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); -/// timer.tick(Duration::from_secs_f32(0.5)); -/// assert_eq!(timer.elapsed(), Duration::from_secs_f32(0.5)); -/// ``` - - #[lua()] - fn elapsed(&self) -> bevy::utils::Duration; + fn just_finished(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -147,54 +131,7 @@ pub struct LuaReal {} /// See also [`Timer::elapsed`](Timer::elapsed). #[lua()] - fn elapsed_secs(&self) -> f32; - -"#, - r#" -/// Sets the elapsed time of the timer without any other considerations. -/// See also [`Stopwatch::set`](Stopwatch::set). -/// # -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); -/// timer.set_elapsed(Duration::from_secs(2)); -/// assert_eq!(timer.elapsed(), Duration::from_secs(2)); -/// // the timer is not finished even if the elapsed time is greater than the duration. -/// assert!(!timer.finished()); -/// ``` - - #[lua()] - fn set_elapsed(&mut self, #[proxy] time: bevy::utils::Duration) -> (); - -"#, - r#" -/// Returns the duration of the timer. -/// # Examples -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let timer = Timer::new(Duration::from_secs(1), TimerMode::Once); -/// assert_eq!(timer.duration(), Duration::from_secs(1)); -/// ``` - - #[lua()] - fn duration(&self) -> bevy::utils::Duration; - -"#, - r#" -/// Sets the duration of the timer. -/// # Examples -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let mut timer = Timer::from_seconds(1.5, TimerMode::Once); -/// timer.set_duration(Duration::from_secs(1)); -/// assert_eq!(timer.duration(), Duration::from_secs(1)); -/// ``` - - #[lua()] - fn set_duration(&mut self, #[proxy] duration: bevy::utils::Duration) -> (); + fn elapsed_secs(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -207,7 +144,9 @@ pub struct LuaReal {} /// ``` #[lua()] - fn mode(&self) -> bevy::time::prelude::TimerMode; + fn mode( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -221,7 +160,10 @@ pub struct LuaReal {} /// ``` #[lua()] - fn set_mode(&mut self, #[proxy] mode: bevy::time::prelude::TimerMode) -> (); + fn set_mode( + _self: LuaReflectRefMutProxy, + mode: LuaReflectValProxy, + ) -> (); "#, r#" @@ -238,7 +180,7 @@ pub struct LuaReal {} /// ``` #[lua()] - fn pause(&mut self) -> (); + fn pause(_self: LuaReflectRefMutProxy) -> (); "#, r#" @@ -257,7 +199,7 @@ pub struct LuaReal {} /// ``` #[lua()] - fn unpause(&mut self) -> (); + fn unpause(_self: LuaReflectRefMutProxy) -> (); "#, r#" @@ -275,7 +217,7 @@ pub struct LuaReal {} /// ``` #[lua()] - fn paused(&self) -> bool; + fn paused(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -294,7 +236,7 @@ pub struct LuaReal {} /// ``` #[lua()] - fn reset(&mut self) -> (); + fn reset(_self: LuaReflectRefMutProxy) -> (); "#, r#" @@ -309,7 +251,7 @@ pub struct LuaReal {} /// ``` #[lua()] - fn fraction(&self) -> f32; + fn fraction(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -324,7 +266,7 @@ pub struct LuaReal {} /// ``` #[lua()] - fn fraction_remaining(&self) -> f32; + fn fraction_remaining(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -341,22 +283,7 @@ pub struct LuaReal {} /// ``` #[lua()] - fn remaining_secs(&self) -> f32; - -"#, - r#" -/// Returns the remaining time using Duration -/// # 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.remaining(), Duration::from_secs_f32(1.5)); -/// ``` - - #[lua()] - fn remaining(&self) -> bevy::utils::Duration; + fn remaining_secs(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -378,19 +305,29 @@ pub struct LuaReal {} /// ``` #[lua()] - fn times_finished_this_tick(&self) -> u32; + fn times_finished_this_tick( + _self: LuaReflectRefProxy, + ) -> u32; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &timer::Timer) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -400,7 +337,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaTimer {} +pub struct Timer {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::time::prelude::TimerMode", @@ -408,20 +345,30 @@ pub struct LuaTimer {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &timer::TimerMode) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::time::prelude::TimerMode; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -431,7 +378,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaTimerMode {} +pub struct TimerMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::time::prelude::Virtual", @@ -440,7 +387,9 @@ pub struct LuaTimerMode {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::time::prelude::Virtual; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -450,7 +399,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaVirtual {} +pub struct Virtual {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::time::Stopwatch", @@ -458,20 +407,27 @@ pub struct LuaVirtual {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &stopwatch::Stopwatch) -> bool; + #[lua(as_trait = "std::cmp::PartialEq::", composite = "eq")] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::time::Stopwatch; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -485,26 +441,7 @@ pub struct LuaVirtual {} /// ``` #[lua()] - fn new() -> bevy::time::Stopwatch; - -"#, - r#" -/// Returns the elapsed time since the last [`reset`](Stopwatch::reset) -/// of the stopwatch. -/// # Examples -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let mut stopwatch = Stopwatch::new(); -/// stopwatch.tick(Duration::from_secs(1)); -/// assert_eq!(stopwatch.elapsed(), Duration::from_secs(1)); -/// ``` -/// # See Also -/// [`elapsed_secs`](Stopwatch::elapsed_secs) - if an `f32` value is desirable instead. -/// [`elapsed_secs_f64`](Stopwatch::elapsed_secs_f64) - if an `f64` is desirable instead. - - #[lua()] - fn elapsed(&self) -> bevy::utils::Duration; + fn new() -> LuaReflectValProxy; "#, r#" @@ -523,7 +460,7 @@ pub struct LuaVirtual {} /// [`elapsed_secs_f64`](Stopwatch::elapsed_secs_f64) - if an `f64` is desirable instead. #[lua()] - fn elapsed_secs(&self) -> f32; + fn elapsed_secs(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -534,22 +471,7 @@ pub struct LuaVirtual {} /// [`elapsed_secs`](Stopwatch::elapsed_secs) - if an `f32` is desirable instead. #[lua()] - fn elapsed_secs_f64(&self) -> f64; - -"#, - r#" -/// Sets the elapsed time of the stopwatch. -/// # Examples -/// ``` -/// # use bevy_time::*; -/// use std::time::Duration; -/// let mut stopwatch = Stopwatch::new(); -/// stopwatch.set_elapsed(Duration::from_secs_f32(1.0)); -/// assert_eq!(stopwatch.elapsed_secs(), 1.0); -/// ``` - - #[lua()] - fn set_elapsed(&mut self, #[proxy] time: bevy::utils::Duration) -> (); + fn elapsed_secs_f64(_self: LuaReflectRefProxy) -> f64; "#, r#" @@ -567,7 +489,7 @@ pub struct LuaVirtual {} /// ``` #[lua()] - fn pause(&mut self) -> (); + fn pause(_self: LuaReflectRefMutProxy) -> (); "#, r#" @@ -586,7 +508,7 @@ pub struct LuaVirtual {} /// ``` #[lua()] - fn unpause(&mut self) -> (); + fn unpause(_self: LuaReflectRefMutProxy) -> (); "#, r#" @@ -603,7 +525,7 @@ pub struct LuaVirtual {} /// ``` #[lua()] - fn paused(&self) -> bool; + fn paused(_self: LuaReflectRefProxy) -> bool; "#, r#" @@ -619,7 +541,7 @@ pub struct LuaVirtual {} /// ``` #[lua()] - fn reset(&mut self) -> (); + fn reset(_self: LuaReflectRefMutProxy) -> (); "#, r#" @@ -629,7 +551,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaStopwatch {} +pub struct Stopwatch {} #[derive(Default)] pub(crate) struct Globals; impl crate::tealr::mlu::ExportInstances for Globals { @@ -657,12 +579,12 @@ fn bevy_time_context_initializer( pub struct BevyTimeScriptingPlugin; impl bevy::app::Plugin for BevyTimeScriptingPlugin { fn build(&self, app: &mut bevy::prelude::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_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); app.add_context_initializer::<()>(bevy_time_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs index 4afe85c0..31058e22 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs @@ -6,7 +6,16 @@ use super::bevy_ecs::*; use super::bevy_reflect::*; use super::bevy_core::*; use super::bevy_hierarchy::*; -use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + IdentityProxy, + }, + RegisterLuaProxy, +}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::transform::components::GlobalTransform", @@ -14,87 +23,58 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + )] fn mul( - self, - #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::GlobalTransform; + _self: LuaReflectValProxy, + transform: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::transform::components::GlobalTransform; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &components::global_transform::GlobalTransform) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua(as_trait = "std::ops::Mul", composite = "mul")] + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + )] fn mul( - self, - #[proxy] - global_transform: bevy::transform::components::GlobalTransform, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua()] - fn from_xyz(x: f32, y: f32, z: f32) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua()] - fn from_translation( - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua()] - fn from_rotation( - #[proxy] - rotation: bevy::math::Quat, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua()] - fn from_scale( - #[proxy] - scale: bevy::math::Vec3, - ) -> bevy::transform::components::GlobalTransform; + _self: LuaReflectValProxy, + global_transform: LuaReflectValProxy< + bevy::transform::components::GlobalTransform, + >, + ) -> LuaReflectValProxy; "#, r#" -/// Returns the 3d affine transformation matrix as a [`Mat4`]. #[lua()] - fn compute_matrix(&self) -> bevy::math::Mat4; - -"#, - r#" -/// Returns the 3d affine transformation matrix as an [`Affine3A`]. - - #[lua()] - fn affine(&self) -> bevy::math::Affine3A; + fn from_xyz( + x: f32, + y: f32, + z: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -103,7 +83,9 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; /// will be invalid. #[lua()] - fn compute_transform(&self) -> bevy::transform::components::Transform; + fn compute_transform( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -140,81 +122,9 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; #[lua()] fn reparented_to( - &self, - #[proxy] - parent: &components::global_transform::GlobalTransform, - ) -> bevy::transform::components::Transform; - -"#, - r#" -///Return the local right vector (X). - - #[lua()] - fn right(&self) -> bevy::math::Vec3; - -"#, - r#" -///Return the local left vector (-X). - - #[lua()] - fn left(&self) -> bevy::math::Vec3; - -"#, - r#" -///Return the local up vector (Y). - - #[lua()] - fn up(&self) -> bevy::math::Vec3; - -"#, - r#" -///Return the local down vector (-Y). - - #[lua()] - fn down(&self) -> bevy::math::Vec3; - -"#, - r#" -///Return the local back vector (Z). - - #[lua()] - fn back(&self) -> bevy::math::Vec3; - -"#, - r#" -///Return the local forward vector (-Z). - - #[lua()] - fn forward(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Get the translation as a [`Vec3`]. - - #[lua()] - fn translation(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Get the translation as a [`Vec3A`]. - - #[lua()] - fn translation_vec3a(&self) -> bevy::math::Vec3A; - -"#, - r#" -/// Get an upper bound of the radius from the given `extents`. - - #[lua()] - fn radius_vec3a(&self, #[proxy] extents: bevy::math::Vec3A) -> f32; - -"#, - r#" -/// Transforms the given `point`, applying shear, scale, rotation and translation. -/// This moves `point` into the local space of this [`GlobalTransform`]. - - #[lua()] - fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; + _self: LuaReflectRefProxy, + parent: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -223,10 +133,9 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; #[lua()] fn mul_transform( - &self, - #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::GlobalTransform; + _self: LuaReflectRefProxy, + transform: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -236,7 +145,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaGlobalTransform(); +pub struct GlobalTransform(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::transform::components::Transform", @@ -244,30 +153,34 @@ pub struct LuaGlobalTransform(); bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &components::transform::Transform) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + )] fn mul( - self, - #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::Transform; - -"#, - r#" - - #[lua(as_trait = "std::ops::Mul", composite = "mul")] - fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; + _self: LuaReflectValProxy, + transform: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::transform::components::Transform; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -276,155 +189,11 @@ pub struct LuaGlobalTransform(); /// `z`-value. #[lua()] - fn from_xyz(x: f32, y: f32, z: f32) -> bevy::transform::components::Transform; - -"#, - r#" -/// Extracts the translation, rotation, and scale from `matrix`. It must be a 3d affine -/// transformation matrix. - - #[lua()] - fn from_matrix( - #[proxy] - matrix: bevy::math::Mat4, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// Creates a new [`Transform`], with `translation`. Rotation will be 0 and scale 1 on -/// all axes. - - #[lua()] - fn from_translation( - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// Creates a new [`Transform`], with `rotation`. Translation will be 0 and scale 1 on -/// all axes. - - #[lua()] - fn from_rotation( - #[proxy] - rotation: bevy::math::Quat, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// Creates a new [`Transform`], with `scale`. Translation will be 0 and rotation 0 on -/// all axes. - - #[lua()] - fn from_scale( - #[proxy] - scale: bevy::math::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// 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 - - #[lua()] - fn looking_at( - self, - #[proxy] - target: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// 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 - - #[lua()] - fn looking_to( - self, - #[proxy] - direction: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// Returns this [`Transform`] with a new translation. - - #[lua()] - fn with_translation( - self, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// Returns this [`Transform`] with a new rotation. - - #[lua()] - fn with_rotation( - self, - #[proxy] - rotation: bevy::math::Quat, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// Returns this [`Transform`] with a new scale. - - #[lua()] - fn with_scale( - self, - #[proxy] - scale: bevy::math::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// Returns the 3d affine transformation matrix from this transforms translation, -/// rotation, and scale. - - #[lua()] - fn compute_matrix(&self) -> bevy::math::Mat4; - -"#, - r#" -/// Returns the 3d affine transformation matrix from this transforms translation, -/// rotation, and scale. - - #[lua()] - fn compute_affine(&self) -> bevy::math::Affine3A; - -"#, - r#" -/// 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 - - #[lua()] - fn rotate(&mut self, #[proxy] rotation: bevy::math::Quat) -> (); - -"#, - r#" -/// 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. - - #[lua()] - fn rotate_axis(&mut self, #[proxy] axis: bevy::math::Vec3, angle: f32) -> (); + fn from_xyz( + x: f32, + y: f32, + z: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -432,7 +201,10 @@ pub struct LuaGlobalTransform(); /// If this [`Transform`] has a parent, the axis is relative to the rotation of the parent. #[lua()] - fn rotate_x(&mut self, angle: f32) -> (); + fn rotate_x( + _self: LuaReflectRefMutProxy, + angle: f32, + ) -> (); "#, r#" @@ -440,7 +212,10 @@ pub struct LuaGlobalTransform(); /// If this [`Transform`] has a parent, the axis is relative to the rotation of the parent. #[lua()] - fn rotate_y(&mut self, angle: f32) -> (); + fn rotate_y( + _self: LuaReflectRefMutProxy, + angle: f32, + ) -> (); "#, r#" @@ -448,106 +223,39 @@ pub struct LuaGlobalTransform(); /// 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`. -/// The `rotation` is relative to this [`Transform`]'s current rotation. - - #[lua()] - fn rotate_local(&mut self, #[proxy] rotation: bevy::math::Quat) -> (); - -"#, - r#" -/// Rotates this [`Transform`] around its local `axis` by `angle` (in radians). - - #[lua()] - fn rotate_local_axis(&mut self, #[proxy] axis: bevy::math::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. -/// 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::Vec3, - #[proxy] - rotation: bevy::math::Quat, + fn rotate_z( + _self: LuaReflectRefMutProxy, + angle: f32, ) -> (); "#, r#" -/// Rotates this [`Transform`] around a `point` in space. -/// If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent. +/// Rotates this [`Transform`] around its local `X` axis by `angle` (in radians). #[lua()] - fn rotate_around( - &mut self, - #[proxy] - point: bevy::math::Vec3, - #[proxy] - rotation: bevy::math::Quat, + fn rotate_local_x( + _self: LuaReflectRefMutProxy, + angle: f32, ) -> (); "#, r#" -/// 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 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 +/// Rotates this [`Transform`] around its local `Y` axis by `angle` (in radians). #[lua()] - fn look_at( - &mut self, - #[proxy] - target: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, + fn rotate_local_y( + _self: LuaReflectRefMutProxy, + angle: f32, ) -> (); "#, r#" -/// 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 +/// Rotates this [`Transform`] around its local `Z` axis by `angle` (in radians). #[lua()] - fn look_to( - &mut self, - #[proxy] - direction: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, + fn rotate_local_z( + _self: LuaReflectRefMutProxy, + angle: f32, ) -> (); "#, @@ -557,23 +265,9 @@ pub struct LuaGlobalTransform(); #[lua()] fn mul_transform( - &self, - #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// 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. - - #[lua()] - fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; + _self: LuaReflectRefProxy, + transform: LuaReflectValProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -582,17 +276,23 @@ pub struct LuaGlobalTransform(); /// this will return `false`. #[lua()] - fn is_finite(&self) -> bool; + fn is_finite( + _self: LuaReflectRefProxy, + ) -> bool; "#, r#" - #[lua(as_trait = "std::ops::Mul", composite = "mul")] + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + )] fn mul( - self, - #[proxy] - global_transform: bevy::transform::components::GlobalTransform, - ) -> bevy::transform::components::GlobalTransform; + _self: LuaReflectValProxy, + global_transform: LuaReflectValProxy< + bevy::transform::components::GlobalTransform, + >, + ) -> LuaReflectValProxy; "#, r#" @@ -602,13 +302,10 @@ fn index(&self) -> String { } "#] )] -pub struct LuaTransform { - #[lua(output(proxy))] - translation: bevy::math::Vec3, - #[lua(output(proxy))] - rotation: bevy::math::Quat, - #[lua(output(proxy))] - scale: bevy::math::Vec3, +pub struct Transform { + translation: ReflectReference, + rotation: ReflectReference, + scale: ReflectReference, } #[derive(Default)] pub(crate) struct Globals; @@ -640,8 +337,8 @@ fn bevy_transform_context_initializer( pub struct BevyTransformScriptingPlugin; impl bevy::app::Plugin for BevyTransformScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); + app.register_proxy::(); + app.register_proxy::(); app.add_context_initializer::<()>(bevy_transform_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs index e5311572..43fcc016 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs @@ -5,7 +5,16 @@ use super::bevy_ecs::*; use super::bevy_reflect::*; use super::bevy_input::*; -use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + IdentityProxy, + }, + RegisterLuaProxy, +}; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::CursorEntered", @@ -14,19 +23,29 @@ use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation}; functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::CursorEntered) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::prelude::CursorEntered; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -36,9 +55,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCursorEntered { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, +pub struct CursorEntered { + window: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -48,19 +66,29 @@ pub struct LuaCursorEntered { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &cursor::CursorIcon) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::prelude::CursorIcon; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -70,7 +98,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCursorIcon {} +pub struct CursorIcon {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::CursorLeft", @@ -79,19 +107,29 @@ pub struct LuaCursorIcon {} functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::CursorLeft) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::prelude::CursorLeft; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -101,9 +139,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCursorLeft { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, +pub struct CursorLeft { + window: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -112,14 +149,22 @@ pub struct LuaCursorLeft { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::CursorMoved) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::prelude::CursorMoved; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -129,12 +174,10 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCursorMoved { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] - position: bevy::math::Vec2, - delta: ReflectedValue, +pub struct CursorMoved { + window: ReflectReference, + position: ReflectReference, + delta: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -144,19 +187,29 @@ pub struct LuaCursorMoved { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::prelude::FileDragAndDrop; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::FileDragAndDrop) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -166,7 +219,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaFileDragAndDrop {} +pub struct FileDragAndDrop {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::Ime", @@ -175,19 +228,29 @@ pub struct LuaFileDragAndDrop {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::prelude::Ime; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::Ime) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -197,7 +260,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaIme {} +pub struct Ime {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::MonitorSelection", @@ -205,20 +268,30 @@ pub struct LuaIme {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::MonitorSelection) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::prelude::MonitorSelection; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -228,7 +301,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaMonitorSelection {} +pub struct MonitorSelection {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::ReceivedCharacter", @@ -237,19 +310,29 @@ pub struct LuaMonitorSelection {} functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::prelude::ReceivedCharacter; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::ReceivedCharacter) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -259,11 +342,9 @@ fn index(&self) -> String { } "#] )] -pub struct LuaReceivedCharacter { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] - char: smol_str::SmolStr, +pub struct ReceivedCharacter { + window: ReflectReference, + char: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -273,7 +354,9 @@ pub struct LuaReceivedCharacter { functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::prelude::Window; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -281,7 +364,10 @@ pub struct LuaReceivedCharacter { /// Setting to false will attempt to un-maximize the window. #[lua()] - fn set_maximized(&mut self, maximized: bool) -> (); + fn set_maximized( + _self: LuaReflectRefMutProxy, + maximized: bool, + ) -> (); "#, r#" @@ -289,7 +375,10 @@ pub struct LuaReceivedCharacter { /// Setting to false will attempt to un-minimize the window. #[lua()] - fn set_minimized(&mut self, minimized: bool) -> (); + fn set_minimized( + _self: LuaReflectRefMutProxy, + minimized: bool, + ) -> (); "#, r#" @@ -297,7 +386,7 @@ pub struct LuaReceivedCharacter { /// See [`WindowResolution`] for an explanation about logical/physical sizes. #[lua()] - fn width(&self) -> f32; + fn width(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -305,7 +394,7 @@ pub struct LuaReceivedCharacter { /// See [`WindowResolution`] for an explanation about logical/physical sizes. #[lua()] - fn height(&self) -> f32; + fn height(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -313,7 +402,7 @@ pub struct LuaReceivedCharacter { /// See [`WindowResolution`] for an explanation about logical/physical sizes. #[lua()] - fn physical_width(&self) -> u32; + fn physical_width(_self: LuaReflectRefProxy) -> u32; "#, r#" @@ -321,7 +410,7 @@ pub struct LuaReceivedCharacter { /// See [`WindowResolution`] for an explanation about logical/physical sizes. #[lua()] - fn physical_height(&self) -> u32; + fn physical_height(_self: LuaReflectRefProxy) -> u32; "#, r#" @@ -329,7 +418,7 @@ pub struct LuaReceivedCharacter { /// Ratio of physical size to logical size, see [`WindowResolution`]. #[lua()] - fn scale_factor(&self) -> f32; + fn scale_factor(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -339,39 +428,28 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindow { - #[lua(output(proxy))] +pub struct Window { cursor: bevy::window::Cursor, - #[lua(output(proxy))] present_mode: bevy::window::PresentMode, - #[lua(output(proxy))] mode: bevy::window::WindowMode, - #[lua(output(proxy))] position: bevy::window::prelude::WindowPosition, - #[lua(output(proxy))] resolution: bevy::window::WindowResolution, title: std::string::String, name: std::option::Option, - #[lua(output(proxy))] composite_alpha_mode: bevy::window::CompositeAlphaMode, - #[lua(output(proxy))] resize_constraints: bevy::window::prelude::WindowResizeConstraints, resizable: bool, - #[lua(output(proxy))] enabled_buttons: bevy::window::EnabledButtons, decorations: bool, transparent: bool, focused: bool, - #[lua(output(proxy))] window_level: bevy::window::WindowLevel, canvas: std::option::Option, prevent_default_event_handling: bool, - #[lua(output(proxy))] internal: bevy::window::InternalWindowState, ime_enabled: bool, - #[lua(output(proxy))] - ime_position: bevy::math::Vec2, - window_theme: ReflectedValue, + ime_position: ReflectReference, + window_theme: ReflectReference, visible: bool, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -381,20 +459,30 @@ pub struct LuaWindow { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::WindowMoved) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::prelude::WindowMoved; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -404,11 +492,9 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowMoved { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] - position: bevy::math::IVec2, +pub struct WindowMoved { + window: ReflectReference, + position: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -418,24 +504,9 @@ pub struct LuaWindowMoved { functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::prelude::WindowPosition; - -"#, - r#" -/// Creates a new [`WindowPosition`] at a position. - - #[lua()] - fn new( - #[proxy] - position: bevy::math::IVec2, - ) -> bevy::window::prelude::WindowPosition; - -"#, - r#" -/// Set the position to a specific point. - - #[lua()] - fn set(&mut self, #[proxy] position: bevy::math::IVec2) -> (); + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -443,16 +514,21 @@ pub struct LuaWindowMoved { #[lua()] fn center( - &mut self, - #[proxy] - monitor: bevy::window::prelude::MonitorSelection, + _self: LuaReflectRefMutProxy, + monitor: LuaReflectValProxy, ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::WindowPosition) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -462,7 +538,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowPosition {} +pub struct WindowPosition {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::prelude::WindowResizeConstraints", @@ -473,19 +549,29 @@ pub struct LuaWindowPosition {} /// Will output warnings if it isn't. #[lua()] - fn check_constraints(&self) -> bevy::window::prelude::WindowResizeConstraints; + fn check_constraints( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::WindowResizeConstraints) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::prelude::WindowResizeConstraints; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -495,7 +581,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowResizeConstraints { +pub struct WindowResizeConstraints { min_width: f32, min_height: f32, max_width: f32, @@ -508,14 +594,22 @@ pub struct LuaWindowResizeConstraints { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::WindowResized) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowResized; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -525,9 +619,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowResized { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, +pub struct WindowResized { + window: ReflectReference, width: f32, height: f32, } @@ -539,19 +632,29 @@ pub struct LuaWindowResized { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::WindowCreated) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowCreated; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -561,9 +664,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowCreated { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, +pub struct WindowCreated { + window: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -573,19 +675,29 @@ pub struct LuaWindowCreated { functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowClosed; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::WindowClosed) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -595,9 +707,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowClosed { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, +pub struct WindowClosed { + window: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -607,19 +718,29 @@ pub struct LuaWindowClosed { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowCloseRequested; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::WindowCloseRequested) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -629,9 +750,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowCloseRequested { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, +pub struct WindowCloseRequested { + window: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -640,20 +760,30 @@ pub struct LuaWindowCloseRequested { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::WindowDestroyed) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowDestroyed; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -663,9 +793,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowDestroyed { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, +pub struct WindowDestroyed { + window: ReflectReference, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -674,20 +803,30 @@ pub struct LuaWindowDestroyed { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::RequestRedraw) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::RequestRedraw; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -697,7 +836,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaRequestRedraw {} +pub struct RequestRedraw {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowFocused", @@ -705,20 +844,30 @@ pub struct LuaRequestRedraw {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::WindowFocused) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowFocused; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -728,9 +877,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowFocused { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, +pub struct WindowFocused { + window: ReflectReference, focused: bool, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -741,19 +889,29 @@ pub struct LuaWindowFocused { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::WindowOccluded) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowOccluded; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -763,9 +921,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowOccluded { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, +pub struct WindowOccluded { + window: ReflectReference, occluded: bool, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -776,13 +933,21 @@ pub struct LuaWindowOccluded { functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowScaleFactorChanged; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::WindowScaleFactorChanged) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -792,9 +957,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowScaleFactorChanged { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, +pub struct WindowScaleFactorChanged { + window: ReflectReference, scale_factor: f64, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -805,13 +969,21 @@ pub struct LuaWindowScaleFactorChanged { functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowBackendScaleFactorChanged; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::WindowBackendScaleFactorChanged) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -821,9 +993,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowBackendScaleFactorChanged { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, +pub struct WindowBackendScaleFactorChanged { + window: ReflectReference, scale_factor: f64, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -834,19 +1005,29 @@ pub struct LuaWindowBackendScaleFactorChanged { functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowThemeChanged; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::WindowThemeChanged) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -856,10 +1037,8 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowThemeChanged { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] +pub struct WindowThemeChanged { + window: ReflectReference, theme: bevy::window::WindowTheme, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -870,19 +1049,29 @@ pub struct LuaWindowThemeChanged { functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::ApplicationLifetime; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &event::ApplicationLifetime) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -892,7 +1081,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaApplicationLifetime {} +pub struct ApplicationLifetime {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::PrimaryWindow", @@ -901,19 +1090,29 @@ pub struct LuaApplicationLifetime {} functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::PrimaryWindow; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::PrimaryWindow) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -923,7 +1122,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaPrimaryWindow {} +pub struct PrimaryWindow {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::Cursor", @@ -932,7 +1131,9 @@ pub struct LuaPrimaryWindow {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::Cursor; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -942,11 +1143,9 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCursor { - #[lua(output(proxy))] +pub struct Cursor { icon: bevy::window::prelude::CursorIcon, visible: bool, - #[lua(output(proxy))] grab_mode: bevy::window::CursorGrabMode, hit_test: bool, } @@ -957,20 +1156,30 @@ pub struct LuaCursor { bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::CursorGrabMode) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::CursorGrabMode; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -980,7 +1189,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCursorGrabMode {} +pub struct CursorGrabMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::CompositeAlphaMode", @@ -989,19 +1198,29 @@ pub struct LuaCursorGrabMode {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::CompositeAlphaMode; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::CompositeAlphaMode) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -1011,7 +1230,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaCompositeAlphaMode {} +pub struct CompositeAlphaMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowResolution", @@ -1019,21 +1238,32 @@ pub struct LuaCompositeAlphaMode {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::WindowResolution) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowResolution; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" /// Creates a new [`WindowResolution`]. #[lua()] - fn new(logical_width: f32, logical_height: f32) -> bevy::window::WindowResolution; + fn new( + logical_width: f32, + logical_height: f32, + ) -> LuaReflectValProxy; "#, r#" @@ -1041,37 +1271,37 @@ pub struct LuaCompositeAlphaMode {} #[lua()] fn with_scale_factor_override( - self, + _self: LuaReflectValProxy, scale_factor_override: f32, - ) -> bevy::window::WindowResolution; + ) -> LuaReflectValProxy; "#, r#" /// The window's client area width in logical pixels. #[lua()] - fn width(&self) -> f32; + fn width(_self: LuaReflectRefProxy) -> f32; "#, r#" /// The window's client area height in logical pixels. #[lua()] - fn height(&self) -> f32; + fn height(_self: LuaReflectRefProxy) -> f32; "#, r#" /// The window's client area width in physical pixels. #[lua()] - fn physical_width(&self) -> u32; + fn physical_width(_self: LuaReflectRefProxy) -> u32; "#, r#" /// The window's client area height in physical pixels. #[lua()] - fn physical_height(&self) -> u32; + fn physical_height(_self: LuaReflectRefProxy) -> u32; "#, r#" @@ -1079,7 +1309,7 @@ pub struct LuaCompositeAlphaMode {} /// `physical_pixels = logical_pixels * scale_factor` #[lua()] - fn scale_factor(&self) -> f32; + fn scale_factor(_self: LuaReflectRefProxy) -> f32; "#, r#" @@ -1087,7 +1317,9 @@ pub struct LuaCompositeAlphaMode {} /// This value is unaffected by [`WindowResolution::scale_factor_override`]. #[lua()] - fn base_scale_factor(&self) -> f32; + fn base_scale_factor( + _self: LuaReflectRefProxy, + ) -> f32; "#, r#" @@ -1095,14 +1327,20 @@ pub struct LuaCompositeAlphaMode {} /// This value may be different from the scale factor reported by the window backend. #[lua()] - fn scale_factor_override(&self) -> std::option::Option; + fn scale_factor_override( + _self: LuaReflectRefProxy, + ) -> std::option::Option; "#, r#" /// Set the window's logical resolution. #[lua()] - fn set(&mut self, width: f32, height: f32) -> (); + fn set( + _self: LuaReflectRefMutProxy, + width: f32, + height: f32, + ) -> (); "#, r#" @@ -1111,14 +1349,21 @@ pub struct LuaCompositeAlphaMode {} /// prefer to use [`WindowResolution::set`]. #[lua()] - fn set_physical_resolution(&mut self, width: u32, height: u32) -> (); + fn set_physical_resolution( + _self: LuaReflectRefMutProxy, + width: u32, + height: u32, + ) -> (); "#, r#" /// Set the window's scale factor, this may get overridden by the backend. #[lua()] - fn set_scale_factor(&mut self, scale_factor: f32) -> (); + fn set_scale_factor( + _self: LuaReflectRefMutProxy, + scale_factor: f32, + ) -> (); "#, r#" @@ -1128,7 +1373,7 @@ pub struct LuaCompositeAlphaMode {} #[lua()] fn set_scale_factor_override( - &mut self, + _self: LuaReflectRefMutProxy, scale_factor_override: std::option::Option, ) -> (); @@ -1140,7 +1385,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowResolution {} +pub struct WindowResolution {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowMode", @@ -1148,20 +1393,30 @@ pub struct LuaWindowResolution {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::WindowMode) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowMode; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -1171,7 +1426,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowMode {} +pub struct WindowMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowLevel", @@ -1179,20 +1434,30 @@ pub struct LuaWindowMode {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::WindowLevel) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowLevel; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" @@ -1202,7 +1467,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowLevel {} +pub struct WindowLevel {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::PresentMode", @@ -1210,20 +1475,30 @@ pub struct LuaWindowLevel {} bms_lua_path = "crate", functions[r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::PresentMode) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::PresentMode; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1233,7 +1508,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaPresentMode {} +pub struct PresentMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::InternalWindowState", @@ -1242,27 +1517,39 @@ pub struct LuaPresentMode {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::InternalWindowState; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::InternalWindowState) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" /// Consumes the current maximize request, if it exists. This should only be called by window backends. #[lua()] - fn take_maximize_request(&mut self) -> std::option::Option; + fn take_maximize_request( + _self: LuaReflectRefMutProxy, + ) -> std::option::Option; "#, r#" /// Consumes the current minimize request, if it exists. This should only be called by window backends. #[lua()] - fn take_minimize_request(&mut self) -> std::option::Option; + fn take_minimize_request( + _self: LuaReflectRefMutProxy, + ) -> std::option::Option; "#, r#" @@ -1272,7 +1559,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaInternalWindowState {} +pub struct InternalWindowState {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::WindowTheme", @@ -1281,19 +1568,29 @@ pub struct LuaInternalWindowState {} functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowTheme; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::WindowTheme) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -1303,7 +1600,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowTheme {} +pub struct WindowTheme {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::EnabledButtons", @@ -1312,13 +1609,21 @@ pub struct LuaWindowTheme {} functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::EnabledButtons; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::EnabledButtons) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -1328,7 +1633,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaEnabledButtons { +pub struct EnabledButtons { minimize: bool, maximize: bool, close: bool, @@ -1341,7 +1646,9 @@ pub struct LuaEnabledButtons { functions[r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::WindowRef; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" @@ -1351,7 +1658,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaWindowRef {} +pub struct WindowRef {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( remote = "bevy::window::NormalizedWindowRef", @@ -1360,26 +1667,29 @@ pub struct LuaWindowRef {} functions[r#" #[lua(as_trait = "std::cmp::Eq")] - fn assert_receiver_is_total_eq(&self) -> (); + fn assert_receiver_is_total_eq( + _self: LuaReflectRefProxy, + ) -> (); "#, r#" #[lua(as_trait = "std::clone::Clone")] - fn clone(&self) -> bevy::window::NormalizedWindowRef; + fn clone( + _self: LuaReflectRefProxy, + ) -> LuaReflectValProxy; "#, r#" -/// Fetch the entity of this window reference - #[lua()] - fn entity(&self) -> bevy::ecs::entity::Entity; - -"#, - r#" - - #[lua(as_trait = "std::cmp::PartialEq", composite = "eq")] - fn eq(&self, #[proxy] other: &window::NormalizedWindowRef) -> bool; + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + )] + fn eq( + _self: LuaReflectRefProxy, + other: LuaReflectRefProxy, + ) -> bool; "#, r#" @@ -1389,7 +1699,7 @@ fn index(&self) -> String { } "#] )] -pub struct LuaNormalizedWindowRef(); +pub struct NormalizedWindowRef(); #[derive(Default)] pub(crate) struct Globals; impl crate::tealr::mlu::ExportInstances for Globals { @@ -1397,11 +1707,6 @@ impl crate::tealr::mlu::ExportInstances for Globals { self, instances: &mut T, ) -> crate::tealr::mlu::mlua::Result<()> { - instances - .add_instance( - "WindowPosition", - crate::tealr::mlu::UserDataProxy::::new, - )?; instances .add_instance( "WindowResolution", @@ -1420,45 +1725,43 @@ fn bevy_window_context_initializer( pub struct BevyWindowScriptingPlugin; impl bevy::app::Plugin for BevyWindowScriptingPlugin { fn build(&self, app: &mut bevy::prelude::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::< - bevy::window::prelude::WindowResizeConstraints, - >(); - 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::(); - 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_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); + app.register_proxy::(); app.add_context_initializer::<()>(bevy_window_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( @@ -1477,9 +1780,6 @@ impl bevy::app::Plugin for BevyWindowScriptingPlugin { .process_type::() .process_type::() .process_type::() - .process_type::< - crate::tealr::mlu::UserDataProxy, - >() .process_type::() .process_type::() .process_type::() diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs index 29c34dd2..e5c805fa 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs @@ -6,7 +6,7 @@ use bevy_mod_scripting_core::{ allocator::ReflectAllocator, bindings::{ReflectReference, WorldAccessGuard, WorldAccessUnit, WorldAccessWrite}, error::ReflectionError, - proxy::{ReflectRefMutProxy, ReflectRefProxy, ReflectValProxy, Unproxy, ValProxy}, + proxy::{Proxy, ReflectRefMutProxy, ReflectRefProxy, ReflectValProxy, Unproxy, ValProxy}, }; use tealr::{ mlu::mlua::{Error, FromLua, IntoLua, Lua, Value}, @@ -18,21 +18,61 @@ pub trait LuaProxied { type Proxy; } +/// Convenience for proxying a type into lua via itself without implementing [`Proxy`] on it. +/// Converts to Lua via T's implementation of IntoLua directly +pub struct IdentityProxy(pub Option); + +impl Proxy for IdentityProxy { + type Input<'i> = T; + fn proxy<'i>(value: Self::Input<'i>) -> Result { + Ok(Self(Some(value))) + } +} + +impl Unproxy for IdentityProxy { + type Output<'o> = T where + Self: 'o; + + fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { + Ok(self + .0 + .take() + .expect("IdentityProxy was already unproxied before")) + } +} + +impl ToTypename for IdentityProxy { + fn to_typename() -> tealr::Type { + T::to_typename() + } +} + +impl<'a, T: IntoLua<'a>> IntoLua<'a> for IdentityProxy { + fn into_lua(self, lua: &'a Lua) -> tealr::mlu::mlua::prelude::LuaResult> { + self.0.into_lua(lua) + } +} + +impl<'a, T: FromLua<'a>> FromLua<'a> for IdentityProxy { + fn from_lua(value: Value<'a>, lua: &'a Lua) -> Result { + Ok(Self(Some(T::from_lua(value, lua)?))) + } +} + pub struct LuaValProxy(pub ValProxy); pub struct LuaReflectValProxy(pub ReflectValProxy); pub struct LuaReflectRefProxy(pub ReflectRefProxy); pub struct LuaReflectRefMutProxy(pub ReflectRefMutProxy); macro_rules! impl_lua_unproxy { - ($ty:ident as $as:ident => $generic:tt : $($bounds:path),* $(| T::Proxy: $($proxy_bounds:tt)*)?) => { - impl<'w, 'c, $generic:'c> Unproxy<'w, 'c> for $ty<$generic> + ($ty:ident as $as:ident ($generic:tt) $($bound_var:path : ($($bounds:tt)+),)*) => { + impl <$generic> Unproxy for $ty<$generic> where - T::Proxy: $($($proxy_bounds)*)?, - T: $($bounds+)*, + $($bound_var : $($bounds)+),* { - type Output = <$as<$generic,$generic::Proxy> as Unproxy<'w, 'c>>::Output; + type Output<'b> = <$as<$generic,$generic::Proxy> as Unproxy>::Output<'b> where Self: 'b; - fn collect_accesses( + fn collect_accesses<'w>( &self, guard: &WorldAccessGuard<'w>, accesses: &mut bevy::utils::smallvec::SmallVec<[WorldAccessWrite<'w>; 1]>, @@ -40,17 +80,17 @@ macro_rules! impl_lua_unproxy { self.0.collect_accesses(guard, accesses) } - fn unproxy(&'c mut self) -> Result { + fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { self.0.unproxy() } - unsafe fn unproxy_with_world( - &'c mut self, + unsafe fn unproxy_with_world<'w,'o>( + &'o mut self, guard: &WorldAccessGuard<'w>, - accesses: &'c [WorldAccessUnit<'w>], + accesses: &'o [WorldAccessUnit<'w>], type_registry: &TypeRegistry, - allocator: &'c ReflectAllocator, - ) -> Result { + allocator: &'o ReflectAllocator, + ) -> Result, ReflectionError> { self.0 .unproxy_with_world(guard, accesses, type_registry, allocator) } @@ -90,13 +130,13 @@ macro_rules! impl_lua_unproxy { macro_rules! impl_lua_proxy { ($ty:ident as $as:ident => $generic:tt : $($bounds:path),* $(| T::Proxy: $($proxy_bounds:tt)*)?) => { - impl<'a,$generic> bevy_mod_scripting_core::proxy::Proxy<'a> for $ty<$generic> + impl<$generic> bevy_mod_scripting_core::proxy::Proxy for $ty<$generic> where T::Proxy: $($($proxy_bounds)*)?, T: $($bounds+)*, { - type Input=<$as<$generic, $generic::Proxy> as bevy_mod_scripting_core::proxy::Proxy<'a>>::Input; - fn proxy(value: Self::Input) -> Result { + type Input<'i>=<$as<$generic, $generic::Proxy> as bevy_mod_scripting_core::proxy::Proxy>::Input<'i>; + fn proxy<'i>(value: Self::Input<'i>) -> Result { Ok(Self($as::<$generic,$generic::Proxy>::proxy(value)?)) } } @@ -108,10 +148,25 @@ macro_rules! impl_lua_proxy { impl_lua_proxy!(LuaValProxy as ValProxy => T : LuaProxied | T::Proxy: From); impl_lua_proxy!(LuaReflectValProxy as ReflectValProxy => T : LuaProxied,Reflect | T::Proxy: From ); -impl_lua_unproxy!(LuaValProxy as ValProxy => T : LuaProxied,From<&'c T::Proxy>); -impl_lua_unproxy!(LuaReflectValProxy as ReflectValProxy => T : LuaProxied,FromReflect | T::Proxy: AsRef); -impl_lua_unproxy!(LuaReflectRefProxy as ReflectRefProxy => T : LuaProxied,Reflect | T::Proxy: AsRef); -impl_lua_unproxy!(LuaReflectRefMutProxy as ReflectRefMutProxy => T: LuaProxied,Reflect | T::Proxy: AsRef); +impl_lua_unproxy!(LuaValProxy as ValProxy (T) + T: (LuaProxied), + T: (for <'l> From<&'l T::Proxy>), +); +impl_lua_unproxy!(LuaReflectValProxy as ReflectValProxy (T) + T: (FromReflect), + T: (LuaProxied), + T::Proxy: (AsRef), +); +impl_lua_unproxy!(LuaReflectRefProxy as ReflectRefProxy (T) + T: (LuaProxied), + T: (Reflect), + T::Proxy: (AsRef), +); +impl_lua_unproxy!(LuaReflectRefMutProxy as ReflectRefMutProxy (T) + T: (LuaProxied), + T: (Reflect), + T::Proxy: (AsRef), +); #[cfg(test)] mod test { @@ -123,10 +178,7 @@ mod test { allocator::ReflectAllocation, bindings::{ReflectBase, ReflectBaseType, ReflectReference}, }; - use tealr::{ - mlu::mlua::{UserData, UserDataMethods}, - Name, - }; + use tealr::mlu::mlua::{UserData, UserDataMethods}; use super::*; diff --git a/crates/languages/bevy_mod_scripting_lua/src/lib.rs b/crates/languages/bevy_mod_scripting_lua/src/lib.rs index 685aa9a0..7ae3205d 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/lib.rs @@ -2,11 +2,12 @@ pub mod assets; pub mod docs; pub mod util; use bevy::{ - app::Plugin, + app::{App, Plugin}, ecs::{entity::Entity, world::World}, + reflect::{FromType, Reflect, TypePath}, }; use bevy_mod_scripting_core::{ - bindings::WorldCallbackAccess, + bindings::{ReflectReference, WorldCallbackAccess}, context::{ContextBuilder, ContextInitializer, ContextPreHandlingInitializer}, error::ScriptError, event::CallbackLabel, @@ -14,10 +15,10 @@ use bevy_mod_scripting_core::{ script::ScriptId, ScriptingPlugin, }; -use bindings::world::LuaWorld; +use bindings::{proxy::LuaProxied, world::LuaWorld}; pub use tealr; pub mod bindings; -use tealr::mlu::mlua::{Function, IntoLuaMulti, Lua}; +use tealr::mlu::mlua::{FromLua, Function, IntoLua, IntoLuaMulti, Lua, Value}; pub mod prelude { pub use crate::tealr::{ @@ -146,3 +147,42 @@ pub fn with_world Result<(), ScriptError>>( f(context) }) } + +/// Registers a lua proxy object via the reflection system +pub trait RegisterLuaProxy { + fn register_proxy(&mut self) -> &mut Self + where + T::Proxy: for<'l> IntoLua<'l> + for<'l> FromLua<'l>, + T::Proxy: From + AsRef; +} + +impl RegisterLuaProxy for App { + fn register_proxy(&mut self) -> &mut Self + where + T::Proxy: for<'l> IntoLua<'l> + for<'l> FromLua<'l>, + T::Proxy: From + AsRef, + { + self.register_type_data::() + } +} + +#[derive(Clone)] +pub struct ReflectLuaProxied { + pub into_proxy: + for<'l> fn(ReflectReference, &'l Lua) -> Result, tealr::mlu::mlua::Error>, + pub from_proxy: + for<'l> fn(Value<'l>, &'l Lua) -> Result, +} + +impl FromType for ReflectLuaProxied +where + T::Proxy: for<'l> IntoLua<'l> + for<'l> FromLua<'l>, + T::Proxy: From + AsRef, +{ + fn from_type() -> Self { + Self { + into_proxy: |p, l| T::Proxy::from(p).into_lua(l), + from_proxy: |v, l| T::Proxy::from_lua(v, l).map(|p| p.as_ref().clone()), + } + } +} diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs index dc2d9c1a..598f5ca3 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -117,8 +117,12 @@ struct FunctionAttrs { /// If passed will generate a metamethod call instead of using the function name pub metamethod: Option, + /// If true will pass in the context as the last argument, + /// i.e. will remove that argument from the function signature and use it's name as the context alias + pub with_context: Flag, - pub raw: Flag + /// Skips the unproxying & proxying call, useful for functions that don't need to access the world + pub no_proxy: Flag } #[proc_macro_derive(LuaProxy, attributes(lua, proxy))] @@ -173,9 +177,20 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { // collect all args into tuple and add lua context arg let ctxt_alias = syn::Ident::new(CTXT_ALIAS, f.sig.inputs.span()); - let ctxt_arg = parse_quote_spanned! {f.span()=> - #ctxt_alias: &#mlua::Lua + + let attrs = FunctionAttrs::from_attributes(&f.attrs).unwrap(); + + let ctxt_arg = if attrs.with_context.is_present() { + f.sig.inputs.pop().expect("Expected at least one argument for the context").into_value() + } else { + parse_quote_spanned! {f.span()=> + #ctxt_alias: &#mlua::Lua + } }; + let ctxt_arg_ident = match &ctxt_arg { + FnArg::Typed(arg) => arg.pat.clone(), + _ => panic!("Expected a typed argument, not a receiver"), + }; let func_name = &f.sig.ident; let (original_arg_idents, original_arg_types) = f @@ -191,7 +206,6 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { }) .unzip::<_, _, Vec<_>, Vec<_>>(); - let attrs = FunctionAttrs::from_attributes(&f.attrs).unwrap(); let span = f.span(); let args_ident = format_ident!("args", span = f.sig.inputs.span()); f.sig.inputs = Punctuated::from_iter(vec![ @@ -208,7 +222,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { // wrap function body in our unwrapping and wrapping logic, ignore pre-existing body - let fn_call = match (f.default, attrs.as_trait) { + let mut fn_call = match (f.default, attrs.as_trait) { (Some(body), _) => quote_spanned!(span=> (||{ #body })() ), @@ -222,38 +236,35 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { ) } }; - f.default = Some(parse_quote_spanned! {span=> - { - let mut world: #bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> = lua.globals().get("world")?; - let mut world = <#bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> as #bms_core::proxy::Unproxy>::unproxy(&mut world).map_err(#mlua::Error::external)?; - let mut world = world.read().ok_or_else(|| #mlua::Error::external("World no longer exists"))?; - - // get allocator and type registry - - let cell = world.as_unsafe_world_cell(); - let allocator_resource_id = cell.components().resource_id::<#bms_core::allocator::ReflectAllocator>().expect("Reflect Allocator wasn't initialized"); - let type_registry_resource_id = cell.components().resource_id::().expect("Type Registry wasn't initialized"); - - let mut allocator_access = world.get_access(allocator_resource_id.into()).expect("Deadlock while accessing allocator"); - let type_registry_access = world.get_access(type_registry_resource_id.into()).expect("Deadlock while accessing type registry"); - - let mut allocator = world.get_resource_mut::<#bms_core::allocator::ReflectAllocator>(&mut allocator_access).unwrap().unwrap(); - let type_registry = world.get_resource::(&type_registry_access).unwrap().unwrap(); - let type_registry = type_registry.read(); - let mut world_acceses = Vec::default(); - // Safety: we pinky promise not to touch world_accessses after this point - let (#( #original_arg_idents ),*) = unsafe { <(#(#original_arg_types),*) as #bms_core::proxy::Unproxy>::unproxy_with_world(&mut #args_ident, &world, &mut world_acceses, &type_registry, &allocator).map_err(#mlua::Error::external)? }; - - // call proxy function - let out = #fn_call; - let out = <#out_type as #bms_core::proxy::Proxy>::proxy_with_allocator(out, &mut allocator).map_err(#mlua::Error::external)?; - - // TODO: output proxies - Ok(out) - } - }); - let name = match attrs.metamethod{ + if f.sig.unsafety.is_some(){ + fn_call = quote_spanned!(span=> + unsafe { #fn_call } + ); + } + + if attrs.no_proxy.is_present() { + f.default = Some(parse_quote_spanned! {span=> + { + #fn_call + } + }); + } else { + f.default = Some(parse_quote_spanned! {span=> + { + let mut world: #bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> = #ctxt_arg_ident.globals().get("world")?; + let mut world = <#bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> as #bms_core::proxy::Unproxy>::unproxy(&mut world).map_err(#mlua::Error::external)?; + let mut world = world.read().ok_or_else(|| #mlua::Error::external("World no longer exists"))?; + let out: #out_type = world.proxy_call(#args_ident, |(#(#original_arg_idents),*)| { + #fn_call + }).map_err(|e| #mlua::Error::external(e))?; + Ok(out) + } + }); + } + + + let name = match &attrs.metamethod{ Some(metamethod) => quote_spanned!(metamethod.span()=> #mlua::MetaMethod::#metamethod ), @@ -261,15 +272,22 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { }; let closure = convert_function_def_to_closure(f); + + let registration_method = if attrs.metamethod.is_some() { + quote_spanned!(span=>add_meta_function) + } else { + quote_spanned!(span=>add_function) + }; + quote_spanned! {span=> - methods.add_function(#name, #closure); + methods.#registration_method(#name, #closure); } }); let vis = &meta.vis; quote_spanned! {meta.ident.span()=> - #[derive(Clone, Debug)] + #[derive(Clone, Debug, #tealr::mlu::UserData, #tealr::ToTypename)] #vis struct #proxy_type_ident (pub #bms_core::bindings::ReflectReference); impl #bms_lua::bindings::proxy::LuaProxied for #target_type { @@ -283,15 +301,50 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } } - impl #tealr::ToTypename for #proxy_type_ident { - fn to_typename() -> #tealr::Type { - #tealr::Type::Single(#tealr::SingleType { - name: #tealr::Name(#target_type_str.into()), - kind: #tealr::KindOfType::External, - }) + // impl #tealr::mlu::mlua::UserData for #proxy_type_ident + // where + // Self: #tealr::mlu::TealData, + // { + // fn add_methods<'lua, T: #tealr::mlu::mlua::UserDataMethods<'lua, Self>>( + // methods: &mut T, + // ) { + // let mut wrapper = tealr::mlu::UserDataWrapper::from_user_data_methods(methods); + // ::add_methods(&mut wrapper); + // } + + // fn add_fields<'lua, T: #tealr::mlu::mlua::UserDataFields<'lua, Self>>(fields: &mut T) { + // let mut wrapper = tealr::mlu::UserDataWrapper::from_user_data_fields(fields); + // ::add_fields(&mut wrapper); + // } + // } + + impl<'lua> #tealr::mlu::mlua::FromLua<'lua> for #proxy_type_ident { + fn from_lua( + value: #tealr::mlu::mlua::Value<'lua>, + _lua: &#tealr::mlu::mlua::Lua, + ) -> Result { + match value { + tealr::mlu::mlua::Value::UserData(ud) => Ok(ud.borrow::()?.clone()), + _ => { + return Err(#tealr::mlu::mlua::Error::FromLuaConversionError { + from: value.type_name(), + to: stringify!(#proxy_type_ident), + message: None, + }) + } + } } } + // impl #tealr::ToTypename for #proxy_type_ident { + // fn to_typename() -> #tealr::Type { + // #tealr::Type::Single(#tealr::SingleType { + // name: #tealr::Name(#target_type_str.into()), + // kind: #tealr::KindOfType::External, + // }) + // } + // } + impl AsRef<#bms_core::bindings::ReflectReference> for #proxy_type_ident { fn as_ref(&self) -> &#bms_core::bindings::ReflectReference { &self.0 diff --git a/makefile b/makefile index f5c44f2a..c6f8a493 100644 --- a/makefile +++ b/makefile @@ -46,8 +46,10 @@ valgrind: --simulate-cache=yes \ ${EXEC} --bench ${T_ID} -install_bevy_api_gen: +install_nightly: rustup install ${NIGHTLY_VERSION} + +install_bevy_api_gen: cargo +${NIGHTLY_VERSION} install --path ./crates/bevy_api_gen prepare_api_gen: From 869c5bfdbe2dbdeb5663550821ae85956b085a68 Mon Sep 17 00:00:00 2001 From: makspll Date: Mon, 6 May 2024 14:32:07 +0100 Subject: [PATCH 12/17] add back support for composites --- crates/bevy_api_gen/templates/header.tera | 4 +- .../src/bindings/providers/bevy_core.rs | 2 +- .../src/bindings/providers/bevy_ecs.rs | 2 +- .../src/bindings/providers/bevy_hierarchy.rs | 2 +- .../src/bindings/providers/bevy_input.rs | 2 +- .../src/bindings/providers/bevy_reflect.rs | 2 +- .../src/bindings/providers/bevy_time.rs | 2 +- .../src/bindings/providers/bevy_transform.rs | 2 +- .../src/bindings/providers/bevy_window.rs | 2 +- .../bevy_mod_scripting_lua_derive/src/lib.rs | 327 ++++++++++++------ 10 files changed, 238 insertions(+), 109 deletions(-) diff --git a/crates/bevy_api_gen/templates/header.tera b/crates/bevy_api_gen/templates/header.tera index 9d1e31ec..2cdbb574 100644 --- a/crates/bevy_api_gen/templates/header.tera +++ b/crates/bevy_api_gen/templates/header.tera @@ -12,7 +12,7 @@ use super::{{crate}}::*; use bevy_mod_scripting_core::{AddContextInitializer, StoreDocumentation, bindings::ReflectReference}; {% if args.self_is_bms_lua %} -use crate::{bindings::proxy::{LuaReflectRefProxy,LuaReflectRefMutProxy,LuaReflectValProxy,LuaValProxy,IdentityProxy},RegisterLuaProxy}; +use crate::{bindings::proxy::{LuaReflectRefProxy,LuaReflectRefMutProxy,LuaReflectValProxy,LuaValProxy,IdentityProxy},RegisterLuaProxy, tealr::mlu::mlua::IntoLua}; {% else %} -use bevy_mod_scripting::{lua::bindings::proxy::{LuaReflectRefProxy,LuaReflectRefMutProxy,LuaReflectValProxy,LuaValProxy,IdentityProxy}, RegisterLuaProxy}; +use bevy_mod_scripting::{lua::bindings::proxy::{LuaReflectRefProxy,LuaReflectRefMutProxy,LuaReflectValProxy,LuaValProxy,IdentityProxy}, RegisterLuaProxy, tealr::mlu::mlua::IntoLua}; {% endif %} \ No newline at end of file diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs index 221180d7..72f95ce8 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs @@ -12,7 +12,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, + RegisterLuaProxy, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs index e6c3afd9..529fe207 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs @@ -11,7 +11,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, + RegisterLuaProxy, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs index f5f05d58..955ce95d 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs @@ -13,7 +13,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, + RegisterLuaProxy, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs index d8f80021..a633a012 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs @@ -12,7 +12,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, + RegisterLuaProxy, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs index 5f494521..1ac97eb9 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs @@ -10,7 +10,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, + RegisterLuaProxy, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs index e116c354..f83bf1be 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs @@ -12,7 +12,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, + RegisterLuaProxy, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs index 31058e22..4e205848 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs @@ -14,7 +14,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, + RegisterLuaProxy, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs index 43fcc016..dc65e81d 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs @@ -13,7 +13,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, + RegisterLuaProxy, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 598f5ca3..54058c4d 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -44,7 +44,7 @@ fn standardise_receiver(receiver: &mut FnArg, target_type: &Path, bms_lua_path: (false, _) => "LuaReflectValProxy", }; let unproxy_ident = syn::Ident::new(unproxy_container_name, receiver.span()); - + Some(syn::FnArg::Typed(parse_quote_spanned! {receiver.span()=> #self_ident: #bms_lua_path::bindings::proxy::#unproxy_ident::<#target_type> })) @@ -84,18 +84,153 @@ fn collect_args_in_tuple<'a, I: Iterator>( /// Convert a function definition to a closure, for example: /// - `fn foo(a: i32, b: f32) -> f32 { a + b }` becomes `|a: i32, b: f32| { a + b} ` -fn convert_function_def_to_closure(f: TraitItemFn) -> ExprClosure { +fn convert_function_def_to_closure(f: &TraitItemFn) -> ExprClosure { let span = f.span(); - let sig = f.sig.inputs; + let sig = &f.sig.inputs; let body = f .default + .as_ref() .unwrap_or_else(|| panic!("Function {} must have a body", f.sig.ident)); parse_quote_spanned! {span => |#sig| #body } } -#[derive(FromAttributes)] +/// Processes the function def to wrap it in the necessary proxying logic +/// Will convert the function signature to take in two arguments: +/// - a context argument +/// - a tuple of all arguments passed to the underlying function +fn proxy_wrap_function_def( + f: &mut TraitItemFn, + target_type: &Path, + bms_core: &Path, + bms_lua: &Path, + mlua: &Path, + attrs: &FunctionAttrs, +) { + if let Some(first_arg) = f.sig.inputs.first_mut() { + standardise_receiver(first_arg, target_type, bms_lua) + }; + + // collect all args into tuple and add lua context arg + let ctxt_alias = syn::Ident::new(CTXT_ALIAS, f.sig.inputs.span()); + + let ctxt_arg = if attrs.with_context.is_present() { + f.sig + .inputs + .pop() + .expect("Expected at least one argument for the context") + .into_value() + } else { + parse_quote_spanned! {f.span()=> + #ctxt_alias: &#mlua::Lua + } + }; + let ctxt_arg_ident = match &ctxt_arg { + FnArg::Typed(arg) => arg.pat.clone(), + _ => panic!("Expected a typed argument, not a receiver for the context argument"), + }; + + let func_name = &f.sig.ident; + let (original_arg_idents, _) = f + .sig + .inputs + .iter() + .map(|arg| { + if let FnArg::Typed(arg) = arg { + (arg.pat.clone(), arg.ty.clone()) + } else { + panic!("Function arguments must be typed") + } + }) + .unzip::<_, _, Vec<_>, Vec<_>>(); + + let span = f.span(); + let args_ident = format_ident!("args", span = f.sig.inputs.span()); + + // change signature to take in a single args tuple instead of multiple arguments (on top of a context arg) + f.sig.inputs = Punctuated::from_iter(vec![ + ctxt_arg, + collect_args_in_tuple(f.sig.inputs.iter(), &args_ident, true), + ]); + + let out_type = match &f.sig.output { + syn::ReturnType::Default => quote_spanned! {f.span()=> + () + }, + syn::ReturnType::Type(_, ty) => ty.to_token_stream(), + }; + + // wrap function body in our unwrapping and wrapping logic, ignore pre-existing body + let mut fn_call = std::panic::catch_unwind(|| { + let mut fn_call = match (&f.default, &attrs.as_trait) { + (Some(body), _) => quote_spanned!(span=> + (||{ #body })() + ), + (_, None) => quote_spanned!(span=> + #target_type::#func_name(#(#original_arg_idents),*) + ), + (_, Some(trait_path)) => { + let trait_path = quote_spanned!(span=> #trait_path); + quote_spanned!(span=> + <#target_type as #trait_path>::#func_name(#(#original_arg_idents),*) + ) + } + }; + fn_call + }) + .unwrap(); // todo: handle the error nicer + + if f.sig.unsafety.is_some() { + fn_call = quote_spanned!(span=> + unsafe { #fn_call } + ); + } + + if attrs.no_proxy.is_present() { + f.default = Some(parse_quote_spanned! {span=> + { + #fn_call + } + }); + } else { + f.default = Some(parse_quote_spanned! {span=> + { + let mut world: #bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> = #ctxt_arg_ident.globals().get("world")?; + let mut world = <#bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> as #bms_core::proxy::Unproxy>::unproxy(&mut world).map_err(#mlua::Error::external)?; + let mut world = world.read().ok_or_else(|| #mlua::Error::external("World no longer exists"))?; + let out: #out_type = world.proxy_call(#args_ident, |(#(#original_arg_idents),*)| { + #fn_call + }).map_err(|e| #mlua::Error::external(e))?; + Ok(out) + } + }); + } +} + +fn generate_methods_registration( + attrs: &FunctionAttrs, + span: Span, + name: proc_macro2::TokenStream, + closure: ExprClosure, +) -> proc_macro2::TokenStream { + let registration_method = if attrs.metamethod.is_some() { + quote_spanned!(span=>add_meta_function) + } else { + quote_spanned!(span=>add_function) + }; + let docs = attrs.doc.iter().map(|doc| { + quote_spanned! {span=> + methods.document(#doc); + } + }); + quote_spanned! {span=> + #(#docs)* + methods.#registration_method(#name, #closure); + } +} + +#[derive(FromAttributes, Clone)] #[darling(attributes(lua))] struct FunctionAttrs { #[darling(multiple)] @@ -122,14 +257,14 @@ struct FunctionAttrs { pub with_context: Flag, /// Skips the unproxying & proxying call, useful for functions that don't need to access the world - pub no_proxy: Flag + pub no_proxy: Flag, } #[proc_macro_derive(LuaProxy, attributes(lua, proxy))] pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let derive_input = parse_macro_input!(input as DeriveInput); - let meta: ProxyInput = match ProxyInput::from_derive_input(&derive_input) { + let mut meta: ProxyInput = match ProxyInput::from_derive_input(&derive_input) { Ok(v) => v, Err(e) => return darling::Error::write_errors(e).into(), }; @@ -151,10 +286,10 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let bms_core = meta.bms_core_path.0; let bms_lua = meta.bms_lua_path.0; - let tealr = quote_spanned!(bms_lua.span()=> + let tealr: Path = parse_quote_spanned!(bms_lua.span()=> #bms_lua::tealr ); - let mlua = quote_spanned!(bms_core.span()=> + let mlua: Path = parse_quote_spanned!(bms_core.span()=> #tealr::mlu::mlua ); @@ -170,118 +305,111 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { ) }); - let add_function_stmts = meta.functions.0.into_iter().map(|mut f| { - if let Some(first_arg) = f.sig.inputs.first_mut() { - standardise_receiver(first_arg, &target_type, &bms_lua) + // extract composites first + let mut composites: HashMap> = HashMap::new(); + meta.functions.0.retain(|f| { + let attrs = FunctionAttrs::from_attributes(&f.attrs).unwrap(); + if let Some(composite_id) = &attrs.composite { + composites + .entry(composite_id.to_owned()) + .or_default() + .push((f.clone(), attrs)); + true + } else { + false + } + }); + + let add_composite_function_stmts = composites.into_values().map(|functions| { + let (first_function, first_function_attrs) = functions + .first() + .cloned() + .expect("At least one function must be a composite for this code to be reached"); + + let name = match &first_function_attrs.metamethod { + Some(metamethod) => quote_spanned!(metamethod.span()=> + #mlua::MetaMethod::#metamethod + ), + None => first_function.sig.ident.to_string().to_token_stream(), }; - // collect all args into tuple and add lua context arg - let ctxt_alias = syn::Ident::new(CTXT_ALIAS, f.sig.inputs.span()); + let value_arg_types = (0..first_function.sig.inputs.len()) + .map(|_| { + quote_spanned!(first_function.span()=> + #mlua::Value + ) + }) + .collect::>(); - let attrs = FunctionAttrs::from_attributes(&f.attrs).unwrap(); + let value_arg_names = (0..first_function.sig.inputs.len()).map(|i| { + format_ident!("arg{}", i, span = first_function.span()) + }).collect::>(); - let ctxt_arg = if attrs.with_context.is_present() { - f.sig.inputs.pop().expect("Expected at least one argument for the context").into_value() - } else { - parse_quote_spanned! {f.span()=> - #ctxt_alias: &#mlua::Lua - } - }; - let ctxt_arg_ident = match &ctxt_arg { - FnArg::Typed(arg) => arg.pat.clone(), - _ => panic!("Expected a typed argument, not a receiver"), - }; - - let func_name = &f.sig.ident; - let (original_arg_idents, original_arg_types) = f - .sig - .inputs - .iter() - .map(|arg| { - if let FnArg::Typed(arg) = arg { - (arg.pat.clone(), arg.ty.clone()) - } else { - panic!("Function arguments must be typed") - } + let closures = functions + .into_iter() + .map(|(mut f, attrs)| { + proxy_wrap_function_def(&mut f, &target_type, &bms_core, &bms_lua, &mlua, &attrs); + convert_function_def_to_closure(&f) }) - .unzip::<_, _, Vec<_>, Vec<_>>(); - - let span = f.span(); - let args_ident = format_ident!("args", span = f.sig.inputs.span()); - f.sig.inputs = Punctuated::from_iter(vec![ - ctxt_arg, - collect_args_in_tuple(f.sig.inputs.iter(), &args_ident, true), - ]); - - let out_type = match &f.sig.output { - syn::ReturnType::Default => quote_spanned! {f.span()=> - () - }, - syn::ReturnType::Type(_, ty) => ty.to_token_stream(), - }; + .collect::>(); + let closure_args_types = closures.iter().map(|closure| { + let last = closure.inputs.last().unwrap(); + if let syn::Pat::Type(pat_type) = last { + &pat_type.ty + } else { + panic!("Closure must have a single argument tuple as its last argument") + } + }); - // wrap function body in our unwrapping and wrapping logic, ignore pre-existing body - let mut fn_call = match (f.default, attrs.as_trait) { - (Some(body), _) => quote_spanned!(span=> - (||{ #body })() - ), - (_, None) => quote_spanned!(span=> - #target_type::#func_name(#(#original_arg_idents),*) - ), - (_, Some(trait_path)) => { - let trait_path = quote_spanned!(span=> #trait_path); - quote_spanned!(span=> - <#target_type as #trait_path>::#func_name(#(#original_arg_idents),*) - ) + // panic!( + // "{}", + // quote! { + // #( + // if let Ok(args) = <#closure_args_types as #mlua::FromLua>::from_lua(args) { + // return (#closures)(ctxt, args); + // } + // )* + // Err(#mlua::Error::external("Invalid arguments for composite function")) + // } + // ); + let closure = parse_quote_spanned! {first_function.span()=> + |ctxt, (#(#value_arg_names,)*): (#(#value_arg_types,)*)| { + let args = #mlua::MultiValue::from_vec(vec![#(#value_arg_names,)*]); + #( + if let Ok(args) = <#closure_args_types as #mlua::FromLuaMulti>::from_lua_multi(args.clone(), ctxt) { + let out : Result<_, #mlua::Error> = (#closures)(ctxt, args); + return out?.into_lua(ctxt) + } + )* + Err(#mlua::Error::external("Invalid arguments for composite function")) } }; + // panic!("asd"); - if f.sig.unsafety.is_some(){ - fn_call = quote_spanned!(span=> - unsafe { #fn_call } - ); - } + generate_methods_registration(&first_function_attrs, first_function.span(), name, closure) + }); - if attrs.no_proxy.is_present() { - f.default = Some(parse_quote_spanned! {span=> - { - #fn_call - } - }); - } else { - f.default = Some(parse_quote_spanned! {span=> - { - let mut world: #bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> = #ctxt_arg_ident.globals().get("world")?; - let mut world = <#bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> as #bms_core::proxy::Unproxy>::unproxy(&mut world).map_err(#mlua::Error::external)?; - let mut world = world.read().ok_or_else(|| #mlua::Error::external("World no longer exists"))?; - let out: #out_type = world.proxy_call(#args_ident, |(#(#original_arg_idents),*)| { - #fn_call - }).map_err(|e| #mlua::Error::external(e))?; - Ok(out) - } - }); + let add_function_stmts = meta.functions.0.into_iter().filter_map(|mut f| { + let attrs = FunctionAttrs::from_attributes(&f.attrs).unwrap(); + + if attrs.skip.is_present() { + return None; } + proxy_wrap_function_def(&mut f, &target_type, &bms_core, &bms_lua, &mlua, &attrs); - let name = match &attrs.metamethod{ + let name = match &attrs.metamethod { Some(metamethod) => quote_spanned!(metamethod.span()=> #mlua::MetaMethod::#metamethod ), None => f.sig.ident.to_string().to_token_stream(), }; + let span = f.span(); - let closure = convert_function_def_to_closure(f); - - let registration_method = if attrs.metamethod.is_some() { - quote_spanned!(span=>add_meta_function) - } else { - quote_spanned!(span=>add_function) - }; + let closure = convert_function_def_to_closure(&f); - quote_spanned! {span=> - methods.#registration_method(#name, #closure); - } + Some(generate_methods_registration(&attrs, span, name, closure)) }); let vis = &meta.vis; @@ -297,6 +425,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { impl #tealr::mlu::TealData for #proxy_type_ident { fn add_methods<'lua, M: #tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut M) { #(#type_level_document_calls)* + #(#add_composite_function_stmts)* #(#add_function_stmts)* } } From 2ea756c08a79d1de7b7901789d9a25a7659833d1 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 25 May 2024 19:36:42 +0100 Subject: [PATCH 13/17] Good chunk of work on refactored common bevy API --- .vscode/launch.json | 62 +- .vscode/tasks.json | 28 +- crates/bevy_mod_scripting_core/src/asset.rs | 7 +- .../bevy_mod_scripting_core/src/bindings.rs | 1156 ----------- .../src/{ => bindings}/allocator.rs | 22 +- .../src/bindings/mod.rs | 6 + .../src/{ => bindings}/proxy.rs | 398 ++-- .../src/bindings/reference.rs | 501 +++++ .../src/bindings/world.rs | 1815 +++++++++++++++++ crates/bevy_mod_scripting_core/src/error.rs | 193 +- crates/bevy_mod_scripting_core/src/lib.rs | 4 +- crates/bevy_mod_scripting_core/src/systems.rs | 2 +- .../src/bindings/mod.rs | 2 + .../src/bindings/providers/bevy_core.rs | 4 +- .../src/bindings/providers/bevy_ecs.rs | 12 +- .../src/bindings/providers/bevy_hierarchy.rs | 6 +- .../src/bindings/providers/bevy_input.rs | 66 +- .../src/bindings/providers/bevy_reflect.rs | 162 +- .../src/bindings/providers/bevy_time.rs | 14 +- .../src/bindings/providers/bevy_transform.rs | 6 +- .../src/bindings/providers/bevy_window.rs | 76 +- .../src/bindings/proxy.rs | 15 +- .../src/bindings/reference.rs | 430 ++++ .../src/bindings/type_registration.rs | 14 + .../src/bindings/world.rs | 50 +- .../bevy_mod_scripting_lua/src/lib.rs | 79 +- .../bevy_mod_scripting_lua/src/util.rs | 2 +- .../bevy_mod_scripting_lua_derive/src/lib.rs | 43 +- 28 files changed, 3468 insertions(+), 1707 deletions(-) delete mode 100644 crates/bevy_mod_scripting_core/src/bindings.rs rename crates/bevy_mod_scripting_core/src/{ => bindings}/allocator.rs (82%) create mode 100644 crates/bevy_mod_scripting_core/src/bindings/mod.rs rename crates/bevy_mod_scripting_core/src/{ => bindings}/proxy.rs (76%) create mode 100644 crates/bevy_mod_scripting_core/src/bindings/reference.rs create mode 100644 crates/bevy_mod_scripting_core/src/bindings/world.rs create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/type_registration.rs diff --git a/.vscode/launch.json b/.vscode/launch.json index a6483eca..76016f0b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,61 +5,33 @@ "version": "0.2.0", "configurations": [ { - "type": "lldb", - "request": "launch", - "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", - "LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:HOME}/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib" - }, - "cwd": "${workspaceFolder}", - }, - { - "name": "Debug example 'game_of_life_lua'", + "name": "Debug a test in bevy_mod_scripting_lua", "type": "lldb", "request": "launch", "cargo": { "args": [ - "build", - "--example=game_of_life_lua", - "--package=bevy_mod_scripting", - "--features=lua54,teal,lua_script_api", + "test", + "--no-run", + "--features", + "lua54", + "--package", + "bevy_mod_scripting_lua", + "--lib", + "--", + "${input:test_name}", + "--show-output" ], "filter": { - "name": "game_of_life_lua", - "kind": "example" + "kind": "lib", + "name": "bevy_mod_scripting_lua" } }, - "args": [], - "cwd": "${workspaceFolder}", + "cwd": "${workspaceFolder}/crates/languages/bevy_mod_scripting_lua", "env": { - "CARGO_MANIFEST_DIR": "${workspaceFolder}", + "CARGO_MANIFEST_DIR": "${workspaceFolder}/crates/languages/bevy_mod_scripting_lua", "LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:HOME}/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib" } }, - { - "name": "Debug example 'game_of_life_rhai'", - "type": "lldb", - "request": "launch", - "cargo": { - "args": [ - "build", - "--example=game_of_life_rhai", - "--package=bevy_mod_scripting", - "--features=rhai,rhai_script_api", - ], - "filter": { - "name": "game_of_life_rhai", - "kind": "example" - } - }, - "args": [], - "cwd": "${workspaceFolder}", - "env": { - "CARGO_MANIFEST_DIR": "${workspaceFolder}" - } - } - ] + ], + "inputs": [] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 14262c18..8a6c3e70 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,29 +1,29 @@ { "version": "2.0.0", "inputs": [ + // used for launch.json as well due to bug https://github.com/microsoft/vscode/issues/212384 { "id": "test_name", "type": "promptString", - "description": "Run only tests including this string in their name", - "default": "" + "description": "Run tests with given path", + "default": "bindings::reference::test::test_index_lua_value_field" }, { "id": "package", "type": "promptString", "description": "The crate location of this unit test", "default": "bevy_mod_scripting" - } - ], - "tasks": [ + }, + { + "id": "features", + "type": "promptString", + "description": "Features to activate for the build", + }, { - "label": "Build specific package's unit tests", - "type": "process", - "command": "make", - "args": [ - "build_test_in_package", - "PACKAGE=${input:package}", - "TEST_NAME=${input:test_name}" - ] - } + "id": "pwd", + "type": "promptString", + "description": "The working directory for the test", + "default": "${workspaceFolder}" + }, ] } \ No newline at end of file diff --git a/crates/bevy_mod_scripting_core/src/asset.rs b/crates/bevy_mod_scripting_core/src/asset.rs index 9369203a..f72d1e7f 100644 --- a/crates/bevy_mod_scripting_core/src/asset.rs +++ b/crates/bevy_mod_scripting_core/src/asset.rs @@ -45,10 +45,9 @@ impl AssetLoader for ScriptAssetLoader { ) -> BoxedFuture<'a, Result> { Box::pin(async move { let mut content = Vec::new(); - reader - .read_to_end(&mut content) - .await - .map_err(|e| ScriptError::new_with_context(load_context.asset_path(), e.into()))?; + reader.read_to_end(&mut content).await.map_err(|e| { + ScriptError::new_lifecycle_error(e).with_context(load_context.asset_path()) + })?; if let Some(processor) = &self.preprocessor { processor(&mut content)?; } diff --git a/crates/bevy_mod_scripting_core/src/bindings.rs b/crates/bevy_mod_scripting_core/src/bindings.rs deleted file mode 100644 index defdd2ac..00000000 --- a/crates/bevy_mod_scripting_core/src/bindings.rs +++ /dev/null @@ -1,1156 +0,0 @@ -//! # Motivation -//! -//! Traits and structs needed to support the creation of bindings for scripting languages. -//! reflection gives us access to `dyn Reflect` objects via their type name, -//! Scripting languages only really support `Clone` objects so if we want to support references, -//! we need wrapper types which have owned and ref variants. -use lockable::LockableHashMap; - -use std::{ - any::TypeId, - cell::UnsafeCell, - fmt::Debug, - marker::PhantomData, - sync::{Arc, Weak}, - time::Duration, -}; - -use bevy::{ - ecs::{ - change_detection::MutUntyped, - component::{Component, ComponentId}, - entity::Entity, - system::Resource, - world::{unsafe_world_cell::UnsafeWorldCell, Mut, World}, - }, - ptr::Ptr, - reflect::{ - ParsedPath, Reflect, ReflectFromPtr, ReflectPath, ReflectPathError, TypeInfo, TypeRegistry, - }, - utils::smallvec::SmallVec, -}; - -use crate::{ - allocator::{ReflectAllocation, ReflectAllocationId}, - error::ReflectionError, - prelude::ReflectAllocator, - proxy::{Proxy, Unproxy}, -}; - -/// Describes kinds of base value we are accessing via reflection -#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] -pub enum ReflectAccessKind { - ComponentOrResource, - Allocation, -} - -/// Describes the id pointing to the base value we are accessing via reflection, for components and resources this is the ComponentId -/// for script owned values this is an allocationId, this is used to ensure we have permission to access the value. -#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] -pub struct ReflectAccessId { - kind: ReflectAccessKind, - id: usize, -} - -impl From for ReflectAccessId { - fn from(value: ComponentId) -> Self { - Self { - kind: ReflectAccessKind::ComponentOrResource, - id: value.index(), - } - } -} - -impl ReflectAccessId { - pub fn new_component_or_resource_id(id: ComponentId) -> Self { - Self { - kind: ReflectAccessKind::ComponentOrResource, - id: id.index(), - } - } - - pub fn new_owned_id(id: ReflectAllocationId) -> Self { - Self { - kind: ReflectAccessKind::Allocation, - id: id.id(), - } - } -} -/// While [`WorldAccessGuard`] prevents aliasing at runtime and also makes sure world exists at least as long as the guard itself, -/// borrows sadly do not persist the script-host boundary :(. That is to be expected, but instead we can make an abstraction which removes the lifetime parameter, making the outer type 'static, -/// while making sure the lifetime is still satisfied! -#[derive(Clone)] -pub struct WorldCallbackAccess(Weak>); - -impl WorldCallbackAccess { - /// Wraps a callback which requires access to the world in a 'static way via [`WorldCallbackAccess`]. - pub fn with_callback_access( - world: &mut World, - callback: impl FnOnce(&WorldCallbackAccess) -> T, - ) -> T { - // - the world cannot be dropped before the world drops since we have mutable reference to it in this entire function - // - nothing can alias inappropriately WorldAccessGuard since it's only instance is behind the raw Arc - let world_guard = Arc::new(WorldAccessGuard::new(world)); - let world_guard = unsafe { WorldCallbackAccess::new(Arc::downgrade(&world_guard)) }; - - callback(&world_guard) - } - - /// Creates a new [`WorldCallbackAccess`] with an erased lifetime. - /// - /// # Safety - /// - The caller must ensure the [`WorldAccessGuard`] must not outlive the 'w lifetime - /// - In practice this means that between the moment the original Arc is dropped, the lifetime 'w must be valid - /// - I.e. you *must* drop the original [`Arc`] before the original 'w scope ends - pub unsafe fn new<'w>(world: Weak>) -> Self { - // Safety: the caller ensures `WorldAccessGuard` does not outlive the original lifetime 'w - - let world = unsafe { - std::mem::transmute::>, Weak>>( - world, - ) - }; - - Self(world) - } - - /// Attempts to read the world access guard, if it still exists - pub fn read(&self) -> Option>> { - self.0.upgrade() - } -} - -/// Unit of world access -pub type WorldAccessUnit<'w> = WorldAccessWrite<'w>; - -/// Provides safe access to the world via [`WorldAccess`] permissions, which enforce aliasing rules at runtime in multi-thread environments -#[derive(Clone)] -pub struct WorldAccessGuard<'w> { - cell: UnsafeWorldCell<'w>, - // TODO: this is fairly hefty, explore other ways to hand out locks on WorldAccess - accesses: Arc>>>, -} - -impl<'w> WorldAccessGuard<'w> { - /// Creates a new [`WorldAccessGuard`] for the given mutable borrow of the world - pub fn new(world: &'w mut World) -> Self { - Self { - cell: world.as_unsafe_world_cell(), - accesses: Default::default(), - } - } - - /// Retrieves the underlying unsafe world cell, with no additional guarantees of safety - /// proceed with caution and only use this if you understand what you're doing - pub fn as_unsafe_world_cell(&self) -> UnsafeWorldCell<'w> { - self.cell - } - - /// Retrieves the underlying read only unsafe world cell, with no additional guarantees of safety - /// proceed with caution and only use this if you understand what you're doing - pub fn as_unsafe_world_cell_readonly(&self) -> UnsafeWorldCell<'w> { - self.cell - } - - /// Tries to get access to the given reflect access id, if it's already returns `None`. If you want to wait for access, use [`WorldAccessGuard::get_access_timeout`] instead. - /// Remember to release this access once done with [`WorldAccessGuard::release_access`] or nobody else will be able to access this id!. - /// - /// Although forgetting to release access is safe, it's frankly quite rude and can lead to deadlocks. - pub fn get_access(&self, raid: ReflectAccessId) -> Option> { - let mut guard = self - .accesses - .blocking_lock(raid, lockable::SyncLimit::no_limit()) - .unwrap(); - let guard = guard.value_or_insert_with(|| { - Some(WorldAccessWrite { - raid, - _ph: PhantomData, - }) - }); - - if guard.is_some() { - guard.take() - } else { - // somebody has access to this already, we cannot access at the moment - None - } - } - - /// Blocking version of [`WorldAccessGuard::get_access`], waits for access to the given reflect access id. Will busy wait at the given intervals, untill the timeout is reached. - /// - /// # Panic - /// Will panic once access was not available after the timeout was reached - pub fn get_access_timeout( - &self, - raid: ReflectAccessId, - timeout: Duration, - interval: Duration, - ) -> WorldAccessUnit<'w> { - let mut access = self.get_access(raid); - let start = std::time::Instant::now(); - - while access.is_none() { - std::thread::sleep(interval); - access = self.get_access(raid); - if start.elapsed() > timeout { - panic!("Timeout reached while waiting for access to {:?}", raid); - } - } - access.unwrap() - } - - /// Releases access to the given reflect access id - pub fn release_access(&self, access: WorldAccessUnit<'w>) { - let mut guard = self - .accesses - .blocking_lock(access.raid, lockable::SyncLimit::no_limit()) - .unwrap(); - - let guard = guard - .value_mut() - .expect("Invariant violated, access should exist"); - - // should not be possible, we are the only ones who can instantiate WorldAccessUnit - debug_assert!( - guard.is_none(), - "Invariant violated, an access has been released by someone else already who shouldn't have been able to do so" - ); - *guard = Some(access); - } - - /// Get access to the given component_id, this is the only way to access a component/resource safely (in the context of the world access guard) - /// since you can only access this component_id through a RwLock, there is no way to break aliasing rules. - /// Additionally the 'w lifetime prevents you from storing this access outside the lifetime of the underlying cell - pub fn get_component_access(&self, cid: ComponentId) -> Option> { - let access_id = ReflectAccessId { - kind: ReflectAccessKind::ComponentOrResource, - id: cid.index(), - }; - self.get_access(access_id) - } - - /// Get access to the given component_id, this is the only way to access a component/resource safely (in the context of the world access guard) - /// since you can only access this component_id through a RwLock, there is no way to break aliasing rules. - /// Additionally the 'w lifetime prevents you from storing this access outside the lifetime of the underlying cell - pub fn get_resource_access(&self, cid: ComponentId) -> Option> { - self.get_component_access(cid) - } - - /// Get access to the given allocation_id, this is the only way to access a script owned value safely (in the context of the world access guard) - pub fn get_allocation_access(&self, id: ReflectAllocationId) -> Option> { - let access_id = ReflectAccessId { - kind: ReflectAccessKind::Allocation, - id: id.id(), - }; - self.get_access(access_id) - } - - /// Call a function on a type which can be proxied, first by unproxying the input with world access, - /// then calling the function and finally proxying the output with the allocator. - pub fn proxy_call<'i, O: Proxy, T: Unproxy, F: Fn(T::Output<'_>) -> O::Input<'i>>( - &self, - mut proxied_input: T, - f: F, - ) -> Result { - let cell = self.as_unsafe_world_cell(); - let allocator_resource_id = cell - .components() - .resource_id::() - .expect("Reflect Allocator wasn't initialized"); - let type_registry_resource_id = cell - .components() - .resource_id::() - .expect("Type Registry wasn't initialized"); - let mut allocator_access = self - .get_access(allocator_resource_id.into()) - .expect("Deadlock while accessing allocator"); - let type_registry_access = self - .get_access(type_registry_resource_id.into()) - .expect("Deadlock while accessing type registry"); - let mut allocator = self - .get_resource_mut::(&mut allocator_access) - .unwrap() - .unwrap(); - let type_registry = self - .get_resource::(&type_registry_access) - .unwrap() - .unwrap(); - let type_registry = type_registry.read(); - let mut world_acceses = SmallVec::default(); - - proxied_input.collect_accesses(self, &mut world_acceses)?; - let input = unsafe { - proxied_input.unproxy_with_world(self, &world_acceses, &type_registry, &allocator)? - }; - let out = f(input); - - O::proxy_with_allocator(out, &mut allocator) - } - - /// Get access to the given component, this is the only way to access a component/resource safely (in the context of the world access guard) - pub fn get_component( - &self, - access: &WorldAccessWrite, - entity: Entity, - ) -> Result, ReflectionError> { - let component_id = match self.cell.components().component_id::() { - Some(id) => id, - None => return Ok(None), - }; - - if access.can_read(ReflectAccessId { - kind: ReflectAccessKind::ComponentOrResource, - id: component_id.index(), - }) { - // Safety: we have the correct access id - return unsafe { Ok(self.cell.get_entity(entity).and_then(|e| e.get::())) }; - } else { - Err(ReflectionError::InsufficientAccess { - base: format!("Component<{}>", std::any::type_name::()), - reason: format!( - "Invalid access, instead got permission to read: {}", - self.cell - .components() - .get_info(ComponentId::new(access.raid.id)) - .map(|info| info.name()) - .unwrap_or("") - ), - }) - } - } - - /// Get access to the given component, this is the only way to access a component/resource safely (in the context of the world access guard) - pub fn get_component_mut( - &self, - access: &mut WorldAccessWrite, - entity: Entity, - ) -> Result>, ReflectionError> { - let component_id = match self.cell.components().component_id::() { - Some(id) => id, - None => return Ok(None), - }; - - if access.can_write(ReflectAccessId { - kind: ReflectAccessKind::ComponentOrResource, - id: component_id.index(), - }) { - // Safety: we have the correct access id - return unsafe { Ok(self.cell.get_entity(entity).and_then(|e| e.get_mut::())) }; - } else { - Err(ReflectionError::InsufficientAccess { - base: format!("Component<{}>", std::any::type_name::()), - reason: format!( - "Invalid access, instead got permission to read: {}", - self.cell - .components() - .get_info(ComponentId::new(access.raid.id)) - .map(|info| info.name()) - .unwrap_or("") - ), - }) - } - } - - /// Get access to the given resource - pub fn get_resource( - &self, - access: &WorldAccessWrite, - ) -> Result, ReflectionError> { - let resource_id = match self.cell.components().resource_id::() { - Some(id) => id, - None => return Ok(None), - }; - - if access.can_read(ReflectAccessId { - kind: ReflectAccessKind::ComponentOrResource, - id: resource_id.index(), - }) { - // Safety: we have the correct access id - return unsafe { Ok(self.cell.get_resource::()) }; - } else { - Err(ReflectionError::InsufficientAccess { - base: format!("Resource<{}>", std::any::type_name::()), - reason: format!( - "Invalid access, instead got permission to read: {}", - self.cell - .components() - .get_info(ComponentId::new(access.raid.id)) - .map(|info| info.name()) - .unwrap_or("") - ), - }) - } - } - - /// Get access to the given resource, this is the only way to access a component/resource safely (in the context of the world access guard) - pub fn get_resource_mut( - &self, - access: &mut WorldAccessWrite, - ) -> Result>, ReflectionError> { - let resource_id = match self.cell.components().resource_id::() { - Some(id) => id, - None => return Ok(None), - }; - - if access.can_write(ReflectAccessId { - kind: ReflectAccessKind::ComponentOrResource, - id: resource_id.index(), - }) { - // Safety: we have the correct access id - return unsafe { Ok(self.cell.get_resource_mut::()) }; - } else { - Err(ReflectionError::InsufficientAccess { - base: format!("Resource<{}>", std::any::type_name::()), - reason: format!( - "Invalid access, instead got permission to read: {}", - self.cell - .components() - .get_info(ComponentId::new(access.raid.id)) - .map(|info| info.name()) - .unwrap_or("") - ), - }) - } - } -} - -/// Having this is permission to access the contained [`ReflectAccessId`], there is no way to access anything safely through a [`WorldAccessGuard`] -/// without having a [`WorldAccess`] instance for that particular [`ReflectAccessId`]. -/// -/// If you do own a [`WorldAccess`] for some [`ReflectAccessId`], you can read and write to it safely. -/// If you only have an immutable borrow of [`WorldAccess`] you can only read it safely. -/// If you have a mutable borrow of [`WorldAccess`] you can read and write to it safely. -#[derive(Debug)] -pub struct WorldAccessWrite<'a> { - pub raid: ReflectAccessId, - pub(self) _ph: PhantomData<&'a usize>, -} - -impl<'w> WorldAccessWrite<'w> { - pub fn can_read(&self, raid: ReflectAccessId) -> bool { - self.raid == raid - } - - #[inline] - pub fn can_write(&self, raid: ReflectAccessId) -> bool { - self.can_read(raid) - } -} - -// pub struct - -/// An accessor to a `dyn Reflect` struct, stores a base ID of the type and a reflection path -/// safe to build but to reflect on the value inside you need to ensure aliasing rules are upheld -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct ReflectReference { - pub base: ReflectBaseType, - // TODO: experiment with Fixed capacity vec, boxed array etc, compromise between heap allocation and runtime cost - // needs benchmarks first though - /// The path from the top level type to the actual value we want to access - pub reflect_path: Vec, -} - -// just a dummy standin for unregistered types -struct UnregisteredType; - -impl ReflectReference { - pub fn new_allocated( - value: T, - allocator: &mut ReflectAllocator, - ) -> ReflectReference { - let id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(value)))); - ReflectReference { - base: ReflectBaseType { - type_id: TypeId::of::(), - base_id: ReflectBase::Owned(id), - }, - reflect_path: Vec::default(), - } - } - - /// Returns `Ok(())` if the given access is sufficient to read the value or an appropriate error otherwise - pub fn expect_read_access<'w>( - &self, - access: &WorldAccessWrite<'w>, - type_registry: &TypeRegistry, - world: UnsafeWorldCell<'w>, - ) -> Result<(), ReflectionError> { - if !access.can_read(self.base.base_id.get_reflect_access_id()) { - Err(ReflectionError::InsufficientAccess { - base: self.base.display_with_type_name(type_registry), - reason: format!( - "Invalid access, instead got permission to read: {}", - ReflectBaseType { - type_id: world - .components() - .get_info(ComponentId::new(access.raid.id)) - .and_then(|c| c.type_id()) - .unwrap_or(TypeId::of::()), - base_id: self.base.base_id.clone() - } - .display_with_type_name(type_registry), - ) - .to_owned(), - }) - } else { - Ok(()) - } - } - - /// Returns `Ok(())` if the given access is sufficient to write to the value or an appropriate error otherwise - /// Note that this is not sufficient for write access, you also need to ensure the [`WorldAccessWrite`] won't be used to access the same value mutably elsewhere, - /// if you have a `&mut WorldAccessWrite` you can guarantee this statically. This function just checks that the access itself is for the right base with write access - pub fn expect_write_access<'w>( - &self, - access: &WorldAccessWrite<'w>, - type_registry: &TypeRegistry, - world: UnsafeWorldCell<'w>, - ) -> Result<(), ReflectionError> { - if !access.can_read(self.base.base_id.get_reflect_access_id()) { - Err(ReflectionError::InsufficientAccess { - base: self.base.display_with_type_name(type_registry), - reason: format!( - "Invalid access, instead got permission to write to: {}", - ReflectBaseType { - type_id: world - .components() - .get_info(ComponentId::new(access.raid.id)) - .and_then(|c| c.type_id()) - .unwrap_or(TypeId::of::()), - base_id: self.base.base_id.clone() - } - .display_with_type_name(type_registry), - ) - .to_owned(), - }) - } else { - Ok(()) - } - } - - /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell. - /// If the underlying componentId is not the same as the one we have access to, an error is returned. - pub fn reflect<'w, 'c>( - &self, - world: UnsafeWorldCell<'w>, - access: &'c WorldAccessWrite<'w>, - type_registry: &TypeRegistry, - allocator: Option<&'c ReflectAllocator>, - ) -> Result<&'c dyn Reflect, ReflectionError> { - self.expect_read_access(access, type_registry, world)?; - // Safety: since we have read access to the underlying componentId we can safely access the component - // and we can return a reference tied to its lifetime, which will prevent invalid aliasing - return unsafe { self.reflect_unsafe(world, type_registry, allocator) }; - } - - /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell. - /// If the underlying componentId is not the same as the one we have access to, an error is returned. - /// - /// If we are accessing a component or resource, it's marked as changed - pub fn reflect_mut<'w, 'c>( - &self, - world: UnsafeWorldCell<'w>, - access: &'c mut WorldAccessWrite<'w>, - type_registry: &TypeRegistry, - allocator: Option<&'c ReflectAllocator>, - ) -> Result<&'c mut dyn Reflect, ReflectionError> { - self.expect_write_access(access, type_registry, world)?; - // Safety: since we have write access to the underlying reflect access id we can safely access the component - // and we can return a reference tied to its lifetime, which will prevent invalid aliasing - return unsafe { self.reflect_mut_unsafe(world, type_registry, allocator) }; - } - - /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell - /// # Safety - /// - The caller must ensure the cell has permission to access the underlying value - /// - The caller must ensure no aliasing mut references to the same value exist at all at the same time - pub unsafe fn reflect_unsafe<'w>( - &self, - world: UnsafeWorldCell<'w>, - type_registry: &TypeRegistry, - allocator: Option<&'w ReflectAllocator>, - ) -> Result<&'w dyn Reflect, ReflectionError> { - if let ReflectBase::Owned(id) = &self.base.base_id { - let allocator = allocator.ok_or_else(|| ReflectionError::AllocationError { - id: *id, - reason: "Allocator missing".to_owned(), - })?; - let arc = allocator - .get(*id) - .ok_or_else(|| ReflectionError::AllocationError { - id: *id, - reason: "Allocation was deallocated before it was accessed".to_owned(), - })?; - - // safety: caller promises it's fine :) - return Ok(unsafe { &*arc.get_ptr() }); - }; - // all Reflect types should have this derived - let from_ptr_data: &ReflectFromPtr = type_registry - .get_type_data(self.base.type_id) - .expect("FromPtr is not registered for this type, cannot retrieve reflect reference"); - - let ptr = self - .base - .base_id - .clone() - .into_ptr(world) - .ok_or_else(|| ReflectionError::InvalidBaseReference { - base: self.base.display_with_type_name(type_registry), - reason: "Base reference is invalid, is the component/resource initialized? does the entity exist?".to_string(), - })?; - - // (Ptr) Safety: we use the same type_id to both - // 1) retrieve the ptr - // 2) retrieve the ReflectFromPtr type data - // (UnsafeWorldCell) Safety: - // we already have access to &world so no &mut world exists - debug_assert_eq!( - from_ptr_data.type_id(), - self.base.type_id, - "Invariant violated" - ); - let mut base = unsafe { from_ptr_data.as_reflect(ptr) }; - - for elem in self.reflect_path.iter() { - base = elem - .reflect_element(base) - .map_err(|e| ReflectionError::Other(e.to_string()))?; - } - - Ok(base) - } - - /// Retrieves mutable reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell - /// # Safety - /// - The caller must ensure the cell has permission to access the underlying value - /// - The caller must ensure no other references to the same value exist at all at the same time (even if you have the correct access) - pub unsafe fn reflect_mut_unsafe<'w>( - &self, - world: UnsafeWorldCell<'w>, - type_registry: &TypeRegistry, - allocator: Option<&'w ReflectAllocator>, - ) -> Result<&'w mut dyn Reflect, ReflectionError> { - if let ReflectBase::Owned(id) = &self.base.base_id { - let allocator = allocator.ok_or_else(|| ReflectionError::AllocationError { - id: *id, - reason: "Allocator missing".to_owned(), - })?; - let arc = allocator - .get_mut(*id) - .ok_or_else(|| ReflectionError::AllocationError { - id: *id, - reason: "Allocation was deallocated before it was accessed".to_owned(), - })?; - // Safety: caller promises this is fine :) - return Ok(unsafe { &mut *arc.get_ptr() }); - }; - - // all Reflect types should have this derived - let from_ptr_data: &ReflectFromPtr = type_registry - .get_type_data(self.base.type_id) - .expect("FromPtr is not registered for this type, cannot retrieve reflect reference"); - - let ptr = self - .base - .base_id - .clone() - .into_ptr_mut(world) - .ok_or_else(|| ReflectionError::InvalidBaseReference { - base: self.base.display_with_type_name(type_registry), - reason: "Base reference is invalid, is the component/resource initialized? does the entity exist?".to_string(), - })? - .into_inner(); - - // (Ptr) Safety: we use the same type_id to both - // 1) retrieve the ptr - // 2) retrieve the ReflectFromPtr type data - // (UnsafeWorldCell) Safety: - // we already have access to &world so no &mut world exists - debug_assert_eq!( - from_ptr_data.type_id(), - self.base.type_id, - "Invariant violated" - ); - let mut base = unsafe { from_ptr_data.as_reflect_mut(ptr) }; - - for elem in self.reflect_path.iter() { - base = elem - .reflect_element_mut(base) - .map_err(|e| ReflectionError::Other(e.to_string()))?; - } - - Ok(base) - } -} - -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct ReflectBaseType { - pub type_id: TypeId, - pub base_id: ReflectBase, -} - -impl ReflectBaseType { - pub fn type_name(type_id: TypeId, type_registry: &TypeRegistry) -> &'static str { - type_registry - .get_type_info(type_id) - .map(TypeInfo::type_path) - .unwrap_or("") - } - - pub fn display_with_type_name(&self, type_registry: &TypeRegistry) -> String { - format!( - "ReflectBase({}, {:?})", - Self::type_name(self.type_id, type_registry), - self.base_id - ) - } -} - -/// The Id of the kind of reflection base being pointed to -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum ReflectBase { - Component(Entity, ComponentId), - Resource(ComponentId), - Owned(ReflectAllocationId), -} - -impl ReflectBase { - /// Retrieves the pointer to the underlying `dyn Reflect` object valid for the 'w lifteime of the world cell - /// - /// # Safety - /// - The caller must ensure the cell has permission to access the underlying value - /// - The caller must ensure no aliasing mutable references to the same value exist at the same time - pub unsafe fn into_ptr(self, world: UnsafeWorldCell<'_>) -> Option> { - match self { - ReflectBase::Component(entity, component_id) => { - // Safety: the caller ensures invariants hold - world.get_entity(entity)?.get_by_id(component_id) - } - ReflectBase::Resource(component_id) => { - // Safety: the caller ensures invariants hold - world.get_resource_by_id(component_id) - } - _ => None, - } - } - - /// Retrieves the pointer to the underlying `dyn Reflect` object valid for the 'w lifteime of the world cell - /// - /// # Safety - /// - The caller must ensure the cell has permission to access the underlying value - /// - The caller must ensure no aliasing references to the same value exist at all at the same time - pub unsafe fn into_ptr_mut(self, world: UnsafeWorldCell<'_>) -> Option> { - match self { - ReflectBase::Component(entity, component_id) => { - // Safety: the caller ensures invariants hold - world.get_entity(entity)?.get_mut_by_id(component_id) - } - ReflectBase::Resource(component_id) => { - // Safety: the caller ensures invariants hold - world.get_resource_mut_by_id(component_id) - } - _ => None, - } - } - - pub fn get_reflect_access_id(&self) -> ReflectAccessId { - match self { - ReflectBase::Component(_, cid) | ReflectBase::Resource(cid) => ReflectAccessId { - kind: ReflectAccessKind::ComponentOrResource, - id: cid.index(), - }, - ReflectBase::Owned(id) => ReflectAccessId { - kind: ReflectAccessKind::Allocation, - id: id.id(), - }, - } - } -} - -/// An element in the reflection path, the base reference included -#[derive(Clone, PartialEq, Eq, Debug)] -pub enum ReflectionPathElem { - /// A standard reflection path, i.e. `.field_name[vec_index]`, pre-parsed since we construct once potentially use many times - Reflection(ParsedPath), - /// a deferred reflection - DeferredReflection(DeferredReflection), -} - -impl ReflectionPathElem { - pub fn new_reflection>(path: I) -> Self { - Self::Reflection(path.into()) - } - - pub fn new_deferred>(defref: I) -> Self { - Self::DeferredReflection(defref.into()) - } -} - -impl From<(A, B)> for DeferredReflection -where - A: Fn(&dyn Reflect) -> Result<&dyn Reflect, ReflectPathError<'static>> + Send + Sync, - B: Fn(&mut dyn Reflect) -> Result<&mut dyn Reflect, ReflectPathError<'static>> + Send + Sync, -{ - fn from((get, get_mut): (A, B)) -> Self { - Self { - get: Arc::new(get), - get_mut: Arc::new(get_mut), - } - } -} - -impl<'a> ReflectPath<'a> for &'a ReflectionPathElem { - fn reflect_element<'r>( - self, - root: &'r dyn Reflect, - ) -> Result<&'r dyn Reflect, ReflectPathError<'a>> { - match self { - ReflectionPathElem::Reflection(path) => path.reflect_element(root), - ReflectionPathElem::DeferredReflection(f) => (f.get)(root), - } - } - - fn reflect_element_mut<'r>( - self, - root: &'r mut dyn Reflect, - ) -> Result<&'r mut dyn Reflect, ReflectPathError<'a>> { - match self { - ReflectionPathElem::Reflection(path) => path.reflect_element_mut(root), - ReflectionPathElem::DeferredReflection(defref) => (defref.get_mut)(root), - } - } -} - -/// A ReflectPath which can perform arbitrary operations on the root object to produce a sub-reference -#[derive(Clone)] -pub struct DeferredReflection { - pub get: - Arc Result<&dyn Reflect, ReflectPathError<'static>> + Send + Sync>, - pub get_mut: Arc< - dyn Fn(&mut dyn Reflect) -> Result<&mut dyn Reflect, ReflectPathError<'static>> - + Send - + Sync, - >, -} - -impl Debug for DeferredReflection { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str("DeferredReflection") - } -} - -impl PartialEq for DeferredReflection { - fn eq(&self, other: &Self) -> bool { - Arc::ptr_eq(&self.get, &other.get) && Arc::ptr_eq(&self.get_mut, &other.get_mut) - } -} - -impl Eq for DeferredReflection {} - -#[cfg(test)] -mod test { - - use std::cell::UnsafeCell; - - use crate::allocator::{ReflectAllocation, ReflectAllocator}; - - use super::*; - use bevy::ecs::{component::Component, system::Resource, world::World}; - - #[derive(Component, Reflect, PartialEq, Eq, Debug)] - struct TestComponent { - strings: Vec, - } - - #[derive(Resource, Reflect, Default, PartialEq, Eq, Debug)] - struct TestResource { - bytes: Vec, - } - - fn setup_world() -> (World, TypeRegistry, ComponentId, ComponentId) { - let mut world = World::default(); - let component_id = world.init_component::(); - let resource_id = world.init_resource::(); - - let mut type_registry = TypeRegistry::new(); - type_registry.register::(); - type_registry.register::(); - - (world, type_registry, component_id, resource_id) - } - - // #[test] - // fn doesnt_compile() { - // let (mut world, type_registry, c_id, _) = setup_world(); - - // let world = WorldAccessGuard::new(&mut world); - - // let reflect_ref = ReflectReference { - // base: ReflectBaseType { - // base_id: ReflectBase::Component(Entity::from_raw(0), c_id), - // type_id: TypeId::of::(), - // }, - // reflect_path: vec![], - // }; - - // let mut access = WorldAccess { - // raid: ReflectAccessId { - // kind: ReflectAccessKind::ComponentOrResource, - // id: c_id.index(), - // }, - // write: true, - // _ph: PhantomData, - // }; - - // let read = reflect_ref - // .reflect(world.as_unsafe_world_cell(), &access, None, &type_registry) - // .unwrap(); - - // // This shouldn't compile! borrow checker should prevent this - // let read_mut = reflect_ref - // .reflect_mut( - // world.as_unsafe_world_cell(), - // &mut access, - // None, - // &type_registry, - // ) - // .unwrap(); - - // drop(read); - // drop(read_mut); - // } - - #[test] - fn test_component_access() { - let (mut world, type_registry, component_id, _) = setup_world(); - let entity = world - .spawn(TestComponent { - strings: vec![String::from("hello")], - }) - .id(); - - let world = WorldAccessGuard::new(&mut world); - - let component_reflect_ref = ReflectReference { - base: ReflectBaseType { - base_id: ReflectBase::Component(entity, component_id), - type_id: TypeId::of::(), - }, - reflect_path: vec![ - ReflectionPathElem::Reflection(ParsedPath::parse_static(".strings").unwrap()), - ReflectionPathElem::DeferredReflection(DeferredReflection { - get: Arc::new(|root| { - let strings = root.downcast_ref::>().unwrap(); - Ok(strings.first().unwrap()) - }), - get_mut: Arc::new(|root| { - let strings = root.downcast_mut::>().unwrap(); - Ok(strings.first_mut().unwrap()) - }), - }), - ], - }; - - let mut component_access = world.get_component_access(component_id).unwrap(); - *component_reflect_ref - .reflect_mut( - world.as_unsafe_world_cell(), - &mut component_access, - &type_registry, - None, - ) - .unwrap() - .downcast_mut::() - .unwrap() = "world".to_owned(); - - assert_eq!( - world - .get_component::(&component_access, entity) - .unwrap() - .unwrap(), - &TestComponent { - strings: vec![String::from("world")] - } - ); - - *world - .get_component_mut::(&mut component_access, entity) - .unwrap() - .unwrap() - .as_mut() = TestComponent { - strings: vec![String::from("typed_world")], - }; - - assert_eq!( - component_reflect_ref - .reflect( - world.as_unsafe_world_cell(), - &component_access, - &type_registry, - None, - ) - .unwrap() - .downcast_ref::() - .unwrap(), - &"typed_world".to_owned() - ); - - world.release_access(component_access); - - assert!( - world.get_component_access(component_id).is_some(), - "access was not release correctly" - ); - } - - #[test] - fn test_resource_access() { - let (mut world, type_registry, _, resource_id) = setup_world(); - - world.insert_resource(TestResource { bytes: vec![42u8] }); - let world = WorldAccessGuard::new(&mut world); - - let resource_reflect_ref = ReflectReference { - base: ReflectBaseType { - base_id: ReflectBase::Resource(resource_id), - type_id: TypeId::of::(), - }, - reflect_path: vec![ - ReflectionPathElem::Reflection(ParsedPath::parse_static(".bytes").unwrap()), - ReflectionPathElem::DeferredReflection(DeferredReflection { - get: Arc::new(|root| { - let strings = root.downcast_ref::>().unwrap(); - Ok(strings.first().unwrap()) - }), - get_mut: Arc::new(|root| { - let strings = root.downcast_mut::>().unwrap(); - Ok(strings.first_mut().unwrap()) - }), - }), - ], - }; - - let mut resource_access = world.get_resource_access(resource_id).unwrap(); - - *resource_reflect_ref - .reflect_mut( - world.as_unsafe_world_cell(), - &mut resource_access, - &type_registry, - None, - ) - .unwrap() - .downcast_mut::() - .unwrap() = 42u8; - - assert_eq!( - world - .get_resource::(&resource_access) - .unwrap() - .unwrap(), - &TestResource { bytes: vec![42u8] } - ); - - *world - .get_resource_mut::(&mut resource_access) - .unwrap() - .unwrap() - .as_mut() = TestResource { bytes: vec![69u8] }; - - assert_eq!( - resource_reflect_ref - .reflect( - world.as_unsafe_world_cell(), - &resource_access, - &type_registry, - None, - ) - .unwrap() - .downcast_ref::() - .unwrap(), - &69u8 - ); - - world.release_access(resource_access); - assert!( - world.get_resource_access(resource_id).is_some(), - "access was not release correctly" - ); - } - - #[test] - fn test_script_alloc_access() { - let (mut world, type_registry, _, _) = setup_world(); - - let world = WorldAccessGuard::new(&mut world); - let mut script_allocator = ReflectAllocator::default(); - let allocation_id = script_allocator.allocate(ReflectAllocation::new(Arc::new( - UnsafeCell::new("hello".to_string()), - ))); - - let owned_reflect_ref = ReflectReference { - base: ReflectBaseType { - base_id: ReflectBase::Owned(allocation_id), - type_id: TypeId::of::(), - }, - reflect_path: vec![], - }; - - let allocation_access = world.get_allocation_access(allocation_id).unwrap(); - - assert_eq!( - owned_reflect_ref - .reflect( - world.as_unsafe_world_cell_readonly(), - &allocation_access, - &type_registry, - Some(&script_allocator), - ) - .unwrap() - .downcast_ref::(), - Some(&String::from("hello")) - ); - - assert!( - world.get_allocation_access(allocation_id).is_none(), - "Multiple accesses to same base ID exist, safety violation" - ); - - world.release_access(allocation_access); - assert!( - world.get_allocation_access(allocation_id).is_some(), - "access was not release correctly" - ); - } - - #[test] - #[allow(clippy::drop_non_drop)] - fn test_invalid_runtime_access() { - let mut world = World::new(); - let world = WorldAccessGuard::new(&mut world); - let access = world.get_component_access(ComponentId::new(0)); - assert!( - world.get_component_access(ComponentId::new(0)).is_none(), - "access was allowed to alias" - ); - drop(access); - } - - #[test] - #[should_panic] - fn test_double_release_panics() { - let mut world = World::new(); - let world = WorldAccessGuard::new(&mut world); - let access = world.get_component_access(ComponentId::new(0)).unwrap(); - world.release_access(access); - // This won't be possible in client code - world.release_access(WorldAccessWrite { - raid: ReflectAccessId { - kind: ReflectAccessKind::ComponentOrResource, - id: 0, - }, - _ph: PhantomData, - }); - } -} diff --git a/crates/bevy_mod_scripting_core/src/allocator.rs b/crates/bevy_mod_scripting_core/src/bindings/allocator.rs similarity index 82% rename from crates/bevy_mod_scripting_core/src/allocator.rs rename to crates/bevy_mod_scripting_core/src/bindings/allocator.rs index 50384939..fe2d2734 100644 --- a/crates/bevy_mod_scripting_core/src/allocator.rs +++ b/crates/bevy_mod_scripting_core/src/bindings/allocator.rs @@ -1,13 +1,13 @@ use bevy::ecs::system::Resource; use bevy::reflect::Reflect; +use std::any::TypeId; use std::cell::UnsafeCell; use std::collections::HashMap; use std::fmt::{Display, Formatter}; -use std::rc::Rc; use std::sync::Arc; #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] -pub struct ReflectAllocationId(pub(self) usize); +pub struct ReflectAllocationId(pub(crate) usize); impl ReflectAllocationId { pub fn id(&self) -> usize { self.0 @@ -41,20 +41,27 @@ impl Display for ReflectAllocationId { pub struct ReflectAllocator { // TODO: experiment with object pools, sparse set etc. allocations: HashMap, + types: HashMap, } impl ReflectAllocator { /// Allocates a new [`Reflect`] value and returns an [`AllocationId`] which can be used to access it later - pub fn allocate(&mut self, value: ReflectAllocation) -> ReflectAllocationId { + pub fn allocate(&mut self, value: T) -> (ReflectAllocationId, ReflectAllocation) { let id = ReflectAllocationId(self.allocations.len()); - self.allocations.insert(id, value); - id + let value = ReflectAllocation::new(Arc::new(UnsafeCell::new(value))); + self.allocations.insert(id, value.clone()); + self.types.insert(id, TypeId::of::()); + (id, value) } pub fn get(&self, id: ReflectAllocationId) -> Option { self.allocations.get(&id).cloned() } + pub fn get_type_id(&self, id: ReflectAllocationId) -> Option { + self.types.get(&id).cloned() + } + pub fn get_mut(&self, id: ReflectAllocationId) -> Option { self.allocations.get(&id).cloned() } @@ -78,10 +85,9 @@ mod test { #[test] fn test_reflect_allocator() { let mut allocator = ReflectAllocator::default(); - let value = ReflectAllocation::new(Arc::new(UnsafeCell::new(0))); - allocator.allocate(value.clone()); + let (id, val) = allocator.allocate(0); assert_eq!(allocator.allocations.len(), 1); - drop(value); + drop(val); allocator.clean_garbage_allocations(); assert_eq!(allocator.allocations.len(), 0); } diff --git a/crates/bevy_mod_scripting_core/src/bindings/mod.rs b/crates/bevy_mod_scripting_core/src/bindings/mod.rs new file mode 100644 index 00000000..13c44cb6 --- /dev/null +++ b/crates/bevy_mod_scripting_core/src/bindings/mod.rs @@ -0,0 +1,6 @@ +pub mod allocator; +pub mod proxy; +pub mod reference; +pub mod world; + +pub use {allocator::*, proxy::*, reference::*, world::*}; diff --git a/crates/bevy_mod_scripting_core/src/proxy.rs b/crates/bevy_mod_scripting_core/src/bindings/proxy.rs similarity index 76% rename from crates/bevy_mod_scripting_core/src/proxy.rs rename to crates/bevy_mod_scripting_core/src/bindings/proxy.rs index c665cef5..16ddd07a 100644 --- a/crates/bevy_mod_scripting_core/src/proxy.rs +++ b/crates/bevy_mod_scripting_core/src/bindings/proxy.rs @@ -13,11 +13,14 @@ use bevy::{ }; use crate::{ - allocator::ReflectAllocation, - bindings::{ - ReflectBaseType, ReflectReference, WorldAccessGuard, WorldAccessUnit, WorldAccessWrite, - }, - prelude::{ReflectAllocator, ReflectionError}, + bindings::ReflectAllocation, + error::ScriptResult, + prelude::{ReflectAllocator, ScriptError}, +}; + +use super::{ + world::{WorldAccessGuard, WorldAccessUnit, WorldAccessWrite}, + ReflectReference, DEFAULT_INTERVAL, DEFAULT_TIMEOUT, }; /// Inverse to [`Unproxy`], packages up a type into a proxy type. @@ -25,19 +28,18 @@ pub trait Proxy: Sized { type Input<'a>; /// Proxies a type without access to the allocator, types which require access to the allocator will throw an error here - fn proxy<'a>(input: Self::Input<'a>) -> Result { - Err(ReflectionError::InsufficientAccess { - base: std::any::type_name::().to_owned(), - reason: "Attempted to proxy a type that requires an allocator without providing it" - .to_owned(), - }) + fn proxy<'a>(input: Self::Input<'a>) -> ScriptResult { + Err(ScriptError::new_reflection_error(format!( + "Cannot unproxy type: `{}` without allocator access. Use proxy_with_allocator instead.", + std::any::type_name::(), + ))) } /// Proxies a type with access to the allocator fn proxy_with_allocator<'a>( input: Self::Input<'a>, _allocator: &mut ReflectAllocator, - ) -> Result { + ) -> ScriptResult { Self::proxy(input) } } @@ -57,7 +59,7 @@ pub trait Unproxy { &self, _guard: &WorldAccessGuard<'w>, _accesses: &mut SmallVec<[WorldAccessWrite<'w>; 1]>, - ) -> Result<(), ReflectionError> { + ) -> ScriptResult<()> { Ok(()) } @@ -67,12 +69,11 @@ pub trait Unproxy { /// Unproxies a proxy type into the represented type without world access /// This will fail on proxies which require world access to unproxy (for example those whose proxies are glorified [`ReflectReference`]'s ) - fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { - Err(ReflectionError::InsufficientAccess { - base: std::any::type_name::>().to_owned(), - reason: "Attempted to unproxy a type that requires world access without providing it" - .to_owned(), - }) + fn unproxy<'o>(&'o mut self) -> ScriptResult> { + Err(ScriptError::new_reflection_error(format!( + "Cannot unproxy type: `{}` without world access. Use unproxy_with_world instead", + std::any::type_name::(), + ))) } /// Unproxies a proxy type into the represented type with world access @@ -84,7 +85,7 @@ pub trait Unproxy { _accesses: &'o [WorldAccessUnit<'w>], _type_registry: &TypeRegistry, _allocator: &'o ReflectAllocator, - ) -> Result, ReflectionError> { + ) -> ScriptResult> { self.unproxy() } } @@ -123,6 +124,7 @@ impl ReflectRefProxy { /// A proxy type which when unproxied will return a mutable reference to a `T` value. /// Assumes that the proxy type contains a [`ReflectReference`] via [`AsRef`] +#[derive(Debug)] pub struct ReflectRefMutProxy(pub P, PhantomData); impl ReflectRefMutProxy { @@ -137,7 +139,7 @@ where { type Output<'o> = T where Self: 'o; - fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { + fn unproxy<'o>(&'o mut self) -> ScriptResult> { Ok(T::from(&self.0)) } } @@ -148,7 +150,7 @@ where { type Input<'a> = T; - fn proxy<'a>(input: Self::Input<'a>) -> Result { + fn proxy<'a>(input: Self::Input<'a>) -> ScriptResult { Ok(ValProxy::new(input.into())) } } @@ -163,7 +165,7 @@ where fn proxy_with_allocator<'a>( input: Self::Input<'a>, allocator: &mut ReflectAllocator, - ) -> Result { + ) -> ScriptResult { Ok(Self::new( ReflectReference::new_allocated(input, allocator).into(), )) @@ -183,25 +185,28 @@ where _accesses: &'o [WorldAccessUnit<'w>], type_registry: &TypeRegistry, allocator: &'o ReflectAllocator, - ) -> Result, ReflectionError> { + ) -> ScriptResult> { let reflect_ref: &ReflectReference = self.0.as_ref(); let access = reflect_ref.base.base_id.get_reflect_access_id(); - let access = - guard - .get_access(access) - .ok_or_else(|| ReflectionError::InsufficientAccess { - base: std::any::type_name::().to_owned(), - reason: "Attempted to access the same component/resource/allocation in one Unproxying operation".to_owned(), - })?; + let access = guard + .get_access_timeout(access, DEFAULT_TIMEOUT, DEFAULT_INTERVAL) + .ok_or_else(|| { + ScriptError::new_reflection_error(format!( + "Could not unproxy type: `{}`. Aliasing access.", + std::any::type_name::() + )) + })?; let out = reflect_ref.reflect( guard.as_unsafe_world_cell(), &access, type_registry, Some(allocator), )?; - let out = T::from_reflect(out).ok_or_else(|| ReflectionError::CannotDowncast { - reference: reflect_ref.clone(), - to: std::any::type_name::().to_string(), + let out = T::from_reflect(out).ok_or_else(|| { + ScriptError::new_reflection_error(format!( + "FromReflect failed for `{}`.", + std::any::type_name::() + )) })?; guard.release_access(access); Ok(out) @@ -218,9 +223,12 @@ where fn proxy_with_allocator<'a>( input: Self::Input<'a>, allocator: &mut ReflectAllocator, - ) -> Result { - let inner = T::from_reflect(input).ok_or_else(|| ReflectionError::FromReflectFailure { - ref_: input.reflect_type_path().to_owned(), + ) -> ScriptResult { + let inner = T::from_reflect(input).ok_or_else(|| { + ScriptError::new_reflection_error(format!( + "FromReflect failed for `{}`.", + std::any::type_name::() + )) })?; Ok(Self::new( ReflectReference::new_allocated(inner, allocator).into(), @@ -239,15 +247,17 @@ where &self, guard: &WorldAccessGuard<'w>, accesses: &mut SmallVec<[WorldAccessUnit<'w>; 1]>, - ) -> Result<(), ReflectionError> { + ) -> ScriptResult<()> { let reflect_ref: &ReflectReference = self.0.as_ref(); let access = reflect_ref.base.base_id.get_reflect_access_id(); - let access = - guard.get_access(access) - .ok_or_else(|| ReflectionError::InsufficientAccess { - base: std::any::type_name::().to_owned(), - reason: "Attempted to access the same component/resource/allocation in one Unproxying operation".to_owned(), - })?; + let access = guard + .get_access_timeout(access, DEFAULT_TIMEOUT, DEFAULT_INTERVAL) + .ok_or_else(|| { + ScriptError::new_reflection_error(format!( + "Could not unproxy type: `{}`. Aliasing access.", + std::any::type_name::() + )) + })?; accesses.push(access); Ok(()) } @@ -258,14 +268,14 @@ where accesses: &'o [WorldAccessUnit<'w>], type_registry: &TypeRegistry, allocator: &'o ReflectAllocator, - ) -> Result, ReflectionError> { + ) -> ScriptResult> { let reflect_ref: &ReflectReference = self.0.as_ref(); - let access = accesses - .last() - .ok_or_else(|| ReflectionError::InsufficientAccess { - base: std::any::type_name::().to_owned(), - reason: "No access collected when unproxying".to_owned(), - })?; + let access = accesses.last().ok_or_else(|| { + ScriptError::new_reflection_error(format!( + "No required access collected when unproxying type: `{}`.", + std::any::type_name::() + )) + })?; let out = reflect_ref.reflect( guard.as_unsafe_world_cell(), @@ -273,12 +283,12 @@ where type_registry, Some(allocator), )?; - let out = out - .downcast_ref() - .ok_or_else(|| ReflectionError::CannotDowncast { - reference: reflect_ref.clone(), - to: std::any::type_name::().to_string(), - })?; + let out = out.downcast_ref().ok_or_else(|| { + ScriptError::new_reflection_error(format!( + "Could not downcast value from reflect reference to type: `{}`.", + std::any::type_name::() + )) + })?; Ok(out) } @@ -298,15 +308,17 @@ where &self, guard: &WorldAccessGuard<'w>, accesses: &mut SmallVec<[WorldAccessUnit<'w>; 1]>, - ) -> Result<(), ReflectionError> { + ) -> ScriptResult<()> { let reflect_ref: &ReflectReference = self.0.as_ref(); let access = reflect_ref.base.base_id.get_reflect_access_id(); - let access = - guard.get_access(access) - .ok_or_else(|| ReflectionError::InsufficientAccess { - base: std::any::type_name::().to_owned(), - reason: "Attempted to access the same component/resource/allocation in one Unproxying operation".to_owned(), - })?; + let access = guard + .get_access_timeout(access, DEFAULT_TIMEOUT, DEFAULT_INTERVAL) + .ok_or_else(|| { + ScriptError::new_reflection_error(format!( + "Could not unproxy type: `{}`. Aliasing access.", + std::any::type_name::() + )) + })?; accesses.push(access); Ok(()) } @@ -317,16 +329,23 @@ where accesses: &'o [WorldAccessUnit<'w>], type_registry: &TypeRegistry, allocator: &'o ReflectAllocator, - ) -> Result, ReflectionError> { + ) -> ScriptResult> { let reflect_ref: &ReflectReference = self.0.as_ref(); accesses .last() - .ok_or_else(|| ReflectionError::InsufficientAccess { - base: std::any::type_name::().to_owned(), - reason: "No access collected when unproxying".to_owned(), + .ok_or_else(|| { + ScriptError::new_reflection_error(format!( + "No required access collected when unproxying type: `{}`.", + std::any::type_name::() + )) }) .and_then(|access| { - reflect_ref.expect_write_access(access, type_registry, guard.as_unsafe_world_cell()) + reflect_ref.expect_write_access( + access, + type_registry, + Some(allocator), + guard.as_unsafe_world_cell(), + ) })?; // Safety: @@ -339,12 +358,12 @@ where Some(allocator), )? }; - let out = out - .downcast_mut() - .ok_or_else(|| ReflectionError::CannotDowncast { - reference: reflect_ref.clone(), - to: std::any::type_name::().to_string(), - })?; + let out = out.downcast_mut().ok_or_else(|| { + ScriptError::new_reflection_error(format!( + "Could not downcast value from reflect reference to type: `{}`.", + std::any::type_name::() + )) + })?; Ok(out) } @@ -362,7 +381,7 @@ macro_rules! impl_unproxy_via_vec { &self, guard: &WorldAccessGuard<'w>, accesses: &mut SmallVec<[WorldAccessUnit<'w>; 1]>, - ) -> Result<(), ReflectionError> { + ) -> ScriptResult<()> { for item in self { item.collect_accesses(guard, accesses)?; } @@ -373,7 +392,7 @@ macro_rules! impl_unproxy_via_vec { self.iter().map(|item| item.accesses_len()).sum() } - fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { + fn unproxy(&mut self) -> ScriptResult> { let mut out = Vec::with_capacity(self.len()); for item in self { let unproxied = item.unproxy()?; @@ -388,10 +407,10 @@ macro_rules! impl_unproxy_via_vec { accesses: &'o [WorldAccessUnit<'w>], type_registry: &TypeRegistry, allocator: &'o ReflectAllocator, - ) -> Result, ReflectionError> { + ) -> ScriptResult> { let mut out = Vec::with_capacity(self.len()); let mut offset = 0; - for item in self { + for item in self.iter_mut() { let width = item.accesses_len(); let unproxied = item.unproxy_with_world( guard, @@ -409,11 +428,11 @@ macro_rules! impl_unproxy_via_vec { } macro_rules! impl_proxy_via_vec { - ($type:ty, $item_type:ty ,$in_type:ty, ($($generics:tt)*)) => { + ($type:ty, $item_type:ty, $in_type:ty, ($($generics:tt)*)) => { impl<$($generics)*> Proxy for $type { type Input<'i> = $in_type; - fn proxy(input: Self::Input<'_>) -> Result { + fn proxy(input: Self::Input<'_>) -> ScriptResult { let mut out = Vec::with_capacity(input.len()); for item in input { out.push(<$item_type as Proxy>::proxy(item)?); @@ -424,7 +443,7 @@ macro_rules! impl_proxy_via_vec { fn proxy_with_allocator( input: Self::Input<'_>, _allocator: &mut ReflectAllocator, - ) -> Result { + ) -> ScriptResult { let mut out = Vec::with_capacity(input.len()); for item in input { out.push(<$item_type as Proxy>::proxy_with_allocator(item, _allocator)?); @@ -438,61 +457,61 @@ macro_rules! impl_proxy_via_vec { impl_unproxy_via_vec!(Vec, Vec>, (T: Unproxy)); impl_proxy_via_vec!(Vec, T, Vec>, (T: Proxy)); impl_unproxy_via_vec!([T; C], [T::Output<'o>; C], (T: Unproxy, const C: usize)); -impl_proxy_via_vec!([T; C],T,[T::Input<'i>; C],(T: Proxy, const C: usize)); +impl_proxy_via_vec!([T; C],T,[T::Input<'i>; C], (T: Proxy, const C: usize)); impl_unproxy_via_vec!(SmallVec<[T; C]>, SmallVec<[T::Output<'o>; C]>, (T: Unproxy, const C: usize)); impl_proxy_via_vec!(SmallVec<[T; C]>, T, SmallVec<[T::Input<'i>; C]>, (T: Proxy, const C: usize)); // impl_proxy_unproxy_via_vec!(T, SmallVec, SmallVec<[T; C]>); -impl<'c, T: Unproxy + 'c> Unproxy for &'c T { - type Output<'o> = &'c T where Self: 'o; - - fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { - Ok(self) - } -} - -impl<'s, T: Proxy> Proxy for &'s T { - type Input<'b> = &'s T; - - fn proxy<'a>(input: Self::Input<'a>) -> Result { - Ok(input) - } - - fn proxy_with_allocator<'a>( - input: Self::Input<'a>, - _allocator: &mut ReflectAllocator, - ) -> Result { - Ok(input) - } -} - -impl Unproxy for &mut T { - type Output<'o> = &'o mut T where Self: 'o; - - fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { - Ok(self) - } -} - -impl<'s, T: Proxy> Proxy for &'s mut T { - type Input<'a> = &'s mut T; - - fn proxy<'a>(input: Self::Input<'a>) -> Result { - Ok(input) - } - - fn proxy_with_allocator<'a>( - input: Self::Input<'a>, - _allocator: &mut ReflectAllocator, - ) -> Result { - Ok(input) - } -} +// impl<'c, T: 'c> Unproxy for &'c T { +// type Output<'o> = &'c T where Self: 'o; + +// fn unproxy(&mut self) -> ScriptResult> { +// Ok(self) +// } +// } + +// impl<'s, T> Proxy for &'s T { +// type Input<'b> = &'s T; + +// fn proxy(input: Self::Input<'_>) -> ScriptResult { +// Ok(input) +// } + +// fn proxy_with_allocator( +// input: Self::Input<'_>, +// _allocator: &mut ReflectAllocator, +// ) -> ScriptResult { +// Ok(input) +// } +// } + +// impl Unproxy for &mut T { +// type Output<'o> = &'o mut T where Self: 'o; + +// fn unproxy(&mut self) -> ScriptResult> { +// Ok(self) +// } +// } + +// impl<'s, T> Proxy for &'s mut T { +// type Input<'a> = &'s mut T; + +// fn proxy(input: Self::Input<'_>) -> ScriptResult { +// Ok(input) +// } + +// fn proxy_with_allocator( +// input: Self::Input<'_>, +// _allocator: &mut ReflectAllocator, +// ) -> ScriptResult { +// Ok(input) +// } +// } impl Unproxy for Option { type Output<'o> = Option> where Self: 'o; - fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { + fn unproxy(&mut self) -> ScriptResult> { if let Some(s) = self { let inner = s.unproxy()?; Ok(Some(inner)) @@ -507,7 +526,7 @@ impl Unproxy for Option { accesses: &'o [WorldAccessUnit<'w>], type_registry: &TypeRegistry, allocator: &'o ReflectAllocator, - ) -> Result, ReflectionError> { + ) -> ScriptResult> { if let Some(s) = self { let inner = s.unproxy_with_world(guard, accesses, type_registry, allocator)?; Ok(Some(inner)) @@ -520,7 +539,7 @@ impl Unproxy for Option { &self, guard: &WorldAccessGuard<'w>, accesses: &mut SmallVec<[WorldAccessWrite<'w>; 1]>, - ) -> Result<(), ReflectionError> { + ) -> ScriptResult<()> { self.as_ref() .map(|s| s.collect_accesses(guard, accesses)) .unwrap_or_else(|| Ok(())) @@ -534,14 +553,14 @@ impl Unproxy for Option { impl Proxy for Option { type Input<'a> = Option>; - fn proxy<'a>(input: Self::Input<'a>) -> Result { + fn proxy(input: Self::Input<'_>) -> ScriptResult { input.map(T::proxy).transpose() } - fn proxy_with_allocator<'a>( - input: Self::Input<'a>, + fn proxy_with_allocator( + input: Self::Input<'_>, _allocator: &mut ReflectAllocator, - ) -> Result { + ) -> ScriptResult { input .map(|i| T::proxy_with_allocator(i, _allocator)) .transpose() @@ -550,15 +569,37 @@ impl Proxy for Option { macro_rules! impl_unproxy_by_move { ($($ty:ty),*) => { - $(impl Unproxy for $ty { - type Output<'o> = $ty; + $( + impl Unproxy for $ty { + type Output<'o> = $ty; + + fn unproxy( + &mut self + ) -> ScriptResult> { + Ok(*self) + } + } + + impl Unproxy for &$ty { + type Output<'o> = &'o $ty where Self : 'o; - fn unproxy<'o>( - &'o mut self - ) -> Result, ReflectionError> { - Ok(*self) + fn unproxy( + &mut self + ) -> ScriptResult> { + Ok(self) + } } - })* + + impl Unproxy for &mut $ty { + type Output<'o> = &'o mut $ty where Self : 'o; + + fn unproxy( + &mut self + ) -> ScriptResult> { + Ok(self) + } + } + )* }; } @@ -568,7 +609,23 @@ macro_rules! impl_proxy_by_move { impl Proxy for $ty { type Input<'a> = Self; - fn proxy<'a>(input: Self::Input<'a>) -> Result { + fn proxy(input: Self::Input<'_>) -> ScriptResult { + Ok(input) + } + } + + impl <'l>Proxy for &'l $ty { + type Input<'a> = Self; + + fn proxy(input: Self::Input<'_>) -> ScriptResult { + Ok(input) + } + } + + impl <'l>Proxy for &'l mut $ty { + type Input<'a> = Self; + + fn proxy(input: Self::Input<'_>) -> ScriptResult { Ok(input) } } @@ -629,7 +686,7 @@ macro_rules! impl_unproxy_by_clone { $(impl Unproxy for $ty { type Output<'o> = $ty; - fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { + fn unproxy(&mut self) -> ScriptResult> { Ok(self.clone()) } })* @@ -646,11 +703,11 @@ macro_rules! impl_tuple_unproxy_proxy { type Input<'a> = ($($ty::Input<'a>,)*); #[allow(clippy::unused_unit)] - fn proxy<'a>(_input: Self::Input<'a>) -> Result { + fn proxy(_input: Self::Input<'_>) -> ScriptResult { Ok(($($ty::proxy(_input.$idx)?,)*)) } - fn proxy_with_allocator<'a>(_input: Self::Input<'a>, _allocator: &mut ReflectAllocator) -> Result { + fn proxy_with_allocator(_input: Self::Input<'_>, _allocator: &mut ReflectAllocator) -> ScriptResult { Ok(($($ty::proxy_with_allocator(_input.$idx, _allocator)?,)*)) } } @@ -662,7 +719,7 @@ macro_rules! impl_tuple_unproxy_proxy { &self, _guard: &WorldAccessGuard<'w>, _accesses: &mut SmallVec<[WorldAccessWrite<'w>; 1]>, - ) -> Result<(), ReflectionError> { + ) -> ScriptResult<()> { $(self.$idx.collect_accesses(_guard, _accesses)?;)* Ok(()) } @@ -673,7 +730,7 @@ macro_rules! impl_tuple_unproxy_proxy { _len } - fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { + fn unproxy(&mut self) -> ScriptResult> { Ok(($( self.$idx.unproxy()? ,)*)) @@ -686,7 +743,7 @@ macro_rules! impl_tuple_unproxy_proxy { _accesses: &'o [WorldAccessUnit<'w>], _type_registry: &TypeRegistry, _allocator: &'o ReflectAllocator, - ) -> Result, ReflectionError> { + ) -> ScriptResult> { let mut _offset = 0; Ok(($( @@ -742,14 +799,10 @@ impl_tuple_unproxy_proxy!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6) #[cfg(test)] mod test { - use std::{cell::UnsafeCell, sync::Arc}; use bevy::ecs::{component::Component, world::World}; - use crate::{ - allocator::ReflectAllocation, - bindings::{ReflectBase, ReflectBaseType}, - }; + use crate::bindings::{ReflectBase, ReflectBaseType}; use super::*; @@ -794,13 +847,10 @@ mod test { let type_registry = TypeRegistry::default(); let mut allocator = ReflectAllocator::default(); - // test allocator version works as well - <$($proxy_ty)* as Proxy>::proxy_with_allocator($original, &mut allocator).unwrap(); - // test proxying works - let mut proxy = <$($proxy_ty)* as Proxy>::proxy($original).unwrap(); + // test with world version + let mut proxy = <$($proxy_ty)* as Proxy>::proxy_with_allocator($original, &mut allocator).unwrap(); proxy.collect_accesses(&world, &mut accesses).unwrap(); - // test both unproxy methods work let unproxied = unsafe { proxy .unproxy_with_world(&world, &mut accesses, &type_registry, &allocator) @@ -812,12 +862,15 @@ mod test { $original, unproxied ); + let mut proxy = <$($proxy_ty)* as Proxy>::proxy($original).unwrap(); + let unproxied_without_world = proxy.unproxy().unwrap(); assert_eq!( unproxied_without_world, $original, "Proxy and unproxy does not yield original type, expected {:?}, got {:?}", $original, unproxied_without_world ); + }; } @@ -845,7 +898,7 @@ mod test { Vec::>> ); assert_proxy_invertible!(vec![&1, &2, &3], Vec::<&usize>); - assert_proxy_invertible!(vec![&(1, 2)], Vec::<&(usize, usize)>); + // assert_proxy_invertible!(vec![&(1, 2)], Vec::<&(usize, usize)>); assert_proxy_invertible!(vec![vec![1, 2], vec![1, 2, 3]], Vec::>); assert_proxy_invertible!( vec![vec![(1, 2), (3, 4)], vec![(1, 2), (3, 4)]], @@ -865,9 +918,7 @@ mod test { #[test] pub fn test_val_proxy() { let mut allocator = ReflectAllocator::default(); - let alloc_id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(Test( - "test", - ))))); + let (alloc_id, _) = allocator.allocate(Test("test")); let mut proxy = ReflectValProxy::::new(TestProxy(ReflectReference { base: ReflectBaseType { @@ -893,9 +944,7 @@ mod test { #[test] pub fn test_proxy_ref() { let mut allocator = ReflectAllocator::default(); - let alloc_id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(Test( - "test", - ))))); + let (alloc_id, _) = allocator.allocate(Test("test")); let mut proxy = ReflectRefProxy::::new(TestProxy(ReflectReference { base: ReflectBaseType { @@ -921,9 +970,7 @@ mod test { #[test] pub fn test_proxy_ref_mut() { let mut allocator = ReflectAllocator::default(); - let alloc_id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(Test( - "test", - ))))); + let (alloc_id, _) = allocator.allocate(Test("test")); let mut proxy = ReflectRefMutProxy::::new(TestProxy(ReflectReference { base: ReflectBaseType { @@ -949,9 +996,7 @@ mod test { #[test] pub fn test_vec_proxy_ref_mut() { let mut allocator = ReflectAllocator::default(); - let alloc_id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(Test( - "test", - ))))); + let (alloc_id, _) = allocator.allocate(Test("test")); let mut proxy = vec![Some(ReflectRefMutProxy::::new(TestProxy( ReflectReference { @@ -980,9 +1025,7 @@ mod test { pub fn test_invalid_access() { let mut allocator = ReflectAllocator::default(); - let allocation_id = allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new( - Test("test"), - )))); + let (allocation_id, _) = allocator.allocate(Test("test")); let reflect_ref = ReflectReference { base: ReflectBaseType { @@ -1003,9 +1046,6 @@ mod test { let world = WorldAccessGuard::new(&mut world); let result = proxy.collect_accesses(&world, &mut accesses); - assert!(matches!( - result, - Err(ReflectionError::InsufficientAccess { .. }) - )); + assert!(matches!(result, Err(..))); } } diff --git a/crates/bevy_mod_scripting_core/src/bindings/reference.rs b/crates/bevy_mod_scripting_core/src/bindings/reference.rs new file mode 100644 index 00000000..5a7e615b --- /dev/null +++ b/crates/bevy_mod_scripting_core/src/bindings/reference.rs @@ -0,0 +1,501 @@ +//! # Motivation +//! +//! Traits and structs needed to support the creation of bindings for scripting languages. +//! reflection gives us access to `dyn Reflect` objects via their type name, +//! Scripting languages only really support `Clone` objects so if we want to support references, +//! we need wrapper types which have owned and ref variants. +use lockable::LockableHashMap; + +use std::{ + any::TypeId, + cell::UnsafeCell, + error::Error, + fmt::Debug, + marker::PhantomData, + ops::Index, + sync::{Arc, Weak}, + time::Duration, +}; + +use bevy::{ + ecs::{ + change_detection::MutUntyped, + component::{Component, ComponentId}, + entity::Entity, + reflect::AppTypeRegistry, + system::Resource, + world::{unsafe_world_cell::UnsafeWorldCell, Mut, World}, + }, + ptr::Ptr, + reflect::{ + Access, ParsedPath, Reflect, ReflectFromPtr, ReflectPath, ReflectPathError, TypeInfo, + TypeRegistry, + }, + utils::smallvec::SmallVec, +}; + +use crate::{ + bindings::{ReflectAllocation, ReflectAllocationId}, + prelude::{ReflectAllocator, ScriptError, ScriptResult}, +}; + +use super::{ + proxy::{Proxy, Unproxy}, + ReflectAccessId, ReflectAccessKind, WorldAccessGuard, WorldAccessWrite, DEFAULT_INTERVAL, + DEFAULT_TIMEOUT, +}; + +/// An accessor to a `dyn Reflect` struct, stores a base ID of the type and a reflection path +/// safe to build but to reflect on the value inside you need to ensure aliasing rules are upheld +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ReflectReference { + pub base: ReflectBaseType, + // TODO: experiment with Fixed capacity vec, boxed array etc, compromise between heap allocation and runtime cost + // needs benchmarks first though + /// The path from the top level type to the actual value we want to access + pub reflect_path: Vec, +} + +// just a dummy standin for unregistered types +struct UnregisteredType; + +impl ReflectReference { + + pub fn new_allocated( + value: T, + allocator: &mut ReflectAllocator, + ) -> ReflectReference { + let (id, _) = allocator.allocate(value); + ReflectReference { + base: ReflectBaseType { + type_id: TypeId::of::(), + base_id: ReflectBase::Owned(id), + }, + reflect_path: Vec::default(), + } + } + + /// Indexes into the reflect path inside this reference. + /// You can use [`Self::reflect`] and [`Self::reflect_mut`] to get the actual value. + pub fn index_path>(&mut self, index: T) { + self.reflect_path.push(index.into()); + } + + /// A form of [`Self::reflect`] which does the access checks for you. + /// Panics if it waits for access too long to prevent deadlocks. + pub fn with_reflect O>( + &self, + world: &WorldAccessGuard, + type_registry: &TypeRegistry, + allocator: Option<&ReflectAllocator>, + f: F, + ) -> O { + let access = world + .get_access_timeout( + self.base.base_id.get_reflect_access_id(), + DEFAULT_TIMEOUT, + DEFAULT_INTERVAL, + ) + .unwrap_or_else(|| panic!("Timeout when waiting for access for: `{:?}`", self)); + + let reflect = self + .reflect( + world.as_unsafe_world_cell(), + &access, + type_registry, + allocator, + ) + .unwrap(); + let o = f(reflect); + world.release_access(access); + o + } + + pub fn with_reflect_mut O>( + &self, + world: &WorldAccessGuard, + type_registry: &TypeRegistry, + allocator: Option<&ReflectAllocator>, + f: F, + ) -> O { + let mut access = world + .get_access_timeout( + self.base.base_id.get_reflect_access_id(), + DEFAULT_TIMEOUT, + DEFAULT_INTERVAL, + ) + .unwrap_or_else(|| panic!("Timeout when waiting for access for: `{:?}`", self)); + + let reflect = self + .reflect_mut( + world.as_unsafe_world_cell(), + &mut access, + type_registry, + allocator, + ) + .unwrap(); + let o = f(reflect); + world.release_access(access); + o + } + + /// Returns `Ok(())` if the given access is sufficient to read the value or an appropriate error otherwise + pub fn expect_read_access<'w>( + &self, + access: &WorldAccessWrite<'w>, + type_registry: &TypeRegistry, + allocator: Option<&ReflectAllocator>, + world: UnsafeWorldCell<'w>, + ) -> ScriptResult<()> { + if !access.can_read(self.base.base_id.get_reflect_access_id()) { + Err(ScriptError::new_reflection_error(format!( + "Invalid access when trying to read: `{}`, instead got access to `{}`", + self.base.display_with_type_name(type_registry), + access.to_enriched_str(type_registry, allocator, world) + ))) + } else { + Ok(()) + } + } + + /// Returns `Ok(())` if the given access is sufficient to write to the value or an appropriate error otherwise + /// Note that this is not sufficient for write access, you also need to ensure the [`WorldAccessWrite`] won't be used to access the same value mutably elsewhere, + /// if you have a `&mut WorldAccessWrite` you can guarantee this statically. This function just checks that the access itself is for the right base with write access + pub fn expect_write_access<'w>( + &self, + access: &WorldAccessWrite<'w>, + type_registry: &TypeRegistry, + allocator: Option<&ReflectAllocator>, + world: UnsafeWorldCell<'w>, + ) -> ScriptResult<()> { + if !access.can_read(self.base.base_id.get_reflect_access_id()) { + Err(ScriptError::new_reflection_error(format!( + "Invalid access when trying to write: `{}`, instead got access to `{}`", + self.base.display_with_type_name(type_registry), + access.to_enriched_str(type_registry, allocator, world) + ))) + } else { + Ok(()) + } + } + + /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell. + /// If the underlying componentId is not the same as the one we have access to, an error is returned. + pub fn reflect<'w, 'c>( + &self, + world: UnsafeWorldCell<'w>, + access: &'c WorldAccessWrite<'w>, + type_registry: &TypeRegistry, + allocator: Option<&'c ReflectAllocator>, + ) -> ScriptResult<&'c dyn Reflect> { + self.expect_read_access(access, type_registry, allocator, world)?; + // Safety: since we have read access to the underlying componentId we can safely access the component + // and we can return a reference tied to its lifetime, which will prevent invalid aliasing + return unsafe { self.reflect_unsafe(world, type_registry, allocator) }; + } + + /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell. + /// If the underlying componentId is not the same as the one we have access to, an error is returned. + /// + /// If we are accessing a component or resource, it's marked as changed + pub fn reflect_mut<'w, 'c>( + &self, + world: UnsafeWorldCell<'w>, + access: &'c mut WorldAccessWrite<'w>, + type_registry: &TypeRegistry, + allocator: Option<&'c ReflectAllocator>, + ) -> ScriptResult<&'c mut dyn Reflect> { + self.expect_write_access(access, type_registry, allocator, world)?; + // Safety: since we have write access to the underlying reflect access id we can safely access the component + // and we can return a reference tied to its lifetime, which will prevent invalid aliasing + return unsafe { self.reflect_mut_unsafe(world, type_registry, allocator) }; + } + + /// Retrieves a reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell + /// # Safety + /// - The caller must ensure the cell has permission to access the underlying value + /// - The caller must ensure no aliasing mut references to the same value exist at all at the same time + pub unsafe fn reflect_unsafe<'w>( + &self, + world: UnsafeWorldCell<'w>, + type_registry: &TypeRegistry, + allocator: Option<&'w ReflectAllocator>, + ) -> ScriptResult<&'w dyn Reflect> { + if let ReflectBase::Owned(id) = &self.base.base_id { + let allocator = + allocator.ok_or_else(|| ScriptError::new_reflection_error("Allocator missing"))?; + let arc = allocator + .get(*id) + .ok_or_else(|| ScriptError::new_reflection_error("Missing allocation"))?; + + // safety: caller promises it's fine :) + return self.walk_path(unsafe { &*arc.get_ptr() }); + }; + // all Reflect types should have this derived + let from_ptr_data: &ReflectFromPtr = type_registry + .get_type_data(self.base.type_id) + .expect("FromPtr is not registered for this type, cannot retrieve reflect reference"); + + let ptr = self + .base + .base_id + .clone() + .into_ptr(world) + .ok_or_else(|| + ScriptError::new_reflection_error( + format!("Base reference is invalid, is the component/resource initialized? does the entity exist?. When accessing: `{}`", self.base.display_with_type_name(type_registry))))?; + + // (Ptr) Safety: we use the same type_id to both + // 1) retrieve the ptr + // 2) retrieve the ReflectFromPtr type data + // (UnsafeWorldCell) Safety: + // we already have access to &world so no &mut world exists + debug_assert_eq!( + from_ptr_data.type_id(), + self.base.type_id, + "Invariant violated" + ); + let base = unsafe { from_ptr_data.as_reflect(ptr) }; + self.walk_path(base) + } + + /// Retrieves mutable reference to the underlying `dyn Reflect` type valid for the 'w lifetime of the world cell + /// # Safety + /// - The caller must ensure the cell has permission to access the underlying value + /// - The caller must ensure no other references to the same value exist at all at the same time (even if you have the correct access) + pub unsafe fn reflect_mut_unsafe<'w>( + &self, + world: UnsafeWorldCell<'w>, + type_registry: &TypeRegistry, + allocator: Option<&'w ReflectAllocator>, + ) -> ScriptResult<&'w mut dyn Reflect> { + if let ReflectBase::Owned(id) = &self.base.base_id { + let allocator = allocator.ok_or_else(|| ScriptError::new_reflection_error("Allocator missing"))?; + + let arc = allocator + .get_mut(*id) + .ok_or_else(|| ScriptError::new_reflection_error("Missing allocation"))?; + + // Safety: caller promises this is fine :) + return self.walk_path_mut(unsafe { &mut *arc.get_ptr() }); + }; + + // all Reflect types should have this derived + let from_ptr_data: &ReflectFromPtr = type_registry + .get_type_data(self.base.type_id) + .expect("FromPtr is not registered for this type, cannot retrieve reflect reference"); + + let ptr = self + .base + .base_id + .clone() + .into_ptr_mut(world) + .ok_or_else(|| + ScriptError::new_reflection_error( + format!("Base reference is invalid, is the component/resource initialized? does the entity exist?. When accessing: `{}`", self.base.display_with_type_name(type_registry))))? + .into_inner(); + + // (Ptr) Safety: we use the same type_id to both + // 1) retrieve the ptr + // 2) retrieve the ReflectFromPtr type data + // (UnsafeWorldCell) Safety: + // we already have access to &world so no &mut world exists + debug_assert_eq!( + from_ptr_data.type_id(), + self.base.type_id, + "Invariant violated" + ); + let base = unsafe { from_ptr_data.as_reflect_mut(ptr) }; + self.walk_path_mut(base) + } + + fn walk_path<'a>(&self, root: &'a dyn Reflect) -> ScriptResult<&'a dyn Reflect> { + let mut current = root; + for elem in self.reflect_path.iter() { + current = elem + .reflect_element(current) + .map_err(|e| ScriptError::new_reflection_error(e.to_string()))?; + } + Ok(current) + } + + fn walk_path_mut<'a>(&self, root: &'a mut dyn Reflect) -> ScriptResult<&'a mut dyn Reflect> { + let mut current = root; + for elem in self.reflect_path.iter() { + current = elem + .reflect_element_mut(current) + .map_err(|e| ScriptError::new_reflection_error(e.to_string()))?; + } + Ok(current) + } +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ReflectBaseType { + pub type_id: TypeId, + pub base_id: ReflectBase, +} + +impl ReflectBaseType { + pub fn type_name(type_id: TypeId, type_registry: &TypeRegistry) -> &'static str { + type_registry + .get_type_info(type_id) + .map(TypeInfo::type_path) + .unwrap_or("") + } + + pub fn display_with_type_name(&self, type_registry: &TypeRegistry) -> String { + format!( + "ReflectBase({}, {:?})", + Self::type_name(self.type_id, type_registry), + self.base_id + ) + } +} + +/// The Id of the kind of reflection base being pointed to +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum ReflectBase { + Component(Entity, ComponentId), + Resource(ComponentId), + Owned(ReflectAllocationId), +} + +impl ReflectBase { + /// Retrieves the pointer to the underlying `dyn Reflect` object valid for the 'w lifteime of the world cell + /// + /// # Safety + /// - The caller must ensure the cell has permission to access the underlying value + /// - The caller must ensure no aliasing mutable references to the same value exist at the same time + pub unsafe fn into_ptr(self, world: UnsafeWorldCell<'_>) -> Option> { + match self { + ReflectBase::Component(entity, component_id) => { + // Safety: the caller ensures invariants hold + world.get_entity(entity)?.get_by_id(component_id) + } + ReflectBase::Resource(component_id) => { + // Safety: the caller ensures invariants hold + world.get_resource_by_id(component_id) + } + _ => None, + } + } + + /// Retrieves the pointer to the underlying `dyn Reflect` object valid for the 'w lifteime of the world cell + /// + /// # Safety + /// - The caller must ensure the cell has permission to access the underlying value + /// - The caller must ensure no aliasing references to the same value exist at all at the same time + pub unsafe fn into_ptr_mut(self, world: UnsafeWorldCell<'_>) -> Option> { + match self { + ReflectBase::Component(entity, component_id) => { + // Safety: the caller ensures invariants hold + world.get_entity(entity)?.get_mut_by_id(component_id) + } + ReflectBase::Resource(component_id) => { + // Safety: the caller ensures invariants hold + world.get_resource_mut_by_id(component_id) + } + _ => None, + } + } + + pub fn get_reflect_access_id(&self) -> ReflectAccessId { + match self { + ReflectBase::Component(_, cid) | ReflectBase::Resource(cid) => (*cid).into(), + ReflectBase::Owned(id) => (*id).into(), + } + } +} + +/// An element in the reflection path, the base reference included +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum ReflectionPathElem { + /// A standard reflection path, i.e. `.field_name[vec_index]`, pre-parsed since we construct once potentially use many times + Reflection(ParsedPath), + /// a deferred reflection + DeferredReflection(DeferredReflection), +} + +impl ReflectionPathElem { + pub fn new_reflection>(path: I) -> Self { + Self::Reflection(path.into()) + } + + pub fn new_deferred>(defref: I) -> Self { + Self::DeferredReflection(defref.into()) + } +} + +impl From<(A, B)> for DeferredReflection +where + A: Fn(&dyn Reflect) -> Result<&dyn Reflect, ReflectPathError<'static>> + Send + Sync, + B: Fn(&mut dyn Reflect) -> Result<&mut dyn Reflect, ReflectPathError<'static>> + Send + Sync, +{ + fn from((get, get_mut): (A, B)) -> Self { + Self { + get: Arc::new(get), + get_mut: Arc::new(get_mut), + } + } +} + +impl> From for ReflectionPathElem { + fn from(value: T) -> Self { + Self::DeferredReflection(value.into()) + } +} + +impl From for ReflectionPathElem { + fn from(value: ParsedPath) -> Self { + Self::Reflection(value) + } +} + +impl<'a> ReflectPath<'a> for &'a ReflectionPathElem { + fn reflect_element<'r>( + self, + root: &'r dyn Reflect, + ) -> Result<&'r dyn Reflect, ReflectPathError<'a>> { + match self { + ReflectionPathElem::Reflection(path) => path.reflect_element(root), + ReflectionPathElem::DeferredReflection(f) => (f.get)(root), + } + } + + fn reflect_element_mut<'r>( + self, + root: &'r mut dyn Reflect, + ) -> Result<&'r mut dyn Reflect, ReflectPathError<'a>> { + match self { + ReflectionPathElem::Reflection(path) => path.reflect_element_mut(root), + ReflectionPathElem::DeferredReflection(defref) => (defref.get_mut)(root), + } + } +} + +/// A ReflectPath which can perform arbitrary operations on the root object to produce a sub-reference +#[derive(Clone)] +pub struct DeferredReflection { + pub get: + Arc Result<&dyn Reflect, ReflectPathError<'static>> + Send + Sync>, + pub get_mut: Arc< + dyn Fn(&mut dyn Reflect) -> Result<&mut dyn Reflect, ReflectPathError<'static>> + + Send + + Sync, + >, +} + +impl Debug for DeferredReflection { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str("DeferredReflection") + } +} + +impl PartialEq for DeferredReflection { + fn eq(&self, other: &Self) -> bool { + Arc::ptr_eq(&self.get, &other.get) && Arc::ptr_eq(&self.get_mut, &other.get_mut) + } +} + +impl Eq for DeferredReflection {} diff --git a/crates/bevy_mod_scripting_core/src/bindings/world.rs b/crates/bevy_mod_scripting_core/src/bindings/world.rs new file mode 100644 index 00000000..84a7396d --- /dev/null +++ b/crates/bevy_mod_scripting_core/src/bindings/world.rs @@ -0,0 +1,1815 @@ +//! # Motivation +//! +//! Traits and structs needed to support the creation of bindings for scripting languages. +//! reflection gives us access to `dyn Reflect` objects via their type name, +//! Scripting languages only really support `Clone` objects so if we want to support references, +//! we need wrapper types which have owned and ref variants. +use lockable::LockableHashMap; + +use std::{ + any::TypeId, + cell::UnsafeCell, + error::Error, + fmt::Debug, + marker::PhantomData, + ops::Index, + sync::{ + atomic::{AtomicBool, AtomicUsize, Ordering}, + Arc, Weak, + }, + time::Duration, +}; + +use bevy::{ + ecs::{ + change_detection::MutUntyped, + component::{Component, ComponentId}, + entity::Entity, + reflect::{AppTypeRegistry, ReflectComponent, ReflectFromWorld, ReflectResource}, + system::{CommandQueue, Commands, Resource}, + world::{unsafe_world_cell::UnsafeWorldCell, Mut, World}, + }, + hierarchy::{BuildChildren, Children, DespawnRecursiveExt, Parent}, + ptr::Ptr, + reflect::{ + std_traits::ReflectDefault, Access, ParsedPath, Reflect, ReflectFromPtr, ReflectPath, + ReflectPathError, TypeInfo, TypeRegistration, TypeRegistry, + }, + utils::smallvec::SmallVec, +}; + +use crate::{ + bindings::{ReflectAllocation, ReflectAllocationId}, + prelude::{ReflectAllocator, ScriptError, ScriptResult}, +}; + +use super::{ + proxy::{Proxy, Unproxy}, + ReflectBase, ReflectBaseType, ReflectReference, +}; + +/// Describes kinds of base value we are accessing via reflection +#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] +pub enum ReflectAccessKind { + ComponentOrResource, + Allocation, +} + +/// Describes the id pointing to the base value we are accessing via reflection, for components and resources this is the ComponentId +/// for script owned values this is an allocationId, this is used to ensure we have permission to access the value. +#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] +pub struct ReflectAccessId { + kind: ReflectAccessKind, + id: usize, +} + +impl From for ReflectAccessId { + fn from(value: ComponentId) -> Self { + Self { + kind: ReflectAccessKind::ComponentOrResource, + id: value.index(), + } + } +} + +impl From for ReflectAccessId { + fn from(value: ReflectAllocationId) -> Self { + Self { + kind: ReflectAccessKind::Allocation, + id: value.id(), + } + } +} + +/// While [`WorldAccessGuard`] prevents aliasing at runtime and also makes sure world exists at least as long as the guard itself, +/// borrows sadly do not persist the script-host boundary :(. That is to be expected, but instead we can make an abstraction which removes the lifetime parameter, making the outer type 'static, +/// while making sure the lifetime is still satisfied! +#[derive(Clone)] +pub struct WorldCallbackAccess(Weak>); + +impl WorldCallbackAccess { + /// Wraps a callback which requires access to the world in a 'static way via [`WorldCallbackAccess`]. + pub fn with_callback_access( + world: &mut World, + callback: impl FnOnce(&WorldCallbackAccess) -> T, + ) -> T { + // - the world cannot be dropped before the world drops since we have mutable reference to it in this entire function + // - nothing can alias inappropriately WorldAccessGuard since it's only instance is behind the raw Arc + let world_guard = Arc::new(WorldAccessGuard::new(world)); + let world_guard = unsafe { WorldCallbackAccess::new(Arc::downgrade(&world_guard)) }; + + callback(&world_guard) + } + + /// Creates a new [`WorldCallbackAccess`] with an erased lifetime. + /// + /// # Safety + /// - The caller must ensure the [`WorldAccessGuard`] must not outlive the 'w lifetime + /// - In practice this means that between the moment the original Arc is dropped, the lifetime 'w must be valid + /// - I.e. you *must* drop the original [`Arc`] before the original 'w scope ends + pub unsafe fn new<'w>(world: Weak>) -> Self { + // Safety: the caller ensures `WorldAccessGuard` does not outlive the original lifetime 'w + + let world = unsafe { + std::mem::transmute::>, Weak>>( + world, + ) + }; + + Self(world) + } + + /// Attempts to read the world access guard, if it still exists + pub fn read(&self) -> Option>> { + self.0.upgrade() + } +} + +const STALE_WORLD_MSG: &str = "Tried to access world via stale reference"; +const CONCURRENT_WORLD_ACCESS_MSG: &str = "Something else is accessing the world right now!"; +const CONCURRENT_ACCESS_MSG: &str = + "Something else is accessing the resource/component/allocation right now!"; + +/// common world methods +impl WorldCallbackAccess { + pub fn get_type_by_name(&self, type_name: &str) -> Option> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + world.with_resource(|_, registry: Mut| { + let registry = registry.read(); + registry + .get_with_short_type_path(type_name) + .or_else(|| registry.get_with_type_path(type_name)) + .map(|registration| Arc::new(registration.clone())) + }) + } + + pub fn add_default_component( + &self, + entity: Entity, + registration: Arc, + ) -> ScriptResult<()> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + let component_data = registration.data::().ok_or_else(|| ScriptError::new_runtime_error(format!( + "Cannot add default component since type: `{}`, Does not have ReflectComponent data registered.", + registration.type_info().type_path() + )))?; + + // we look for ReflectDefault or ReflectFromWorld data then a ReflectComponent data + let instance = if let Some(default_td) = registration.data::() { + default_td.default() + } else if let Some(from_world_td) = registration.data::() { + if let Some(world) = world.get_whole_world_access() { + from_world_td.from_world(world) + } else { + panic!("{CONCURRENT_WORLD_ACCESS_MSG}") + } + } else { + return Err(ScriptError::new_runtime_error(format!( + "Cannot add default component since type: `{}`, Does not have ReflectDefault or ReflectFromWorld data registered.", + registration.type_info().type_path() + ))); + }; + + // TODO: this shouldn't need entire world access it feels + if let Some(world) = world.get_whole_world_access() { + let app_registry = world + .remove_resource::() + .unwrap_or_else(|| panic!("Missing type registry")); + + let mut entity = world.get_entity_mut(entity).ok_or_else(|| { + ScriptError::new_runtime_error(format!("Entity does not exist: {:?}", entity)) + })?; + { + let registry = app_registry.read(); + component_data.insert(&mut entity, instance.as_ref(), ®istry); + } + world.insert_resource(app_registry); + } else { + panic!("{CONCURRENT_WORLD_ACCESS_MSG}") + } + + Ok(()) + } + + pub fn get_component( + &self, + entity: Entity, + component_id: ComponentId, + ) -> ScriptResult> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + let entity = world.cell.get_entity(entity).ok_or_else(|| { + ScriptError::new_runtime_error(format!("Entity does not exist: {:?}", entity)) + })?; + + let component_info = world + .cell + .components() + .get_info(component_id) + .ok_or_else(|| { + ScriptError::new_runtime_error(format!( + "Component does not exist: {:?}", + component_id + )) + })?; + + if entity.contains_id(component_id) { + Ok(Some(ReflectReference { + base: ReflectBaseType { + type_id: component_info + .type_id() + .expect("Component does not have type id"), + base_id: ReflectBase::Component(entity.id(), component_id), + }, + reflect_path: Default::default(), + })) + } else { + Ok(None) + } + } + + pub fn has_component(&self, entity: Entity, component_id: ComponentId) -> ScriptResult { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + let entity = world.cell.get_entity(entity).ok_or_else(|| { + ScriptError::new_runtime_error(format!("Entity does not exist: {:?}", entity)) + })?; + + Ok(entity.contains_id(component_id)) + } + + pub fn remove_component( + &self, + entity: Entity, + registration: Arc, + ) -> ScriptResult<()> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + let component_data = registration.data::().ok_or_else(|| ScriptError::new_runtime_error(format!( + "Cannot remove component since type: `{}`, Does not have ReflectComponent data registered.", + registration.type_info().type_path() + )))?; + + // TODO: this shouldn't need entire world access it feels + if let Some(world) = world.get_whole_world_access() { + let mut entity = world.get_entity_mut(entity).ok_or_else(|| { + ScriptError::new_runtime_error(format!("Entity does not exist: {:?}", entity)) + })?; + + component_data.remove(&mut entity); + } else { + panic!("{CONCURRENT_WORLD_ACCESS_MSG}") + } + Ok(()) + } + + pub fn get_resource(&self, resource_id: ComponentId) -> ScriptResult { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + let component_info = world + .cell + .components() + .get_info(resource_id) + .ok_or_else(|| { + ScriptError::new_runtime_error(format!( + "Resource does not exist: {:?}", + resource_id + )) + })?; + + Ok(ReflectReference { + base: ReflectBaseType { + type_id: component_info + .type_id() + .expect("Resource does not have type id"), + base_id: ReflectBase::Resource(resource_id), + }, + reflect_path: Default::default(), + }) + } + + pub fn remove_resource(&self, registration: Arc) -> ScriptResult<()> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + let component_data = registration.data::().ok_or_else(|| ScriptError::new_runtime_error(format!( + "Cannot remove resource since type: `{}`, Does not have ReflectResource data registered.", + registration.type_info().type_path() + )))?; + + // TODO: this shouldn't need entire world access it feels + if let Some(world) = world.get_whole_world_access() { + component_data.remove(world); + } else { + panic!("{CONCURRENT_WORLD_ACCESS_MSG}") + } + Ok(()) + } + + pub fn has_resource(&self, resource_id: ComponentId) -> bool { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + world.cell.components().get_info(resource_id).is_some() + } + + pub fn get_children(&self, entity: Entity) -> ScriptResult> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + let access = world + .get_component_access_typed::() + .unwrap_or_else(|| panic!("{CONCURRENT_ACCESS_MSG}")); + + Ok(world + .get_component::(&access, entity)? + .map(|c| c.to_vec()) + .unwrap_or_default()) + } + + pub fn get_parent(&self, entity: Entity) -> ScriptResult> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + let access = world + .get_component_access_typed::() + .unwrap_or_else(|| panic!("{CONCURRENT_ACCESS_MSG}")); + + Ok(world + .get_component::(&access, entity)? + .map(|c| c.get())) + } + + pub fn push_children(&self, parent: Entity, children: &[Entity]) -> ScriptResult<()> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + if let Some(world) = world.get_whole_world_access() { + let mut queue = CommandQueue::default(); + let mut commands = Commands::new(&mut queue, world); + commands.entity(parent).push_children(children); + queue.apply(world); + } else { + panic!("{CONCURRENT_WORLD_ACCESS_MSG}") + } + + Ok(()) + } + + pub fn remove_children(&self, parent: Entity, children: &[Entity]) -> ScriptResult<()> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + if let Some(world) = world.get_whole_world_access() { + let mut queue = CommandQueue::default(); + let mut commands = Commands::new(&mut queue, world); + commands.entity(parent).remove_children(children); + queue.apply(world); + } else { + panic!("{CONCURRENT_WORLD_ACCESS_MSG}") + } + + Ok(()) + } + + pub fn insert_children( + &self, + parent: Entity, + index: usize, + children: &[Entity], + ) -> ScriptResult<()> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + if let Some(world) = world.get_whole_world_access() { + let mut queue = CommandQueue::default(); + let mut commands = Commands::new(&mut queue, world); + commands.entity(parent).insert_children(index, children); + queue.apply(world); + } else { + panic!("{CONCURRENT_WORLD_ACCESS_MSG}") + } + + Ok(()) + } + + pub fn despawn_recursive(&self, entity: Entity) -> ScriptResult<()> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + if let Some(world) = world.get_whole_world_access() { + let mut queue = CommandQueue::default(); + let mut commands = Commands::new(&mut queue, world); + commands.entity(entity).despawn_recursive(); + queue.apply(world); + } else { + panic!("{CONCURRENT_WORLD_ACCESS_MSG}") + } + + Ok(()) + } + + pub fn despawn(&self, entity: Entity) -> ScriptResult<()> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + if let Some(world) = world.get_whole_world_access() { + let mut queue = CommandQueue::default(); + let mut commands = Commands::new(&mut queue, world); + commands.entity(entity).despawn(); + queue.apply(world); + } else { + panic!("{CONCURRENT_WORLD_ACCESS_MSG}") + } + + Ok(()) + } + + pub fn despawn_descendants(&self, entity: Entity) -> ScriptResult<()> { + let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); + + if let Some(world) = world.get_whole_world_access() { + let mut queue = CommandQueue::default(); + let mut commands = Commands::new(&mut queue, world); + commands.entity(entity).despawn_descendants(); + queue.apply(world); + } else { + panic!("{CONCURRENT_WORLD_ACCESS_MSG}") + } + + Ok(()) + } +} + +/// Unit of world access +pub type WorldAccessUnit<'w> = WorldAccessWrite<'w>; + +pub const DEFAULT_TIMEOUT: Duration = Duration::from_secs(5); +pub const DEFAULT_INTERVAL: Duration = Duration::from_millis(10); + +/// Provides safe access to the world via [`WorldAccess`] permissions, which enforce aliasing rules at runtime in multi-thread environments +#[derive(Clone)] +pub struct WorldAccessGuard<'w> { + cell: UnsafeWorldCell<'w>, + // TODO: this is fairly hefty, explore other ways to hand out locks on WorldAccess + accesses: Arc>>>, + /// true if anybody has any access to the world + accesses_count: Arc, + // TODO can we track code/stack locations of things holding onto theese locks for debugging? +} + +impl<'w> WorldAccessGuard<'w> { + /// Creates a new [`WorldAccessGuard`] for the given mutable borrow of the world + pub fn new(world: &'w mut World) -> Self { + Self { + cell: world.as_unsafe_world_cell(), + accesses: Default::default(), + accesses_count: Arc::new(AtomicUsize::new(0)), + } + } + + /// Retrieves the underlying unsafe world cell, with no additional guarantees of safety + /// proceed with caution and only use this if you understand what you're doing + pub fn as_unsafe_world_cell(&self) -> UnsafeWorldCell<'w> { + self.cell + } + + /// Retrieves the underlying read only unsafe world cell, with no additional guarantees of safety + /// proceed with caution and only use this if you understand what you're doing + pub fn as_unsafe_world_cell_readonly(&self) -> UnsafeWorldCell<'w> { + self.cell + } + + /// Checks nobody else is currently accessing the world, and if so locks access to it until + /// [`release_whole_world_access`] is called. + pub fn get_whole_world_access(&self) -> Option<&mut World> { + if self.accesses_count.load(Ordering::Relaxed) == 0 { + Some(unsafe { self.cell.world_mut() }) + } else { + None + } + } + + /// Releases whole world access. Allowing others to access it. + pub fn release_whole_world_access(&self, _world: &mut World) { + // we do not need ot use the world reference, it's there as proof that the caller has claimed access before + assert_eq!(self.accesses_count.load(Ordering::Relaxed), 1); + self.accesses_count.fetch_sub(1, Ordering::Relaxed); + } + + /// Tries to get access to the given reflect access id, if it's already given out returns `None`. If you want to wait for access, use [`WorldAccessGuard::get_access_timeout`] instead. + /// Remember to release this access once done with [`WorldAccessGuard::release_access`] or nobody else will be able to access this id!. + /// + /// Although forgetting to release access is safe, it's frankly quite rude and can lead to deadlocks. + pub fn get_access(&self, raid: ReflectAccessId) -> Option> { + let mut guard = self + .accesses + .blocking_lock(raid, lockable::SyncLimit::no_limit()) + .unwrap(); + let guard = guard.value_or_insert_with(|| { + Some(WorldAccessWrite { + raid, + _ph: PhantomData, + }) + }); + + if guard.is_some() { + self.accesses_count.fetch_add(1, Ordering::Relaxed); + guard.take() + } else { + // somebody has access to this already, we cannot access at the moment + None + } + } + + /// Blocking version of [`WorldAccessGuard::get_access`], waits for access to the given reflect access id. Will busy wait at the given intervals, untill the timeout is reached. + /// If interval is zero this is equivalent to busy waiting. + /// + /// # Panic + /// Will panic once access was not available after the timeout was reached + pub fn get_access_timeout( + &self, + raid: ReflectAccessId, + timeout: Duration, + interval: Duration, + ) -> Option> { + let mut access = self.get_access(raid); + let start = std::time::Instant::now(); + + while access.is_none() { + std::thread::sleep(interval); + access = self.get_access(raid); + if start.elapsed() > timeout { + return None; + } + } + access + } + + /// Releases access to the given reflect access id + pub fn release_access(&self, access: WorldAccessUnit<'w>) { + let mut guard = self + .accesses + .blocking_lock(access.raid, lockable::SyncLimit::no_limit()) + .unwrap(); + + let guard = guard + .value_mut() + .expect("Invariant violated, access should exist"); + + // should not be possible, we are the only ones who can instantiate WorldAccessUnit + assert!( + guard.is_none(), + "Invariant violated, an access has been released by someone else already who shouldn't have been able to do so" + ); + + self.accesses_count.fetch_sub(1, Ordering::Relaxed); + *guard = Some(access); + } + + /// Get access to the given component_id, this is the only way to access a component/resource safely (in the context of the world access guard) + /// since you can only access this component_id through a RwLock, there is no way to break aliasing rules. + /// Additionally the 'w lifetime prevents you from storing this access outside the lifetime of the underlying cell + pub fn get_component_access(&self, cid: ComponentId) -> Option> { + let access_id = ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: cid.index(), + }; + self.get_access(access_id) + } + + /// Similar to [`Self::get_component_access`] but typed, additionally panics if the component is not registered + pub fn get_component_access_typed(&self) -> Option> { + self.get_component_access( + self.cell + .components() + .component_id::() + .unwrap_or_else(|| { + panic!("Component not registered: `{}`", std::any::type_name::()) + }), + ) + } + + /// Get access to the given component_id, this is the only way to access a component/resource safely (in the context of the world access guard) + /// since you can only access this component_id through a RwLock, there is no way to break aliasing rules. + /// Additionally the 'w lifetime prevents you from storing this access outside the lifetime of the underlying cell + pub fn get_resource_access(&self, cid: ComponentId) -> Option> { + self.get_component_access(cid) + } + + /// Similar to [`Self::get_resource_access`] but typed, additionally panics if the resource is not registered + pub fn get_resource_access_typed(&self) -> Option> { + self.get_resource_access( + self.cell + .components() + .resource_id::() + .unwrap_or_else(|| { + panic!("Resource not registered: `{}`", std::any::type_name::()) + }), + ) + } + + /// Get access to the given allocation_id, this is the only way to access a script owned value safely (in the context of the world access guard) + pub fn get_allocation_access(&self, id: ReflectAllocationId) -> Option> { + let access_id = ReflectAccessId { + kind: ReflectAccessKind::Allocation, + id: id.id(), + }; + self.get_access(access_id) + } + + /// Provides access to a resource via callback. Panics if the resource does not exist or if waiting for access times out. + pub fn with_resource) -> O>(&self, f: F) -> O { + let cid = self + .cell + .components() + .resource_id::() + .unwrap_or_else(|| panic!("Resource not registered: `{}`", std::any::type_name::())); + + let mut access = self + .get_access_timeout(cid.into(), DEFAULT_TIMEOUT, DEFAULT_INTERVAL) + .unwrap_or_else(|| { + panic!( + "Timed out while waiting for access to resource: `{}`", + std::any::type_name::() + ) + }); + + let resource = self + .get_resource_mut::(&mut access) + .expect("invariant") + .expect("invariant"); + let out = f(self, resource); + self.release_access(access); + out + } + + /// Call a function on a type which can be proxied, first by unproxying the input with world access, + /// then calling the function and finally proxying the output with the allocator. + pub fn proxy_call<'i, O: Proxy, T: Unproxy, F: Fn(T::Output<'_>) -> O::Input<'i>>( + &self, + mut proxied_input: T, + f: F, + ) -> ScriptResult { + self.with_resource(|world, type_registry: Mut| { + world.with_resource(|_, mut allocator: Mut| { + let type_registry = type_registry.read(); + let mut world_acceses = SmallVec::default(); + + proxied_input.collect_accesses(self, &mut world_acceses)?; + let input = unsafe { + proxied_input.unproxy_with_world( + self, + &world_acceses, + &type_registry, + &allocator, + )? + }; + let out = f(input); + + O::proxy_with_allocator(out, &mut allocator) + }) + }) + } + + /// Get access to the given component, this is the only way to access a component/resource safely (in the context of the world access guard) + pub fn get_component( + &self, + access: &WorldAccessWrite, + entity: Entity, + ) -> ScriptResult> { + let component_id = match self.cell.components().component_id::() { + Some(id) => id, + None => return Ok(None), + }; + + if access.can_read(ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: component_id.index(), + }) { + // Safety: we have the correct access id + return unsafe { Ok(self.cell.get_entity(entity).and_then(|e| e.get::())) }; + } else { + Err(ScriptError::new_reflection_error( + "Cannot read component, received invalid access".to_string(), + )) + } + } + + /// Get access to the given component, this is the only way to access a component/resource safely (in the context of the world access guard) + pub fn get_component_mut( + &self, + access: &mut WorldAccessWrite, + entity: Entity, + ) -> ScriptResult>> { + let component_id = match self.cell.components().component_id::() { + Some(id) => id, + None => return Ok(None), + }; + + if access.can_write(ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: component_id.index(), + }) { + // Safety: we have the correct access id + return unsafe { Ok(self.cell.get_entity(entity).and_then(|e| e.get_mut::())) }; + } else { + Err(ScriptError::new_reflection_error( + "Cannot write component, received invalid access".to_string(), + )) + } + } + + /// Get access to the given resource + pub fn get_resource(&self, access: &WorldAccessWrite) -> ScriptResult> { + let resource_id = match self.cell.components().resource_id::() { + Some(id) => id, + None => return Ok(None), + }; + + if access.can_read(ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: resource_id.index(), + }) { + // Safety: we have the correct access id + return unsafe { Ok(self.cell.get_resource::()) }; + } else { + Err(ScriptError::new_reflection_error( + "Cannot read resource, received invalid access".to_string(), + )) + } + } + + /// Get access to the given resource, this is the only way to access a component/resource safely (in the context of the world access guard) + pub fn get_resource_mut( + &self, + access: &mut WorldAccessWrite, + ) -> ScriptResult>> { + let resource_id = match self.cell.components().resource_id::() { + Some(id) => id, + None => return Ok(None), + }; + + if access.can_write(ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: resource_id.index(), + }) { + // Safety: we have the correct access id + return unsafe { Ok(self.cell.get_resource_mut::()) }; + } else { + Err(ScriptError::new_reflection_error( + "Cannot write resource, received invalid access".to_string(), + )) + } + } +} + +/// Having this is permission to access the contained [`ReflectAccessId`], there is no way to access anything safely through a [`WorldAccessGuard`] +/// without having a [`WorldAccess`] instance for that particular [`ReflectAccessId`]. +/// +/// If you do own a [`WorldAccess`] for some [`ReflectAccessId`], you can read and write to it safely. +/// If you only have an immutable borrow of [`WorldAccess`] you can only read it safely. +/// If you have a mutable borrow of [`WorldAccess`] you can read and write to it safely. +#[derive(Debug)] +pub struct WorldAccessWrite<'a> { + pub raid: ReflectAccessId, + pub(self) _ph: PhantomData<&'a usize>, +} + +impl<'w> WorldAccessWrite<'w> { + pub fn can_read(&self, raid: ReflectAccessId) -> bool { + self.raid == raid + } + + #[inline] + pub fn can_write(&self, raid: ReflectAccessId) -> bool { + self.can_read(raid) + } + + /// Prints the type of access this [`WorldAccessWrite`] entails, enriched with type information from the registry + pub fn to_enriched_str( + &self, + registry: &TypeRegistry, + allocator: Option<&ReflectAllocator>, + cell: UnsafeWorldCell, + ) -> String { + let (base_type, type_id) = match self.raid.kind { + ReflectAccessKind::ComponentOrResource => { + let type_id = cell + .components() + .get_info(ComponentId::new(self.raid.id)) + .and_then(|info| info.type_id()); + + ("Component/Resource", type_id) + } + ReflectAccessKind::Allocation => { + let type_id = allocator + .and_then(|allocator| allocator.get_type_id(ReflectAllocationId(self.raid.id))); + ("Allocation", type_id) + } + }; + + type_id + .and_then(|type_id| registry.get_type_info(type_id)) + .map(|info| format!("{base_type}<{}>", info.type_path())) + .unwrap_or(format!("{:?}", self.raid)) + } +} + +// pub struct + +#[cfg(test)] +mod test { + + use std::{any::Any, cell::UnsafeCell, convert::identity, sync::RwLock}; + + use crate::{ + bindings::{ + DeferredReflection, ReflectBase, ReflectBaseType, ReflectReference, ReflectionPathElem, + }, + bindings::{ReflectAllocation, ReflectAllocator}, + }; + + use super::*; + use bevy::{ + ecs::{component::Component, reflect::ReflectResource, system::Resource, world::World}, + reflect::TypeRegistryArc, + }; + + #[derive(Component, Reflect, PartialEq, Eq, Debug)] + #[reflect(Component)] + pub(crate) struct TestComponent { + pub strings: Vec, + } + + #[derive(Resource, Reflect, Default, PartialEq, Eq, Debug)] + #[reflect(Resource)] + pub(crate) struct TestResource { + pub bytes: Vec, + } + + pub(crate) fn setup_world( + init: F, + ) -> (World, ComponentId, ComponentId) { + let mut world = World::default(); + let allocator = ReflectAllocator::default(); + + let component_id = world.init_component::(); + let resource_id = world.init_resource::(); + + let mut type_registry = TypeRegistry::new(); + type_registry.register::(); + type_registry.register::(); + + init(&mut world, &mut type_registry); + + world.insert_resource(allocator); + + world.insert_resource(AppTypeRegistry(TypeRegistryArc { + internal: Arc::new(RwLock::new(type_registry)), + })); + + (world, component_id, resource_id) + } + + /// Tests that the given ref_ can be accessed and the value is as expected and access is released correctly (not for allocated values) + fn assert_access_yields< + O: Reflect + PartialEq + Debug, + F: FnOnce(&mut World, ComponentId, ComponentId) -> ReflectReference, + G: FnOnce(&WorldAccessGuard, ComponentId, ComponentId), + >( + init: F, + post_check: G, + expected: O, + ) { + let (mut world, component_id, resource_id) = setup_world(|_, _| {}); + let ref_ = init(&mut world, component_id, resource_id); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let world = world.read().unwrap(); + + // test read + world.with_resource(|world, allocator: Mut| { + world.with_resource(|world, type_registry: Mut| { + let type_registry = type_registry.read(); + ref_.with_reflect(world, &type_registry, Some(&allocator), |reflect| { + let orig = reflect.downcast_ref::(); + + let orig = match orig { + Some(v) => v, + None => { + panic!( + "Could not downcast value {reflect:?} to {}", + std::any::type_name::() + ) + } + }; + + assert_eq!(orig, &expected); + }) + }) + }); + + assert!( + world.get_component_access(component_id).is_some(), + "access to component was not release correctly" + ); + + assert!( + world.get_resource_access(resource_id).is_some(), + "access to component was not release correctly" + ); + + post_check(&world, component_id, resource_id); + }); + } + + /// Tests that setting to the expected value works as well as follow up reads give the expected value + fn assert_set_then_get_yields< + O: Reflect + PartialEq + Debug + Clone, + F: FnOnce(&mut World, ComponentId, ComponentId) -> ReflectReference, + G: FnOnce(&WorldAccessGuard, ComponentId, ComponentId), + >( + init: F, + post_check: G, + expected: O, + ) { + let (mut world, component_id, resource_id) = setup_world(|_, _| {}); + let ref_ = init(&mut world, component_id, resource_id); + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let world = world.read().unwrap(); + // test set + world.with_resource(|world, allocator: Mut| { + world.with_resource(|world, type_registry: Mut| { + let type_registry = type_registry.read(); + ref_.with_reflect_mut(world, &type_registry, Some(&allocator), |reflect| { + let orig = reflect.downcast_mut::(); + + let orig = match orig { + Some(v) => v, + None => { + panic!( + "Could not downcast value {reflect:?} to {}", + std::any::type_name::() + ) + } + }; + + *orig = expected.clone(); + }) + }) + }); + + // test read + world.with_resource(|world, allocator: Mut| { + world.with_resource(|world, type_registry: Mut| { + let type_registry = type_registry.read(); + ref_.with_reflect(world, &type_registry, Some(&allocator), |reflect| { + let orig = reflect.downcast_ref::(); + + let orig = match orig { + Some(v) => v, + None => { + panic!( + "Could not downcast value {reflect:?} to {}", + std::any::type_name::() + ) + } + }; + + assert_eq!(orig, &expected); + }) + }) + }); + post_check(&world, component_id, resource_id); + }); + } + + #[test] + fn test_component_access() { + let init = |world: &mut World, component_id, _| { + let entity = world + .spawn(TestComponent { + strings: vec![String::from("initial")], + }) + .id(); + + ReflectReference { + base: ReflectBaseType { + base_id: ReflectBase::Component(entity, component_id), + type_id: TypeId::of::(), + }, + reflect_path: vec![ + ReflectionPathElem::Reflection(ParsedPath::parse_static(".strings").unwrap()), + ReflectionPathElem::DeferredReflection(DeferredReflection { + get: Arc::new(|root| { + let strings = root.downcast_ref::>().unwrap(); + Ok(strings.first().unwrap()) + }), + get_mut: Arc::new(|root| { + let strings = root.downcast_mut::>().unwrap(); + Ok(strings.first_mut().unwrap()) + }), + }), + ], + } + }; + + assert_access_yields(init, |_, _, _| {}, String::from("initial")); + assert_set_then_get_yields(init, |_, _, _| {}, String::from("set")); + } + + #[test] + fn test_resource_access() { + let init = |world: &mut World, _, resource_id| { + world.insert_resource(TestResource { bytes: vec![42u8] }); + + ReflectReference { + base: ReflectBaseType { + base_id: ReflectBase::Resource(resource_id), + type_id: TypeId::of::(), + }, + reflect_path: vec![ + ReflectionPathElem::Reflection(ParsedPath::parse_static(".bytes").unwrap()), + ReflectionPathElem::DeferredReflection(DeferredReflection { + get: Arc::new(|root| { + let strings = root.downcast_ref::>().unwrap(); + Ok(strings.first().unwrap()) + }), + get_mut: Arc::new(|root| { + let strings = root.downcast_mut::>().unwrap(); + Ok(strings.first_mut().unwrap()) + }), + }), + ], + } + }; + assert_access_yields(init, |_, _, _| {}, 42u8); + assert_set_then_get_yields(init, |_, _, _| {}, 69u8); + } + + #[test] + fn test_script_alloc_access() { + let init = |world: &mut World, _, _| { + let mut script_allocator = ReflectAllocator::default(); + let mut ref_ = ReflectReference::new_allocated( + TestComponent { + strings: vec![String::from("initial")], + }, + &mut script_allocator, + ); + ref_.index_path(ParsedPath::parse_static(".strings").unwrap()); + ref_.index_path(DeferredReflection { + get: Arc::new(|root| { + let strings = root.downcast_ref::>().unwrap(); + Ok(strings.first().unwrap()) + }), + get_mut: Arc::new(|root| { + let strings = root.downcast_mut::>().unwrap(); + Ok(strings.first_mut().unwrap()) + }), + }); + world.insert_resource(script_allocator); + ref_ + }; + let post_check = |world: &WorldAccessGuard, _, _| { + assert!( + world + .get_allocation_access(ReflectAllocationId(0)) + .is_some(), + "allocation access was not released correctly" + ); + }; + assert_access_yields(init, post_check, String::from("initial")); + assert_set_then_get_yields(init, post_check, String::from("set")); + } + + #[test] + #[allow(clippy::drop_non_drop)] + fn test_invalid_runtime_access() { + let mut world = World::new(); + let world = WorldAccessGuard::new(&mut world); + let access = world.get_component_access(ComponentId::new(0)); + assert!( + world.get_component_access(ComponentId::new(0)).is_none(), + "access was allowed to alias" + ); + drop(access); + } + + #[test] + #[should_panic] + fn test_double_release_panics() { + let mut world = World::new(); + let world = WorldAccessGuard::new(&mut world); + let access = world.get_component_access(ComponentId::new(0)).unwrap(); + world.release_access(access); + // This won't be possible in client code + world.release_access(WorldAccessWrite { + raid: ReflectAccessId { + kind: ReflectAccessKind::ComponentOrResource, + id: 0, + }, + _ph: PhantomData, + }); + } + + #[test] + fn test_count_updated_correctly() { + let mut world = World::new(); + let guard = WorldAccessGuard::new(&mut world); + let access = guard.get_access(ComponentId::new(0).into()).unwrap(); + assert_eq!(1, guard.accesses_count.load(Ordering::Relaxed)); + guard.release_access(access); + assert_eq!(0, guard.accesses_count.load(Ordering::Relaxed)); + } +} + +#[cfg(test)] +mod test_api { + use bevy::ecs::system::{CommandQueue, Commands}; + use bevy::ecs::world::FromWorld; + use bevy::hierarchy::BuildChildren; + + use crate::prelude::{ScriptErrorInner, ScriptErrorKind}; + + use super::test::{setup_world, TestComponent, TestResource}; + + use super::*; + + fn get_reg(world: &WorldCallbackAccess, name: &str) -> Arc { + world.get_type_by_name(name).expect("Type not found") + } + + fn test_comp_reg(world: &WorldCallbackAccess) -> Arc { + world + .get_type_by_name("TestComponent") + .expect("Component not found") + } + + fn test_resource_reg(world: &WorldCallbackAccess) -> Arc { + world + .get_type_by_name("TestResource") + .expect("Resource not found") + } + + #[test] + fn test_get_type_by_name() { + let (mut world, _, _) = setup_world(|_, _| {}); + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let comp_reg = world.get_type_by_name("TestComponent").unwrap(); + let resource_reg = world.get_type_by_name("TestResource").unwrap(); + + assert_eq!( + comp_reg.type_info().type_id(), + std::any::TypeId::of::() + ); + assert_eq!( + resource_reg.type_info().type_id(), + std::any::TypeId::of::() + ); + }); + } + + #[test] + fn test_get_type_by_name_invalid() { + let (mut world, _, _) = setup_world(|_, _| {}); + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let comp_reg = world.get_type_by_name("x"); + let resource_reg = world.get_type_by_name("z"); + + assert!(comp_reg.is_none()); + assert!(resource_reg.is_none()); + }); + } + + #[test] + fn test_add_default_component_from_world() { + #[derive(Reflect, Component, PartialEq, Debug)] + #[reflect(FromWorld, Component)] + struct CompWithFromWorld(pub String); + impl FromWorld for CompWithFromWorld { + fn from_world(_: &mut World) -> Self { + Self(String::from("FromWorld")) + } + } + + let (mut world, _, _) = setup_world(|w, r| { + w.init_component::(); + r.register::(); + }); + + let entity = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let comp_reg = get_reg(world, "CompWithFromWorld"); + world.add_default_component(entity, comp_reg).unwrap() + }); + + assert_eq!( + world.get_entity(entity).unwrap().get::(), + Some(&CompWithFromWorld(String::from("FromWorld"))) + ); + } + + #[test] + fn test_add_default_component_default() { + #[derive(Reflect, Component, PartialEq, Debug)] + #[reflect(Default, Component)] + struct CompWithFromWorld(pub String); + + impl Default for CompWithFromWorld { + fn default() -> Self { + Self(String::from("Default")) + } + } + + let (mut world, _, _) = setup_world(|w, r| { + w.init_component::(); + r.register::(); + }); + + let entity = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let comp_reg = get_reg(world, "CompWithFromWorld"); + world.add_default_component(entity, comp_reg).unwrap() + }); + + assert_eq!( + world.get_entity(entity).unwrap().get::(), + Some(&CompWithFromWorld(String::from("Default"))) + ); + } + + #[test] + fn test_add_default_component_missing_from_world_and_default() { + #[derive(Reflect, Component, PartialEq, Debug)] + #[reflect(Component)] + struct CompWithFromWorld(pub String); + + let (mut world, _, _) = setup_world(|w, r| { + w.init_component::(); + r.register::(); + }); + + let entity = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let comp_reg = get_reg(world, "CompWithFromWorld"); + match world.add_default_component(entity, comp_reg.clone()) { + Ok(_) => { + panic!("Expected error") + } + Err(ScriptError(inner)) => { + assert_eq!(inner.kind, ScriptErrorKind::RuntimeError); + assert_eq!(inner.reason.to_string(), format!("Cannot add default component since type: `{}`, Does not have ReflectDefault or ReflectFromWorld data registered.", comp_reg.type_info().type_path())); + } + } + }); + } + + #[test] + fn test_add_default_component_missing_component_data() { + #[derive(Reflect, Component, PartialEq, Debug)] + #[reflect(Default)] + struct CompWithFromWorld(pub String); + + impl Default for CompWithFromWorld { + fn default() -> Self { + Self(String::from("Default")) + } + } + + let (mut world, _, _) = setup_world(|w, r| { + w.init_component::(); + r.register::(); + }); + + let entity = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let comp_reg = get_reg(world, "CompWithFromWorld"); + match world.add_default_component(entity, comp_reg.clone()) { + Ok(_) => { + panic!("Expected error") + } + Err(ScriptError(inner)) => { + assert_eq!(inner.kind, ScriptErrorKind::RuntimeError); + assert_eq!(inner.reason.to_string(), format!("Cannot add default component since type: `{}`, Does not have ReflectComponent data registered.", comp_reg.type_info().type_path())); + } + } + }); + } + + #[test] + fn test_get_component_existing() { + let (mut world, comp_id, _) = setup_world(|_, _| {}); + let entity = world.spawn(TestComponent { strings: vec![] }).id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let comp_ref = world.get_component(entity, comp_id).unwrap().unwrap(); + assert_eq!( + comp_ref, + ReflectReference { + base: ReflectBaseType { + type_id: std::any::TypeId::of::(), + base_id: ReflectBase::Component(entity, comp_id), + }, + reflect_path: Default::default(), + } + ); + }); + } + + #[test] + fn test_get_component_missing() { + let (mut world, comp_id, _) = setup_world(|_, _| {}); + let entity = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let comp_ref = world.get_component(entity, comp_id).unwrap(); + assert_eq!(comp_ref, None); + }); + } + + #[test] + fn test_get_component_missing_entity() { + let (mut world, comp_id, _) = setup_world(|_, _| {}); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let comp_ref = world.get_component(Entity::from_raw(0), comp_id); + match comp_ref { + Ok(_) => { + panic!("Expected error") + } + Err(e) => { + assert_eq!(e.kind, ScriptErrorKind::RuntimeError); + assert_eq!(e.reason.to_string(), "Entity does not exist: 0v1"); + } + } + }); + } + + #[test] + fn test_get_component_unregistered_component() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let entity = world.spawn_empty().id(); + let fake_id = ComponentId::new(999); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let comp_ref = world.get_component(entity, fake_id); + match comp_ref { + Ok(_) => { + panic!("Expected error") + } + Err(e) => { + assert_eq!(e.kind, ScriptErrorKind::RuntimeError); + assert_eq!( + e.reason.to_string(), + format!("Component does not exist: {fake_id:?}"), + ); + } + } + }); + } + + #[test] + fn test_remove_component() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let entity = world + .spawn(TestComponent { + strings: vec![String::from("strings")], + }) + .id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world + .remove_component(entity, test_comp_reg(world)) + .unwrap(); + }); + + assert_eq!( + world.get_entity(entity).unwrap().get::(), + None + ); + } + + #[test] + fn test_remove_component_empty_idempotent() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let entity = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world + .remove_component(entity, test_comp_reg(world)) + .unwrap(); + }); + + assert_eq!( + world.get_entity(entity).unwrap().get::(), + None + ); + } + + #[test] + fn test_remove_component_missing_comp_registration() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let entity = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let result = world.remove_component(entity, test_resource_reg(world)); + match result { + Ok(_) => { + panic!("Expected error") + } + Err(e) => { + assert_eq!(e.kind, ScriptErrorKind::RuntimeError); + assert_eq!(e.reason.to_string(), format!("Cannot remove component since type: `{}`, Does not have ReflectComponent data registered.", test_resource_reg(world).type_info().type_path())); + } + } + }); + + assert_eq!( + world.get_entity(entity).unwrap().get::(), + None + ); + } + + #[test] + fn test_remove_component_missing_entity() { + let (mut world, _, _) = setup_world(|_, _| {}); + let fake_entity = Entity::from_raw(0); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let result = world.remove_component(fake_entity, test_comp_reg(world)); + match result { + Ok(_) => { + panic!("Expected error") + } + Err(e) => { + assert_eq!(e.kind, ScriptErrorKind::RuntimeError); + assert_eq!(e.reason.to_string(), "Entity does not exist: 0v1"); + } + } + }); + } + + #[test] + fn test_get_resource_existing() { + let (mut world, _, resource_id) = setup_world(|_, _| {}); + world.insert_resource(TestResource { bytes: vec![1] }); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let comp_ref = world.get_resource(resource_id).unwrap(); + assert_eq!( + comp_ref, + ReflectReference { + base: ReflectBaseType { + type_id: std::any::TypeId::of::(), + base_id: ReflectBase::Resource(resource_id), + }, + reflect_path: Default::default(), + } + ); + }); + } + + #[test] + fn test_get_resource_non_existing() { + let (mut world, _, _) = setup_world(|_, _| {}); + let fake_comp = ComponentId::new(999); + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let comp_ref = world.get_resource(fake_comp); + match comp_ref { + Ok(_) => panic!("Expected error"), + Err(e) => { + assert_eq!(e.kind, ScriptErrorKind::RuntimeError); + assert_eq!( + e.reason.to_string(), + format!("Resource does not exist: {fake_comp:?}") + ) + } + } + }); + } + + #[test] + fn test_remove_resource() { + let (mut world, _, _) = setup_world(|_, _| {}); + + world.insert_resource(TestResource { bytes: vec![1] }); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world.remove_resource(test_resource_reg(world)).unwrap(); + }); + + assert_eq!(world.get_resource::(), None); + } + + #[test] + fn test_remove_resource_missing_idempotent() { + let (mut world, _, _) = setup_world(|_, _| {}); + + world.remove_resource::(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world.remove_resource(test_resource_reg(world)).unwrap(); + }); + + assert_eq!(world.get_resource::(), None); + } + + #[test] + fn test_remove_resource_missing_resource_registration() { + let (mut world, _, _) = setup_world(|_, _| {}); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + match world.remove_resource(test_comp_reg(world)) { + Ok(_) => panic!("Expected error"), + Err(e) => { + assert_eq!(e.kind, ScriptErrorKind::RuntimeError); + assert_eq!(e.reason.to_string(), format!("Cannot remove resource since type: `{}`, Does not have ReflectResource data registered.", test_comp_reg(world).type_info().type_path())); + } + } + }); + } + + #[test] + fn test_has_resource_existing() { + let (mut world, _, res_reg) = setup_world(|_, _| {}); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + assert!(world.has_resource(res_reg)); + }); + } + + #[test] + fn test_has_resource_missing() { + let (mut world, _, res_reg) = setup_world(|_, _| {}); + + world.remove_resource::(); + WorldCallbackAccess::with_callback_access(&mut world, |world| { + assert!(world.has_resource(res_reg)); + }); + } + + #[test] + fn test_get_children_1_child() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let parent = world.spawn_empty().id(); + let child = world.spawn_empty().id(); + let mut cmnds = CommandQueue::default(); + let mut cmnd = Commands::new(&mut cmnds, &world); + cmnd.entity(parent).push_children(&[child]); + cmnds.apply(&mut world); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let children = world.get_children(parent).unwrap(); + assert_eq!(children.len(), 1); + assert_eq!(children[0], child); + }); + } + + #[test] + #[should_panic( + expected = "Component not registered: `bevy_hierarchy::components::children::Children`" + )] + fn test_get_children_children_component_unregistered() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let parent = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world.get_children(parent).unwrap(); + }); + } + + #[test] + fn test_get_children_no_children() { + let (mut world, _, _) = setup_world(|_, _| {}); + + world.init_component::(); + let parent = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let children = world.get_children(parent).unwrap(); + assert_eq!(children.len(), 0); + }); + } + + #[test] + fn test_get_parent_1_parent() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let parent = world.spawn_empty().id(); + let child = world.spawn_empty().id(); + let mut cmnds = CommandQueue::default(); + let mut cmnd = Commands::new(&mut cmnds, &world); + cmnd.entity(parent).push_children(&[child]); + cmnds.apply(&mut world); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let found_parent = world.get_parent(child).unwrap(); + assert_eq!(found_parent, Some(parent)); + }); + } + + #[test] + fn test_get_parent_no_parent() { + let (mut world, _, _) = setup_world(|_, _| {}); + world.init_component::(); + + let child = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + let found_parent = world.get_parent(child).unwrap(); + assert_eq!(found_parent, None); + }); + } + + #[test] + #[should_panic( + expected = "Component not registered: `bevy_hierarchy::components::parent::Parent`" + )] + fn test_get_parent_parent_component_unregistered() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let child = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world.get_parent(child).unwrap(); + }); + } + + #[test] + fn test_push_children_empty_entity() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let parent = world.spawn_empty().id(); + let child = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world.push_children(parent, &[child]).unwrap(); + }); + + let children = world.get::(parent).unwrap(); + assert_eq!(children.len(), 1); + assert_eq!(children[0], child); + } + + #[test] + fn test_push_children_entity_with_1_child() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let parent = world.spawn_empty().id(); + let child = world.spawn_empty().id(); + let mut cmnds = CommandQueue::default(); + let mut cmnd = Commands::new(&mut cmnds, &world); + cmnd.entity(parent).push_children(&[child]); + cmnds.apply(&mut world); + + let child_2 = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world.push_children(parent, &[child_2]).unwrap(); + }); + + let children = world.get::(parent).unwrap(); + assert_eq!(children.len(), 2); + assert_eq!(children[0], child); + assert_eq!(children[1], child_2); + } + + #[test] + fn test_remove_children_entity_with_1_child() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let parent = world.spawn_empty().id(); + let child = world.spawn_empty().id(); + let mut cmnds = CommandQueue::default(); + let mut cmnd = Commands::new(&mut cmnds, &world); + cmnd.entity(parent).push_children(&[child]); + cmnds.apply(&mut world); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world.remove_children(parent, &[child]).unwrap(); + }); + + let children = world.get::(parent); + assert!(children.is_none()); + } + + #[test] + fn test_remove_children_remove_half_children() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let parent = world.spawn_empty().id(); + let child = world.spawn_empty().id(); + let child_2 = world.spawn_empty().id(); + let mut cmnds = CommandQueue::default(); + let mut cmnd = Commands::new(&mut cmnds, &world); + cmnd.entity(parent).push_children(&[child, child_2]); + cmnds.apply(&mut world); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world.remove_children(parent, &[child]).unwrap(); + }); + + let children = world.get::(parent).unwrap(); + assert_eq!(children.len(), 1); + assert_eq!(children[0], child_2); + } + + #[test] + fn test_insert_children_empty() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let parent = world.spawn_empty().id(); + let child = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world.insert_children(parent, 0, &[child]).unwrap(); + }); + + let children = world.get::(parent).unwrap(); + assert_eq!(children.len(), 1); + assert_eq!(children[0], child); + } + + #[test] + fn test_insert_children_middle() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let parent = world.spawn_empty().id(); + let child = world.spawn_empty().id(); + let child_2 = world.spawn_empty().id(); + let mut cmnds = CommandQueue::default(); + let mut cmnd = Commands::new(&mut cmnds, &world); + cmnd.entity(parent).push_children(&[child, child_2]); + cmnds.apply(&mut world); + + let child_to_insert = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world + .insert_children(parent, 1, &[child_to_insert]) + .unwrap(); + }); + + let children = world.get::(parent).unwrap(); + assert_eq!(children.len(), 3); + assert_eq!(children[0], child); + assert_eq!(children[1], child_to_insert); + assert_eq!(children[2], child_2); + } + + #[test] + fn test_despawn_entity() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let entity = world.spawn_empty().id(); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world.despawn(entity).unwrap(); + }); + + assert!(world.get_entity(entity).is_none()); + } + + #[test] + fn test_despawn_recursive() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let parent = world.spawn_empty().id(); + let child = world.spawn_empty().id(); + let mut cmnds = CommandQueue::default(); + let mut cmnd = Commands::new(&mut cmnds, &world); + cmnd.entity(parent).push_children(&[child]); + cmnds.apply(&mut world); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world.despawn_recursive(parent).unwrap(); + }); + + assert!(world.get_entity(parent).is_none()); + assert!(world.get_entity(child).is_none()); + } + + #[test] + fn test_despawn_descendants() { + let (mut world, _, _) = setup_world(|_, _| {}); + + let parent = world.spawn_empty().id(); + let child = world.spawn_empty().id(); + let mut cmnds = CommandQueue::default(); + let mut cmnd = Commands::new(&mut cmnds, &world); + cmnd.entity(parent).push_children(&[child]); + cmnds.apply(&mut world); + + WorldCallbackAccess::with_callback_access(&mut world, |world| { + world.despawn_descendants(parent).unwrap(); + }); + + assert!(world.get_entity(parent).is_some()); + assert!(world.get_entity(child).is_none()); + } +} diff --git a/crates/bevy_mod_scripting_core/src/error.rs b/crates/bevy_mod_scripting_core/src/error.rs index 15debe9b..ad111348 100644 --- a/crates/bevy_mod_scripting_core/src/error.rs +++ b/crates/bevy_mod_scripting_core/src/error.rs @@ -1,7 +1,38 @@ +use std::{ + ops::{Deref, DerefMut}, + sync::Arc, +}; + use bevy::reflect::Reflect; use thiserror::Error; -use crate::{allocator::ReflectAllocationId, bindings::ReflectReference}; +use crate::{bindings::ReflectAllocationId, bindings::ReflectReference}; + +pub type ScriptResult = Result; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum ScriptErrorKind { + /// Any other error, default for script errors generated via Into conversions + Other, + /// Errors specifically to do with reflecting & reading/writing stuff from the world + ReflectionError, + /// Erorrs to do with invalid script API usage, invalid arguments etc. + RuntimeError, + /// Errors to do with the script lifecycle, loading, unloading etc. + Lifecycle, +} + +impl std::fmt::Display for ScriptErrorKind { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ScriptErrorKind::ReflectionError => f.write_str("Reflection Error"), + ScriptErrorKind::Lifecycle => f.write_str("Script Lifecycle Error"), + ScriptErrorKind::Other => f.write_str("Error"), + ScriptErrorKind::RuntimeError => f.write_str("Runtime Error"), + }; + Ok(()) + } +} #[derive(Error, Debug)] pub struct ScriptErrorWrapper(ScriptError); @@ -18,89 +49,133 @@ impl From for Box { } } /// An error with an optional script Context +#[derive(Debug, Clone)] +pub struct ScriptError(pub Arc); + +impl Deref for ScriptError { + type Target = ScriptErrorInner; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +/// The innards are separated to reduce the size of this error #[derive(Debug)] -pub struct ScriptError { +pub struct ScriptErrorInner { pub script: Option, - pub additional_message: Option, - pub reason: Box, + pub kind: ScriptErrorKind, + pub context: String, + pub reason: Arc, } impl ScriptError { - pub fn new(reason: Box) -> Self { - Self { + pub fn new_reflection_error>>( + reason: E, + ) -> Self { + Self(Arc::new(ScriptErrorInner { script: None, - reason, - additional_message: None, - } + kind: ScriptErrorKind::ReflectionError, + reason: Arc::from(reason.into()), + context: Default::default(), + })) + } + + pub fn new_generic_error>>(reason: E) -> Self { + Self(Arc::new(ScriptErrorInner { + script: None, + kind: ScriptErrorKind::Other, + reason: Arc::from(reason.into()), + context: Default::default(), + })) } - pub fn new_with_context( - script: T, - reason: Box, + pub fn new_lifecycle_error>>( + reason: E, ) -> Self { - Self { - script: Some(script.to_string()), - reason, - additional_message: None, - } + Self(Arc::new(ScriptErrorInner { + script: None, + kind: ScriptErrorKind::Lifecycle, + reason: Arc::from(reason.into()), + context: Default::default(), + })) } - pub fn with_context(self, script: T) -> Self { - Self { - script: Some(script.to_string()), - reason: self.reason, - additional_message: self.additional_message, - } + pub fn new_runtime_error>>(reason: E) -> Self { + Self(Arc::new(ScriptErrorInner { + script: None, + kind: ScriptErrorKind::RuntimeError, + reason: Arc::from(reason.into()), + context: Default::default(), + })) } - pub fn with_msg(self, msg: T) -> Self { - Self { - script: self.script, - reason: self.reason, - additional_message: Some(msg.to_string()), - } + pub fn with_context(self, context: S) -> Self { + Self(Arc::new(ScriptErrorInner { + script: self.0.script.clone(), + kind: self.0.kind.clone(), + context: context.to_string(), + reason: self.0.reason.clone(), + })) } } impl From for ScriptError { fn from(value: T) -> Self { - Self::new(Box::new(value)) + Self::new_generic_error(value) } } impl std::fmt::Display for ScriptError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - if let Some(script) = &self.script { - write!(f, "Script `{}` failed: {}", script, self.reason) + if let Some(script) = &self.0.script { + write!( + f, + "Encountered {} error in script `{}`: {}", + self.0.kind, script, self.0.reason + ) } else { - write!(f, "Script failed: {}", self.reason) + write!( + f, + "Encountered {} error in a script: {}", + self.0.kind, self.0.reason + ) } } } -#[derive(Error, Debug, Clone)] -pub enum ReflectionError { - #[error("Base reference `{base}` is invalid. {reason}")] - InvalidBaseReference { base: String, reason: String }, - #[error("Cannot safely access `{base}`. {reason}")] - InsufficientAccess { base: String, reason: String }, - #[error("Tried to access `{base:?}` with insufficient provenance. {reason}")] - InsufficientProvenance { - base: ReflectReference, - reason: String, - }, - #[error("Cannot downcast reference: {reference:?} to: {to}")] - CannotDowncast { - reference: ReflectReference, - to: String, - }, - #[error("Failed to build concrete type from &Reflect type: {ref_}")] - FromReflectFailure { ref_: String }, - #[error("Could not dereference script allocation with ID: {id}. {reason}")] - AllocationError { - id: ReflectAllocationId, - reason: String, - }, - #[error("{0}")] - Other(String), -} +// #[derive(Error, Debug, Clone)] +// pub enum ReflectionError { +// #[error("Base reference `{base}` is invalid. {reason}")] +// InvalidBaseReference { base: String, reason: String }, +// #[error("Cannot safely access `{base}`. {reason}")] +// InsufficientAccess { base: String, reason: String }, +// #[error("Tried to access `{base:?}` with insufficient provenance. {reason}")] +// InsufficientProvenance { +// base: ReflectReference, +// reason: String, +// }, +// #[error("Cannot downcast reference: {reference:?} to: {to}")] +// CannotDowncast { +// reference: ReflectReference, +// to: String, +// }, +// #[error("Could not assign `{rhs}` to `{lhs:?}`. {reason}")] +// InvalidAssignment { +// lhs: ReflectReference, +// rhs: String, +// reason: String, +// }, +// #[error("Failed to build concrete type from &Reflect type: `{ref_}`. Does this type have a FromReflect type data?")] +// FromReflectFailure { ref_: String }, +// #[error("Could not dereference script allocation with ID: {id}. {reason}")] +// AllocationError { +// id: ReflectAllocationId, +// reason: String, +// }, +// #[error("Attempted to access world via stale world reference. Did you store a reference to a world across a frame boundary?")] +// StaleWorldAccess, + +// #[error("{0}")] +// Other(String), +// } diff --git a/crates/bevy_mod_scripting_core/src/lib.rs b/crates/bevy_mod_scripting_core/src/lib.rs index e6e1c0c8..0b762ba5 100644 --- a/crates/bevy_mod_scripting_core/src/lib.rs +++ b/crates/bevy_mod_scripting_core/src/lib.rs @@ -1,9 +1,9 @@ #![allow(clippy::arc_with_non_send_sync)] use crate::event::ScriptErrorEvent; -use allocator::ReflectAllocator; use asset::{ScriptAsset, ScriptAssetLoader, ScriptAssetSettings}; use bevy::prelude::*; +use bindings::ReflectAllocator; use context::{ Context, ContextAssigner, ContextBuilder, ContextInitializer, ContextLoadingSettings, ContextPreHandlingInitializer, ScriptContexts, @@ -18,7 +18,6 @@ use runtime::{Runtime, RuntimeContainer}; use script::Scripts; use systems::garbage_collector; -pub mod allocator; pub mod asset; pub mod bindings; pub mod commands; @@ -27,7 +26,6 @@ pub mod docs; pub mod error; pub mod event; pub mod handler; -pub mod proxy; pub mod runtime; pub mod script; pub mod systems; diff --git a/crates/bevy_mod_scripting_core/src/systems.rs b/crates/bevy_mod_scripting_core/src/systems.rs index e3a97372..5ab54765 100644 --- a/crates/bevy_mod_scripting_core/src/systems.rs +++ b/crates/bevy_mod_scripting_core/src/systems.rs @@ -2,8 +2,8 @@ use bevy::{ecs::system::SystemState, prelude::*}; use std::any::type_name; use crate::{ - allocator::ReflectAllocator, asset::{ScriptAsset, ScriptAssetSettings}, + bindings::ReflectAllocator, commands::{CreateOrUpdateScript, DeleteScript}, context::{Context, ContextLoadingSettings, ScriptContexts}, event::{IntoCallbackLabel, ScriptCallbackEvent, ScriptErrorEvent}, diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs index 798828bd..99941536 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs @@ -2,4 +2,6 @@ use bevy_mod_scripting_core::bindings::WorldCallbackAccess; pub mod providers; pub mod proxy; +pub mod reference; +pub mod type_registration; pub mod world; diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs index 72f95ce8..6dbc5893 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs @@ -12,7 +12,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, tealr::mlu::mlua::IntoLua, + RegisterLua, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -67,7 +67,7 @@ fn bevy_core_context_initializer( pub struct BevyCoreScriptingPlugin; impl bevy::app::Plugin for BevyCoreScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { - app.register_proxy::(); + app.register_lua_proxy::(); app.add_context_initializer::<()>(bevy_core_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs index 529fe207..3a7aacb1 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs @@ -11,7 +11,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, tealr::mlu::mlua::IntoLua, + RegisterLua, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -356,11 +356,11 @@ fn bevy_ecs_context_initializer( pub struct BevyEcsScriptingPlugin; impl bevy::app::Plugin for BevyEcsScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); app.add_context_initializer::<()>(bevy_ecs_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs index 955ce95d..ccf9e8ac 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs @@ -13,7 +13,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, tealr::mlu::mlua::IntoLua, + RegisterLua, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -92,8 +92,8 @@ fn bevy_hierarchy_context_initializer( pub struct BevyHierarchyScriptingPlugin; impl bevy::app::Plugin for BevyHierarchyScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { - app.register_proxy::(); - app.register_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); app.add_context_initializer::<()>(bevy_hierarchy_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs index a633a012..d460a79c 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs @@ -12,7 +12,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, tealr::mlu::mlua::IntoLua, + RegisterLua, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -1578,38 +1578,38 @@ fn bevy_input_context_initializer( pub struct BevyInputScriptingPlugin; impl bevy::app::Plugin for BevyInputScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); app.add_context_initializer::<()>(bevy_input_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs index 1ac97eb9..462af8c4 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs @@ -10,7 +10,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, tealr::mlu::mlua::IntoLua, + RegisterLua, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -25407,86 +25407,86 @@ fn bevy_reflect_context_initializer( pub struct BevyReflectScriptingPlugin; impl bevy::app::Plugin for BevyReflectScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); app.add_context_initializer::<()>(bevy_reflect_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs index f83bf1be..fac87247 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs @@ -12,7 +12,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, tealr::mlu::mlua::IntoLua, + RegisterLua, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -579,12 +579,12 @@ fn bevy_time_context_initializer( pub struct BevyTimeScriptingPlugin; impl bevy::app::Plugin for BevyTimeScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); app.add_context_initializer::<()>(bevy_time_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs index 4e205848..28497380 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs @@ -14,7 +14,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, tealr::mlu::mlua::IntoLua, + RegisterLua, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -337,8 +337,8 @@ fn bevy_transform_context_initializer( pub struct BevyTransformScriptingPlugin; impl bevy::app::Plugin for BevyTransformScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { - app.register_proxy::(); - app.register_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); app.add_context_initializer::<()>(bevy_transform_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs index dc65e81d..3dadf07e 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs @@ -13,7 +13,7 @@ use crate::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, IdentityProxy, }, - RegisterLuaProxy, tealr::mlu::mlua::IntoLua, + RegisterLua, tealr::mlu::mlua::IntoLua, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -1725,43 +1725,43 @@ fn bevy_window_context_initializer( pub struct BevyWindowScriptingPlugin; impl bevy::app::Plugin for BevyWindowScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); - app.register_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); app.add_context_initializer::<()>(bevy_window_context_initializer); app.add_documentation_fragment( crate::docs::LuaDocumentationFragment::new( diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs index e5c805fa..fea60e75 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs @@ -3,10 +3,10 @@ use bevy::reflect::{FromReflect, Reflect, TypeRegistry}; use bevy_mod_scripting_core::{ - allocator::ReflectAllocator, + bindings::ReflectAllocator, + bindings::{Proxy, ReflectRefMutProxy, ReflectRefProxy, ReflectValProxy, Unproxy, ValProxy}, bindings::{ReflectReference, WorldAccessGuard, WorldAccessUnit, WorldAccessWrite}, error::ReflectionError, - proxy::{Proxy, ReflectRefMutProxy, ReflectRefProxy, ReflectValProxy, Unproxy, ValProxy}, }; use tealr::{ mlu::mlua::{Error, FromLua, IntoLua, Lua, Value}, @@ -80,7 +80,7 @@ macro_rules! impl_lua_unproxy { self.0.collect_accesses(guard, accesses) } - fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { + fn unproxy(&mut self) -> Result, ReflectionError> { self.0.unproxy() } @@ -130,12 +130,12 @@ macro_rules! impl_lua_unproxy { macro_rules! impl_lua_proxy { ($ty:ident as $as:ident => $generic:tt : $($bounds:path),* $(| T::Proxy: $($proxy_bounds:tt)*)?) => { - impl<$generic> bevy_mod_scripting_core::proxy::Proxy for $ty<$generic> + impl<$generic> bevy_mod_scripting_core::bindings::Proxy for $ty<$generic> where T::Proxy: $($($proxy_bounds)*)?, T: $($bounds+)*, { - type Input<'i>=<$as<$generic, $generic::Proxy> as bevy_mod_scripting_core::proxy::Proxy>::Input<'i>; + type Input<'i>=<$as<$generic, $generic::Proxy> as bevy_mod_scripting_core::bindings::Proxy>::Input<'i>; fn proxy<'i>(value: Self::Input<'i>) -> Result { Ok(Self($as::<$generic,$generic::Proxy>::proxy(value)?)) } @@ -175,7 +175,7 @@ mod test { use bevy::{ecs::component::Component, reflect::Reflect}; use bevy_mod_scripting_core::{ - allocator::ReflectAllocation, + bindings::ReflectAllocation, bindings::{ReflectBase, ReflectBaseType, ReflectReference}, }; use tealr::mlu::mlua::{UserData, UserDataMethods}; @@ -254,8 +254,7 @@ mod test { let globals = lua.globals(); let test = Test("test".to_string()); let mut allocator = ReflectAllocator::default(); - let allocation_id = - allocator.allocate(ReflectAllocation::new(Arc::new(UnsafeCell::new(test)))); + let (allocation_id, _) = allocator.allocate(test); let reflect_ref = ReflectReference { base: ReflectBaseType { type_id: std::any::TypeId::of::(), diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs new file mode 100644 index 00000000..f4812808 --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs @@ -0,0 +1,430 @@ +use std::{any::Any, error::Error}; + +use bevy::{ + ecs::{reflect::AppTypeRegistry, world::Mut}, + reflect::{OffsetAccess, ParsedPath, ReflectFromReflect}, +}; +use bevy_mod_scripting_core::{ + bindings::ReflectAllocator, + bindings::Unproxy, + bindings::{ReflectReference, WorldCallbackAccess}, + error::ReflectionError, +}; +use tealr::mlu::{ + mlua::{self, FromLua, IntoLua, Lua, MetaMethod, UserData, Value}, + TealData, +}; + +use crate::{impl_userdata_from_lua, ReflectLuaProxied, ReflectLuaValue}; + +use super::{ + proxy::{LuaProxied, LuaValProxy}, + world::GetWorld, +}; + +/// Lua UserData wrapper for [`bevy_mod_scripting_core::bindings::ReflectReference`]. +/// Acts as a lua reflection interface. Any value which is registered in the type registry can be interacted with using this type. +#[derive(Debug, Clone, tealr::mlu::UserData, tealr::ToTypename)] +pub struct LuaReflectReference(pub ReflectReference); + +impl LuaReflectReference { + /// Queries the reflection system for a proxy registration for the underlying type. + /// If found will convert to lua using this proxy + /// If not found will use ::into_lua to convert to lua + pub fn to_lua_proxy(self, lua: &Lua) -> Result, mlua::Error> { + // note we do not need to refer to LuaWorld here, it does not matter what the proxy is, that's pretty neat, + let world = lua.get_world()?; + // TODO: i don't like the pingponging between errors here, need something more ergonomic + world + .with_resource(|world, type_registry: Mut| { + world.with_resource(|world, allocator: Mut| { + let type_registry = type_registry.read(); + // first we need the type id of the pointed to object to figure out how to work with it + let type_id = + self.0 + .with_reflect(world, &type_registry, Some(&allocator), |r| { + Ok(r.type_id()) + })?; + if let Some(type_data) = type_registry.get_type_data::(type_id) + { + self.0 + .with_reflect(world, &type_registry, Some(&allocator), |r| { + Ok((type_data.into_value)(r, lua)?) + }) + } else if let Some(type_data) = + type_registry.get_type_data::(type_id) + { + Ok((type_data.into_proxy)(self.0.clone(), lua)?) + } else { + Ok(self.clone().into_lua(lua)?) + } + }) + }) + .map_err(mlua::Error::external) + } + + pub fn set_with_lua_proxy(&self, lua: &Lua, value: Value) -> Result<(), mlua::Error> { + let world = lua.get_world()?; + world + .with_resource(|world, type_registry: Mut| { + world.with_resource(|world, allocator: Mut| { + let type_registry = type_registry.read(); + let type_id = + self.0 + .with_reflect(world, &type_registry, Some(&allocator), |r| { + Ok(r.type_id()) + })?; + + if let Some(type_data) = type_registry.get_type_data::(type_id) + { + self.0 + .with_reflect_mut(world, &type_registry, Some(&allocator), |r| { + Ok((type_data.set_value)(r, value, lua)?) + }) + } else if let Some(type_data) = + type_registry.get_type_data::(type_id) + { + let other = (type_data.from_proxy)(value, lua)?; + + // first we need to get a copy of the other value + let other = + other.with_reflect(world, &type_registry, Some(&allocator), |r| { + Ok(type_registry + .get_type_data::(r.type_id()) + .and_then(|from_reflect_td| from_reflect_td.from_reflect(r)) + .ok_or_else(|| ReflectionError::FromReflectFailure { + ref_: r + .get_represented_type_info() + .map(|t| t.type_path()) + .unwrap_or_else(|| "Unknown Type") + .to_owned(), + })?) + })?; + + // now we can set it + self.0 + .with_reflect_mut(world, &type_registry, Some(&allocator), |r| { + r.set(other).map_err(|e| { + Box::new(ReflectionError::InvalidAssignment { + lhs: self.0.clone(), + rhs: format!("{e:?}"), + reason: "Invalid type".to_owned(), + }) + as Box + }) + })?; + Ok(()) + } else { + Err(Box::new(ReflectionError::InvalidAssignment { + lhs: self.0.clone(), + rhs: format!("{value:?}"), + reason: "Lhs has no registered LuaValue or LuaProxied type data." + .to_owned(), + })) + } + }) + }) + .map_err(mlua::Error::external) + } + + /// Adjusts all the numeric accesses in the path from 1-indexed to 0-indexed + pub fn to_host_index(path: &mut ParsedPath) { + path.0.iter_mut().for_each(|a| match a.access { + bevy::reflect::Access::FieldIndex(ref mut i) => *i -= 1, + bevy::reflect::Access::TupleIndex(ref mut i) => *i -= 1, + bevy::reflect::Access::ListIndex(ref mut i) => *i -= 1, + _ => {} + }); + } + + /// Adjusts all the numeric accesses in the path from 0-indexed to 1-indexed + pub fn from_host_index(path: &mut ParsedPath) { + path.0.iter_mut().for_each(|a| match a.access { + bevy::reflect::Access::FieldIndex(ref mut i) => *i += 1, + bevy::reflect::Access::TupleIndex(ref mut i) => *i += 1, + bevy::reflect::Access::ListIndex(ref mut i) => *i += 1, + _ => {} + }); + } + + pub fn parse_value_index(value: Value) -> Result { + if let Some(num) = value.as_usize() { + Ok(vec![OffsetAccess { + access: bevy::reflect::Access::ListIndex(num), + offset: Some(1), + }] + .into()) + } else if let Some(key) = value.as_str() { + if let Some(tuple_struct_index) = key.strip_prefix("_") { + if let Ok(index) = tuple_struct_index.parse::() { + return Ok(vec![OffsetAccess { + access: bevy::reflect::Access::TupleIndex(index), + offset: Some(1), + }] + .into()); + } + } + + ParsedPath::parse(key).map_err(|e| mlua::Error::external(e.to_string())) + } else { + Err(mlua::Error::external("Invalid index")) + } + } +} + +impl_userdata_from_lua!(LuaReflectReference); + +impl LuaProxied for ReflectReference { + type Proxy = LuaReflectReference; +} + +impl TealData for LuaReflectReference { + fn add_methods<'lua, T: tealr::mlu::TealDataMethods<'lua, Self>>(m: &mut T) { + m.add_meta_function( + MetaMethod::Index, + |l, (mut self_, key): (LuaReflectReference, Value)| { + // catchall, parse the path + let mut elem = Self::parse_value_index(key)?; + Self::to_host_index(&mut elem); + self_.0.index_path(elem); + self_.to_lua_proxy(l) + }, + ); + m.add_meta_function( + MetaMethod::NewIndex, + |l, (mut self_, key, value): (LuaReflectReference, Value, Value)| { + let mut elem = Self::parse_value_index(key)?; + Self::to_host_index(&mut elem); + self_.0.index_path(elem); + self_.set_with_lua_proxy(l, value) + }, + ); + } +} + +#[cfg(test)] +mod test { + + use bevy::{ + app::App, + ecs::{reflect::AppTypeRegistry, world::World}, + reflect::{FromReflect, OffsetAccess, Reflect}, + }; + use bevy_mod_scripting_core::{ + bindings::ReflectAllocator, + bindings::{ReflectBase, ReflectBaseType, WorldAccessGuard, WorldCallbackAccess}, + }; + use bevy_mod_scripting_lua_derive::LuaProxy; + + use crate::{bindings::world::LuaWorld, RegisterLua}; + + use super::*; + + #[derive(Reflect)] + struct TestStruct { + value: usize, + proxy: TestProxied, + proxies: Vec, + } + + #[derive(Reflect)] + struct TestTupleStruct(usize, TestProxied, Vec); + + #[derive(Reflect)] + enum TestTupleEnum { + Value(usize), + Proxy(TestProxied), + Proxies(Vec), + } + + #[derive(Reflect, LuaProxy)] + #[proxy(bms_core_path = "bevy_mod_scripting_core", bms_lua_path = "crate")] + #[reflect(LuaProxied)] + pub struct TestProxied; + + impl PartialEq for LuaTestProxied { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } + } + + /// asserts that setting then indexing into a LuaReflectReference of type T with the given expression returns the expected value. + /// Provides `t and `world` globals, with t being the LuaReflectReference to the provided value. + fn assert_lua_set_get_returns< + T: Reflect, + F: Fn(ReflectReference) -> O, + O: for<'l> FromLua<'l> + for<'l> IntoLua<'l> + PartialEq + std::fmt::Debug, + >( + world: Option, + val: T, + expr: &'static str, + expected: F, + ) { + let mut world = world.unwrap_or_default(); + let lua = Lua::new(); + let mut allocator = ReflectAllocator::default(); + let reflect_ref = LuaReflectReference(ReflectReference::new_allocated(val, &mut allocator)); + world.insert_resource(allocator); + + WorldCallbackAccess::with_callback_access(&mut world, |access| { + let globals = lua.globals(); + globals.set("test", reflect_ref.clone()).unwrap(); + globals.set("world", LuaWorld(access.clone())).unwrap(); + globals + .set("expected", expected(reflect_ref.0.clone())) + .unwrap(); + + let lua_code = format!( + r#" + {expr} = expected + return {expr} + "# + ); + let result = lua + .load(&lua_code) + .into_function() + .unwrap_or_else(|e| panic!("Could not load lua code into function: `{e}`")) + .call(()) + .unwrap_or_else(|e| { + panic!("Could not convert expression value to expected type: `{e}`") + }); + let result: O = result; + assert_eq!(result, expected(reflect_ref.0)); + }); + } + + #[test] + fn test_index_lua_value() { + // so we have the registry and can just do this + let mut app = App::new(); + app.register_lua_value::(); + + assert_lua_set_get_returns( + Some(app.world), + TestStruct { + value: 123, + proxy: TestProxied, + proxies: vec![], + }, + "test.value", + |_| 123usize, + ); + + let mut app = App::new(); + app.register_lua_value::(); + + assert_lua_set_get_returns( + Some(app.world), + TestTupleStruct(123, TestProxied, vec![]), + "test._1", + |_| 123usize, + ); + + let mut app = App::new(); + app.register_lua_value::(); + + assert_lua_set_get_returns( + Some(app.world), + TestTupleEnum::Value(123usize), + "test._1", + |_| 123usize, + ); + } + + #[test] + fn test_index_lua_proxy() { + // so we have the registry and can just do this + let mut app = App::new(); + app.register_lua_proxy::(); + + assert_lua_set_get_returns( + Some(app.world), + TestStruct { + value: 123, + proxy: TestProxied, + proxies: vec![], + }, + "test.proxy", + |mut r| { + r.index_path(ParsedPath::parse_static("proxy").unwrap()); + LuaTestProxied(r) + }, + ); + + let mut app = App::new(); + app.register_lua_proxy::(); + + assert_lua_set_get_returns( + Some(app.world), + TestTupleStruct(123, TestProxied, vec![]), + "test._2", + |mut r| { + r.index_path(ParsedPath::parse_static(".1").unwrap()); + LuaTestProxied(r) + }, + ); + + let mut app = App::new(); + app.register_lua_proxy::(); + + assert_lua_set_get_returns( + Some(app.world), + TestTupleEnum::Proxy(TestProxied), + "test._1", + |mut r| { + r.index_path(ParsedPath::parse_static(".0").unwrap()); + LuaTestProxied(r) + }, + ); + } + + #[test] + fn test_index_lua_proxy_vec() { + // so we have the registry and can just do this + let mut app = App::new(); + app.register_lua_proxy::(); + + assert_lua_set_get_returns( + Some(app.world), + TestStruct { + value: 123, + proxy: TestProxied, + proxies: vec![TestProxied], + }, + "test.proxies[1]", + |mut r| { + r.index_path(ParsedPath::parse_static("proxies").unwrap()); + r.index_path(ParsedPath::parse_static("[0]").unwrap()); + LuaTestProxied(r) + }, + ); + + let mut app = App::new(); + app.register_lua_proxy::(); + + assert_lua_set_get_returns( + Some(app.world), + TestTupleStruct(123, TestProxied, vec![TestProxied]), + "test._3[1]", + |mut r| { + r.index_path(ParsedPath::parse_static(".2").unwrap()); + r.index_path(ParsedPath::parse_static("[0]").unwrap()); + LuaTestProxied(r) + }, + ); + + let mut app = App::new(); + app.register_lua_proxy::(); + + assert_lua_set_get_returns( + Some(app.world), + TestTupleEnum::Proxies(vec![TestProxied]), + "test._1[1]", + |mut r| { + r.index_path(ParsedPath::parse_static(".0").unwrap()); + r.index_path(ParsedPath::parse_static("[0]").unwrap()); + LuaTestProxied(r) + }, + ); + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/type_registration.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/type_registration.rs new file mode 100644 index 00000000..897dbd65 --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/type_registration.rs @@ -0,0 +1,14 @@ +use std::sync::Arc; + +use bevy::reflect::TypeRegistration; +use tealr::mlu::TealData; + +use crate::impl_userdata_from_lua; + +/// Caches information about type data +#[derive(Clone, tealr::mlu::UserData, tealr::ToTypename)] +pub struct LuaTypeRegistration(Arc); + +impl_userdata_from_lua!(LuaTypeRegistration); + +impl TealData for LuaTypeRegistration {} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs index b3c9f80d..9b1bfc54 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs @@ -1,19 +1,27 @@ -use bevy_mod_scripting_core::bindings::WorldCallbackAccess; +use std::sync::Arc; + +use bevy::ecs::{reflect::AppTypeRegistry, world::Mut}; +use bevy_mod_scripting_core::{ + bindings::{Unproxy, WorldAccessGuard, WorldCallbackAccess}, + error::ScriptError, +}; use tealr::{ - mlu::{mlua::FromLua, FromToLua, TealData}, + mlu::{ + mlua::{self, FromLua}, + FromToLua, TealData, + }, ToTypename, Type, }; use crate::{impl_userdata_from_lua, impl_userdata_with_tealdata}; -use super::proxy::LuaProxied; +use super::proxy::{LuaProxied, LuaValProxy}; /// Lua UserData wrapper for [`bevy::ecs::world::World`] -#[derive(Clone)] +#[derive(Clone, tealr::mlu::UserData, tealr::ToTypename)] pub struct LuaWorld(pub WorldCallbackAccess); impl_userdata_from_lua!(LuaWorld); -impl_userdata_with_tealdata!(LuaWorld); impl LuaProxied for WorldCallbackAccess { type Proxy = LuaWorld; @@ -27,13 +35,35 @@ impl From<&LuaWorld> for WorldCallbackAccess { impl TealData for LuaWorld { fn add_methods<'lua, T: tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { - // methods.add_function("spawn_entity", |_, _, _| Ok(())); + // methods.add_method("get_type_by_name", |_, world, type_name: String| { + // let world = world + // .0 + // .read() + // .ok_or_else(|| mlua::Error::external(ReflectionError::StaleWorldAccess))?; + + // world.with_resource(|world, registry: Mut| { + // let registry = registry.read(); + // Ok(registry.get_with_short_type_path(&type_name).map(Arc::new)) + // }) + // }); } } -impl ToTypename for LuaWorld { - fn to_typename() -> Type { - Type::new_single("World", tealr::KindOfType::External) +pub trait GetWorld { + fn get_world(&self) -> Result>, mlua::Error>; +} + +impl GetWorld for mlua::Lua { + fn get_world(&self) -> Result>, mlua::Error> { + self.globals() + .get::<_, LuaValProxy>("world")? + .unproxy() + .and_then(|guard| { + guard + .read() + .ok_or_else(|| ScriptError::new_reflection_error("Stale world access")) + }) + .map_err(mlua::Error::external) } } @@ -44,7 +74,7 @@ mod test { use bevy::ecs::world::World; use bevy_mod_scripting_core::{ bindings::WorldAccessGuard, - proxy::{Unproxy, ValProxy}, + bindings::{Unproxy, ValProxy}, }; use tealr::mlu::mlua::Lua; diff --git a/crates/languages/bevy_mod_scripting_lua/src/lib.rs b/crates/languages/bevy_mod_scripting_lua/src/lib.rs index 7ae3205d..7a5dc299 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/lib.rs @@ -4,7 +4,7 @@ pub mod util; use bevy::{ app::{App, Plugin}, ecs::{entity::Entity, world::World}, - reflect::{FromType, Reflect, TypePath}, + reflect::{FromType, GetTypeRegistration, Reflect, TypePath}, }; use bevy_mod_scripting_core::{ bindings::{ReflectReference, WorldCallbackAccess}, @@ -56,6 +56,22 @@ impl Default for LuaScriptingPlugin { impl Plugin for LuaScriptingPlugin { fn build(&self, app: &mut bevy::prelude::App) { self.scripting_plugin.build(app); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); + app.register_lua_value::(); } } @@ -142,30 +158,54 @@ pub fn with_world Result<(), ScriptError>>( f: F, ) -> Result<(), ScriptError> { WorldCallbackAccess::with_callback_access(world, |guard| { - context.globals().set("world", LuaWorld(guard.clone())); + context.globals().set("world", LuaWorld(guard.clone()))?; // TODO set entity + script id as well f(context) }) } /// Registers a lua proxy object via the reflection system -pub trait RegisterLuaProxy { - fn register_proxy(&mut self) -> &mut Self +pub trait RegisterLua { + fn register_lua_proxy( + &mut self, + ) -> &mut Self where T::Proxy: for<'l> IntoLua<'l> + for<'l> FromLua<'l>, T::Proxy: From + AsRef; + + fn register_lua_value( + &mut self, + ) -> &mut Self + where + T: for<'l> IntoLua<'l> + for<'l> FromLua<'l>; } -impl RegisterLuaProxy for App { - fn register_proxy(&mut self) -> &mut Self +impl RegisterLua for App { + fn register_lua_proxy( + &mut self, + ) -> &mut Self where T::Proxy: for<'l> IntoLua<'l> + for<'l> FromLua<'l>, T::Proxy: From + AsRef, { + self.register_type::(); self.register_type_data::() } + + fn register_lua_value( + &mut self, + ) -> &mut Self + where + T: for<'l> IntoLua<'l> + for<'l> FromLua<'l>, + { + self.register_type::(); + self.register_type_data::() + } } +/// Stores the procedure used to convert a lua value to a reflect value and vice versa, Used for types which are represented in lua via proxies which store +/// a reference to the actual value. +/// This is used for types which are represented in lua with pass by reference semantics #[derive(Clone)] pub struct ReflectLuaProxied { pub into_proxy: @@ -186,3 +226,30 @@ where } } } + +/// Stores the procedure used to convert a lua value to a reflect value and vice versa, Used for types which are represented directly in lua with +/// pass by value semantics, These need to implement [`Clone`] +#[derive(Clone)] +pub struct ReflectLuaValue { + pub into_value: for<'l> fn(&dyn Reflect, &'l Lua) -> Result, tealr::mlu::mlua::Error>, + pub set_value: + for<'l> fn(&mut dyn Reflect, Value<'l>, &'l Lua) -> Result<(), tealr::mlu::mlua::Error>, + pub from_value: + for<'l> fn(Value<'l>, &'l Lua) -> Result, tealr::mlu::mlua::Error>, +} + +impl IntoLua<'l> + for<'l> FromLua<'l>> FromType + for ReflectLuaValue +{ + fn from_type() -> Self { + Self { + into_value: |v, l| v.downcast_ref::().unwrap().clone().into_lua(l), + set_value: |t, v, l| { + let mut t = t.downcast_mut::().unwrap(); + *t = T::from_lua(v, l)?; + Ok(()) + }, + from_value: |v, l| T::from_lua(v, l).map(|v| Box::new(v) as Box), + } + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/util.rs b/crates/languages/bevy_mod_scripting_lua/src/util.rs index 25758547..be5faab0 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/util.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/util.rs @@ -157,7 +157,7 @@ macro_rules! __cfg_feature_any_lua52_lua53_lua54_luajit52 { #[macro_export] macro_rules! impl_userdata_from_lua { ($ty:ident) => { - impl<'lua> FromLua<'lua> for $ty { + impl<'lua> ::tealr::mlu::mlua::FromLua<'lua> for $ty { fn from_lua( value: ::tealr::mlu::mlua::Value<'lua>, _lua: &::tealr::mlu::mlua::Lua, diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 54058c4d..f9c99824 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -163,7 +163,7 @@ fn proxy_wrap_function_def( // wrap function body in our unwrapping and wrapping logic, ignore pre-existing body let mut fn_call = std::panic::catch_unwind(|| { - let mut fn_call = match (&f.default, &attrs.as_trait) { + match (&f.default, &attrs.as_trait) { (Some(body), _) => quote_spanned!(span=> (||{ #body })() ), @@ -176,8 +176,7 @@ fn proxy_wrap_function_def( <#target_type as #trait_path>::#func_name(#(#original_arg_idents),*) ) } - }; - fn_call + } }) .unwrap(); // todo: handle the error nicer @@ -197,7 +196,7 @@ fn proxy_wrap_function_def( f.default = Some(parse_quote_spanned! {span=> { let mut world: #bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> = #ctxt_arg_ident.globals().get("world")?; - let mut world = <#bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> as #bms_core::proxy::Unproxy>::unproxy(&mut world).map_err(#mlua::Error::external)?; + let mut world = <#bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> as #bms_core::bindings::Unproxy>::unproxy(&mut world).map_err(#mlua::Error::external)?; let mut world = world.read().ok_or_else(|| #mlua::Error::external("World no longer exists"))?; let out: #out_type = world.proxy_call(#args_ident, |(#(#original_arg_idents),*)| { #fn_call @@ -362,17 +361,6 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } }); - // panic!( - // "{}", - // quote! { - // #( - // if let Ok(args) = <#closure_args_types as #mlua::FromLua>::from_lua(args) { - // return (#closures)(ctxt, args); - // } - // )* - // Err(#mlua::Error::external("Invalid arguments for composite function")) - // } - // ); let closure = parse_quote_spanned! {first_function.span()=> |ctxt, (#(#value_arg_names,)*): (#(#value_arg_types,)*)| { let args = #mlua::MultiValue::from_vec(vec![#(#value_arg_names,)*]); @@ -385,7 +373,6 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { Err(#mlua::Error::external("Invalid arguments for composite function")) } }; - // panic!("asd"); generate_methods_registration(&first_function_attrs, first_function.span(), name, closure) }); @@ -430,22 +417,6 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } } - // impl #tealr::mlu::mlua::UserData for #proxy_type_ident - // where - // Self: #tealr::mlu::TealData, - // { - // fn add_methods<'lua, T: #tealr::mlu::mlua::UserDataMethods<'lua, Self>>( - // methods: &mut T, - // ) { - // let mut wrapper = tealr::mlu::UserDataWrapper::from_user_data_methods(methods); - // ::add_methods(&mut wrapper); - // } - - // fn add_fields<'lua, T: #tealr::mlu::mlua::UserDataFields<'lua, Self>>(fields: &mut T) { - // let mut wrapper = tealr::mlu::UserDataWrapper::from_user_data_fields(fields); - // ::add_fields(&mut wrapper); - // } - // } impl<'lua> #tealr::mlu::mlua::FromLua<'lua> for #proxy_type_ident { fn from_lua( @@ -465,14 +436,6 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } } - // impl #tealr::ToTypename for #proxy_type_ident { - // fn to_typename() -> #tealr::Type { - // #tealr::Type::Single(#tealr::SingleType { - // name: #tealr::Name(#target_type_str.into()), - // kind: #tealr::KindOfType::External, - // }) - // } - // } impl AsRef<#bms_core::bindings::ReflectReference> for #proxy_type_ident { fn as_ref(&self) -> &#bms_core::bindings::ReflectReference { From 541c1c7cf8ad1c0b67d9cdedeecc9f00c705cc4f Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 25 May 2024 19:48:00 +0100 Subject: [PATCH 14/17] Move type registration into its own type --- .../src/bindings/mod.rs | 3 +- .../src/bindings/query.rs | 47 +++++++++++++++++++ .../src/bindings/world.rs | 19 ++++---- 3 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 crates/bevy_mod_scripting_core/src/bindings/query.rs diff --git a/crates/bevy_mod_scripting_core/src/bindings/mod.rs b/crates/bevy_mod_scripting_core/src/bindings/mod.rs index 13c44cb6..24f8ddf4 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/mod.rs +++ b/crates/bevy_mod_scripting_core/src/bindings/mod.rs @@ -1,6 +1,7 @@ pub mod allocator; pub mod proxy; +pub mod query; pub mod reference; pub mod world; -pub use {allocator::*, proxy::*, reference::*, world::*}; +pub use {allocator::*, proxy::*, query::*, reference::*, world::*}; diff --git a/crates/bevy_mod_scripting_core/src/bindings/query.rs b/crates/bevy_mod_scripting_core/src/bindings/query.rs new file mode 100644 index 00000000..d89944cb --- /dev/null +++ b/crates/bevy_mod_scripting_core/src/bindings/query.rs @@ -0,0 +1,47 @@ +use std::{ops::Deref, sync::Arc}; + +use bevy::reflect::TypeRegistration; + +/// A wrapper around a `TypeRegistration` that provides additional information about the type. +/// +/// This is used as a hook to a rust type from a scripting language. We should be able to easily convert between a type name and a [`ScriptTypeRegistration`]. +#[derive(Clone)] +pub struct ScriptTypeRegistration(pub(crate) Arc); + +impl ScriptTypeRegistration { + pub fn new(arc: Arc) -> Self { + Self(arc) + } + + #[inline(always)] + pub fn short_name(&self) -> &str { + self.0.type_info().type_path_table().short_path() + } + + #[inline(always)] + pub fn type_name(&self) -> &'static str { + self.0.type_info().type_path_table().path() + } +} + +impl std::fmt::Debug for ScriptTypeRegistration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_tuple("ScriptTypeRegistration") + .field(&self.0.type_info().type_path()) + .finish() + } +} + +impl std::fmt::Display for ScriptTypeRegistration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(self.0.type_info().type_path()) + } +} + +impl Deref for ScriptTypeRegistration { + type Target = Arc; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} diff --git a/crates/bevy_mod_scripting_core/src/bindings/world.rs b/crates/bevy_mod_scripting_core/src/bindings/world.rs index 84a7396d..289f66a5 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/world.rs +++ b/crates/bevy_mod_scripting_core/src/bindings/world.rs @@ -45,7 +45,7 @@ use crate::{ use super::{ proxy::{Proxy, Unproxy}, - ReflectBase, ReflectBaseType, ReflectReference, + ReflectBase, ReflectBaseType, ReflectReference, ScriptTypeRegistration, }; /// Describes kinds of base value we are accessing via reflection @@ -132,7 +132,7 @@ const CONCURRENT_ACCESS_MSG: &str = /// common world methods impl WorldCallbackAccess { - pub fn get_type_by_name(&self, type_name: &str) -> Option> { + pub fn get_type_by_name(&self, type_name: &str) -> Option { let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); world.with_resource(|_, registry: Mut| { @@ -140,14 +140,14 @@ impl WorldCallbackAccess { registry .get_with_short_type_path(type_name) .or_else(|| registry.get_with_type_path(type_name)) - .map(|registration| Arc::new(registration.clone())) + .map(|registration| ScriptTypeRegistration::new(Arc::new(registration.clone()))) }) } pub fn add_default_component( &self, entity: Entity, - registration: Arc, + registration: ScriptTypeRegistration, ) -> ScriptResult<()> { let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); @@ -243,7 +243,7 @@ impl WorldCallbackAccess { pub fn remove_component( &self, entity: Entity, - registration: Arc, + registration: ScriptTypeRegistration, ) -> ScriptResult<()> { let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); @@ -290,7 +290,7 @@ impl WorldCallbackAccess { }) } - pub fn remove_resource(&self, registration: Arc) -> ScriptResult<()> { + pub fn remove_resource(&self, registration: ScriptTypeRegistration) -> ScriptResult<()> { let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); let component_data = registration.data::().ok_or_else(|| ScriptError::new_runtime_error(format!( @@ -1124,23 +1124,24 @@ mod test_api { use bevy::ecs::world::FromWorld; use bevy::hierarchy::BuildChildren; + use crate::bindings::ScriptTypeRegistration; use crate::prelude::{ScriptErrorInner, ScriptErrorKind}; use super::test::{setup_world, TestComponent, TestResource}; use super::*; - fn get_reg(world: &WorldCallbackAccess, name: &str) -> Arc { + fn get_reg(world: &WorldCallbackAccess, name: &str) -> ScriptTypeRegistration { world.get_type_by_name(name).expect("Type not found") } - fn test_comp_reg(world: &WorldCallbackAccess) -> Arc { + fn test_comp_reg(world: &WorldCallbackAccess) -> ScriptTypeRegistration { world .get_type_by_name("TestComponent") .expect("Component not found") } - fn test_resource_reg(world: &WorldCallbackAccess) -> Arc { + fn test_resource_reg(world: &WorldCallbackAccess) -> ScriptTypeRegistration { world .get_type_by_name("TestResource") .expect("Resource not found") From 86362054f4fdd6f69b89a61e0f075fdf90cf99b6 Mon Sep 17 00:00:00 2001 From: makspll Date: Sun, 9 Jun 2024 13:52:37 +0100 Subject: [PATCH 15/17] :construction: burn down and simplify crates --- Cargo.toml | 6 +- crates/bevy_api_gen/src/bin/main.rs | 5 +- crates/bevy_api_gen/src/feature_graph.rs | 43 ++++-- crates/bevy_mod_scripting_common/Cargo.toml | 33 ----- crates/bevy_mod_scripting_common/readme.md | 3 - crates/bevy_mod_scripting_common/src/lib.rs | 2 - .../src/bindings/query.rs | 71 +++++++++- .../src/bindings/world.rs | 14 +- .../Cargo.toml | 12 +- .../readme.md | 0 .../src/input.rs | 11 +- .../src/lib.rs | 86 +++++++----- .../src/utils.rs | 0 .../bevy_mod_scripting_lua/Cargo.toml | 2 +- .../src/bindings/proxy.rs | 127 ++---------------- .../src/bindings/reference.rs | 74 +++++----- .../src/bindings/type_registration.rs | 9 +- .../src/bindings/world.rs | 109 ++++++++++----- .../bevy_mod_scripting_lua_derive/Cargo.toml | 38 ------ .../bevy_mod_scripting_rhai_derive/readme.md | 3 - .../bevy_mod_scripting_rhai_derive/src/lib.rs | 13 -- 21 files changed, 305 insertions(+), 356 deletions(-) delete mode 100644 crates/bevy_mod_scripting_common/Cargo.toml delete mode 100644 crates/bevy_mod_scripting_common/readme.md delete mode 100644 crates/bevy_mod_scripting_common/src/lib.rs rename crates/{languages/bevy_mod_scripting_rhai_derive => bevy_mod_scripting_derive}/Cargo.toml (67%) rename crates/{languages/bevy_mod_scripting_lua_derive => bevy_mod_scripting_derive}/readme.md (100%) rename crates/{bevy_mod_scripting_common => bevy_mod_scripting_derive}/src/input.rs (83%) rename crates/{languages/bevy_mod_scripting_lua_derive => bevy_mod_scripting_derive}/src/lib.rs (90%) rename crates/{bevy_mod_scripting_common => bevy_mod_scripting_derive}/src/utils.rs (100%) delete mode 100644 crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml delete mode 100644 crates/languages/bevy_mod_scripting_rhai_derive/readme.md delete mode 100644 crates/languages/bevy_mod_scripting_rhai_derive/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index d7462c0c..1c462138 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,7 +72,6 @@ bevy_mod_scripting_rune = { path = "crates/languages/bevy_mod_scripting_rune", v [workspace.dependencies] bevy = { version = "=0.13.1", default-features = false } bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.6.0" } -bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.6.0" } [dev-dependencies] bevy = { workspace = true, default-features = true } @@ -84,13 +83,10 @@ rhai-rand = "0.1" [workspace] members = [ "crates/bevy_mod_scripting_core", - # "crates/bevy_script_api", + "crates/bevy_mod_scripting_derive", "crates/languages/bevy_mod_scripting_lua", - "crates/languages/bevy_mod_scripting_lua_derive", "crates/languages/bevy_mod_scripting_rhai", - "crates/languages/bevy_mod_scripting_rhai_derive", "crates/languages/bevy_mod_scripting_rune", - "crates/bevy_mod_scripting_common", ] resolver = "2" exclude = ["crates/bevy_api_gen", "crates/macro_tests"] diff --git a/crates/bevy_api_gen/src/bin/main.rs b/crates/bevy_api_gen/src/bin/main.rs index a5c93bf2..0f5fee32 100644 --- a/crates/bevy_api_gen/src/bin/main.rs +++ b/crates/bevy_api_gen/src/bin/main.rs @@ -39,7 +39,10 @@ fn main() { (Some(root), true) => { let feature_graph = FeatureGraph::from_metadata(&metadata, root); let dependencies = feature_graph - .dependencies_for_features(args.features.as_ref(), !args.no_default_features) + .workspace_dependencies_for_features( + args.features.as_ref(), + !args.no_default_features, + ) .into_iter() .map(|s| s.to_owned()) .collect::>(); diff --git a/crates/bevy_api_gen/src/feature_graph.rs b/crates/bevy_api_gen/src/feature_graph.rs index 33b491ee..feddbd0d 100644 --- a/crates/bevy_api_gen/src/feature_graph.rs +++ b/crates/bevy_api_gen/src/feature_graph.rs @@ -58,9 +58,9 @@ pub struct FeatureGraph { } impl FeatureGraph { - /// Works out which dependencies are enabled by the given feature, including transitive relations between crates + /// Works out which dependencies are enabled (in the workspace) are enabled by the given feature, including transitive relations between crates /// includes normal dependencies as well - pub fn dependencies_for_features( + pub fn workspace_dependencies_for_features( &self, features: &[String], include_default: bool, @@ -70,14 +70,24 @@ impl FeatureGraph { .crates .iter() .find(|c| c.name == self.workspace_root) - .unwrap(); + .unwrap_or_else(|| { + panic!( + "Failed to find workspace root `{}`, in crates in this workspace.", + self.workspace_root + ) + }); let mut buffer = Default::default(); - self.dependencies_for_features_on_crate(root, features, include_default, &mut buffer); + self.workspace_dependencies_for_features_on_crate( + root, + features, + include_default, + &mut buffer, + ); buffer.iter().map(|c| c.name.as_str()).collect() } - fn dependencies_for_features_on_crate<'a>( + fn workspace_dependencies_for_features_on_crate<'a>( &'a self, crate_: &'a Crate, features: &[String], @@ -107,15 +117,19 @@ impl FeatureGraph { enable_optional, } => { if *enable_optional { - deps.entry(self.crates.iter().find(|c| c.name == *dependency).unwrap()) - .or_default() - .push(feature.to_owned()); + if let Some(workspace_dep) = + self.crates.iter().find(|c| c.name == *dependency) + { + deps.entry(workspace_dep) + .or_default() + .push(feature.to_owned()); + } } } FeatureEffect::EnableOptionalDep(d) => { - _ = deps - .entry(self.crates.iter().find(|c| c.name == *d).unwrap()) - .or_default() + if let Some(workspace_dep) = self.crates.iter().find(|c| c.name == *d) { + deps.entry(workspace_dep).or_default(); + } } _ => unreachable!(), }; @@ -131,7 +145,12 @@ impl FeatureGraph { // repeat for all dependencies recursively for (dep, features) in deps.iter() { buffer.insert(dep); - self.dependencies_for_features_on_crate(dep, features, include_default, buffer); + self.workspace_dependencies_for_features_on_crate( + dep, + features, + include_default, + buffer, + ); } } diff --git a/crates/bevy_mod_scripting_common/Cargo.toml b/crates/bevy_mod_scripting_common/Cargo.toml deleted file mode 100644 index 3bd15938..00000000 --- a/crates/bevy_mod_scripting_common/Cargo.toml +++ /dev/null @@ -1,33 +0,0 @@ -[package] -name = "bevy_mod_scripting_common" -version = "0.6.0" -authors = ["Maksymilian Mozolewski "] -edition = "2021" -license = "MIT OR Apache-2.0" -description = "Traits and syn structures for language implementors" -repository = "https://github.com/makspll/bevy_mod_scripting" -homepage = "https://github.com/makspll/bevy_mod_scripting" -keywords = ["bevy", "gamedev", "scripting", "lua"] -categories = ["game-development"] -readme = "readme.md" - -[lib] -name = "bevy_mod_scripting_common" -path = "src/lib.rs" - -[dependencies] -darling = "0.20.3" -paste = "1.0.7" -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"] } -strum = { version = "0.24.1", features = ["derive"] } diff --git a/crates/bevy_mod_scripting_common/readme.md b/crates/bevy_mod_scripting_common/readme.md deleted file mode 100644 index 674bf81c..00000000 --- a/crates/bevy_mod_scripting_common/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# bevy_mod_scripting_common - -This crate is a part of the ["bevy_mod_scripting" workspace](https://github.com/makspll/bevy_mod_scripting). \ No newline at end of file diff --git a/crates/bevy_mod_scripting_common/src/lib.rs b/crates/bevy_mod_scripting_common/src/lib.rs deleted file mode 100644 index 5d7b01f9..00000000 --- a/crates/bevy_mod_scripting_common/src/lib.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod input; -pub mod utils; diff --git a/crates/bevy_mod_scripting_core/src/bindings/query.rs b/crates/bevy_mod_scripting_core/src/bindings/query.rs index d89944cb..5a7db18a 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/query.rs +++ b/crates/bevy_mod_scripting_core/src/bindings/query.rs @@ -1,6 +1,9 @@ -use std::{ops::Deref, sync::Arc}; +use std::{any::TypeId, ops::Deref, sync::Arc}; -use bevy::reflect::TypeRegistration; +use bevy::{ecs::entity::Entity, reflect::TypeRegistration}; + +use super::{ReflectReference, WorldCallbackAccess, STALE_WORLD_MSG}; +use crate::prelude::{ScriptError, ScriptResult}; /// A wrapper around a `TypeRegistration` that provides additional information about the type. /// @@ -22,6 +25,11 @@ impl ScriptTypeRegistration { pub fn type_name(&self) -> &'static str { self.0.type_info().type_path_table().path() } + + #[inline(always)] + pub fn type_id(&self) -> TypeId { + self.0.type_info().type_id() + } } impl std::fmt::Debug for ScriptTypeRegistration { @@ -45,3 +53,62 @@ impl Deref for ScriptTypeRegistration { &self.0 } } + +#[derive(Clone)] +pub struct ScriptQueryBuilder { + world: WorldCallbackAccess, + components: Vec, + with: Vec, + without: Vec, +} + +impl ScriptQueryBuilder { + pub fn new(world: WorldCallbackAccess) -> Self { + Self { + world, + components: vec![], + with: vec![], + without: vec![], + } + } + + pub fn components(&mut self, components: Vec) -> &mut Self { + self.components.extend(components); + self + } + + pub fn with(&mut self, with: Vec) -> &mut Self { + self.with.extend(with); + self + } + + pub fn without(&mut self, without: Vec) -> &mut Self { + self.without.extend(without); + self + } + + pub fn build(&mut self) -> ScriptResult> { + self.world.query( + std::mem::take(&mut self.components), + std::mem::take(&mut self.with), + std::mem::take(&mut self.without), + ) + } +} + +#[derive(Clone)] +pub struct ScriptQueryResult(pub Entity, pub Vec); + +impl WorldCallbackAccess { + pub fn query( + &mut self, + components: Vec, + with: Vec, + without: Vec, + ) -> ScriptResult> { + // for c in components { + + // } + todo!() + } +} diff --git a/crates/bevy_mod_scripting_core/src/bindings/world.rs b/crates/bevy_mod_scripting_core/src/bindings/world.rs index 289f66a5..f7cff106 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/world.rs +++ b/crates/bevy_mod_scripting_core/src/bindings/world.rs @@ -33,7 +33,7 @@ use bevy::{ ptr::Ptr, reflect::{ std_traits::ReflectDefault, Access, ParsedPath, Reflect, ReflectFromPtr, ReflectPath, - ReflectPathError, TypeInfo, TypeRegistration, TypeRegistry, + ReflectPathError, TypeInfo, TypePath, TypeRegistration, TypeRegistry, }, utils::smallvec::SmallVec, }; @@ -84,7 +84,7 @@ impl From for ReflectAccessId { /// While [`WorldAccessGuard`] prevents aliasing at runtime and also makes sure world exists at least as long as the guard itself, /// borrows sadly do not persist the script-host boundary :(. That is to be expected, but instead we can make an abstraction which removes the lifetime parameter, making the outer type 'static, /// while making sure the lifetime is still satisfied! -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct WorldCallbackAccess(Weak>); impl WorldCallbackAccess { @@ -125,12 +125,14 @@ impl WorldCallbackAccess { } } -const STALE_WORLD_MSG: &str = "Tried to access world via stale reference"; -const CONCURRENT_WORLD_ACCESS_MSG: &str = "Something else is accessing the world right now!"; -const CONCURRENT_ACCESS_MSG: &str = +pub(crate) const STALE_WORLD_MSG: &str = "Tried to access world via stale reference"; +pub(crate) const CONCURRENT_WORLD_ACCESS_MSG: &str = + "Something else is accessing the world right now!"; +pub(crate) const CONCURRENT_ACCESS_MSG: &str = "Something else is accessing the resource/component/allocation right now!"; -/// common world methods +/// common world methods, see: +/// - [`crate::bindings::query`] for query related functionality impl WorldCallbackAccess { pub fn get_type_by_name(&self, type_name: &str) -> Option { let world = self.read().unwrap_or_else(|| panic!("{STALE_WORLD_MSG}")); diff --git a/crates/languages/bevy_mod_scripting_rhai_derive/Cargo.toml b/crates/bevy_mod_scripting_derive/Cargo.toml similarity index 67% rename from crates/languages/bevy_mod_scripting_rhai_derive/Cargo.toml rename to crates/bevy_mod_scripting_derive/Cargo.toml index 18afb127..4540176a 100644 --- a/crates/languages/bevy_mod_scripting_rhai_derive/Cargo.toml +++ b/crates/bevy_mod_scripting_derive/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "bevy_mod_scripting_rhai_derive" +name = "bevy_mod_scripting_derive" version = "0.6.0" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" -description = "Necessary functionality for Rhai support with bevy_mod_scripting" +description = "Necessary functionality for Lua support with bevy_mod_scripting" repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] @@ -12,14 +12,14 @@ categories = ["game-development"] readme = "readme.md" [lib] -name = "bevy_mod_scripting_rhai_derive" +name = "bevy_mod_scripting_derive" path = "src/lib.rs" proc-macro = true [dependencies] -bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.6.0" } paste = "1.0.7" -syn = { version = "1.0.57", features = ["full", "fold", "extra-traits"] } +darling = "0.20.3" +syn = { version = "2.0.38", features = ["full", "fold", "extra-traits"] } quote = "1.0.8" proc-macro2 = "1.0" convert_case = "0.5.0" @@ -27,3 +27,5 @@ rustdoc-types = "0.11.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"] } +vec1 = "1.10.1" diff --git a/crates/languages/bevy_mod_scripting_lua_derive/readme.md b/crates/bevy_mod_scripting_derive/readme.md similarity index 100% rename from crates/languages/bevy_mod_scripting_lua_derive/readme.md rename to crates/bevy_mod_scripting_derive/readme.md diff --git a/crates/bevy_mod_scripting_common/src/input.rs b/crates/bevy_mod_scripting_derive/src/input.rs similarity index 83% rename from crates/bevy_mod_scripting_common/src/input.rs rename to crates/bevy_mod_scripting_derive/src/input.rs index 8200dc38..c7c8a35a 100644 --- a/crates/bevy_mod_scripting_common/src/input.rs +++ b/crates/bevy_mod_scripting_derive/src/input.rs @@ -1,4 +1,4 @@ -use darling::{FromDeriveInput, FromMeta}; +use darling::{util::Flag, FromDeriveInput, FromMeta}; use proc_macro2::Ident; use std::ops::{Deref, DerefMut}; use syn::{spanned::Spanned, visit_mut::VisitMut, Attribute, Field, TraitItemFn, Variant}; @@ -30,11 +30,20 @@ pub struct ProxyInput { pub vis: syn::Visibility, /// The generics on the target type pub generics: syn::Generics, + /// The attributes on the target type pub attrs: Vec, /// The path to the type for which we are generating a proxy if it's a foreign type pub remote: Option, + /// If set to true, will generate a simple newtype instead of a ReflectReference wrapping type + /// Only used for the special world proxies, probably not useful for anything else, the macro assumes we have an inner ReflectReference in the wrapper + pub proxy_as_self: Flag, + + /// Special flag for world proxies, if set to true the proxy will be treated as a world proxy, meaning we do not double fetch the world and instead use the world from the wrapper. + /// This requires proxy_as_self to also be true + pub self_is_world: Flag, + /// The path to the bevy_mod_scripting_core crate #[darling(default)] pub bms_core_path: BMSCorePath, diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/crates/bevy_mod_scripting_derive/src/lib.rs similarity index 90% rename from crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs rename to crates/bevy_mod_scripting_derive/src/lib.rs index f9c99824..24cd09d0 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/crates/bevy_mod_scripting_derive/src/lib.rs @@ -1,29 +1,25 @@ -use std::collections::HashMap; +mod input; +mod utils; + +use crate::{input::*, utils::doc_attribute_to_string_lit}; -use bevy_mod_scripting_common::{input::*, utils::doc_attribute_to_string_lit}; +use std::collections::HashMap; use darling::util::Flag; -use syn::punctuated::Punctuated; -use syn::{parse_macro_input, parse_quote_spanned, DeriveInput, ExprClosure, FnArg, Variant}; use syn::{ - parse_quote, spanned::Spanned, AttrStyle, Attribute, Field, Meta, Path, Token, TraitItemFn, + spanned::Spanned, Path, Token, TraitItemFn, parse_quote, + parse_macro_input, parse_quote_spanned, DeriveInput, ExprClosure, FnArg, + punctuated::Punctuated }; use darling::{FromAttributes, FromDeriveInput}; use proc_macro::TokenStream; use proc_macro2::*; use quote::*; -use vec1::{vec1, Vec1}; + const SELF_ALIAS: &str = "_self"; const CTXT_ALIAS: &str = "lua"; -const RAW_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", -]; /// Convert receiver to a standardised form, for example: /// - instead o a `&self` receiver we have a `_self: LuaRefProxy` @@ -63,7 +59,7 @@ fn collect_args_in_tuple<'a, I: Iterator>( name: &Ident, outer_mut: bool, ) -> FnArg { - let (arg_names, arg_types) = args + let (_, arg_types) = args .map(|arg| { if let FnArg::Typed(arg) = arg { (arg.pat.clone(), arg.ty.clone()) @@ -313,9 +309,9 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { .entry(composite_id.to_owned()) .or_default() .push((f.clone(), attrs)); - true - } else { false + } else { + true } }); @@ -400,10 +396,45 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { }); let vis = &meta.vis; + + let definition = if meta.proxy_as_self.is_present() { + quote_spanned!(derive_input.span()=> + #[derive(Clone, Debug, #tealr::mlu::UserData, #tealr::ToTypename)] + #vis struct #proxy_type_ident (pub #target_type); + ) + } else { + quote_spanned!(derive_input.span()=> + #[derive(Clone, Debug, #tealr::mlu::UserData, #tealr::ToTypename)] + #vis struct #proxy_type_ident (pub #bms_core::bindings::ReflectReference); + ) + }; + + let conversions = if meta.proxy_as_self.is_present() { + quote!( + impl <'a>From<&'a #proxy_type_ident> for #target_type { + fn from(r: &'a #proxy_type_ident) -> Self { + r.0.clone() + } + } + ) + } else { + quote_spanned!(derive_input.span()=> + impl AsRef<#bms_core::bindings::ReflectReference> for #proxy_type_ident { + fn as_ref(&self) -> &#bms_core::bindings::ReflectReference { + &self.0 + } + } + + impl From<#bms_core::bindings::ReflectReference> for #proxy_type_ident { + fn from(r: #bms_core::bindings::ReflectReference) -> Self { + Self(r) + } + } + ) + }; quote_spanned! {meta.ident.span()=> - #[derive(Clone, Debug, #tealr::mlu::UserData, #tealr::ToTypename)] - #vis struct #proxy_type_ident (pub #bms_core::bindings::ReflectReference); + #definition impl #bms_lua::bindings::proxy::LuaProxied for #target_type { type Proxy = #proxy_type_ident; @@ -436,25 +467,8 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } } - - impl AsRef<#bms_core::bindings::ReflectReference> for #proxy_type_ident { - fn as_ref(&self) -> &#bms_core::bindings::ReflectReference { - &self.0 - } - } - - impl From<#bms_core::bindings::ReflectReference> for #proxy_type_ident { - fn from(r: #bms_core::bindings::ReflectReference) -> Self { - Self(r) - } - } - - + #conversions } .into() } -// test cases TODO: -// - pub/private wrapper being generated correctly -// - proxy name being generated correctly with custom name -// - proxy name being generated correctly with default name diff --git a/crates/bevy_mod_scripting_common/src/utils.rs b/crates/bevy_mod_scripting_derive/src/utils.rs similarity index 100% rename from crates/bevy_mod_scripting_common/src/utils.rs rename to crates/bevy_mod_scripting_derive/src/utils.rs diff --git a/crates/languages/bevy_mod_scripting_lua/Cargo.toml b/crates/languages/bevy_mod_scripting_lua/Cargo.toml index a1125484..ded1c20e 100644 --- a/crates/languages/bevy_mod_scripting_lua/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_lua/Cargo.toml @@ -41,7 +41,7 @@ path = "src/lib.rs" [dependencies] bevy = { workspace = true, default-features = false } bevy_mod_scripting_core = { workspace = true } -bevy_mod_scripting_lua_derive = { path = "../bevy_mod_scripting_lua_derive", version = "0.6.0" } +bevy_mod_scripting_derive = { path = "../../bevy_mod_scripting_derive", version = "0.6.0" } tealr = { version = "0.9", features = [ "mlua_vendored", "mlua_send", diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs index fea60e75..b557c3b2 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs @@ -3,10 +3,11 @@ use bevy::reflect::{FromReflect, Reflect, TypeRegistry}; use bevy_mod_scripting_core::{ - bindings::ReflectAllocator, - bindings::{Proxy, ReflectRefMutProxy, ReflectRefProxy, ReflectValProxy, Unproxy, ValProxy}, - bindings::{ReflectReference, WorldAccessGuard, WorldAccessUnit, WorldAccessWrite}, - error::ReflectionError, + bindings::{ + Proxy, ReflectAllocator, ReflectRefMutProxy, ReflectRefProxy, ReflectReference, + ReflectValProxy, Unproxy, ValProxy, WorldAccessGuard, WorldAccessUnit, WorldAccessWrite, + }, + error::ScriptResult, }; use tealr::{ mlu::mlua::{Error, FromLua, IntoLua, Lua, Value}, @@ -24,7 +25,7 @@ pub struct IdentityProxy(pub Option); impl Proxy for IdentityProxy { type Input<'i> = T; - fn proxy<'i>(value: Self::Input<'i>) -> Result { + fn proxy<'i>(value: Self::Input<'i>) -> ScriptResult { Ok(Self(Some(value))) } } @@ -33,7 +34,7 @@ impl Unproxy for IdentityProxy { type Output<'o> = T where Self: 'o; - fn unproxy<'o>(&'o mut self) -> Result, ReflectionError> { + fn unproxy<'o>(&'o mut self) -> ScriptResult> { Ok(self .0 .take() @@ -76,11 +77,11 @@ macro_rules! impl_lua_unproxy { &self, guard: &WorldAccessGuard<'w>, accesses: &mut bevy::utils::smallvec::SmallVec<[WorldAccessWrite<'w>; 1]>, - ) -> Result<(), ReflectionError> { + ) -> ScriptResult<()> { self.0.collect_accesses(guard, accesses) } - fn unproxy(&mut self) -> Result, ReflectionError> { + fn unproxy(&mut self) -> ScriptResult> { self.0.unproxy() } @@ -90,7 +91,7 @@ macro_rules! impl_lua_unproxy { accesses: &'o [WorldAccessUnit<'w>], type_registry: &TypeRegistry, allocator: &'o ReflectAllocator, - ) -> Result, ReflectionError> { + ) -> ScriptResult> { self.0 .unproxy_with_world(guard, accesses, type_registry, allocator) } @@ -136,7 +137,7 @@ macro_rules! impl_lua_proxy { T: $($bounds+)*, { type Input<'i>=<$as<$generic, $generic::Proxy> as bevy_mod_scripting_core::bindings::Proxy>::Input<'i>; - fn proxy<'i>(value: Self::Input<'i>) -> Result { + fn proxy<'i>(value: Self::Input<'i>) -> ScriptResult { Ok(Self($as::<$generic,$generic::Proxy>::proxy(value)?)) } } @@ -167,109 +168,3 @@ impl_lua_unproxy!(LuaReflectRefMutProxy as ReflectRefMutProxy (T) T: (Reflect), T::Proxy: (AsRef), ); - -#[cfg(test)] -mod test { - - use std::{cell::UnsafeCell, sync::Arc}; - - use bevy::{ecs::component::Component, reflect::Reflect}; - use bevy_mod_scripting_core::{ - bindings::ReflectAllocation, - bindings::{ReflectBase, ReflectBaseType, ReflectReference}, - }; - use tealr::mlu::mlua::{UserData, UserDataMethods}; - - use super::*; - - #[derive(Reflect, Component)] - struct Test(pub String); - - impl Test { - fn _set(&mut self, value: &Test) { - self.0 = value.0.clone(); - } - } - - impl LuaProxied for Test { - type Proxy = TestProxy; - } - - #[derive(Debug, Clone)] - struct TestProxy(ReflectReference); - - impl From for ReflectReference { - fn from(value: TestProxy) -> Self { - value.0 - } - } - - impl From for TestProxy { - fn from(value: ReflectReference) -> Self { - TestProxy(value) - } - } - - impl AsRef for TestProxy { - fn as_ref(&self) -> &ReflectReference { - &self.0 - } - } - impl<'lua> FromLua<'lua> for TestProxy { - fn from_lua( - value: Value<'lua>, - _lua: &'lua Lua, - ) -> tealr::mlu::mlua::prelude::LuaResult { - match value { - Value::UserData(ud) => { - if let Ok(s) = ud.borrow::() { - Ok(s.clone()) - } else { - panic!() - } - } - _ => panic!(), - } - } - } - - impl UserData for TestProxy { - fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) { - methods.add_method("set", |_lua, _self_, _val: LuaReflectRefProxy| Ok(())) - } - } - - impl tealr::ToTypename for TestProxy { - fn to_typename() -> tealr::Type { - tealr::Type::Single(tealr::SingleType { - name: tealr::Name("test".into()), - kind: tealr::KindOfType::External, - }) - } - } - - #[test] - pub fn test_call_set() { - let lua = Lua::new(); - let globals = lua.globals(); - let test = Test("test".to_string()); - let mut allocator = ReflectAllocator::default(); - let (allocation_id, _) = allocator.allocate(test); - let reflect_ref = ReflectReference { - base: ReflectBaseType { - type_id: std::any::TypeId::of::(), - base_id: ReflectBase::Owned(allocation_id), - }, - reflect_path: vec![], - }; - let proxy = TestProxy(reflect_ref); - globals.set("test", proxy).unwrap(); - lua.load( - r#" - test:set(test) - "#, - ) - .exec() - .unwrap(); - } -} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs index f4812808..32093342 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs @@ -5,10 +5,8 @@ use bevy::{ reflect::{OffsetAccess, ParsedPath, ReflectFromReflect}, }; use bevy_mod_scripting_core::{ - bindings::ReflectAllocator, - bindings::Unproxy, - bindings::{ReflectReference, WorldCallbackAccess}, - error::ReflectionError, + bindings::{ReflectAllocator, ReflectReference, Unproxy, WorldCallbackAccess}, + error::ScriptError, }; use tealr::mlu::{ mlua::{self, FromLua, IntoLua, Lua, MetaMethod, UserData, Value}, @@ -35,16 +33,14 @@ impl LuaReflectReference { // note we do not need to refer to LuaWorld here, it does not matter what the proxy is, that's pretty neat, let world = lua.get_world()?; // TODO: i don't like the pingponging between errors here, need something more ergonomic - world - .with_resource(|world, type_registry: Mut| { + let result: Result = + world.with_resource(|world, type_registry: Mut| { world.with_resource(|world, allocator: Mut| { let type_registry = type_registry.read(); // first we need the type id of the pointed to object to figure out how to work with it let type_id = self.0 - .with_reflect(world, &type_registry, Some(&allocator), |r| { - Ok(r.type_id()) - })?; + .with_reflect(world, &type_registry, Some(&allocator), |r| r.type_id()); if let Some(type_data) = type_registry.get_type_data::(type_id) { self.0 @@ -59,21 +55,19 @@ impl LuaReflectReference { Ok(self.clone().into_lua(lua)?) } }) - }) - .map_err(mlua::Error::external) + }); + result.map_err(mlua::Error::external) } pub fn set_with_lua_proxy(&self, lua: &Lua, value: Value) -> Result<(), mlua::Error> { let world = lua.get_world()?; - world - .with_resource(|world, type_registry: Mut| { + let result: Result<(), ScriptError> = + world.with_resource(|world, type_registry: Mut| { world.with_resource(|world, allocator: Mut| { let type_registry = type_registry.read(); let type_id = self.0 - .with_reflect(world, &type_registry, Some(&allocator), |r| { - Ok(r.type_id()) - })?; + .with_reflect(world, &type_registry, Some(&allocator), |r| r.type_id()); if let Some(type_data) = type_registry.get_type_data::(type_id) { @@ -87,44 +81,42 @@ impl LuaReflectReference { let other = (type_data.from_proxy)(value, lua)?; // first we need to get a copy of the other value - let other = - other.with_reflect(world, &type_registry, Some(&allocator), |r| { - Ok(type_registry + let other = other + .with_reflect(world, &type_registry, Some(&allocator), |r| { + type_registry .get_type_data::(r.type_id()) .and_then(|from_reflect_td| from_reflect_td.from_reflect(r)) - .ok_or_else(|| ReflectionError::FromReflectFailure { - ref_: r - .get_represented_type_info() - .map(|t| t.type_path()) - .unwrap_or_else(|| "Unknown Type") - .to_owned(), - })?) + }) + .ok_or_else(|| { + ScriptError::new_reflection_error(format!( + "Failed to call ReflectFromReflect for type id: {:?}", + type_registry.get_type_info(type_id).map(|t| t.type_path()) + )) })?; // now we can set it self.0 .with_reflect_mut(world, &type_registry, Some(&allocator), |r| { r.set(other).map_err(|e| { - Box::new(ReflectionError::InvalidAssignment { - lhs: self.0.clone(), - rhs: format!("{e:?}"), - reason: "Invalid type".to_owned(), - }) - as Box + ScriptError::new_runtime_error(format!( + "Invalid assignment `{:?}` = `{:?}`. Wrong type.", + self.0.clone(), + e, + )) }) })?; Ok(()) } else { - Err(Box::new(ReflectionError::InvalidAssignment { - lhs: self.0.clone(), - rhs: format!("{value:?}"), - reason: "Lhs has no registered LuaValue or LuaProxied type data." - .to_owned(), - })) + Err(ScriptError::new_runtime_error(format!( + "Invalid assignment `{:?}` = `{:?}`. Wrong type.", + self.0.clone(), + value, + ))) } }) - }) - .map_err(mlua::Error::external) + }); + + result.map_err(mlua::Error::external) } /// Adjusts all the numeric accesses in the path from 1-indexed to 0-indexed @@ -214,7 +206,7 @@ mod test { bindings::ReflectAllocator, bindings::{ReflectBase, ReflectBaseType, WorldAccessGuard, WorldCallbackAccess}, }; - use bevy_mod_scripting_lua_derive::LuaProxy; + use bevy_mod_scripting_derive::LuaProxy; use crate::{bindings::world::LuaWorld, RegisterLua}; diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/type_registration.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/type_registration.rs index 897dbd65..51d00197 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/type_registration.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/type_registration.rs @@ -1,14 +1,21 @@ use std::sync::Arc; use bevy::reflect::TypeRegistration; +use bevy_mod_scripting_core::bindings::ScriptTypeRegistration; use tealr::mlu::TealData; use crate::impl_userdata_from_lua; /// Caches information about type data #[derive(Clone, tealr::mlu::UserData, tealr::ToTypename)] -pub struct LuaTypeRegistration(Arc); +pub struct LuaTypeRegistration(pub ScriptTypeRegistration); impl_userdata_from_lua!(LuaTypeRegistration); impl TealData for LuaTypeRegistration {} + +impl From for LuaTypeRegistration { + fn from(value: ScriptTypeRegistration) -> Self { + Self(value) + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs index 9b1bfc54..6bb967b5 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs @@ -2,9 +2,10 @@ use std::sync::Arc; use bevy::ecs::{reflect::AppTypeRegistry, world::Mut}; use bevy_mod_scripting_core::{ - bindings::{Unproxy, WorldAccessGuard, WorldCallbackAccess}, + bindings::{Unproxy, WorldAccessGuard}, error::ScriptError, }; +use bevy_mod_scripting_derive::LuaProxy; use tealr::{ mlu::{ mlua::{self, FromLua}, @@ -15,39 +16,64 @@ use tealr::{ use crate::{impl_userdata_from_lua, impl_userdata_with_tealdata}; -use super::proxy::{LuaProxied, LuaValProxy}; +use super::{ + providers::bevy_ecs::LuaEntity, + proxy::{LuaProxied, LuaValProxy}, + type_registration::LuaTypeRegistration, +}; /// Lua UserData wrapper for [`bevy::ecs::world::World`] -#[derive(Clone, tealr::mlu::UserData, tealr::ToTypename)] -pub struct LuaWorld(pub WorldCallbackAccess); - -impl_userdata_from_lua!(LuaWorld); - -impl LuaProxied for WorldCallbackAccess { - type Proxy = LuaWorld; -} - -impl From<&LuaWorld> for WorldCallbackAccess { - fn from(value: &LuaWorld) -> Self { - value.0.clone() - } -} - -impl TealData for LuaWorld { - fn add_methods<'lua, T: tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { - // methods.add_method("get_type_by_name", |_, world, type_name: String| { - // let world = world - // .0 - // .read() - // .ok_or_else(|| mlua::Error::external(ReflectionError::StaleWorldAccess))?; - - // world.with_resource(|world, registry: Mut| { - // let registry = registry.read(); - // Ok(registry.get_with_short_type_path(&type_name).map(Arc::new)) - // }) - // }); - } -} +#[derive(LuaProxy)] +#[proxy( + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + proxy_as_self, + remote = "bevy_mod_scripting_core::bindings::WorldCallbackAccess", + functions [ + r#" + #[lua()] + fn get_type_by_name(&self, type_name: String) -> Result; + "#, + r#" + #[lua()] + fn add_default_component(&self, entity: LuaEntity, registration: LuaTypeRegistration) -> Result<(), ScriptError>; + "#, + ] +)] +pub struct World; + +// impl_userdata_from_lua!(LuaWorld); + +// impl LuaProxied for WorldCallbackAccess { +// type Proxy = LuaWorld; +// } + +// impl From<&LuaWorld> for WorldCallbackAccess { +// fn from(value: &LuaWorld) -> Self { +// value.0.clone() +// } +// } + +// impl TealData for LuaWorld { +// // fn add_methods<'lua, T: tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { +// // methods.add_method("get_type_by_name", |_, world, type_name: String| { +// // Ok(world +// // .0 +// // .get_type_by_name(type_name.as_str()) +// // .map(Into::::into)) +// // }); + +// // methods.add_method( +// // "add_default_component", +// // |_, world, (entity, registration): (LuaEntity, LuaTypeRegistration)| { +// // let entity = entity.0.with_reflect(world, type_registry, allocator, f) +// // Ok(world +// // .0 +// // .add_default_component(entity.0.with, registration.0.clone())) +// // }, +// // ) +// // } +// } pub trait GetWorld { fn get_world(&self) -> Result>, mlua::Error>; @@ -56,7 +82,7 @@ pub trait GetWorld { impl GetWorld for mlua::Lua { fn get_world(&self) -> Result>, mlua::Error> { self.globals() - .get::<_, LuaValProxy>("world")? + .get::<_, LuaValProxy>("world")? .unproxy() .and_then(|guard| { guard @@ -86,13 +112,22 @@ mod test { fn test_world_from_to_lua() { let mut world = World::new(); let world_access_guard = Arc::new(WorldAccessGuard::new(&mut world)); - let callback_access = - unsafe { WorldCallbackAccess::new(Arc::downgrade(&world_access_guard)) }; - let proxy = LuaValProxy::(ValProxy::new(LuaWorld(callback_access))); + let callback_access = unsafe { + bevy_mod_scripting_core::bindings::WorldCallbackAccess::new(Arc::downgrade( + &world_access_guard, + )) + }; + let proxy = LuaValProxy::( + ValProxy::new(LuaWorld(callback_access)), + ); let lua = Lua::new(); let lua_val = proxy.into_lua(&lua).unwrap(); - let mut val = LuaValProxy::::from_lua(lua_val, &lua).unwrap(); + let mut val = + LuaValProxy::::from_lua( + lua_val, &lua, + ) + .unwrap(); let _val = val.unproxy().unwrap(); } diff --git a/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml b/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml deleted file mode 100644 index 56104dd0..00000000 --- a/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml +++ /dev/null @@ -1,38 +0,0 @@ -[package] -name = "bevy_mod_scripting_lua_derive" -version = "0.6.0" -authors = ["Maksymilian Mozolewski "] -edition = "2021" -license = "MIT OR Apache-2.0" -description = "Necessary functionality for Lua support with bevy_mod_scripting" -repository = "https://github.com/makspll/bevy_mod_scripting" -homepage = "https://github.com/makspll/bevy_mod_scripting" -keywords = ["bevy", "gamedev", "scripting", "rhai"] -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 = '^(?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 - -[dependencies] -bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.6.0" } -paste = "1.0.7" -darling = "0.20.3" -syn = { version = "2.0.38", 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"] } -strum = { version = "0.24.1", features = ["derive"] } -vec1 = "1.10.1" diff --git a/crates/languages/bevy_mod_scripting_rhai_derive/readme.md b/crates/languages/bevy_mod_scripting_rhai_derive/readme.md deleted file mode 100644 index e058ed4f..00000000 --- a/crates/languages/bevy_mod_scripting_rhai_derive/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# bevy_mod_scripting_lua_derive - -This crate is a part of the ["bevy_mod_scripting" workspace](https://github.com/makspll/bevy_mod_scripting). \ No newline at end of file diff --git a/crates/languages/bevy_mod_scripting_rhai_derive/src/lib.rs b/crates/languages/bevy_mod_scripting_rhai_derive/src/lib.rs deleted file mode 100644 index 4feb6fce..00000000 --- a/crates/languages/bevy_mod_scripting_rhai_derive/src/lib.rs +++ /dev/null @@ -1,13 +0,0 @@ -use proc_macro::TokenStream; - -#[proc_macro] -pub fn impl_lua_newtype(tokens: TokenStream) -> TokenStream { - // let newtype = parse_macro_input!(tokens as Newtype); - - // implementor - // .generate(newtype) - // .map_err(|e| e.to_compile_error()) - // .unwrap_or_else(core::convert::identity) - // .into() - tokens -} From 71ad8b0d41adb5ae26fd7d7475656f35d1bbab9d Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 7 Sep 2024 11:31:16 +0100 Subject: [PATCH 16/17] WIP --- crates/bevy_mod_scripting_derive/src/lib.rs | 59 ++++++++++++++++----- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/crates/bevy_mod_scripting_derive/src/lib.rs b/crates/bevy_mod_scripting_derive/src/lib.rs index 24cd09d0..5f697bb2 100644 --- a/crates/bevy_mod_scripting_derive/src/lib.rs +++ b/crates/bevy_mod_scripting_derive/src/lib.rs @@ -25,7 +25,8 @@ const PROXY_PREFIX: &str = "Lua"; /// - instead o a `&self` receiver we have a `_self: LuaRefProxy` /// - instead of a `&mut self` receiver we have a `_self: LuaRefMutProxy` /// - instead of a `self` receiver we have a `_self: ValLuaProxy` -fn standardise_receiver(receiver: &mut FnArg, target_type: &Path, bms_lua_path: &Path) { +/// Returns true if the receiver was changed +fn standardise_receiver(receiver: &mut FnArg, target_type: &Path, bms_lua_path: &Path, proxy_as_self: bool) -> bool { let replacement = if let FnArg::Receiver(receiver) = receiver { let ref_ = &receiver.reference.as_ref().map(|(amp, lifetime)| { quote_spanned! {receiver.span()=> @@ -34,21 +35,34 @@ fn standardise_receiver(receiver: &mut FnArg, target_type: &Path, bms_lua_path: }); let self_ident = syn::Ident::new(SELF_ALIAS, receiver.span()); - let unproxy_container_name = match (ref_.is_some(), receiver.mutability.is_some()) { - (true, true) => "LuaReflectRefMutProxy", - (true, false) => "LuaReflectRefProxy", - (false, _) => "LuaReflectValProxy", + let self_ident_type = if proxy_as_self { + quote_spanned! {receiver.span()=> + #target_type + } + } else { + let unproxy_container_name = match (ref_.is_some(), receiver.mutability.is_some()) { + (true, true) => "LuaReflectRefMutProxy", + (true, false) => "LuaReflectRefProxy", + (false, _) => "LuaReflectValProxy", + }; + let unproxy_ident = syn::Ident::new(unproxy_container_name, receiver.span()); + + quote_spanned! {receiver.span()=> + #bms_lua_path::bindings::proxy::#unproxy_ident::<#target_type> + } }; - let unproxy_ident = syn::Ident::new(unproxy_container_name, receiver.span()); Some(syn::FnArg::Typed(parse_quote_spanned! {receiver.span()=> - #self_ident: #bms_lua_path::bindings::proxy::#unproxy_ident::<#target_type> + #self_ident: #self_ident_type })) } else { None }; if let Some(replacement) = replacement { *receiver = replacement; + true + } else { + false } } @@ -101,12 +115,11 @@ fn proxy_wrap_function_def( target_type: &Path, bms_core: &Path, bms_lua: &Path, + proxy_as_self: bool, + self_is_world: bool, mlua: &Path, attrs: &FunctionAttrs, ) { - if let Some(first_arg) = f.sig.inputs.first_mut() { - standardise_receiver(first_arg, target_type, bms_lua) - }; // collect all args into tuple and add lua context arg let ctxt_alias = syn::Ident::new(CTXT_ALIAS, f.sig.inputs.span()); @@ -122,11 +135,17 @@ fn proxy_wrap_function_def( #ctxt_alias: &#mlua::Lua } }; + let ctxt_arg_ident = match &ctxt_arg { FnArg::Typed(arg) => arg.pat.clone(), _ => panic!("Expected a typed argument, not a receiver for the context argument"), }; + let mut has_receiver = false; + if let Some(first_arg) = f.sig.inputs.first_mut() { + has_receiver = standardise_receiver(first_arg, target_type, bms_lua, proxy_as_self); + }; + let func_name = &f.sig.ident; let (original_arg_idents, _) = f .sig @@ -189,11 +208,23 @@ fn proxy_wrap_function_def( } }); } else { - f.default = Some(parse_quote_spanned! {span=> - { + let world = if self_is_world { + quote_spanned!(span=> let mut world: #bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> = #ctxt_arg_ident.globals().get("world")?; let mut world = <#bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> as #bms_core::bindings::Unproxy>::unproxy(&mut world).map_err(#mlua::Error::external)?; let mut world = world.read().ok_or_else(|| #mlua::Error::external("World no longer exists"))?; + ) + } else { + let first_arg_ident = original_arg_idents.first() + .expect("Expected at least one argument if self_is_world is passed"); + quote_spanned!(span=> + let world = #args_ident.0; + ) + }; + + f.default = Some(parse_quote_spanned! {span=> + { + #world let out: #out_type = world.proxy_call(#args_ident, |(#(#original_arg_idents),*)| { #fn_call }).map_err(|e| #mlua::Error::external(e))?; @@ -343,7 +374,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let closures = functions .into_iter() .map(|(mut f, attrs)| { - proxy_wrap_function_def(&mut f, &target_type, &bms_core, &bms_lua, &mlua, &attrs); + proxy_wrap_function_def(&mut f, &target_type, &bms_core, &bms_lua, meta.proxy_as_self.is_present(), meta.self_is_world.is_present(), &mlua, &attrs); convert_function_def_to_closure(&f) }) .collect::>(); @@ -380,7 +411,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { return None; } - proxy_wrap_function_def(&mut f, &target_type, &bms_core, &bms_lua, &mlua, &attrs); + proxy_wrap_function_def(&mut f, &target_type, &bms_core, &bms_lua, meta.proxy_as_self.is_present(), meta.self_is_world.is_present(), &mlua, &attrs); let name = match &attrs.metamethod { Some(metamethod) => quote_spanned!(metamethod.span()=> From 061bd423d9f0c9410ca9e3f8faf30cc095ef132c Mon Sep 17 00:00:00 2001 From: makspll Date: Tue, 5 Nov 2024 20:46:18 +0000 Subject: [PATCH 17/17] WIP --- .../src/bindings/proxy.rs | 68 ++++++++++ .../src/bindings/world.rs | 60 +++++++++ crates/bevy_mod_scripting_derive/src/input.rs | 11 +- crates/bevy_mod_scripting_derive/src/lib.rs | 122 +++++++++++------- .../src/bindings/mod.rs | 1 + .../src/bindings/providers/bevy_core.rs | 2 +- .../src/bindings/providers/bevy_ecs.rs | 2 +- .../src/bindings/providers/bevy_hierarchy.rs | 2 +- .../src/bindings/providers/bevy_input.rs | 2 +- .../src/bindings/providers/bevy_reflect.rs | 2 +- .../src/bindings/providers/bevy_time.rs | 2 +- .../src/bindings/providers/bevy_transform.rs | 2 +- .../src/bindings/providers/bevy_window.rs | 2 +- .../src/bindings/proxy.rs | 33 ++++- .../src/bindings/std.rs | 39 ++++++ .../src/bindings/world.rs | 69 ++++++---- 16 files changed, 322 insertions(+), 97 deletions(-) create mode 100644 crates/languages/bevy_mod_scripting_lua/src/bindings/std.rs diff --git a/crates/bevy_mod_scripting_core/src/bindings/proxy.rs b/crates/bevy_mod_scripting_core/src/bindings/proxy.rs index 16ddd07a..31d5793a 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/proxy.rs +++ b/crates/bevy_mod_scripting_core/src/bindings/proxy.rs @@ -567,6 +567,74 @@ impl Proxy for Option { } } +impl Proxy for Result { + type Input<'a> = Result, E>; + + fn proxy(input: Self::Input<'_>) -> ScriptResult { + match input { + Ok(i) => Ok(Ok(T::proxy(i)?)), + Err(e) => Ok(Err(e)), + } + } + + fn proxy_with_allocator( + input: Self::Input<'_>, + _allocator: &mut ReflectAllocator, + ) -> ScriptResult { + match input { + Ok(i) => Ok(Ok(T::proxy_with_allocator(i, _allocator)?)), + Err(e) => Ok(Err(e)), + } + } +} + +impl Unproxy for Result { + type Output<'o> = Result, E::Output<'o>> where Self: 'o; + + fn unproxy(&mut self) -> ScriptResult> { + match self { + Ok(s) => Ok(Ok(s.unproxy()?)), + Err(e) => Ok(Err(e.unproxy()?)), + } + } + + unsafe fn unproxy_with_world<'w, 'o>( + &'o mut self, + guard: &WorldAccessGuard<'w>, + accesses: &'o [WorldAccessUnit<'w>], + type_registry: &TypeRegistry, + allocator: &'o ReflectAllocator, + ) -> ScriptResult> { + match self { + Ok(s) => Ok(Ok(s.unproxy_with_world( + guard, + accesses, + type_registry, + allocator, + )?)), + Err(e) => Ok(Err(e.unproxy()?)), + } + } + + fn collect_accesses<'w>( + &self, + guard: &WorldAccessGuard<'w>, + accesses: &mut SmallVec<[WorldAccessWrite<'w>; 1]>, + ) -> ScriptResult<()> { + match self { + Ok(s) => s.collect_accesses(guard, accesses), + Err(_) => Ok(()), + } + } + + fn accesses_len(&self) -> usize { + match self { + Ok(s) => s.accesses_len(), + Err(_) => 0, + } + } +} + macro_rules! impl_unproxy_by_move { ($($ty:ty),*) => { $( diff --git a/crates/bevy_mod_scripting_core/src/bindings/world.rs b/crates/bevy_mod_scripting_core/src/bindings/world.rs index f7cff106..ab81d908 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/world.rs +++ b/crates/bevy_mod_scripting_core/src/bindings/world.rs @@ -759,6 +759,66 @@ impl<'w> WorldAccessGuard<'w> { } } +/// Impl block for higher level world methods +impl<'w> WorldAccessGuard<'w> { + pub fn get_type_by_name(&self, type_name: &str) -> Option { + self.with_resource(|_, registry: Mut| { + let registry = registry.read(); + registry + .get_with_short_type_path(type_name) + .or_else(|| registry.get_with_type_path(type_name)) + .map(|registration| ScriptTypeRegistration::new(Arc::new(registration.clone()))) + }) + } + + pub fn add_default_component( + &self, + entity: Entity, + registration: ScriptTypeRegistration, + ) -> ScriptResult<()> { + let component_data = registration.data::().ok_or_else(|| ScriptError::new_runtime_error(format!( + "Cannot add default component since type: `{}`, Does not have ReflectComponent data registered.", + registration.type_info().type_path() + )))?; + + // we look for ReflectDefault or ReflectFromWorld data then a ReflectComponent data + let instance = if let Some(default_td) = registration.data::() { + default_td.default() + } else if let Some(from_world_td) = registration.data::() { + if let Some(world) = self.get_whole_world_access() { + from_world_td.from_world(world) + } else { + panic!("{CONCURRENT_WORLD_ACCESS_MSG}") + } + } else { + return Err(ScriptError::new_runtime_error(format!( + "Cannot add default component since type: `{}`, Does not have ReflectDefault or ReflectFromWorld data registered.", + registration.type_info().type_path() + ))); + }; + + // TODO: this shouldn't need entire world access it feels + if let Some(world) = self.get_whole_world_access() { + let app_registry = world + .remove_resource::() + .unwrap_or_else(|| panic!("Missing type registry")); + + let mut entity = world.get_entity_mut(entity).ok_or_else(|| { + ScriptError::new_runtime_error(format!("Entity does not exist: {:?}", entity)) + })?; + { + let registry = app_registry.read(); + component_data.insert(&mut entity, instance.as_ref(), ®istry); + } + world.insert_resource(app_registry); + } else { + panic!("{CONCURRENT_WORLD_ACCESS_MSG}") + } + + Ok(()) + } +} + /// Having this is permission to access the contained [`ReflectAccessId`], there is no way to access anything safely through a [`WorldAccessGuard`] /// without having a [`WorldAccess`] instance for that particular [`ReflectAccessId`]. /// diff --git a/crates/bevy_mod_scripting_derive/src/input.rs b/crates/bevy_mod_scripting_derive/src/input.rs index c7c8a35a..4fc68695 100644 --- a/crates/bevy_mod_scripting_derive/src/input.rs +++ b/crates/bevy_mod_scripting_derive/src/input.rs @@ -36,13 +36,12 @@ pub struct ProxyInput { /// The path to the type for which we are generating a proxy if it's a foreign type pub remote: Option, - /// If set to true, will generate a simple newtype instead of a ReflectReference wrapping type - /// Only used for the special world proxies, probably not useful for anything else, the macro assumes we have an inner ReflectReference in the wrapper - pub proxy_as_self: Flag, + /// if provided will call the function at this path to get the world callback access. Normally this is retrieved using a global variable. + pub get_world_callback_access_fn: Option, - /// Special flag for world proxies, if set to true the proxy will be treated as a world proxy, meaning we do not double fetch the world and instead use the world from the wrapper. - /// This requires proxy_as_self to also be true - pub self_is_world: Flag, + /// If set will use the given path as the type for the proxy instead of generating a new one + /// Only used for the special world proxies, probably not useful for anything else, the macro assumes we have an inner ReflectReference in the wrapper + pub proxy_as_type: Option, /// The path to the bevy_mod_scripting_core crate #[darling(default)] diff --git a/crates/bevy_mod_scripting_derive/src/lib.rs b/crates/bevy_mod_scripting_derive/src/lib.rs index 5f697bb2..6c932ffc 100644 --- a/crates/bevy_mod_scripting_derive/src/lib.rs +++ b/crates/bevy_mod_scripting_derive/src/lib.rs @@ -26,7 +26,7 @@ const PROXY_PREFIX: &str = "Lua"; /// - instead of a `&mut self` receiver we have a `_self: LuaRefMutProxy` /// - instead of a `self` receiver we have a `_self: ValLuaProxy` /// Returns true if the receiver was changed -fn standardise_receiver(receiver: &mut FnArg, target_type: &Path, bms_lua_path: &Path, proxy_as_self: bool) -> bool { +fn standardise_receiver(receiver: &mut FnArg, target_type: &Path, bms_lua_path: &Path, proxy_as_type: Option<&Path>) -> bool { let replacement = if let FnArg::Receiver(receiver) = receiver { let ref_ = &receiver.reference.as_ref().map(|(amp, lifetime)| { quote_spanned! {receiver.span()=> @@ -35,20 +35,23 @@ fn standardise_receiver(receiver: &mut FnArg, target_type: &Path, bms_lua_path: }); let self_ident = syn::Ident::new(SELF_ALIAS, receiver.span()); - let self_ident_type = if proxy_as_self { - quote_spanned! {receiver.span()=> - #target_type - } - } else { - let unproxy_container_name = match (ref_.is_some(), receiver.mutability.is_some()) { - (true, true) => "LuaReflectRefMutProxy", - (true, false) => "LuaReflectRefProxy", - (false, _) => "LuaReflectValProxy", - }; - let unproxy_ident = syn::Ident::new(unproxy_container_name, receiver.span()); - - quote_spanned! {receiver.span()=> - #bms_lua_path::bindings::proxy::#unproxy_ident::<#target_type> + let self_ident_type = match proxy_as_type{ + Some(target_type) => { + quote_spanned! {receiver.span()=> + #target_type + } + }, + None => { + let unproxy_container_name = match (ref_.is_some(), receiver.mutability.is_some()) { + (true, true) => "LuaReflectRefMutProxy", + (true, false) => "LuaReflectRefProxy", + (false, _) => "LuaReflectValProxy", + }; + let unproxy_ident = syn::Ident::new(unproxy_container_name, receiver.span()); + + quote_spanned! {receiver.span()=> + #bms_lua_path::bindings::proxy::#unproxy_ident::<#target_type> + } } }; @@ -115,8 +118,8 @@ fn proxy_wrap_function_def( target_type: &Path, bms_core: &Path, bms_lua: &Path, - proxy_as_self: bool, - self_is_world: bool, + get_world_callback_access_fn: Option<&Path>, + proxy_as_type: Option<&Path>, mlua: &Path, attrs: &FunctionAttrs, ) { @@ -143,11 +146,11 @@ fn proxy_wrap_function_def( let mut has_receiver = false; if let Some(first_arg) = f.sig.inputs.first_mut() { - has_receiver = standardise_receiver(first_arg, target_type, bms_lua, proxy_as_self); + has_receiver = standardise_receiver(first_arg, target_type, bms_lua, proxy_as_type); }; let func_name = &f.sig.ident; - let (original_arg_idents, _) = f + let (mut original_arg_idents, _) = f .sig .inputs .iter() @@ -162,6 +165,22 @@ fn proxy_wrap_function_def( let span = f.span(); let args_ident = format_ident!("args", span = f.sig.inputs.span()); + let args_tail_ident = format_ident!("args_tail", span = f.sig.inputs.span()); + let args_head_ident = format_ident!("args_head", span = f.sig.inputs.span()); + let args_split = if get_world_callback_access_fn.is_some() { + let tail = (1..original_arg_idents.len()).map(|i| { + let i = syn::Index::from(i); + quote_spanned!(span=> #args_ident.#i) + }); + quote_spanned!(span=> + let #args_head_ident = #args_ident.0; + let #args_tail_ident = (#(#tail),*); + ) + } else { + Default::default() + }; + + // change signature to take in a single args tuple instead of multiple arguments (on top of a context arg) f.sig.inputs = Punctuated::from_iter(vec![ @@ -169,6 +188,13 @@ fn proxy_wrap_function_def( collect_args_in_tuple(f.sig.inputs.iter(), &args_ident, true), ]); + let args_var_to_use = if get_world_callback_access_fn.is_some() { + original_arg_idents.remove(0); + args_tail_ident + } else { + args_ident + }; + let out_type = match &f.sig.output { syn::ReturnType::Default => quote_spanned! {f.span()=> () @@ -176,16 +202,20 @@ fn proxy_wrap_function_def( syn::ReturnType::Type(_, ty) => ty.to_token_stream(), }; + // wrap function body in our unwrapping and wrapping logic, ignore pre-existing body let mut fn_call = std::panic::catch_unwind(|| { - match (&f.default, &attrs.as_trait) { - (Some(body), _) => quote_spanned!(span=> + match (&f.default, &attrs.as_trait, get_world_callback_access_fn.is_some()) { + (_, _, true) => quote_spanned!(span=> + world.#func_name(#(#original_arg_idents),*) + ), + (Some(body), _, _) => quote_spanned!(span=> (||{ #body })() ), - (_, None) => quote_spanned!(span=> + (_, None, _) => quote_spanned!(span=> #target_type::#func_name(#(#original_arg_idents),*) ), - (_, Some(trait_path)) => { + (_, Some(trait_path), _) => { let trait_path = quote_spanned!(span=> #trait_path); quote_spanned!(span=> <#target_type as #trait_path>::#func_name(#(#original_arg_idents),*) @@ -208,24 +238,25 @@ fn proxy_wrap_function_def( } }); } else { - let world = if self_is_world { + let world = if let Some(world_getter_fn_path) = get_world_callback_access_fn { quote_spanned!(span=> - let mut world: #bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> = #ctxt_arg_ident.globals().get("world")?; - let mut world = <#bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> as #bms_core::bindings::Unproxy>::unproxy(&mut world).map_err(#mlua::Error::external)?; + let mut world: #bms_core::bindings::WorldCallbackAccess = #world_getter_fn_path(#args_head_ident); let mut world = world.read().ok_or_else(|| #mlua::Error::external("World no longer exists"))?; ) } else { - let first_arg_ident = original_arg_idents.first() - .expect("Expected at least one argument if self_is_world is passed"); quote_spanned!(span=> - let world = #args_ident.0; + let mut world: #bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> = #ctxt_arg_ident.globals().get("world")?; + let mut world = <#bms_lua::bindings::proxy::LuaValProxy<#bms_core::bindings::WorldCallbackAccess> as #bms_core::bindings::Unproxy>::unproxy(&mut world).map_err(#mlua::Error::external)?; + let mut world = world.read().ok_or_else(|| #mlua::Error::external("World no longer exists"))?; ) }; + f.default = Some(parse_quote_spanned! {span=> { + #args_split #world - let out: #out_type = world.proxy_call(#args_ident, |(#(#original_arg_idents),*)| { + let out: #out_type = world.proxy_call(#args_var_to_use, |(#(#original_arg_idents),*)| { #fn_call }).map_err(|e| #mlua::Error::external(e))?; Ok(out) @@ -306,9 +337,11 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let target_type = meta.remote.unwrap_or(meta.ident.clone().into()); let target_type_str = target_type.segments.last().unwrap().ident.to_string(); - let proxy_type_ident = meta.proxy_name.unwrap_or_else(|| { - format_ident!("{PROXY_PREFIX}{}", &meta.ident, span = meta.ident.span()) - }); + let proxy_type_ident = match meta.proxy_as_type.as_ref() { + Some(proxy_as_type) => proxy_as_type.clone(), + None => meta.proxy_name.unwrap_or_else(|| format_ident!("{PROXY_PREFIX}{}", &target_type_str, span = meta.ident.span())).into(), + }; + let bms_core = meta.bms_core_path.0; let bms_lua = meta.bms_lua_path.0; @@ -374,7 +407,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let closures = functions .into_iter() .map(|(mut f, attrs)| { - proxy_wrap_function_def(&mut f, &target_type, &bms_core, &bms_lua, meta.proxy_as_self.is_present(), meta.self_is_world.is_present(), &mlua, &attrs); + proxy_wrap_function_def(&mut f, &target_type, &bms_core, &bms_lua, meta.get_world_callback_access_fn.as_ref() ,meta.proxy_as_type.as_ref(), &mlua, &attrs); convert_function_def_to_closure(&f) }) .collect::>(); @@ -411,7 +444,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { return None; } - proxy_wrap_function_def(&mut f, &target_type, &bms_core, &bms_lua, meta.proxy_as_self.is_present(), meta.self_is_world.is_present(), &mlua, &attrs); + proxy_wrap_function_def(&mut f, &target_type, &bms_core, &bms_lua, meta.get_world_callback_access_fn.as_ref(), meta.proxy_as_type.as_ref(), &mlua, &attrs); let name = match &attrs.metamethod { Some(metamethod) => quote_spanned!(metamethod.span()=> @@ -428,11 +461,8 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let vis = &meta.vis; - let definition = if meta.proxy_as_self.is_present() { - quote_spanned!(derive_input.span()=> - #[derive(Clone, Debug, #tealr::mlu::UserData, #tealr::ToTypename)] - #vis struct #proxy_type_ident (pub #target_type); - ) + let definition = if let Some(proxy_as_type) = meta.proxy_as_type.as_ref() { + Default::default() } else { quote_spanned!(derive_input.span()=> #[derive(Clone, Debug, #tealr::mlu::UserData, #tealr::ToTypename)] @@ -440,14 +470,8 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { ) }; - let conversions = if meta.proxy_as_self.is_present() { - quote!( - impl <'a>From<&'a #proxy_type_ident> for #target_type { - fn from(r: &'a #proxy_type_ident) -> Self { - r.0.clone() - } - } - ) + let conversions = if let Some(proxy_as_type) = meta.proxy_as_type.as_ref() { + Default::default() } else { quote_spanned!(derive_input.span()=> impl AsRef<#bms_core::bindings::ReflectReference> for #proxy_type_ident { @@ -463,6 +487,8 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } ) }; + + quote_spanned! {meta.ident.span()=> #definition diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs index 99941536..5a278b63 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/mod.rs @@ -3,5 +3,6 @@ use bevy_mod_scripting_core::bindings::WorldCallbackAccess; pub mod providers; pub mod proxy; pub mod reference; +pub mod std; pub mod type_registration; pub mod world; diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs index 6dbc5893..f27b993e 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_core.rs @@ -10,7 +10,7 @@ use bevy_mod_scripting_core::{ use crate::{ bindings::proxy::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, - IdentityProxy, + LuaIdentityProxy, }, RegisterLua, tealr::mlu::mlua::IntoLua, }; diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs index 3a7aacb1..deeb5d0e 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_ecs.rs @@ -9,7 +9,7 @@ use bevy_mod_scripting_core::{ use crate::{ bindings::proxy::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, - IdentityProxy, + LuaIdentityProxy, }, RegisterLua, tealr::mlu::mlua::IntoLua, }; diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs index ccf9e8ac..2b75e619 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_hierarchy.rs @@ -11,7 +11,7 @@ use bevy_mod_scripting_core::{ use crate::{ bindings::proxy::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, - IdentityProxy, + LuaIdentityProxy, }, RegisterLua, tealr::mlu::mlua::IntoLua, }; diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs index d460a79c..d4a9f2b4 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_input.rs @@ -10,7 +10,7 @@ use bevy_mod_scripting_core::{ use crate::{ bindings::proxy::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, - IdentityProxy, + LuaIdentityProxy, }, RegisterLua, tealr::mlu::mlua::IntoLua, }; diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs index 462af8c4..66a8a679 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_reflect.rs @@ -8,7 +8,7 @@ use bevy_mod_scripting_core::{ use crate::{ bindings::proxy::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, - IdentityProxy, + LuaIdentityProxy, }, RegisterLua, tealr::mlu::mlua::IntoLua, }; diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs index fac87247..100f3222 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_time.rs @@ -10,7 +10,7 @@ use bevy_mod_scripting_core::{ use crate::{ bindings::proxy::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, - IdentityProxy, + LuaIdentityProxy, }, RegisterLua, tealr::mlu::mlua::IntoLua, }; diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs index 28497380..16449985 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_transform.rs @@ -12,7 +12,7 @@ use bevy_mod_scripting_core::{ use crate::{ bindings::proxy::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, - IdentityProxy, + LuaIdentityProxy, }, RegisterLua, tealr::mlu::mlua::IntoLua, }; diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs index 3dadf07e..c23f2b0d 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/providers/bevy_window.rs @@ -11,7 +11,7 @@ use bevy_mod_scripting_core::{ use crate::{ bindings::proxy::{ LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, - IdentityProxy, + LuaIdentityProxy, }, RegisterLua, tealr::mlu::mlua::IntoLua, }; diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs index b557c3b2..cc383a7c 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/proxy.rs @@ -7,7 +7,7 @@ use bevy_mod_scripting_core::{ Proxy, ReflectAllocator, ReflectRefMutProxy, ReflectRefProxy, ReflectReference, ReflectValProxy, Unproxy, ValProxy, WorldAccessGuard, WorldAccessUnit, WorldAccessWrite, }, - error::ScriptResult, + error::{ScriptError, ScriptResult}, }; use tealr::{ mlu::mlua::{Error, FromLua, IntoLua, Lua, Value}, @@ -21,16 +21,16 @@ pub trait LuaProxied { /// Convenience for proxying a type into lua via itself without implementing [`Proxy`] on it. /// Converts to Lua via T's implementation of IntoLua directly -pub struct IdentityProxy(pub Option); +pub struct LuaIdentityProxy(pub Option); -impl Proxy for IdentityProxy { +impl Proxy for LuaIdentityProxy { type Input<'i> = T; fn proxy<'i>(value: Self::Input<'i>) -> ScriptResult { Ok(Self(Some(value))) } } -impl Unproxy for IdentityProxy { +impl Unproxy for LuaIdentityProxy { type Output<'o> = T where Self: 'o; @@ -42,27 +42,46 @@ impl Unproxy for IdentityProxy { } } -impl ToTypename for IdentityProxy { +impl ToTypename for LuaIdentityProxy { fn to_typename() -> tealr::Type { T::to_typename() } } -impl<'a, T: IntoLua<'a>> IntoLua<'a> for IdentityProxy { +impl<'a, T: IntoLua<'a>> IntoLua<'a> for LuaIdentityProxy { fn into_lua(self, lua: &'a Lua) -> tealr::mlu::mlua::prelude::LuaResult> { self.0.into_lua(lua) } } -impl<'a, T: FromLua<'a>> FromLua<'a> for IdentityProxy { +impl<'a, T: FromLua<'a>> FromLua<'a> for LuaIdentityProxy { fn from_lua(value: Value<'a>, lua: &'a Lua) -> Result { Ok(Self(Some(T::from_lua(value, lua)?))) } } +/// Proxy which uses [`ValProxy`] to represent the type in Lua. Requires that the type implements [`LuaProxied`] and that the proxy implements [`From`] for the type. +/// +/// Used for types which are copied into lua rather than references to originals in the world. +/// Use when your type does not implement Reflect or if it's a simple type that can be copied into lua. pub struct LuaValProxy(pub ValProxy); + +/// Proxy which uses [`ReflectValProxy`] to represent the type in Lua. Requires that the type implements [`LuaProxied`] and [`FromReflect`] and that the proxy implements [`AsRef`]. +/// Think of the proxy as just a container for a [`ReflectReference`]. +/// +/// Semantically equivalent to `T`, use it where you would use the `T` type. pub struct LuaReflectValProxy(pub ReflectValProxy); + +/// Proxy which uses [`ReflectRefProxy`] to represent the type in Lua. Requires that the type implements [`LuaProxied`] and [`Reflect`] and that the proxy implements [`AsRef`]. +/// Think of the proxy as just a container for a [`ReflectReference`]. +/// +/// Semantically equivalent to `&T`, use it where you would use the `&T` type. pub struct LuaReflectRefProxy(pub ReflectRefProxy); + +/// Proxy which uses [`ReflectRefMutProxy`] to represent the type in Lua. Requires that the type implements [`LuaProxied`] and [`Reflect`] and that the proxy implements [`AsRef`]. +/// Think of the proxy as just a container for a [`ReflectReference`]. +/// +/// Semantically equivalent to `&mut T`, use it where you would use the `&mut T` type. pub struct LuaReflectRefMutProxy(pub ReflectRefMutProxy); macro_rules! impl_lua_unproxy { diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/std.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/std.rs new file mode 100644 index 00000000..9d6e8763 --- /dev/null +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/std.rs @@ -0,0 +1,39 @@ +use tealr::{ + mlu::{mlua::IntoLua, TealData}, + ToTypename, +}; + +pub struct LuaResult(Result); + +impl TealData for LuaResult +where + T: ToTypename + for<'l> IntoLua<'l>, + E: ToTypename + for<'l> IntoLua<'l>, +{ + fn add_methods<'lua, M: tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut M) { + methods.add_method("is_ok", |_, this, _: ()| Ok(this.0.is_ok())); + methods.add_method("is_err", |_, this, _: ()| Ok(this.0.is_err())); + methods.add_function("unwrap", |_, this: LuaResult| match this.0 { + Ok(value) => Ok(value), + Err(_) => Err(tealr::mlu::mlua::Error::RuntimeError( + "called `LuaResult::unwrap()` on an `Err` value".to_string(), + )), + }); + methods.add_method("unwrap_err", |_, this, _: ()| match &this.0 { + Ok(_) => Err(tealr::mlu::mlua::Error::RuntimeError( + "called `LuaResult::unwrap_err()` on an `Ok` value".to_string(), + )), + Err(value) => Ok(value), + }); + } + + fn add_fields<'lua, F: tealr::mlu::TealDataFields<'lua, Self>>(_fields: &mut F) {} +} + +impl ToTypename for LuaResult { + fn to_typename() -> tealr::Type { + let t = std::any::type_name::(); + let e = std::any::type_name::(); + tealr::Type::new_single(format!("LuaResult<{t},{e}>"), tealr::KindOfType::External) + } +} diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs index 6bb967b5..ace651c9 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/world.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use bevy::ecs::{reflect::AppTypeRegistry, world::Mut}; use bevy_mod_scripting_core::{ - bindings::{Unproxy, WorldAccessGuard}, + bindings::{Unproxy, WorldAccessGuard, WorldCallbackAccess}, error::ScriptError, }; use bevy_mod_scripting_derive::LuaProxy; @@ -18,7 +18,7 @@ use crate::{impl_userdata_from_lua, impl_userdata_with_tealdata}; use super::{ providers::bevy_ecs::LuaEntity, - proxy::{LuaProxied, LuaValProxy}, + proxy::{LuaIdentityProxy, LuaProxied, LuaValProxy}, type_registration::LuaTypeRegistration, }; @@ -27,20 +27,33 @@ use super::{ #[proxy( bms_core_path = "bevy_mod_scripting_core", bms_lua_path = "crate", - proxy_as_self, - remote = "bevy_mod_scripting_core::bindings::WorldCallbackAccess", + get_world_callback_access_fn = "self::LuaWorld::world_callback_access", + proxy_as_type = "self::LuaWorld", + remote = "bevy_mod_scripting_core::bindings::WorldAccessGuard<'_>", functions [ r#" #[lua()] - fn get_type_by_name(&self, type_name: String) -> Result; - "#, - r#" - #[lua()] - fn add_default_component(&self, entity: LuaEntity, registration: LuaTypeRegistration) -> Result<(), ScriptError>; + fn add_default_component(&self, entity: LuaEntity, registration: LuaTypeRegistration) -> Result, ScriptError>; "#, + // r#" + // #[lua()] + // fn get_type_by_name(&self, type_name: String) -> Result; + // "#, ] )] -pub struct World; +pub struct LuaWorld(WorldCallbackAccess); + +impl LuaWorld { + pub fn world_callback_access(self) -> WorldCallbackAccess { + self.0.clone() + } +} + +impl ToTypename for LuaWorld { + fn to_typename() -> Type { + Type::Userdata + } +} // impl_userdata_from_lua!(LuaWorld); @@ -55,24 +68,24 @@ pub struct World; // } // impl TealData for LuaWorld { -// // fn add_methods<'lua, T: tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { -// // methods.add_method("get_type_by_name", |_, world, type_name: String| { -// // Ok(world -// // .0 -// // .get_type_by_name(type_name.as_str()) -// // .map(Into::::into)) -// // }); - -// // methods.add_method( -// // "add_default_component", -// // |_, world, (entity, registration): (LuaEntity, LuaTypeRegistration)| { -// // let entity = entity.0.with_reflect(world, type_registry, allocator, f) -// // Ok(world -// // .0 -// // .add_default_component(entity.0.with, registration.0.clone())) -// // }, -// // ) -// // } +// fn add_methods<'lua, T: tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { +// methods.add_method("get_type_by_name", |_, world, type_name: String| { +// Ok(world +// .0 +// .get_type_by_name(type_name.as_str()) +// .map(Into::::into)) +// }); + +// methods.add_method( +// "add_default_component", +// |_, world, (entity, registration): (LuaEntity, LuaTypeRegistration)| { +// let entity = entity.0.with_reflect(world, type_registry, allocator, f) +// Ok(world +// .0 +// .add_default_component(entity.0.with, registration.0.clone())) +// }, +// ) +// } // } pub trait GetWorld {