diff --git a/.github/workflows/bevy_api_gen.yml b/.github/workflows/bevy_api_gen.yml deleted file mode 100644 index 8c5ea41f..00000000 --- a/.github/workflows/bevy_api_gen.yml +++ /dev/null @@ -1,145 +0,0 @@ -on: - push: - branches: - - "**" - paths: - - "crates/bevy_api_gen/**" - - ".github/workflows/bevy_api_gen.yml" - - ".github/workflows/generate_bindings.yml" - - - -name: Check and Lint - bevy_api_gen - -env: - RUST_TOOLCHAIN: nightly-2024-12-15 - -jobs: - check: - name: Check - bevy_api_gen - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - sparse-checkout: 'crates/bevy_api_gen' - sparse-checkout-cone-mode: false - - name: Move bevy_api_gen to root - run: | - mv crates/bevy_api_gen/* . - rm -rf crates - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ env.RUST_TOOLCHAIN }} - override: true - - name: Rust Cache - uses: Swatinem/rust-cache@v2.7.3 - - name: Clear space - run: rm -rf /usr/share/dotnet; rm -rf /opt/ghc; rm -rf "/usr/local/share/boost"; rm -rf "$AGENT_TOOLSDIRECTORY" - - uses: actions-rs/cargo@v1 - with: - command: check - args: --profile=ephemeral-build - - fmt: - name: Rustfmt - bevy_api_gen - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - sparse-checkout: 'crates/bevy_api_gen' - sparse-checkout-cone-mode: false - - name: Move bevy_api_gen to root - run: | - mv crates/bevy_api_gen/* . - rm -rf crates - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - components: rustfmt - toolchain: ${{ env.RUST_TOOLCHAIN }} - override: true - - name: Rust Cache - uses: Swatinem/rust-cache@v2.7.3 - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - clippy: - name: Clippy - bevy_api_gen - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - sparse-checkout: 'crates/bevy_api_gen' - sparse-checkout-cone-mode: false - - name: Move bevy_api_gen to root - run: | - mv crates/bevy_api_gen/* . - rm -rf crates - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - components: clippy - override: true - - name: Rust Cache - uses: Swatinem/rust-cache@v2.7.3 - - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --profile=ephemeral-build -- -D warnings - tests: - name: Tests - bevy_api_gen - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - sparse-checkout: 'crates/bevy_api_gen' - sparse-checkout-cone-mode: false - - name: Move bevy_api_gen to root - run: | - mv crates/bevy_api_gen/* . - rm -rf crates - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - override: true - - name: Rust Cache - uses: Swatinem/rust-cache@v2.7.3 - - uses: actions-rs/cargo@v1 - with: - command: test - args: --profile=ephemeral-build - docs: - name: Docs - bevy_api_gen - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - sparse-checkout: 'crates/bevy_api_gen' - sparse-checkout-cone-mode: false - - name: Move bevy_api_gen to root - run: | - mv crates/bevy_api_gen/* . - rm -rf crates - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - override: true - - name: Rust Cache - uses: Swatinem/rust-cache@v2.7.3 - # - name: Find docs.rs features - # run: echo "DOCS_FEATURES=$(cargo metadata --no-deps | python -c "import sys,json; [print(','.join(x['metadata']['docs.rs']['features'])) for x in json.load(sys.stdin)['packages'] if x['name'] == 'bevy_mod_scripting']")" >> $GITHUB_OUTPUT - # id: features - - uses: actions-rs/cargo@v1 - with: - command: doc - args: --profile=ephemeral-build - bindings: - permissions: - contents: write - pull-requests: write - name: Generate Bindings - bevy_api_gen - uses: ./.github/workflows/generate_bindings.yml - secrets: inherit \ No newline at end of file diff --git a/.github/workflows/bevy_mod_scripting.yml b/.github/workflows/bevy_mod_scripting.yml index c422973c..a9b6968d 100644 --- a/.github/workflows/bevy_mod_scripting.yml +++ b/.github/workflows/bevy_mod_scripting.yml @@ -3,11 +3,7 @@ on: branches: - "**" paths-ignore: - - 'crates/bevy_api_gen/**' - - 'crates/macro_tests/**' - '.github/workflows/release-plz.yml' - - '.github/workflows/bevy_api_gen.yml' - - '.github/workflows/macro_tests.yml' - 'docs/**' @@ -17,7 +13,9 @@ name: Check and Lint - bevy_mod_scripting env: REGISTRY: ghcr.io IMAGE_NAME: bevy-mod-scripting - + CODEGEN_BRANCH_NAME: __update-bevy-bindings-${{ github.head_ref || github.ref_name }} + GH_TOKEN: ${{ github.token }} + concurrency: # Use github.run_id on main branch # Use github.event.pull_request.number on pull requests, so it's unique per pull request @@ -99,4 +97,48 @@ jobs: if [[ -n $(git status -s) ]]; then git commit -m "chore(badge): Update coverage badge" -m "[skip ci]" git push - fi \ No newline at end of file + fi + generate_bindings: + name: Bindings - Synchronise + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Bot GitHub Credentials + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + - name: Setup + run: | + cargo xtask init + - name: Generate Bindings + run: | + cargo xtask codegen + - name: Check for changes + id: check_changes + run: | + if [[ -n $(git status --porcelain) ]]; then + echo "changes=true" >> "$GITHUB_OUTPUT"; + fi + - name: Commit Changes + if: steps.check_changes.outputs.changes + run: | + git checkout -b ${{ env.CODEGEN_BRANCH_NAME }} || git checkout ${{ env.CODEGEN_BRANCH_NAME }} + git add -A + git commit -m "chore(codegen): update bevy bindings" + git push -u origin ${{ env.CODEGEN_BRANCH_NAME }} --force + - uses: jwalton/gh-find-current-pr@master + if: steps.check_changes.outputs.changes + id: findPR + with: + state: all + - name: Create Or Update PR + if: steps.check_changes.outputs.changes && success() && steps.findPR.outputs.number + run: | + gh pr list --base ${{ github.ref }} --search "chore(codegen): update bevy bindings" --json number > prs.json + if [ $(jq '. | length' prs.json) -eq 0 ]; then + gh pr create --title "chore(codegen): update bevy bindings" --body "This PR updates the bevy bindings for #${{ steps.findPR.outputs.number }}" --base ${{ github.ref }} --head ${{ env.CODEGEN_BRANCH_NAME }} || true + fi \ No newline at end of file diff --git a/.github/workflows/generate_bindings.yml b/.github/workflows/generate_bindings.yml deleted file mode 100644 index a9e7b8e1..00000000 --- a/.github/workflows/generate_bindings.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: Generate Bindings (Bevy, Glam) - -on: - workflow_call: - workflow_dispatch: - -env: - RUST_TOOLCHAIN: nightly-2024-12-15 - BEVY_API_GEN_PATH: ${{ github.workspace }}/crates/bevy_api_gen - BEVY_PATH: ${{ github.workspace }}/target/codegen/bevy - OUTPUT_PATH: ${{ github.workspace }}/crates/bevy_mod_scripting_functions/src/bevy_bindings/ - BEVY_FEATURES: bevy_asset,bevy_animation,bevy_core_pipeline,bevy_ui,bevy_pbr,bevy_render,bevy_text,bevy_sprite,file_watcher,multi_threaded - BRANCH_NAME: __update-bevy-bindings-${{ github.head_ref || github.ref_name }} - GH_TOKEN: ${{ github.token }} - - -jobs: - generate_bindings: - permissions: - contents: write - pull-requests: write - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Bot GitHub Credentials - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - - name: Install Rust Toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - components: rust-src, rustc-dev, llvm-tools-preview - override: true - - name: Install bevy_api_gen Binaries - run: cargo install --path ${{ env.BEVY_API_GEN_PATH }} - - name: read bevy workspace version - uses: SebRollen/toml-action@v1.2.0 - id: read_toml - with: - file: 'Cargo.toml' - field: 'workspace.dependencies.bevy.version' - - name: Prepare Directories - run: | - mkdir -p ${{ env.OUTPUT_PATH }} - mkdir -p ${{ env.BEVY_PATH }} - - name: Clone Bevy - run: | - git clone https://github.com/bevyengine/bevy --branch v${{ steps.read_toml.outputs.value }} --depth 1 ${{ env.BEVY_PATH }} - cd ${{ env.BEVY_PATH }} && git fetch --tags && git checkout v${{ steps.read_toml.outputs.value }} - ls -la ${{ env.BEVY_PATH }} - - name: Generate Bevy Bindings - run: | - cd ${{ env.BEVY_PATH }} && cargo bevy-api-gen generate --output ${{ env.OUTPUT_PATH }} --template-args '{ "self_is_bms_lua": true}' --features ${{ env.BEVY_FEATURES }} -vv - - name: Collect Bevy Bindings - run: | - ls -la ${{ env.BEVY_PATH }} - cd ${{ env.BEVY_PATH }} && cargo bevy-api-gen collect --output ${{ env.OUTPUT_PATH }} --template-args '{ "self_is_bms_lua": true}' - - name: Prune Output - run: | - find ${{ env.OUTPUT_PATH }} -type f ! -name "*.rs" -delete - - name: Check for changes - id: check_changes - run: | - if [[ -n $(git status --porcelain) ]]; then - echo "changes=true" >> "$GITHUB_OUTPUT"; - fi - - name: Commit Changes - if: steps.check_changes.outputs.changes - run: | - git checkout -b ${{ env.BRANCH_NAME }} || git checkout ${{ env.BRANCH_NAME }} - git add -A - git commit -m "chore(codegen): update bevy bindings" - git push -u origin ${{ env.BRANCH_NAME }} --force - - uses: jwalton/gh-find-current-pr@master - if: steps.check_changes.outputs.changes - id: findPR - with: - state: all - - name: Create Or Update PR - if: steps.check_changes.outputs.changes && success() && steps.findPR.outputs.number - run: | - gh pr list --base feature/bevy-system-refactor --search "chore(codegen): update bevy bindings" --json number > prs.json - if [ $(jq '. | length' prs.json) -eq 0 ]; then - gh pr create --title "chore(codegen): update bevy bindings" --body "This PR updates the bevy bindings for #${{ steps.findPR.outputs.number }}" --base ${{ github.ref }} --head ${{ env.BRANCH_NAME }} || true - fi \ No newline at end of file diff --git a/.vscode/.gitignore b/.vscode/.gitignore new file mode 100644 index 00000000..c3d3a20e --- /dev/null +++ b/.vscode/.gitignore @@ -0,0 +1 @@ +settings.json \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 3979afae..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "lldb.displayFormat": "auto", - "lldb.showDisassembly": "never", - "lldb.dereferencePointers": true, - "lldb.consoleMode": "commands", - "[rust]": { - "editor.formatOnSave": true, - "editor.formatOnSaveMode": "file", - "editor.defaultFormatter": "rust-lang.rust-analyzer" - }, - "rust-analyzer.rustc.source": "discover", - "rust-analyzer.linkedProjects": [ - // "./crates/bevy_api_gen/Cargo.toml", - "Cargo.toml", - ], - "rust-analyzer.check.invocationStrategy": "once", - "rust-analyzer.check.overrideCommand": [ - "/home/makspll/git/bevy_mod_scripting/check.sh" - ], - "rust-analyzer.cargo.buildScripts.overrideCommand": [ - "/home/makspll/git/bevy_mod_scripting/check.sh" - ], - "rust-analyzer.showUnlinkedFileNotification": false, - "rust-analyzer.runnables.extraTestBinaryArgs": [ - "--show-output", - ], - "rust-analyzer.runnables.extraArgs": [ - "--profile=release-with-debug", - ], - // "rust-analyzer.cargo.features": [ - // "bevy_mod_scripting_functions/test_functions" - // ] - // "rust-analyzer.semanticHighlighting.operator.enable": false -} \ No newline at end of file diff --git a/check.exe b/check.exe deleted file mode 100644 index e69db476..00000000 Binary files a/check.exe and /dev/null differ diff --git a/check.ps1 b/check.ps1 index f62f53e8..a13d9e24 100644 --- a/check.ps1 +++ b/check.ps1 @@ -1,9 +1,3 @@ #!/usr/bin/env pwsh -Remove-Variable -Name RUSTUP_TOOLCHAIN -ErrorAction SilentlyContinue -$CURRENT_DIR = Split-Path -Leaf -Path (Get-Location) - -if ($CURRENT_DIR -eq "bevy_api_gen") { - cargo +nightly-2024-12-15 clippy --all-targets --message-format=json -} else { - cargo clippy --workspace --all-targets --message-format=json --features="lua54 rhai rune bevy/file_watcher bevy/multi_threaded" -} \ No newline at end of file +Set-Location -Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) +cargo xtask check --ide-mode \ No newline at end of file diff --git a/crates/bevy_api_gen/Cargo.bootstrap.toml b/crates/bevy_api_gen/Cargo.bootstrap.toml index 7a61c4ae..fc55cd02 100644 --- a/crates/bevy_api_gen/Cargo.bootstrap.toml +++ b/crates/bevy_api_gen/Cargo.bootstrap.toml @@ -1,11 +1,11 @@ -# Cargo.toml file used for bootstrapping of mlua and other dependencies which need to be included in every crate for analysis +# Cargo.toml file used for bootstrapping of bms and other dependencies which need to be included in every crate for analysis [package] name = "bevy_analyzer_deps_bootstrap" version = "0.1.0" edition = "2021" [dependencies] -mlua = { version = "0.10", features = ["lua54", "vendored", "send", "macros"] } +bevy_mod_scripting_core = { path = "{{BMS_CORE_PATH}}" } bevy_reflect = { version = "0.15.0", features = [ "bevy", "glam", diff --git a/crates/bevy_api_gen/Cargo.toml b/crates/bevy_api_gen/Cargo.toml index 25d12e94..fc2979fa 100644 --- a/crates/bevy_api_gen/Cargo.toml +++ b/crates/bevy_api_gen/Cargo.toml @@ -54,6 +54,7 @@ convert_case = "0.6" syn = { version = "2", features = ["parsing"], no-default-features = true } clap-verbosity-flag = "2.2" itertools = "0.12" +chrono = "0.4" [build-dependencies] toml = "0.8" diff --git a/crates/bevy_api_gen/src/args.rs b/crates/bevy_api_gen/src/args.rs index 69ff5294..2316b18b 100644 --- a/crates/bevy_api_gen/src/args.rs +++ b/crates/bevy_api_gen/src/args.rs @@ -54,6 +54,10 @@ pub struct Args { /// additional template context in the form of json, provided to the templates under an 'args' key #[arg(global = true, long)] pub template_args: Option, + + /// The path to the bevy_mod_scripting_core crate, used to bootstrap necessary traits + #[arg(global = true, long, default_value = ".")] + pub bms_core_path: Utf8PathBuf, } #[derive(clap::Args, Debug, Clone, Default, Serialize, Deserialize)] diff --git a/crates/bevy_api_gen/src/bin/driver.rs b/crates/bevy_api_gen/src/bin/driver.rs index 492f0673..a8cdbc17 100644 --- a/crates/bevy_api_gen/src/bin/driver.rs +++ b/crates/bevy_api_gen/src/bin/driver.rs @@ -2,6 +2,8 @@ use bevy_api_gen::*; fn main() { + // initially set it to high so no logs are missed, but later when we parse the args we will set it to the correct level + std::env::set_var("RUST_LOG", "trace"); env_logger::init(); rustc_plugin::driver_main(BevyAnalyzer); } diff --git a/crates/bevy_api_gen/src/bin/main.rs b/crates/bevy_api_gen/src/bin/main.rs index 137f00ee..d435cccb 100644 --- a/crates/bevy_api_gen/src/bin/main.rs +++ b/crates/bevy_api_gen/src/bin/main.rs @@ -9,13 +9,13 @@ use std::{ }; use bevy_api_gen::*; -use cargo_metadata::camino::Utf8Path; +use cargo_metadata::camino::{Utf8Path, Utf8PathBuf}; use clap::Parser; use log::{debug, error, info}; use strum::VariantNames; use tera::Context; -const BOOTSTRAP_DEPS: [&str; 2] = ["mlua", "bevy_reflect"]; +const BOOTSTRAP_DEPS: [&str; 2] = ["bevy_reflect", "bevy_mod_scripting_core"]; fn main() { // parse this here to early exit on wrong args @@ -26,6 +26,8 @@ fn main() { } env_logger::init(); + info!("Using RUST_LOG: {:?}", env::var("RUST_LOG")); + info!("Computing crate metadata"); let metadata = cargo_metadata::MetadataCommand::new() .no_deps() @@ -122,19 +124,20 @@ fn main() { } }); let meta_loader = MetaLoader::new(vec![output.to_owned()], workspace_meta); - let context = Collect { - crates: crates - .map(|c| { - let name = c.to_str().unwrap().to_owned(); - log::info!("Collecting crate: {}", name); - let meta = meta_loader - .meta_for(&name) - .expect("Could not find meta file for crate"); - Crate { name, meta } - }) - .collect(), - api_name, - }; + let mut crates: Vec<_> = crates + .map(|c| { + let name = c.to_str().unwrap().to_owned(); + log::info!("Collecting crate: {}", name); + let meta = meta_loader + .meta_for(&name) + .expect("Could not find meta file for crate"); + Crate { name, meta } + }) + .collect(); + + crates.sort_by(|a, b| a.name.cmp(&b.name)); + + let context = Collect { crates, api_name }; let mut context = Context::from_serialize(context).expect("Could not create template context"); @@ -154,7 +157,7 @@ fn main() { debug!("Bootstrap directory: {}", &temp_dir.as_path().display()); - write_bootstrap_files(temp_dir.as_path()); + write_bootstrap_files(args.bms_core_path, temp_dir.as_path()); let bootstrap_rlibs = build_bootstrap(temp_dir.as_path(), &plugin_target_dir.join("bootstrap")); @@ -183,6 +186,9 @@ fn main() { debug!("RUSTFLAGS={}", env::var("RUSTFLAGS").unwrap_or_default()); + // disable incremental compilation + env::set_var("CARGO_INCREMENTAL", "0"); + rustc_plugin::cli_main(BevyAnalyzer); // just making sure the temp dir lives until everything is done @@ -325,14 +331,21 @@ fn find_bootstrap_dir() -> PathBuf { } /// Generate bootstrapping crate files -fn write_bootstrap_files(path: &Path) { +fn write_bootstrap_files(bms_core_path: Utf8PathBuf, path: &Path) { + const BMS_CORE_PATH_PLACEHOLDER: &str = "{{BMS_CORE_PATH}}"; + // write manifest file 'Cargo.toml' - let manifest_content = include_bytes!("../../Cargo.bootstrap.toml"); + let mut manifest_content = + String::from_utf8(include_bytes!("../../Cargo.bootstrap.toml").to_vec()) + .expect("Could not read manifest template as utf8"); + + manifest_content = manifest_content.replace(BMS_CORE_PATH_PLACEHOLDER, bms_core_path.as_str()); + let manifest_path = path.join("Cargo.toml"); let mut file = File::create(manifest_path) .expect("Could not create manifest file for bootstrapping crate."); - file.write_all(manifest_content) + file.write_all(manifest_content.as_bytes()) .expect("Failed writing to manifest file for bootstrapping crate"); // write dummy main function diff --git a/crates/bevy_api_gen/src/callback.rs b/crates/bevy_api_gen/src/callback.rs index d2e7483b..8be9e21f 100644 --- a/crates/bevy_api_gen/src/callback.rs +++ b/crates/bevy_api_gen/src/callback.rs @@ -59,6 +59,7 @@ impl rustc_driver::Callbacks for BevyAnalyzerCallbacks { // tera environment for import processor let tera = crate::configure_tera(tcx.crate_name(LOCAL_CRATE).as_str(), &templates_dir); + info!("Using meta directories: {:?}", meta_dirs); let mut ctxt = crate::BevyCtxt::new( tcx, &meta_dirs, diff --git a/crates/bevy_api_gen/src/context.rs b/crates/bevy_api_gen/src/context.rs index 1e282a74..252ea8f3 100644 --- a/crates/bevy_api_gen/src/context.rs +++ b/crates/bevy_api_gen/src/context.rs @@ -81,8 +81,15 @@ impl ReflectType<'_> { } } -pub(crate) const DEF_PATHS_FROM_LUA: [&str; 2] = ["value::FromLuaMulti", "mlua::FromLuaMulti"]; -pub(crate) const DEF_PATHS_INTO_LUA: [&str; 2] = ["value::IntoLuaMulti", "mlua::IntoLuaMulti"]; +pub(crate) const DEF_PATHS_BMS_FROM_SCRIPT: [&str; 2] = [ + "bevy_mod_scripting_core::bindings::function::from::FromScript", + "bindings::function::from::FromScript", +]; +pub(crate) const DEF_PATHS_BMS_INTO_SCRIPT: [&str; 2] = [ + "bevy_mod_scripting_core::bindings::function::into::IntoScript", + "bindings::function::into::IntoScript", +]; + pub(crate) const DEF_PATHS_REFLECT: [&str; 2] = ["bevy_reflect::PartialReflect", "reflect::PartialReflect"]; pub(crate) const DEF_PATHS_GET_TYPE_REGISTRATION: [&str; 2] = [ @@ -115,8 +122,8 @@ pub(crate) const STD_SOURCE_TRAITS: [&str; 14] = [ /// A collection of common traits stored for quick access. #[derive(Default)] pub(crate) struct CachedTraits { - pub(crate) mlua_from_lua_multi: Option, - pub(crate) mlua_into_lua_multi: Option, + pub(crate) bms_into_script: Option, + pub(crate) bms_from_script: Option, pub(crate) bevy_reflect_reflect: Option, pub(crate) bevy_reflect_get_type_registration: Option, /// Map from def_path_str to DefId of common std traits we work with @@ -125,8 +132,8 @@ pub(crate) struct CachedTraits { } impl CachedTraits { - pub(crate) fn has_all_mlua_traits(&self) -> bool { - self.mlua_from_lua_multi.is_some() && self.mlua_into_lua_multi.is_some() + pub(crate) fn has_all_bms_traits(&self) -> bool { + self.bms_into_script.is_some() && self.bms_from_script.is_some() } pub(crate) fn has_all_bevy_traits(&self) -> bool { diff --git a/crates/bevy_api_gen/src/meta.rs b/crates/bevy_api_gen/src/meta.rs index d517d0dd..87e70747 100644 --- a/crates/bevy_api_gen/src/meta.rs +++ b/crates/bevy_api_gen/src/meta.rs @@ -6,9 +6,10 @@ use std::{ }; use cargo_metadata::camino::Utf8PathBuf; +use chrono::NaiveDateTime; use log::trace; use rustc_hir::def_id::DefPathHash; -use serde::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize, Serializer}; use crate::WorkspaceMeta; @@ -25,6 +26,27 @@ pub struct Meta { /// False if no files are going to be generated for this crate pub(crate) will_generate: bool, pub(crate) meta_version: String, + #[serde( + serialize_with = "serialize_timestamp", + deserialize_with = "deserialize_timestamp" + )] + pub(crate) timestamp: NaiveDateTime, +} + +fn serialize_timestamp( + timestamp: &NaiveDateTime, + serializer: S, +) -> Result { + // format as date and time + serializer.serialize_str(×tamp.format("%Y-%m-%d %H:%M:%S").to_string()) +} + +fn deserialize_timestamp<'de, D>(deserializer: D) -> Result +where + D: serde::Deserializer<'de>, +{ + let s = String::deserialize(deserializer)?; + NaiveDateTime::parse_from_str(&s, "%Y-%m-%d %H:%M:%S").map_err(serde::de::Error::custom) } impl Meta { @@ -37,7 +59,7 @@ impl Meta { } } -#[derive(Serialize, Deserialize, Clone)] +#[derive(Serialize, Deserialize, Clone, Debug)] pub(crate) struct ProxyMeta { pub(crate) ident: String, pub(crate) stable_crate_id: u64, @@ -46,8 +68,8 @@ pub(crate) struct ProxyMeta { /// Manages deserialisation and retrieval of meta files pub struct MetaLoader { - pub(crate) meta_dirs: Vec, - pub(crate) workspace_meta: WorkspaceMeta, + pub meta_dirs: Vec, + pub workspace_meta: WorkspaceMeta, cache: RefCell>, } @@ -78,7 +100,7 @@ impl MetaLoader { ) -> bool { let meta = match meta_sources .iter() - .filter(|s| curr_source.is_none() || curr_source.is_some_and(|cs| cs == **s)) + .filter(|s| curr_source.is_none() || curr_source.is_some_and(|cs| cs != **s)) .find_map(|s| self.meta_for(s)) { Some(meta) => meta, @@ -100,7 +122,7 @@ impl MetaLoader { if meta.is_none() { log::trace!( - "Could not find meta for crate: `{}`, is_workspace_and_included: '{}'", + "Could not find meta file for crate: `{}`, is_workspace_and_included: '{}'", crate_name, needs_meta ) @@ -118,11 +140,15 @@ impl MetaLoader { trace!("Loading meta from cache for: {}", crate_name); cache.get(crate_name).cloned() } else { - trace!("Loading meta from filesystem for: {}", crate_name); drop(cache); let mut cache = self.cache.borrow_mut(); - let meta = - Self::opt_load_meta(dir.join(Self::crate_name_to_meta_filename(crate_name)))?; + let dir = dir.join(Self::crate_name_to_meta_filename(crate_name)); + trace!( + "Attempting to load meta from filesystem for crate: {}, at: {}", + crate_name, + dir + ); + let meta = Self::opt_load_meta(dir)?; cache.insert(crate_name.to_owned(), meta.clone()); Some(meta) } @@ -150,7 +176,7 @@ impl MetaLoader { let file = File::create(&path).unwrap(); let mut writer = BufWriter::new(file); - serde_json::to_writer(&mut writer, meta).unwrap(); + serde_json::to_writer_pretty(&mut writer, meta).unwrap(); writer.flush().expect("Could not flush data to meta file"); } diff --git a/crates/bevy_api_gen/src/modifying_file_loader.rs b/crates/bevy_api_gen/src/modifying_file_loader.rs index 5458080d..c0028179 100644 --- a/crates/bevy_api_gen/src/modifying_file_loader.rs +++ b/crates/bevy_api_gen/src/modifying_file_loader.rs @@ -28,7 +28,7 @@ impl FileLoader for ModifyingFileLoader { RealFileLoader.read_file(path).map(|mut f| { // we make it pub so in case we are re-exporting this crate we won't run into private re-export issues - for crate_ in &["bevy_reflect", "mlua"] { + for crate_ in &["bevy_reflect", "bevy_mod_scripting_core"] { if !f.contains(&format!("extern crate {crate_}")) { if f.contains(&format!("pub use {crate_}")) { f.push_str(&format!( diff --git a/crates/bevy_api_gen/src/passes/cache_traits.rs b/crates/bevy_api_gen/src/passes/cache_traits.rs index c0c36b05..93eb5358 100644 --- a/crates/bevy_api_gen/src/passes/cache_traits.rs +++ b/crates/bevy_api_gen/src/passes/cache_traits.rs @@ -3,8 +3,8 @@ use rustc_hir::def_id::LOCAL_CRATE; use rustc_span::Symbol; use crate::{ - Args, BevyCtxt, DEF_PATHS_FROM_LUA, DEF_PATHS_GET_TYPE_REGISTRATION, DEF_PATHS_INTO_LUA, - DEF_PATHS_REFLECT, STD_SOURCE_TRAITS, + Args, BevyCtxt, DEF_PATHS_BMS_FROM_SCRIPT, DEF_PATHS_BMS_INTO_SCRIPT, + DEF_PATHS_GET_TYPE_REGISTRATION, DEF_PATHS_REFLECT, STD_SOURCE_TRAITS, }; /// Finds and caches relevant traits, if they cannot be found throws an ICE @@ -13,14 +13,7 @@ pub(crate) fn cache_traits(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool { for trait_did in tcx.all_traits() { let def_path_str = tcx.def_path_str(trait_did); - - if DEF_PATHS_FROM_LUA.contains(&def_path_str.as_str()) { - trace!("found FromLuaMulti trait def id: {trait_did:?}"); - ctxt.cached_traits.mlua_from_lua_multi = Some(trait_did); - } else if DEF_PATHS_INTO_LUA.contains(&def_path_str.as_str()) { - trace!("found ToLuaMulti trait def id: {trait_did:?}"); - ctxt.cached_traits.mlua_into_lua_multi = Some(trait_did); - } else if DEF_PATHS_REFLECT.contains(&def_path_str.as_str()) { + if DEF_PATHS_REFLECT.contains(&def_path_str.as_str()) { trace!("found Reflect trait def id: {trait_did:?}"); ctxt.cached_traits.bevy_reflect_reflect = Some(trait_did); } else if DEF_PATHS_GET_TYPE_REGISTRATION.contains(&def_path_str.as_str()) { @@ -31,12 +24,18 @@ pub(crate) fn cache_traits(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool { ctxt.cached_traits .std_source_traits .insert(def_path_str.to_string(), trait_did); + } else if DEF_PATHS_BMS_INTO_SCRIPT.contains(&def_path_str.as_str()) { + trace!("found IntoScript trait def id: {trait_did:?}"); + ctxt.cached_traits.bms_into_script = Some(trait_did); + } else if DEF_PATHS_BMS_FROM_SCRIPT.contains(&def_path_str.as_str()) { + trace!("found FromScript trait def id: {trait_did:?}"); + ctxt.cached_traits.bms_from_script = Some(trait_did); } } - if !ctxt.cached_traits.has_all_mlua_traits() { + if !ctxt.cached_traits.has_all_bms_traits() { panic!( - "Could not find all mlua traits in crate: {}, did bootstrapping go wrong?", + "Could not find all bms traits in crate: {}", tcx.crate_name(LOCAL_CRATE) ) } 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 583ad0ae..7acffc23 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 @@ -350,11 +350,19 @@ fn type_is_adt_and_reflectable<'tcx>( tcx.def_path_hash(did), ); - log::trace!( - "Meta for type: `{}`, contained in meta `{}`", - tcx.item_name(did), - contains_hash - ); + if contains_hash { + log::info!( + "Meta for type: `{}` with hash: `{:?}`, contained in the meta file", + tcx.item_name(did), + tcx.def_path_hash(did), + ); + } else { + log::info!( + "Meta for type: `{}` with hash: `{:?}`, was not found in meta files for {crate_name} or in bevy_reflect, meaning it will not generate a proxy.", + tcx.item_name(did), + tcx.def_path_hash(did), + ); + } contains_hash }) @@ -368,12 +376,7 @@ fn type_is_supported_as_non_proxy_arg<'tcx>( ty: Ty<'tcx>, ) -> bool { trace!("Checking type is supported as non proxy arg: '{ty:?}' with param_env: '{param_env:?}'"); - impls_trait( - tcx, - param_env, - ty, - cached_traits.mlua_from_lua_multi.unwrap(), - ) + impls_trait(tcx, param_env, ty, cached_traits.bms_from_script.unwrap()) } /// Checks if the type can be used directly as a lua function output @@ -390,12 +393,7 @@ fn type_is_supported_as_non_proxy_return_val<'tcx>( } } - impls_trait( - tcx, - param_env, - ty, - cached_traits.mlua_into_lua_multi.unwrap(), - ) + impls_trait(tcx, param_env, ty, cached_traits.bms_into_script.unwrap()) } pub(crate) fn impls_trait<'tcx>( 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 7a6cb832..408ba7c6 100644 --- a/crates/bevy_api_gen/src/passes/find_trait_impls.rs +++ b/crates/bevy_api_gen/src/passes/find_trait_impls.rs @@ -33,13 +33,13 @@ pub(crate) fn find_trait_impls(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool { // filter out types which have impls both ways let retaining = type_impl_of_trait( tcx, - ctxt.cached_traits.mlua_from_lua_multi.unwrap(), + ctxt.cached_traits.bms_from_script.unwrap(), reflect_ty_did, ) .is_empty() || type_impl_of_trait( tcx, - ctxt.cached_traits.mlua_into_lua_multi.unwrap(), + ctxt.cached_traits.bms_into_script.unwrap(), reflect_ty_did, ) .is_empty(); 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 2af392cd..955845b1 100644 --- a/crates/bevy_api_gen/src/passes/populate_template_data.rs +++ b/crates/bevy_api_gen/src/passes/populate_template_data.rs @@ -32,7 +32,19 @@ pub(crate) fn populate_template_data(ctxt: &mut BevyCtxt<'_>, args: &Args) -> bo let has_static_methods = fn_ctxts.iter().any(|fn_ctxt| !fn_ctxt.has_self); let mut functions = process_functions(ctxt, fn_ctxts); - functions.sort_by(|a, b| a.ident.cmp(&b.ident)); + functions.sort_by(|a, b| { + a.ident + .cmp(&b.ident) + .then(a.args.len().cmp(&b.args.len())) + .then( + a.args + .iter() + .zip(b.args.iter()) + .fold(std::cmp::Ordering::Equal, |acc, (a, b)| { + acc.then(a.ty.cmp(&b.ty)) + }), + ) + }); let variant = ty_ctxt.variant_data.as_ref().unwrap(); @@ -70,35 +82,10 @@ pub(crate) fn populate_template_data(ctxt: &mut BevyCtxt<'_>, args: &Args) -> bo } let crate_name = tcx.crate_name(LOCAL_CRATE).to_string(); - let dep_names = tcx - .crates(()) - .iter() - .map(|d| tcx.crate_name(*d).to_ident_string()) - .collect::>(); - - let dependencies = ctxt - .meta_loader - .workspace_meta - .crates - .iter() - .filter(|c| { - dep_names.contains(c) - && ctxt - .meta_loader - .meta_for(c) - .unwrap_or_else(|| panic!("Expected meta for dependency: {c}")) - .will_generate - }) - .cloned() - .collect(); ctxt.clear(); - ctxt.template_context = Some(TemplateContext { - crate_name, - items, - dependencies, - }); + ctxt.template_context = Some(TemplateContext { crate_name, items }); if let crate::Command::Generate { template_data_only, .. @@ -113,10 +100,6 @@ pub(crate) fn populate_template_data(ctxt: &mut BevyCtxt<'_>, args: &Args) -> bo } trace!("Populated template context:"); - trace!( - "{}", - serde_json::to_string_pretty(&ctxt.template_context).unwrap() - ); true } @@ -230,11 +213,10 @@ fn ty_to_string<'tcx>(ctxt: &BevyCtxt<'tcx>, ty: Ty<'tcx>, proxy_types: bool) -> "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, - ) + trace!("Checking ADT: `{}`.", ctxt.tcx.item_name(def_id),); + + ctxt.meta_loader + .one_of_meta_files_contains(&meta_sources, None, def_path_hash) }) .is_some_and(identity) }), @@ -326,7 +308,6 @@ impl<'a> TyPrinter<'a> { } pub fn print(mut self, ty: Ty<'_>) -> String { - log::trace!("Printing type: {:#?}", ty); self.print_ty(ty); self.buffer } @@ -357,7 +338,6 @@ impl<'a> TyPrinter<'a> { } 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); @@ -365,8 +345,6 @@ impl<'a> TyPrinter<'a> { } fn print_ty(&mut self, ty: Ty<'_>) { - log::trace!("Printing type: {:#?}", ty); - match ty.kind() { TyKind::Bool => self.print_literal("bool"), TyKind::Char => self.print_literal("char"), diff --git a/crates/bevy_api_gen/src/passes/write_meta.rs b/crates/bevy_api_gen/src/passes/write_meta.rs index 41749583..e21d60a9 100644 --- a/crates/bevy_api_gen/src/passes/write_meta.rs +++ b/crates/bevy_api_gen/src/passes/write_meta.rs @@ -2,7 +2,7 @@ use rustc_hir::def_id::LOCAL_CRATE; use crate::{Args, BevyCtxt, Meta, ProxyMeta, META_VERSION}; -/// Finds and caches relevant mlua traits, if they cannot be found throws an ICE +/// Finds and caches relevant traits, if they cannot be found throws an ICE pub(crate) fn write_meta(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool { let tcx = &ctxt.tcx; @@ -20,6 +20,7 @@ pub(crate) fn write_meta(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool { proxies, will_generate, meta_version: META_VERSION.to_string(), + timestamp: chrono::Local::now().naive_local(), }; ctxt.meta_loader diff --git a/crates/bevy_api_gen/src/plugin.rs b/crates/bevy_api_gen/src/plugin.rs index cc4bc10c..bae2dbfc 100644 --- a/crates/bevy_api_gen/src/plugin.rs +++ b/crates/bevy_api_gen/src/plugin.rs @@ -32,6 +32,8 @@ impl RustcPlugin for BevyAnalyzer { compiler_args: Vec, plugin_args: Self::Args, ) -> rustc_interface::interface::Result<()> { + log::set_max_level(plugin_args.verbose.get_log_level().to_level_filter()); + if let Some(includes) = WorkspaceMeta::from_env().include_crates { let crate_name = compiler_args .iter() diff --git a/crates/bevy_api_gen/src/template.rs b/crates/bevy_api_gen/src/template.rs index 2349dcaf..5fd0842e 100644 --- a/crates/bevy_api_gen/src/template.rs +++ b/crates/bevy_api_gen/src/template.rs @@ -59,7 +59,6 @@ impl ValueEnum for TemplateKind { #[derive(Serialize)] pub(crate) struct TemplateContext { - pub(crate) dependencies: Vec, pub(crate) crate_name: String, pub(crate) items: Vec, } diff --git a/crates/bevy_api_gen/templates/header.tera b/crates/bevy_api_gen/templates/header.tera index a9116009..f50067af 100644 --- a/crates/bevy_api_gen/templates/header.tera +++ b/crates/bevy_api_gen/templates/header.tera @@ -2,13 +2,6 @@ #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] -{% for crate in dependencies %} -{% if crate != crate_name %} -use super::{{crate}}::*; -{% endif %} -{% endfor %} - - use bevy_mod_scripting_core::{ bindings::{ ReflectReference, diff --git a/crates/bevy_mod_scripting_functions/src/bevy_bindings/.gitignore b/crates/bevy_mod_scripting_functions/src/bevy_bindings/.gitignore new file mode 100644 index 00000000..94a2dd14 --- /dev/null +++ b/crates/bevy_mod_scripting_functions/src/bevy_bindings/.gitignore @@ -0,0 +1 @@ +*.json \ No newline at end of file diff --git a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_core.rs b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_core.rs index 78dac678..be31d2d8 100644 --- a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_core.rs +++ b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_core.rs @@ -2,8 +2,6 @@ #![allow(clippy::all)] #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] -use super::bevy_ecs::*; -use super::bevy_reflect::*; use bevy_mod_scripting_core::bindings::{ ReflectReference, function::{ diff --git a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_ecs.rs b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_ecs.rs index 2c212292..a5881aed 100644 --- a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_ecs.rs +++ b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_ecs.rs @@ -2,7 +2,6 @@ #![allow(clippy::all)] #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] -use super::bevy_reflect::*; use bevy_mod_scripting_core::bindings::{ ReflectReference, function::{ diff --git a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_hierarchy.rs b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_hierarchy.rs index d429479d..45f345a6 100644 --- a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_hierarchy.rs +++ b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_hierarchy.rs @@ -2,9 +2,6 @@ #![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 bevy_mod_scripting_core::bindings::{ ReflectReference, function::{ @@ -57,6 +54,16 @@ impl ::bevy::app::Plugin for BevyHierarchyScriptingPlugin { .into(); output }, + ) + .register( + "get", + |_self: Ref| { + let output: Val = bevy::hierarchy::prelude::Parent::get( + &_self, + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::hierarchy::HierarchyEvent>::new(world) .register( diff --git a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_input.rs b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_input.rs index 31a0471f..7a041086 100644 --- a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_input.rs +++ b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_input.rs @@ -2,10 +2,6 @@ #![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_math::*; use bevy_mod_scripting_core::bindings::{ ReflectReference, function::{ @@ -19,6 +15,16 @@ impl ::bevy::app::Plugin for BevyInputScriptingPlugin { fn build(&self, app: &mut ::bevy::prelude::App) { let mut world = app.world_mut(); NamespaceBuilder::<::bevy::input::gamepad::Gamepad>::new(world) + .register( + "dpad", + |_self: Ref| { + let output: Val = bevy::input::gamepad::Gamepad::dpad( + &_self, + ) + .into(); + output + }, + ) .register( "just_pressed", | @@ -47,6 +53,16 @@ impl ::bevy::app::Plugin for BevyInputScriptingPlugin { output }, ) + .register( + "left_stick", + |_self: Ref| { + let output: Val = bevy::input::gamepad::Gamepad::left_stick( + &_self, + ) + .into(); + output + }, + ) .register( "pressed", | @@ -71,6 +87,16 @@ impl ::bevy::app::Plugin for BevyInputScriptingPlugin { output }, ) + .register( + "right_stick", + |_self: Ref| { + let output: Val = bevy::input::gamepad::Gamepad::right_stick( + &_self, + ) + .into(); + output + }, + ) .register( "vendor_id", |_self: Ref| { @@ -473,6 +499,22 @@ impl ::bevy::app::Plugin for BevyInputScriptingPlugin { .into(); output }, + ) + .register( + "new", + | + entity: Val, + axis: Val, + value: f32| + { + let output: Val = bevy::input::gamepad::GamepadAxisChangedEvent::new( + entity.into_inner(), + axis.into_inner(), + value, + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::input::gamepad::GamepadButtonChangedEvent>::new(world) .register( @@ -497,6 +539,24 @@ impl ::bevy::app::Plugin for BevyInputScriptingPlugin { .into(); output }, + ) + .register( + "new", + | + entity: Val, + button: Val, + state: Val, + value: f32| + { + let output: Val = bevy::input::gamepad::GamepadButtonChangedEvent::new( + entity.into_inner(), + button.into_inner(), + state.into_inner(), + value, + ) + .into(); + output + }, ); NamespaceBuilder::< ::bevy::input::gamepad::GamepadButtonStateChangedEvent, @@ -535,6 +595,24 @@ impl ::bevy::app::Plugin for BevyInputScriptingPlugin { .into(); output }, + ) + .register( + "new", + | + entity: Val, + button: Val, + state: Val| + { + let output: Val< + bevy::input::gamepad::GamepadButtonStateChangedEvent, + > = bevy::input::gamepad::GamepadButtonStateChangedEvent::new( + entity.into_inner(), + button.into_inner(), + state.into_inner(), + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::input::gamepad::GamepadConnection>::new(world) .register( @@ -603,6 +681,20 @@ impl ::bevy::app::Plugin for BevyInputScriptingPlugin { .into(); output }, + ) + .register( + "new", + | + gamepad: Val, + connection: Val| + { + let output: Val = bevy::input::gamepad::GamepadConnectionEvent::new( + gamepad.into_inner(), + connection.into_inner(), + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::input::gamepad::GamepadEvent>::new(world) .register( @@ -672,6 +764,16 @@ impl ::bevy::app::Plugin for BevyInputScriptingPlugin { .into(); output }, + ) + .register( + "gamepad", + |_self: Ref| { + let output: Val = bevy::input::gamepad::GamepadRumbleRequest::gamepad( + &_self, + ) + .into(); + output + }, ); NamespaceBuilder::< ::bevy::input::gamepad::RawGamepadAxisChangedEvent, @@ -698,6 +800,22 @@ impl ::bevy::app::Plugin for BevyInputScriptingPlugin { .into(); output }, + ) + .register( + "new", + | + gamepad: Val, + axis_type: Val, + value: f32| + { + let output: Val = bevy::input::gamepad::RawGamepadAxisChangedEvent::new( + gamepad.into_inner(), + axis_type.into_inner(), + value, + ) + .into(); + output + }, ); NamespaceBuilder::< ::bevy::input::gamepad::RawGamepadButtonChangedEvent, @@ -726,6 +844,24 @@ impl ::bevy::app::Plugin for BevyInputScriptingPlugin { .into(); output }, + ) + .register( + "new", + | + gamepad: Val, + button_type: Val, + value: f32| + { + let output: Val< + bevy::input::gamepad::RawGamepadButtonChangedEvent, + > = bevy::input::gamepad::RawGamepadButtonChangedEvent::new( + gamepad.into_inner(), + button_type.into_inner(), + value, + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::input::gamepad::RawGamepadEvent>::new(world) .register( diff --git a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_math.rs b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_math.rs index 6e5d7c68..0a6ef265 100644 --- a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_math.rs +++ b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_math.rs @@ -2,7 +2,6 @@ #![allow(clippy::all)] #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] -use super::bevy_reflect::*; use bevy_mod_scripting_core::bindings::{ ReflectReference, function::{ @@ -178,6 +177,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "from_translation", + |translation: Val| { + let output: Val = bevy::math::Isometry2d::from_translation( + translation.into_inner(), + ) + .into(); + output + }, + ) .register( "from_xy", |x: f32, y: f32| { @@ -210,6 +219,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "inverse_transform_point", + | + _self: Ref, + point: Val| + { + let output: Val = bevy::math::Isometry2d::inverse_transform_point( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) .register( "mul", |_self: Val, rhs: Val| { @@ -232,6 +255,47 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "mul", + | + _self: Val, + rhs: Val| + { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + .into(); + output + }, + ) + .register( + "new", + | + translation: Val, + rotation: Val| + { + let output: Val = bevy::math::Isometry2d::new( + translation.into_inner(), + rotation.into_inner(), + ) + .into(); + output + }, + ) + .register( + "transform_point", + | + _self: Ref, + point: Val| + { + let output: Val = bevy::math::Isometry2d::transform_point( + &_self, + point.into_inner(), + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::Isometry3d>::new(world) .register( @@ -254,6 +318,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "from_rotation", + |rotation: Val| { + let output: Val = bevy::math::Isometry3d::from_rotation( + rotation.into_inner(), + ) + .into(); + output + }, + ) .register( "from_xyz", |x: f32, y: f32, z: f32| { @@ -297,6 +371,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "mul", + |_self: Val, rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + .into(); + output + }, + ) .register( "mul", | @@ -309,6 +393,19 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "mul", + | + _self: Val, + rhs: Val| + { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::Ray2d>::new(world) .register( @@ -330,6 +427,47 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "get_point", + |_self: Ref, distance: f32| { + let output: Val = bevy::math::Ray2d::get_point( + &_self, + distance, + ) + .into(); + output + }, + ) + .register( + "intersect_plane", + | + _self: Ref, + plane_origin: Val, + plane: Val| + { + let output: std::option::Option = bevy::math::Ray2d::intersect_plane( + &_self, + plane_origin.into_inner(), + plane.into_inner(), + ) + .into(); + output + }, + ) + .register( + "new", + | + origin: Val, + direction: Val| + { + let output: Val = bevy::math::Ray2d::new( + origin.into_inner(), + direction.into_inner(), + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::Ray3d>::new(world) .register( @@ -351,6 +489,47 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "get_point", + |_self: Ref, distance: f32| { + let output: Val = bevy::math::Ray3d::get_point( + &_self, + distance, + ) + .into(); + output + }, + ) + .register( + "intersect_plane", + | + _self: Ref, + plane_origin: Val, + plane: Val| + { + let output: std::option::Option = bevy::math::Ray3d::intersect_plane( + &_self, + plane_origin.into_inner(), + plane.into_inner(), + ) + .into(); + output + }, + ) + .register( + "new", + | + origin: Val, + direction: Val| + { + let output: Val = bevy::math::Ray3d::new( + origin.into_inner(), + direction.into_inner(), + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::Rot2>::new(world) .register( @@ -547,6 +726,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "mul", + |_self: Val, rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + .into(); + output + }, + ) .register( "nlerp", |_self: Val, end: Val, s: f32| { @@ -612,6 +801,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { }, ); NamespaceBuilder::<::bevy::math::prelude::Dir2>::new(world) + .register( + "as_vec2", + |_self: Ref| { + let output: Val = bevy::math::prelude::Dir2::as_vec2( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -656,6 +855,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "mul", + |_self: Val, rhs: f32| { + let output: Val = >::mul(_self.into_inner(), rhs) + .into(); + output + }, + ) .register( "neg", |_self: Val| { @@ -666,6 +875,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "new_unchecked", + |value: Val| { + let output: Val = bevy::math::prelude::Dir2::new_unchecked( + value.into_inner(), + ) + .into(); + output + }, + ) .register( "rotation_from", | @@ -751,6 +970,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { }, ); NamespaceBuilder::<::bevy::math::prelude::Dir3>::new(world) + .register( + "as_vec3", + |_self: Ref| { + let output: Val = bevy::math::prelude::Dir3::as_vec3( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -796,6 +1025,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "mul", + |_self: Val, rhs: f32| { + let output: Val = >::mul(_self.into_inner(), rhs) + .into(); + output + }, + ) .register( "neg", |_self: Val| { @@ -806,6 +1045,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "new_unchecked", + |value: Val| { + let output: Val = bevy::math::prelude::Dir3::new_unchecked( + value.into_inner(), + ) + .into(); + output + }, + ) .register( "slerp", | @@ -823,6 +1072,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { }, ); NamespaceBuilder::<::bevy::math::prelude::Dir3A>::new(world) + .register( + "as_vec3a", + |_self: Ref| { + let output: Val = bevy::math::prelude::Dir3A::as_vec3a( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -868,6 +1127,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "mul", + |_self: Val, rhs: f32| { + let output: Val = >::mul(_self.into_inner(), rhs) + .into(); + output + }, + ) .register( "neg", |_self: Val| { @@ -878,6 +1147,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "new_unchecked", + |value: Val| { + let output: Val = bevy::math::prelude::Dir3A::new_unchecked( + value.into_inner(), + ) + .into(); + output + }, + ) .register( "slerp", | @@ -925,6 +1204,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "center", + |_self: Ref| { + let output: Val = bevy::math::prelude::IRect::center( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -935,6 +1224,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "contains", + | + _self: Ref, + point: Val| + { + let output: bool = bevy::math::prelude::IRect::contains( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) .register( "eq", | @@ -948,6 +1251,58 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "from_center_half_size", + | + origin: Val, + half_size: Val| + { + let output: Val = bevy::math::prelude::IRect::from_center_half_size( + origin.into_inner(), + half_size.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_center_size", + | + origin: Val, + size: Val| + { + let output: Val = bevy::math::prelude::IRect::from_center_size( + origin.into_inner(), + size.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_corners", + | + p0: Val, + p1: Val| + { + let output: Val = bevy::math::prelude::IRect::from_corners( + p0.into_inner(), + p1.into_inner(), + ) + .into(); + output + }, + ) + .register( + "half_size", + |_self: Ref| { + let output: Val = bevy::math::prelude::IRect::half_size( + &_self, + ) + .into(); + output + }, + ) .register( "height", |_self: Ref| { @@ -1001,6 +1356,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "size", + |_self: Ref| { + let output: Val = bevy::math::prelude::IRect::size( + &_self, + ) + .into(); + output + }, + ) .register( "union", | @@ -1015,6 +1380,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "union_point", + | + _self: Ref, + other: Val| + { + let output: Val = bevy::math::prelude::IRect::union_point( + &_self, + other.into_inner(), + ) + .into(); + output + }, + ) .register( "width", |_self: Ref| { @@ -1043,6 +1422,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "center", + |_self: Ref| { + let output: Val = bevy::math::prelude::Rect::center( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -1053,6 +1442,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "contains", + | + _self: Ref, + point: Val| + { + let output: bool = bevy::math::prelude::Rect::contains( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) .register( "eq", | @@ -1066,6 +1469,55 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "from_center_half_size", + | + origin: Val, + half_size: Val| + { + let output: Val = bevy::math::prelude::Rect::from_center_half_size( + origin.into_inner(), + half_size.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_center_size", + | + origin: Val, + size: Val| + { + let output: Val = bevy::math::prelude::Rect::from_center_size( + origin.into_inner(), + size.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_corners", + |p0: Val, p1: Val| { + let output: Val = bevy::math::prelude::Rect::from_corners( + p0.into_inner(), + p1.into_inner(), + ) + .into(); + output + }, + ) + .register( + "half_size", + |_self: Ref| { + let output: Val = bevy::math::prelude::Rect::half_size( + &_self, + ) + .into(); + output + }, + ) .register( "height", |_self: Ref| { @@ -1133,6 +1585,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "size", + |_self: Ref| { + let output: Val = bevy::math::prelude::Rect::size( + &_self, + ) + .into(); + output + }, + ) .register( "union", | @@ -1147,6 +1609,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "union_point", + | + _self: Ref, + other: Val| + { + let output: Val = bevy::math::prelude::Rect::union_point( + &_self, + other.into_inner(), + ) + .into(); + output + }, + ) .register( "width", |_self: Ref| { @@ -1185,6 +1661,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "center", + |_self: Ref| { + let output: Val = bevy::math::prelude::URect::center( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -1195,6 +1681,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "contains", + | + _self: Ref, + point: Val| + { + let output: bool = bevy::math::prelude::URect::contains( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) .register( "eq", | @@ -1208,6 +1708,58 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "from_center_half_size", + | + origin: Val, + half_size: Val| + { + let output: Val = bevy::math::prelude::URect::from_center_half_size( + origin.into_inner(), + half_size.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_center_size", + | + origin: Val, + size: Val| + { + let output: Val = bevy::math::prelude::URect::from_center_size( + origin.into_inner(), + size.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_corners", + | + p0: Val, + p1: Val| + { + let output: Val = bevy::math::prelude::URect::from_corners( + p0.into_inner(), + p1.into_inner(), + ) + .into(); + output + }, + ) + .register( + "half_size", + |_self: Ref| { + let output: Val = bevy::math::prelude::URect::half_size( + &_self, + ) + .into(); + output + }, + ) .register( "height", |_self: Ref| { @@ -1261,6 +1813,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "size", + |_self: Ref| { + let output: Val = bevy::math::prelude::URect::size( + &_self, + ) + .into(); + output + }, + ) .register( "union", | @@ -1275,6 +1837,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "union_point", + | + _self: Ref, + other: Val| + { + let output: Val = bevy::math::prelude::URect::union_point( + &_self, + other.into_inner(), + ) + .into(); + output + }, + ) .register( "width", |_self: Ref| { @@ -1303,6 +1879,34 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "closest_point", + | + _self: Ref, + point: Val| + { + let output: Val = bevy::math::bounding::Aabb2d::closest_point( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) + .register( + "new", + | + center: Val, + half_size: Val| + { + let output: Val = bevy::math::bounding::Aabb2d::new( + center.into_inner(), + half_size.into_inner(), + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::bounding::BoundingCircle>::new(world) .register( @@ -1325,6 +1929,31 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "closest_point", + | + _self: Ref, + point: Val| + { + let output: Val = bevy::math::bounding::BoundingCircle::closest_point( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) + .register( + "new", + |center: Val, radius: f32| { + let output: Val = bevy::math::bounding::BoundingCircle::new( + center.into_inner(), + radius, + ) + .into(); + output + }, + ) .register( "radius", |_self: Ref| { @@ -1346,6 +1975,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "closest_point", + | + _self: Ref, + point: Val| + { + let output: Val = bevy::math::primitives::Circle::closest_point( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) .register( "diameter", |_self: Ref| { @@ -1388,6 +2031,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "closest_point", + | + _self: Ref, + point: Val| + { + let output: Val = bevy::math::primitives::Annulus::closest_point( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) .register( "diameter", |_self: Ref| { @@ -1453,6 +2110,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "chord_midpoint", + |_self: Ref| { + let output: Val = bevy::math::primitives::Arc2d::chord_midpoint( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -1535,6 +2202,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "left_endpoint", + |_self: Ref| { + let output: Val = bevy::math::primitives::Arc2d::left_endpoint( + &_self, + ) + .into(); + output + }, + ) .register( "length", |_self: Ref| { @@ -1543,6 +2220,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "midpoint", + |_self: Ref| { + let output: Val = bevy::math::primitives::Arc2d::midpoint( + &_self, + ) + .into(); + output + }, + ) .register( "new", |radius: f32, half_angle: f32| { @@ -1554,6 +2241,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "right_endpoint", + |_self: Ref| { + let output: Val = bevy::math::primitives::Arc2d::right_endpoint( + &_self, + ) + .into(); + output + }, + ) .register( "sagitta", |_self: Ref| { @@ -1648,6 +2345,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "chord_midpoint", + |_self: Ref| { + let output: Val = bevy::math::primitives::CircularSector::chord_midpoint( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -1796,6 +2503,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "chord_midpoint", + |_self: Ref| { + let output: Val = bevy::math::primitives::CircularSegment::chord_midpoint( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -1947,6 +2664,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "from_size", + |size: Val| { + let output: Val = bevy::math::primitives::Ellipse::from_size( + size.into_inner(), + ) + .into(); + output + }, + ) .register( "new", |half_width: f32, half_height: f32| { @@ -2021,6 +2748,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "new", + |normal: Val| { + let output: Val = bevy::math::primitives::Plane2d::new( + normal.into_inner(), + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::primitives::Rectangle>::new(world) .register( @@ -2033,6 +2770,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "closest_point", + | + _self: Ref, + point: Val| + { + let output: Val = bevy::math::primitives::Rectangle::closest_point( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) .register( "eq", | @@ -2046,6 +2797,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "from_corners", + | + point1: Val, + point2: Val| + { + let output: Val = bevy::math::primitives::Rectangle::from_corners( + point1.into_inner(), + point2.into_inner(), + ) + .into(); + output + }, + ) .register( "from_length", |length: f32| { @@ -2056,6 +2821,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "from_size", + |size: Val| { + let output: Val = bevy::math::primitives::Rectangle::from_size( + size.into_inner(), + ) + .into(); + output + }, + ) .register( "new", |width: f32, height: f32| { @@ -2066,6 +2841,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "size", + |_self: Ref| { + let output: Val = bevy::math::primitives::Rectangle::size( + &_self, + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::primitives::RegularPolygon>::new(world) .register( @@ -2193,6 +2978,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "closest_point", + | + _self: Ref, + point: Val| + { + let output: Val = bevy::math::primitives::Rhombus::closest_point( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) .register( "eq", | @@ -2287,6 +3086,26 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "point1", + |_self: Ref| { + let output: Val = bevy::math::primitives::Segment2d::point1( + &_self, + ) + .into(); + output + }, + ) + .register( + "point2", + |_self: Ref| { + let output: Val = bevy::math::primitives::Segment2d::point2( + &_self, + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::primitives::Triangle2d>::new(world) .register( @@ -2342,6 +3161,22 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "new", + | + a: Val, + b: Val, + c: Val| + { + let output: Val = bevy::math::primitives::Triangle2d::new( + a.into_inner(), + b.into_inner(), + c.into_inner(), + ) + .into(); + output + }, + ) .register( "reverse", |mut _self: Mut| { @@ -2425,6 +3260,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "closest_point", + | + _self: Ref, + point: Val| + { + let output: Val = bevy::math::primitives::Sphere::closest_point( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) .register( "diameter", |_self: Ref| { @@ -2467,6 +3316,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "closest_point", + | + _self: Ref, + point: Val| + { + let output: Val = bevy::math::primitives::Cuboid::closest_point( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) .register( "eq", | @@ -2480,6 +3343,20 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "from_corners", + | + point1: Val, + point2: Val| + { + let output: Val = bevy::math::primitives::Cuboid::from_corners( + point1.into_inner(), + point2.into_inner(), + ) + .into(); + output + }, + ) .register( "from_length", |length: f32| { @@ -2490,6 +3367,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "from_size", + |size: Val| { + let output: Val = bevy::math::primitives::Cuboid::from_size( + size.into_inner(), + ) + .into(); + output + }, + ) .register( "new", |x_length: f32, y_length: f32, z_length: f32| { @@ -2501,6 +3388,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "size", + |_self: Ref| { + let output: Val = bevy::math::primitives::Cuboid::size( + &_self, + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::primitives::Cylinder>::new(world) .register( @@ -2726,6 +3623,34 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "isometry_from_xy", + | + _self: Ref, + origin: Val| + { + let output: Val = bevy::math::primitives::InfinitePlane3d::isometry_from_xy( + &_self, + origin.into_inner(), + ) + .into(); + output + }, + ) + .register( + "isometry_into_xy", + | + _self: Ref, + origin: Val| + { + let output: Val = bevy::math::primitives::InfinitePlane3d::isometry_into_xy( + &_self, + origin.into_inner(), + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::primitives::Line3d>::new(world) .register( @@ -2785,6 +3710,26 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "point1", + |_self: Ref| { + let output: Val = bevy::math::primitives::Segment3d::point1( + &_self, + ) + .into(); + output + }, + ) + .register( + "point2", + |_self: Ref| { + let output: Val = bevy::math::primitives::Segment3d::point2( + &_self, + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::primitives::Torus>::new(world) .register( @@ -2838,6 +3783,26 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { }, ); NamespaceBuilder::<::bevy::math::primitives::Triangle3d>::new(world) + .register( + "centroid", + |_self: Ref| { + let output: Val = bevy::math::primitives::Triangle3d::centroid( + &_self, + ) + .into(); + output + }, + ) + .register( + "circumcenter", + |_self: Ref| { + let output: Val = bevy::math::primitives::Triangle3d::circumcenter( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -2891,6 +3856,22 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "new", + | + a: Val, + b: Val, + c: Val| + { + let output: Val = bevy::math::primitives::Triangle3d::new( + a.into_inner(), + b.into_inner(), + c.into_inner(), + ) + .into(); + output + }, + ) .register( "reverse", |mut _self: Mut| { @@ -2950,6 +3931,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "direction_recip", + |_self: Ref| { + let output: Val = bevy::math::bounding::RayCast2d::direction_recip( + &_self, + ) + .into(); + output + }, + ) .register( "from_ray", |ray: Val, max: f32| { @@ -2960,6 +3951,22 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "new", + | + origin: Val, + direction: Val, + max: f32| + { + let output: Val = bevy::math::bounding::RayCast2d::new( + origin.into_inner(), + direction.into_inner(), + max, + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::bounding::AabbCast2d>::new(world) .register( @@ -3001,6 +4008,24 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "new", + | + aabb: Val, + origin: Val, + direction: Val, + max: f32| + { + let output: Val = bevy::math::bounding::AabbCast2d::new( + aabb.into_inner(), + origin.into_inner(), + direction.into_inner(), + max, + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::bounding::BoundingCircleCast>::new(world) .register( @@ -3042,6 +4067,24 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "new", + | + circle: Val, + origin: Val, + direction: Val, + max: f32| + { + let output: Val = bevy::math::bounding::BoundingCircleCast::new( + circle.into_inner(), + origin.into_inner(), + direction.into_inner(), + max, + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::bounding::RayCast3d>::new(world) .register( @@ -3068,6 +4111,16 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "direction_recip", + |_self: Ref| { + let output: Val = bevy::math::bounding::RayCast3d::direction_recip( + &_self, + ) + .into(); + output + }, + ) .register( "from_ray", |ray: Val, max: f32| { @@ -3389,8 +4442,32 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { .into(); output }, + ) + .register( + "new", + | + normal: Val, + half_size: Val| + { + let output: Val = bevy::math::primitives::Plane3d::new( + normal.into_inner(), + half_size.into_inner(), + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::math::primitives::Tetrahedron>::new(world) + .register( + "centroid", + |_self: Ref| { + let output: Val = bevy::math::primitives::Tetrahedron::centroid( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -3414,6 +4491,24 @@ impl ::bevy::app::Plugin for BevyMathScriptingPlugin { output }, ) + .register( + "new", + | + a: Val, + b: Val, + c: Val, + d: Val| + { + let output: Val = bevy::math::primitives::Tetrahedron::new( + a.into_inner(), + b.into_inner(), + c.into_inner(), + d.into_inner(), + ) + .into(); + output + }, + ) .register( "signed_volume", |_self: Ref| { diff --git a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_reflect.rs b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_reflect.rs index 1307cb3e..bd06a19b 100644 --- a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_reflect.rs +++ b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_reflect.rs @@ -1256,20 +1256,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), rhs) + bevy::math::Vec3, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: f32| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + f32, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -1537,10 +1537,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Ref| { let output: Val = >::div(_self.into_inner(), rhs) + &bevy::math::Vec3, + >>::div(_self.into_inner(), &rhs) .into(); output }, @@ -1557,10 +1557,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: f32| { let output: Val = >::div(_self.into_inner(), &rhs) + f32, + >>::div(_self.into_inner(), rhs) .into(); output }, @@ -1842,10 +1842,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs) + &bevy::math::Vec3, + >>::mul(_self.into_inner(), &rhs) .into(); output }, @@ -1862,10 +1862,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: f32| { let output: Val = >::mul(_self.into_inner(), &rhs) + f32, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -2025,10 +2025,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs) + &bevy::math::Vec3, + >>::rem(_self.into_inner(), &rhs) .into(); output }, @@ -2045,10 +2045,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: f32| { let output: Val = >::rem(_self.into_inner(), &rhs) + f32, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -2110,20 +2110,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + &bevy::math::Vec3, + >>::sub(_self.into_inner(), &rhs) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), &rhs) + bevy::math::Vec3, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -2211,10 +2211,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: i32| { + |_self: Val, rhs: Ref| { let output: Val = >::add(_self.into_inner(), rhs) + &bevy::math::IVec2, + >>::add(_self.into_inner(), &rhs) .into(); output }, @@ -2231,10 +2231,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: i32| { let output: Val = >::add(_self.into_inner(), &rhs) + i32, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -2414,20 +2414,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: i32| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), rhs) + bevy::math::IVec2, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i32| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + i32, + >>::div(_self.into_inner(), rhs) .into(); output }, @@ -2582,20 +2582,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: i32| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs) + bevy::math::IVec2, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i32| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + i32, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -2641,30 +2641,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + &bevy::math::IVec2, + >>::rem(_self.into_inner(), &rhs) .into(); output }, ) .register( "rem", - |_self: Val, rhs: i32| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), rhs) + bevy::math::IVec2, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: i32| { let output: Val = >::rem(_self.into_inner(), &rhs) + i32, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -2803,20 +2803,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: i32| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), rhs) + bevy::math::IVec2, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i32| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + i32, + >>::sub(_self.into_inner(), rhs) .into(); output }, @@ -3153,20 +3153,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: i32| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), rhs) + bevy::math::IVec3, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i32| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + i32, + >>::div(_self.into_inner(), rhs) .into(); output }, @@ -3311,30 +3311,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + &bevy::math::IVec3, + >>::mul(_self.into_inner(), &rhs) .into(); output }, ) .register( "mul", - |_self: Val, rhs: i32| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs) + bevy::math::IVec3, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: i32| { let output: Val = >::mul(_self.into_inner(), &rhs) + i32, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -3359,20 +3359,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + &bevy::math::IVec3, + >>::rem(_self.into_inner(), &rhs) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), &rhs) + bevy::math::IVec3, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -3657,10 +3657,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: i32| { + |_self: Val, rhs: Ref| { let output: Val = >::add(_self.into_inner(), rhs) + &bevy::math::IVec4, + >>::add(_self.into_inner(), &rhs) .into(); output }, @@ -3677,10 +3677,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: i32| { let output: Val = >::add(_self.into_inner(), &rhs) + i32, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -3860,20 +3860,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: i32| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), rhs) + bevy::math::IVec4, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i32| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + i32, + >>::div(_self.into_inner(), rhs) .into(); output }, @@ -4070,20 +4070,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: i32| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), rhs) + bevy::math::IVec4, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i32| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + i32, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -4201,20 +4201,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + &bevy::math::IVec4, + >>::sub(_self.into_inner(), &rhs) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), &rhs) + bevy::math::IVec4, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -4379,20 +4379,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), rhs) + bevy::math::I64Vec2, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i64| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + i64, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -4572,20 +4572,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), rhs) + bevy::math::I64Vec2, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i64| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + i64, + >>::div(_self.into_inner(), rhs) .into(); output }, @@ -4738,10 +4738,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs) + &bevy::math::I64Vec2, + >>::mul(_self.into_inner(), &rhs) .into(); output }, @@ -4758,10 +4758,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: i64| { let output: Val = >::mul(_self.into_inner(), &rhs) + i64, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -4817,20 +4817,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), rhs) + bevy::math::I64Vec2, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i64| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + i64, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -4959,20 +4959,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + &bevy::math::I64Vec2, + >>::sub(_self.into_inner(), &rhs) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), &rhs) + bevy::math::I64Vec2, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -5095,30 +5095,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + &bevy::math::I64Vec3, + >>::add(_self.into_inner(), &rhs) .into(); output }, ) .register( "add", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), rhs) + bevy::math::I64Vec3, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: i64| { let output: Val = >::add(_self.into_inner(), &rhs) + i64, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -5309,10 +5309,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Ref| { let output: Val = >::div(_self.into_inner(), rhs) + &bevy::math::I64Vec3, + >>::div(_self.into_inner(), &rhs) .into(); output }, @@ -5329,10 +5329,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: i64| { let output: Val = >::div(_self.into_inner(), &rhs) + i64, + >>::div(_self.into_inner(), rhs) .into(); output }, @@ -5485,30 +5485,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + &bevy::math::I64Vec3, + >>::mul(_self.into_inner(), &rhs) .into(); output }, ) .register( "mul", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs) + bevy::math::I64Vec3, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: i64| { let output: Val = >::mul(_self.into_inner(), &rhs) + i64, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -5537,10 +5537,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs) + &bevy::math::I64Vec3, + >>::rem(_self.into_inner(), &rhs) .into(); output }, @@ -5557,10 +5557,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: i64| { let output: Val = >::rem(_self.into_inner(), &rhs) + i64, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -5688,20 +5688,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), rhs) + bevy::math::I64Vec3, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i64| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + i64, + >>::sub(_self.into_inner(), rhs) .into(); output }, @@ -5835,30 +5835,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + &bevy::math::I64Vec4, + >>::add(_self.into_inner(), &rhs) .into(); output }, ) .register( "add", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), rhs) + bevy::math::I64Vec4, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: i64| { let output: Val = >::add(_self.into_inner(), &rhs) + i64, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -6028,30 +6028,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Ref| { let output: Val = >::div(_self.into_inner(), rhs) + &bevy::math::I64Vec4, + >>::div(_self.into_inner(), &rhs) .into(); output }, ) .register( "div", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), &rhs) + bevy::math::I64Vec4, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i64| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + i64, + >>::div(_self.into_inner(), rhs) .into(); output }, @@ -6203,20 +6203,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs) + bevy::math::I64Vec4, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i64| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + i64, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -6246,30 +6246,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs) + &bevy::math::I64Vec4, + >>::rem(_self.into_inner(), &rhs) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), &rhs) + bevy::math::I64Vec4, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i64| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + i64, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -6387,30 +6387,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: i64| { + |_self: Val, rhs: Ref| { let output: Val = >::sub(_self.into_inner(), rhs) + &bevy::math::I64Vec4, + >>::sub(_self.into_inner(), &rhs) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), &rhs) + bevy::math::I64Vec4, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: i64| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + i64, + >>::sub(_self.into_inner(), rhs) .into(); output }, @@ -6545,30 +6545,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { NamespaceBuilder::<::bevy::math::UVec2>::new(world) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + &bevy::math::UVec2, + >>::add(_self.into_inner(), &rhs) .into(); output }, ) .register( "add", - |_self: Val, rhs: u32| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), rhs) + bevy::math::UVec2, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: u32| { let output: Val = >::add(_self.into_inner(), &rhs) + u32, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -6874,20 +6874,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + &bevy::math::UVec2, + >>::mul(_self.into_inner(), &rhs) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), &rhs) + bevy::math::UVec2, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -6912,20 +6912,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + &bevy::math::UVec2, + >>::rem(_self.into_inner(), &rhs) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), &rhs) + bevy::math::UVec2, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -7021,30 +7021,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: u32| { + |_self: Val, rhs: Ref| { let output: Val = >::sub(_self.into_inner(), rhs) + &bevy::math::UVec2, + >>::sub(_self.into_inner(), &rhs) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), &rhs) + bevy::math::UVec2, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u32| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + u32, + >>::sub(_self.into_inner(), rhs) .into(); output }, @@ -7146,20 +7146,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: u32| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), rhs) + bevy::math::UVec3, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u32| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + u32, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -7339,30 +7339,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + &bevy::math::UVec3, + >>::div(_self.into_inner(), &rhs) .into(); output }, ) .register( "div", - |_self: Val, rhs: u32| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), rhs) + bevy::math::UVec3, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "div", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: u32| { let output: Val = >::div(_self.into_inner(), &rhs) + u32, + >>::div(_self.into_inner(), rhs) .into(); output }, @@ -7496,20 +7496,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: u32| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs) + bevy::math::UVec3, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u32| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + u32, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -7524,30 +7524,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: u32| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs) + &bevy::math::UVec3, + >>::rem(_self.into_inner(), &rhs) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), &rhs) + bevy::math::UVec3, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u32| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + u32, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -7643,20 +7643,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: u32| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), rhs) + bevy::math::UVec3, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u32| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + u32, + >>::sub(_self.into_inner(), rhs) .into(); output }, @@ -7769,30 +7769,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { NamespaceBuilder::<::bevy::math::UVec4>::new(world) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + &bevy::math::UVec4, + >>::add(_self.into_inner(), &rhs) .into(); output }, ) .register( "add", - |_self: Val, rhs: u32| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), rhs) + bevy::math::UVec4, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: u32| { let output: Val = >::add(_self.into_inner(), &rhs) + u32, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -7961,20 +7961,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: u32| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), rhs) + bevy::math::UVec4, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u32| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + u32, + >>::div(_self.into_inner(), rhs) .into(); output }, @@ -8087,10 +8087,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: u32| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs) + &bevy::math::UVec4, + >>::mul(_self.into_inner(), &rhs) .into(); output }, @@ -8107,10 +8107,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: u32| { let output: Val = >::mul(_self.into_inner(), &rhs) + u32, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -8130,30 +8130,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + &bevy::math::UVec4, + >>::rem(_self.into_inner(), &rhs) .into(); output }, ) .register( "rem", - |_self: Val, rhs: u32| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), rhs) + bevy::math::UVec4, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: u32| { let output: Val = >::rem(_self.into_inner(), &rhs) + u32, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -8249,20 +8249,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: u32| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), rhs) + bevy::math::UVec4, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u32| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + u32, + >>::sub(_self.into_inner(), rhs) .into(); output }, @@ -8386,30 +8386,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { NamespaceBuilder::<::bevy::math::U64Vec2>::new(world) .register( "add", - |_self: Val, rhs: u64| { + |_self: Val, rhs: Ref| { let output: Val = >::add(_self.into_inner(), rhs) + &bevy::math::U64Vec2, + >>::add(_self.into_inner(), &rhs) .into(); output }, ) .register( "add", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), &rhs) + bevy::math::U64Vec2, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u64| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + u64, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -8568,20 +8568,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + &bevy::math::U64Vec2, + >>::div(_self.into_inner(), &rhs) .into(); output }, ) .register( "div", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), &rhs) + bevy::math::U64Vec2, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -8723,20 +8723,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + &bevy::math::U64Vec2, + >>::mul(_self.into_inner(), &rhs) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), &rhs) + bevy::math::U64Vec2, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -8761,20 +8761,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + &bevy::math::U64Vec2, + >>::rem(_self.into_inner(), &rhs) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), &rhs) + bevy::math::U64Vec2, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -8870,30 +8870,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: u64| { + |_self: Val, rhs: Ref| { let output: Val = >::sub(_self.into_inner(), rhs) + &bevy::math::U64Vec2, + >>::sub(_self.into_inner(), &rhs) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), &rhs) + bevy::math::U64Vec2, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u64| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + u64, + >>::sub(_self.into_inner(), rhs) .into(); output }, @@ -8985,30 +8985,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { NamespaceBuilder::<::bevy::math::U64Vec3>::new(world) .register( "add", - |_self: Val, rhs: u64| { + |_self: Val, rhs: Ref| { let output: Val = >::add(_self.into_inner(), rhs) + &bevy::math::U64Vec3, + >>::add(_self.into_inner(), &rhs) .into(); output }, ) .register( "add", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), &rhs) + bevy::math::U64Vec3, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u64| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + u64, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -9198,20 +9198,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: u64| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), rhs) + bevy::math::U64Vec3, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u64| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + u64, + >>::div(_self.into_inner(), rhs) .into(); output }, @@ -9353,20 +9353,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: u64| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs) + bevy::math::U64Vec3, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u64| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + u64, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -9385,30 +9385,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: u64| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs) + &bevy::math::U64Vec3, + >>::rem(_self.into_inner(), &rhs) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), &rhs) + bevy::math::U64Vec3, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u64| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + u64, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -9494,30 +9494,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + &bevy::math::U64Vec3, + >>::sub(_self.into_inner(), &rhs) .into(); output }, ) .register( "sub", - |_self: Val, rhs: u64| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), rhs) + bevy::math::U64Vec3, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: u64| { let output: Val = >::sub(_self.into_inner(), &rhs) + u64, + >>::sub(_self.into_inner(), rhs) .into(); output }, @@ -9630,30 +9630,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { NamespaceBuilder::<::bevy::math::U64Vec4>::new(world) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + &bevy::math::U64Vec4, + >>::add(_self.into_inner(), &rhs) .into(); output }, ) .register( "add", - |_self: Val, rhs: u64| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), rhs) + bevy::math::U64Vec4, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: u64| { let output: Val = >::add(_self.into_inner(), &rhs) + u64, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -9956,30 +9956,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + &bevy::math::U64Vec4, + >>::mul(_self.into_inner(), &rhs) .into(); output }, ) .register( "mul", - |_self: Val, rhs: u64| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs) + bevy::math::U64Vec4, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: u64| { let output: Val = >::mul(_self.into_inner(), &rhs) + u64, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -9997,6 +9997,16 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { output }, ) + .register( + "rem", + |_self: Val, rhs: Ref| { + let output: Val = >::rem(_self.into_inner(), &rhs) + .into(); + output + }, + ) .register( "rem", |_self: Val, rhs: Val| { @@ -10017,16 +10027,6 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { output }, ) - .register( - "rem", - |_self: Val, rhs: Ref| { - let output: Val = >::rem(_self.into_inner(), &rhs) - .into(); - output - }, - ) .register( "saturating_add", |_self: Val, rhs: Val| { @@ -10108,30 +10108,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: u64| { + |_self: Val, rhs: Ref| { let output: Val = >::sub(_self.into_inner(), rhs) + &bevy::math::U64Vec4, + >>::sub(_self.into_inner(), &rhs) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), &rhs) + bevy::math::U64Vec4, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: u64| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + u64, + >>::sub(_self.into_inner(), rhs) .into(); output }, @@ -10291,20 +10291,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), rhs) + bevy::math::Vec2, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: f32| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + f32, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -10552,20 +10552,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + &bevy::math::Vec2, + >>::div(_self.into_inner(), &rhs) .into(); output }, ) .register( "div", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), &rhs) + bevy::math::Vec2, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -10867,30 +10867,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs) + &bevy::math::Vec2, + >>::mul(_self.into_inner(), &rhs) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), &rhs) + bevy::math::Vec2, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: f32| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + f32, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -11081,20 +11081,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), rhs) + bevy::math::Vec2, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: f32| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + f32, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -11183,20 +11183,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + &bevy::math::Vec2, + >>::sub(_self.into_inner(), &rhs) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), &rhs) + bevy::math::Vec2, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -11297,20 +11297,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), rhs) + bevy::math::Vec3A, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: f32| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + f32, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -11578,30 +11578,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + &bevy::math::Vec3A, + >>::div(_self.into_inner(), &rhs) .into(); output }, ) .register( "div", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), rhs) + bevy::math::Vec3A, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "div", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: f32| { let output: Val = >::div(_self.into_inner(), &rhs) + f32, + >>::div(_self.into_inner(), rhs) .into(); output }, @@ -11893,10 +11893,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs) + &bevy::math::Vec3A, + >>::mul(_self.into_inner(), &rhs) .into(); output }, @@ -11913,10 +11913,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: f32| { let output: Val = >::mul(_self.into_inner(), &rhs) + f32, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -12080,30 +12080,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs) + &bevy::math::Vec3A, + >>::rem(_self.into_inner(), &rhs) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), &rhs) + bevy::math::Vec3A, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: f32| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + f32, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -12165,10 +12165,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Ref| { let output: Val = >::sub(_self.into_inner(), rhs) + &bevy::math::Vec3A, + >>::sub(_self.into_inner(), &rhs) .into(); output }, @@ -12185,10 +12185,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: f32| { let output: Val = >::sub(_self.into_inner(), &rhs) + f32, + >>::sub(_self.into_inner(), rhs) .into(); output }, @@ -12825,10 +12825,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs) + &bevy::math::Vec4, + >>::mul(_self.into_inner(), &rhs) .into(); output }, @@ -12845,10 +12845,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: f32| { let output: Val = >::mul(_self.into_inner(), &rhs) + f32, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -13008,30 +13008,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs) + &bevy::math::Vec4, + >>::rem(_self.into_inner(), &rhs) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), &rhs) + bevy::math::Vec4, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: f32| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + f32, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -13093,30 +13093,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "sub", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::sub(_self.into_inner(), rhs.into_inner()) + &bevy::math::Vec4, + >>::sub(_self.into_inner(), &rhs) .into(); output }, ) .register( "sub", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Val| { let output: Val = >::sub(_self.into_inner(), rhs) + bevy::math::Vec4, + >>::sub(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "sub", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: f32| { let output: Val = >::sub(_self.into_inner(), &rhs) + f32, + >>::sub(_self.into_inner(), rhs) .into(); output }, @@ -13502,30 +13502,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + &bevy::math::DVec2, + >>::add(_self.into_inner(), &rhs) .into(); output }, ) .register( "add", - |_self: Val, rhs: f64| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), rhs) + bevy::math::DVec2, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: f64| { let output: Val = >::add(_self.into_inner(), &rhs) + f64, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -13773,20 +13773,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + &bevy::math::DVec2, + >>::div(_self.into_inner(), &rhs) .into(); output }, ) .register( "div", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), &rhs) + bevy::math::DVec2, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -14088,20 +14088,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + &bevy::math::DVec2, + >>::mul(_self.into_inner(), &rhs) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), &rhs) + bevy::math::DVec2, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -14296,30 +14296,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: f64| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs) + &bevy::math::DVec2, + >>::rem(_self.into_inner(), &rhs) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), &rhs) + bevy::math::DVec2, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: f64| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + f64, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -14512,30 +14512,30 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + &bevy::math::DVec3, + >>::add(_self.into_inner(), &rhs) .into(); output }, ) .register( "add", - |_self: Val, rhs: f64| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), rhs) + bevy::math::DVec3, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "add", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: f64| { let output: Val = >::add(_self.into_inner(), &rhs) + f64, + >>::add(_self.into_inner(), rhs) .into(); output }, @@ -14823,20 +14823,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "div", - |_self: Val, rhs: f64| { + |_self: Val, rhs: Val| { let output: Val = >::div(_self.into_inner(), rhs) + bevy::math::DVec3, + >>::div(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "div", - |_self: Val, rhs: Val| { + |_self: Val, rhs: f64| { let output: Val = >::div(_self.into_inner(), rhs.into_inner()) + f64, + >>::div(_self.into_inner(), rhs) .into(); output }, @@ -15118,10 +15118,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: f64| { + |_self: Val, rhs: Ref| { let output: Val = >::mul(_self.into_inner(), rhs) + &bevy::math::DVec3, + >>::mul(_self.into_inner(), &rhs) .into(); output }, @@ -15138,10 +15138,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: f64| { let output: Val = >::mul(_self.into_inner(), &rhs) + f64, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -15315,20 +15315,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: f64| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), rhs) + bevy::math::DVec3, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: f64| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + f64, + >>::rem(_self.into_inner(), rhs) .into(); output }, @@ -15507,20 +15507,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "add", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::add(_self.into_inner(), rhs.into_inner()) + &bevy::math::DVec4, + >>::add(_self.into_inner(), &rhs) .into(); output }, ) .register( "add", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::add(_self.into_inner(), &rhs) + bevy::math::DVec4, + >>::add(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -16060,20 +16060,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: f64| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs) + bevy::math::DVec4, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: f64| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + f64, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -16242,20 +16242,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "rem", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Ref| { let output: Val = >::rem(_self.into_inner(), rhs.into_inner()) + &bevy::math::DVec4, + >>::rem(_self.into_inner(), &rhs) .into(); output }, ) .register( "rem", - |_self: Val, rhs: Ref| { + |_self: Val, rhs: Val| { let output: Val = >::rem(_self.into_inner(), &rhs) + bevy::math::DVec4, + >>::rem(_self.into_inner(), rhs.into_inner()) .into(); output }, @@ -16651,9 +16651,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { - let output: Val = , rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -16661,20 +16661,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: f32| { - let output: Val = >::mul(_self.into_inner(), rhs) + |_self: Val, rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: f32| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + f32, + >>::mul(_self.into_inner(), rhs) .into(); output }, @@ -17089,19 +17089,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs) - .into(); - output - }, - ) - .register( - "mul", - |_self: Val, rhs: Val| { - let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -17119,9 +17109,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { - let output: Val = , rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -17137,6 +17127,16 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { output }, ) + .register( + "mul", + |_self: Val, rhs: f32| { + let output: Val = >::mul(_self.into_inner(), rhs) + .into(); + output + }, + ) .register( "mul_mat3", |_self: Ref, rhs: Ref| { @@ -17593,19 +17593,19 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: f32| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs) + bevy::math::Affine2, + >>::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Val| { - let output: Val = , rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -17613,9 +17613,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { - let output: Val = , rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -17623,9 +17623,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { - let output: Val = , rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -17633,10 +17633,10 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { - let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + |_self: Val, rhs: f32| { + let output: Val = >::mul(_self.into_inner(), rhs) .into(); output }, @@ -18150,9 +18150,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -18160,9 +18160,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -19145,9 +19145,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -19155,9 +19155,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -19165,20 +19165,20 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: f64| { - let output: Val = >::mul(_self.into_inner(), rhs) + |_self: Val, rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output }, ) .register( "mul", - |_self: Val, rhs: Val| { - let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) + |_self: Val, rhs: f64| { + let output: Val = >::mul(_self.into_inner(), rhs) .into(); output }, @@ -19673,9 +19673,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { + |_self: Val, rhs: Val| { let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -19683,9 +19683,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { - let output: Val = , rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -19693,9 +19693,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { - let output: Val = , rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -21489,9 +21489,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { - let output: Val = , rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output @@ -21499,9 +21499,9 @@ impl ::bevy::app::Plugin for BevyReflectScriptingPlugin { ) .register( "mul", - |_self: Val, rhs: Val| { - let output: Val = , rhs: Val| { + let output: Val = >::mul(_self.into_inner(), rhs.into_inner()) .into(); output diff --git a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_time.rs b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_time.rs index 4e5f4d5a..1118b34f 100644 --- a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_time.rs +++ b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_time.rs @@ -2,8 +2,6 @@ #![allow(clippy::all)] #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] -use super::bevy_ecs::*; -use super::bevy_reflect::*; use bevy_mod_scripting_core::bindings::{ ReflectReference, function::{ @@ -59,6 +57,26 @@ impl ::bevy::app::Plugin for BevyTimeScriptingPlugin { output }, ) + .register( + "duration", + |_self: Ref| { + let output: Val = bevy::time::prelude::Timer::duration( + &_self, + ) + .into(); + output + }, + ) + .register( + "elapsed", + |_self: Ref| { + let output: Val = bevy::time::prelude::Timer::elapsed( + &_self, + ) + .into(); + output + }, + ) .register( "elapsed_secs", |_self: Ref| { @@ -145,6 +163,20 @@ impl ::bevy::app::Plugin for BevyTimeScriptingPlugin { output }, ) + .register( + "new", + | + duration: Val, + mode: Val| + { + let output: Val = bevy::time::prelude::Timer::new( + duration.into_inner(), + mode.into_inner(), + ) + .into(); + output + }, + ) .register( "pause", |mut _self: Mut| { @@ -160,6 +192,16 @@ impl ::bevy::app::Plugin for BevyTimeScriptingPlugin { output }, ) + .register( + "remaining", + |_self: Ref| { + let output: Val = bevy::time::prelude::Timer::remaining( + &_self, + ) + .into(); + output + }, + ) .register( "remaining_secs", |_self: Ref| { @@ -176,6 +218,34 @@ impl ::bevy::app::Plugin for BevyTimeScriptingPlugin { output }, ) + .register( + "set_duration", + | + mut _self: Mut, + duration: Val| + { + let output: () = bevy::time::prelude::Timer::set_duration( + &mut _self, + duration.into_inner(), + ) + .into(); + output + }, + ) + .register( + "set_elapsed", + | + mut _self: Mut, + time: Val| + { + let output: () = bevy::time::prelude::Timer::set_elapsed( + &mut _self, + time.into_inner(), + ) + .into(); + output + }, + ) .register( "set_mode", | @@ -274,6 +344,16 @@ impl ::bevy::app::Plugin for BevyTimeScriptingPlugin { output }, ) + .register( + "elapsed", + |_self: Ref| { + let output: Val = bevy::time::Stopwatch::elapsed( + &_self, + ) + .into(); + output + }, + ) .register( "elapsed_secs", |_self: Ref| { @@ -328,6 +408,20 @@ impl ::bevy::app::Plugin for BevyTimeScriptingPlugin { output }, ) + .register( + "set_elapsed", + | + mut _self: Mut, + time: Val| + { + let output: () = bevy::time::Stopwatch::set_elapsed( + &mut _self, + time.into_inner(), + ) + .into(); + output + }, + ) .register( "unpause", |mut _self: Mut| { diff --git a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_transform.rs b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_transform.rs index ce8666a3..c74b804a 100644 --- a/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_transform.rs +++ b/crates/bevy_mod_scripting_functions/src/bevy_bindings/bevy_transform.rs @@ -2,11 +2,6 @@ #![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_math::*; -use super::bevy_hierarchy::*; use bevy_mod_scripting_core::bindings::{ ReflectReference, function::{ @@ -20,6 +15,26 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { fn build(&self, app: &mut ::bevy::prelude::App) { let mut world = app.world_mut(); NamespaceBuilder::<::bevy::transform::components::GlobalTransform>::new(world) + .register( + "affine", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::affine( + &_self, + ) + .into(); + output + }, + ) + .register( + "back", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::back( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -30,6 +45,16 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { output }, ) + .register( + "compute_matrix", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::compute_matrix( + &_self, + ) + .into(); + output + }, + ) .register( "compute_transform", |_self: Ref| { @@ -40,6 +65,16 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { output }, ) + .register( + "down", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::down( + &_self, + ) + .into(); + output + }, + ) .register( "eq", | @@ -53,6 +88,56 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { output }, ) + .register( + "forward", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::forward( + &_self, + ) + .into(); + output + }, + ) + .register( + "from_isometry", + |iso: Val| { + let output: Val = bevy::transform::components::GlobalTransform::from_isometry( + iso.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_rotation", + |rotation: Val| { + let output: Val = bevy::transform::components::GlobalTransform::from_rotation( + rotation.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_scale", + |scale: Val| { + let output: Val = bevy::transform::components::GlobalTransform::from_scale( + scale.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_translation", + |translation: Val| { + let output: Val = bevy::transform::components::GlobalTransform::from_translation( + translation.into_inner(), + ) + .into(); + output + }, + ) .register( "from_xyz", |x: f32, y: f32, z: f32| { @@ -65,15 +150,25 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { output }, ) + .register( + "left", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::left( + &_self, + ) + .into(); + output + }, + ) .register( "mul", | _self: Val, - transform: Val| + value: Val| { - let output: Val = >::mul(_self.into_inner(), transform.into_inner()) + let output: Val = >::mul(_self.into_inner(), value.into_inner()) .into(); output }, @@ -91,6 +186,19 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { output }, ) + .register( + "mul", + | + _self: Val, + transform: Val| + { + let output: Val = >::mul(_self.into_inner(), transform.into_inner()) + .into(); + output + }, + ) .register( "mul_transform", | @@ -105,6 +213,20 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { output }, ) + .register( + "radius_vec3a", + | + _self: Ref, + extents: Val| + { + let output: f32 = bevy::transform::components::GlobalTransform::radius_vec3a( + &_self, + extents.into_inner(), + ) + .into(); + output + }, + ) .register( "reparented_to", | @@ -118,8 +240,102 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { .into(); output }, + ) + .register( + "right", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::right( + &_self, + ) + .into(); + output + }, + ) + .register( + "rotation", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::rotation( + &_self, + ) + .into(); + output + }, + ) + .register( + "scale", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::scale( + &_self, + ) + .into(); + output + }, + ) + .register( + "to_isometry", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::to_isometry( + &_self, + ) + .into(); + output + }, + ) + .register( + "transform_point", + | + _self: Ref, + point: Val| + { + let output: Val = bevy::transform::components::GlobalTransform::transform_point( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) + .register( + "translation", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::translation( + &_self, + ) + .into(); + output + }, + ) + .register( + "translation_vec3a", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::translation_vec3a( + &_self, + ) + .into(); + output + }, + ) + .register( + "up", + |_self: Ref| { + let output: Val = bevy::transform::components::GlobalTransform::up( + &_self, + ) + .into(); + output + }, ); NamespaceBuilder::<::bevy::transform::components::Transform>::new(world) + .register( + "back", + |_self: Ref| { + let output: Val = bevy::transform::components::Transform::back( + &_self, + ) + .into(); + output + }, + ) .register( "clone", |_self: Ref| { @@ -130,6 +346,36 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { output }, ) + .register( + "compute_affine", + |_self: Ref| { + let output: Val = bevy::transform::components::Transform::compute_affine( + &_self, + ) + .into(); + output + }, + ) + .register( + "compute_matrix", + |_self: Ref| { + let output: Val = bevy::transform::components::Transform::compute_matrix( + &_self, + ) + .into(); + output + }, + ) + .register( + "down", + |_self: Ref| { + let output: Val = bevy::transform::components::Transform::down( + &_self, + ) + .into(); + output + }, + ) .register( "eq", | @@ -143,6 +389,66 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { output }, ) + .register( + "forward", + |_self: Ref| { + let output: Val = bevy::transform::components::Transform::forward( + &_self, + ) + .into(); + output + }, + ) + .register( + "from_isometry", + |iso: Val| { + let output: Val = bevy::transform::components::Transform::from_isometry( + iso.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_matrix", + |world_from_local: Val| { + let output: Val = bevy::transform::components::Transform::from_matrix( + world_from_local.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_rotation", + |rotation: Val| { + let output: Val = bevy::transform::components::Transform::from_rotation( + rotation.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_scale", + |scale: Val| { + let output: Val = bevy::transform::components::Transform::from_scale( + scale.into_inner(), + ) + .into(); + output + }, + ) + .register( + "from_translation", + |translation: Val| { + let output: Val = bevy::transform::components::Transform::from_translation( + translation.into_inner(), + ) + .into(); + output + }, + ) .register( "from_xyz", |x: f32, y: f32, z: f32| { @@ -165,6 +471,59 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { output }, ) + .register( + "left", + |_self: Ref| { + let output: Val = bevy::transform::components::Transform::left( + &_self, + ) + .into(); + output + }, + ) + .register( + "local_x", + |_self: Ref| { + let output: Val = bevy::transform::components::Transform::local_x( + &_self, + ) + .into(); + output + }, + ) + .register( + "local_y", + |_self: Ref| { + let output: Val = bevy::transform::components::Transform::local_y( + &_self, + ) + .into(); + output + }, + ) + .register( + "local_z", + |_self: Ref| { + let output: Val = bevy::transform::components::Transform::local_z( + &_self, + ) + .into(); + output + }, + ) + .register( + "mul", + | + _self: Val, + value: Val| + { + let output: Val = >::mul(_self.into_inner(), value.into_inner()) + .into(); + output + }, + ) .register( "mul", | @@ -205,6 +564,92 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { output }, ) + .register( + "right", + |_self: Ref| { + let output: Val = bevy::transform::components::Transform::right( + &_self, + ) + .into(); + output + }, + ) + .register( + "rotate", + | + mut _self: Mut, + rotation: Val| + { + let output: () = bevy::transform::components::Transform::rotate( + &mut _self, + rotation.into_inner(), + ) + .into(); + output + }, + ) + .register( + "rotate_around", + | + mut _self: Mut, + point: Val, + rotation: Val| + { + let output: () = bevy::transform::components::Transform::rotate_around( + &mut _self, + point.into_inner(), + rotation.into_inner(), + ) + .into(); + output + }, + ) + .register( + "rotate_axis", + | + mut _self: Mut, + axis: Val, + angle: f32| + { + let output: () = bevy::transform::components::Transform::rotate_axis( + &mut _self, + axis.into_inner(), + angle, + ) + .into(); + output + }, + ) + .register( + "rotate_local", + | + mut _self: Mut, + rotation: Val| + { + let output: () = bevy::transform::components::Transform::rotate_local( + &mut _self, + rotation.into_inner(), + ) + .into(); + output + }, + ) + .register( + "rotate_local_axis", + | + mut _self: Mut, + axis: Val, + angle: f32| + { + let output: () = bevy::transform::components::Transform::rotate_local_axis( + &mut _self, + axis.into_inner(), + angle, + ) + .into(); + output + }, + ) .register( "rotate_local_x", |mut _self: Mut, angle: f32| { @@ -270,6 +715,98 @@ impl ::bevy::app::Plugin for BevyTransformScriptingPlugin { .into(); output }, + ) + .register( + "to_isometry", + |_self: Ref| { + let output: Val = bevy::transform::components::Transform::to_isometry( + &_self, + ) + .into(); + output + }, + ) + .register( + "transform_point", + | + _self: Ref, + point: Val| + { + let output: Val = bevy::transform::components::Transform::transform_point( + &_self, + point.into_inner(), + ) + .into(); + output + }, + ) + .register( + "translate_around", + | + mut _self: Mut, + point: Val, + rotation: Val| + { + let output: () = bevy::transform::components::Transform::translate_around( + &mut _self, + point.into_inner(), + rotation.into_inner(), + ) + .into(); + output + }, + ) + .register( + "up", + |_self: Ref| { + let output: Val = bevy::transform::components::Transform::up( + &_self, + ) + .into(); + output + }, + ) + .register( + "with_rotation", + | + _self: Val, + rotation: Val| + { + let output: Val = bevy::transform::components::Transform::with_rotation( + _self.into_inner(), + rotation.into_inner(), + ) + .into(); + output + }, + ) + .register( + "with_scale", + | + _self: Val, + scale: Val| + { + let output: Val = bevy::transform::components::Transform::with_scale( + _self.into_inner(), + scale.into_inner(), + ) + .into(); + output + }, + ) + .register( + "with_translation", + | + _self: Val, + translation: Val| + { + let output: Val = bevy::transform::components::Transform::with_translation( + _self.into_inner(), + translation.into_inner(), + ) + .into(); + output + }, ); } } diff --git a/crates/bevy_mod_scripting_functions/src/bevy_bindings/mod.rs b/crates/bevy_mod_scripting_functions/src/bevy_bindings/mod.rs index 7aa09772..6cec6902 100644 --- a/crates/bevy_mod_scripting_functions/src/bevy_bindings/mod.rs +++ b/crates/bevy_mod_scripting_functions/src/bevy_bindings/mod.rs @@ -2,24 +2,24 @@ #![allow(clippy::all)] #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] -pub mod bevy_reflect; -pub mod bevy_math; -pub mod bevy_input; -pub mod bevy_transform; pub mod bevy_core; -pub mod bevy_hierarchy; pub mod bevy_ecs; +pub mod bevy_hierarchy; +pub mod bevy_input; +pub mod bevy_math; +pub mod bevy_reflect; pub mod bevy_time; +pub mod bevy_transform; pub struct LuaBevyScriptingPlugin; impl ::bevy::app::Plugin for LuaBevyScriptingPlugin { fn build(&self, app: &mut ::bevy::prelude::App) { - bevy_reflect::BevyReflectScriptingPlugin.build(app); - bevy_math::BevyMathScriptingPlugin.build(app); - bevy_input::BevyInputScriptingPlugin.build(app); - bevy_transform::BevyTransformScriptingPlugin.build(app); bevy_core::BevyCoreScriptingPlugin.build(app); - bevy_hierarchy::BevyHierarchyScriptingPlugin.build(app); bevy_ecs::BevyEcsScriptingPlugin.build(app); + bevy_hierarchy::BevyHierarchyScriptingPlugin.build(app); + bevy_input::BevyInputScriptingPlugin.build(app); + bevy_math::BevyMathScriptingPlugin.build(app); + bevy_reflect::BevyReflectScriptingPlugin.build(app); bevy_time::BevyTimeScriptingPlugin.build(app); + bevy_transform::BevyTransformScriptingPlugin.build(app); } } diff --git a/crates/xtask/Cargo.toml b/crates/xtask/Cargo.toml index 3e8b6280..2ce44b72 100644 --- a/crates/xtask/Cargo.toml +++ b/crates/xtask/Cargo.toml @@ -19,3 +19,7 @@ itertools = "0.14" cargo_metadata = "*" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +glob = "0.3" +toml = "0.8" +tera = "1.20" +json_comments = "0.2" diff --git a/crates/xtask/src/main.rs b/crates/xtask/src/main.rs index 7a7c8227..56904acf 100644 --- a/crates/xtask/src/main.rs +++ b/crates/xtask/src/main.rs @@ -1,13 +1,14 @@ -use anyhow::*; +use anyhow::{Context, *}; use clap::Parser; use itertools::Itertools; +use json_comments::StripComments; use log::*; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::{ collections::{HashMap, HashSet}, ffi::{OsStr, OsString}, io::Write, - path::Path, + path::{Path, PathBuf}, process::Command, str::FromStr, }; @@ -234,11 +235,11 @@ impl CiOs { #[derive(Debug, Clone, Parser)] struct App { - #[clap(flatten)] - global_args: GlobalArgs, - #[clap(subcommand)] subcmd: Xtasks, + + #[clap(flatten)] + global_args: GlobalArgs, } impl App { @@ -300,6 +301,16 @@ impl App { Xtasks::CiMatrix => { cmd.arg("ci-matrix"); } + Xtasks::Codegen { + output_dir, + bevy_features, + } => { + cmd.arg("codegen") + .arg("--output-dir") + .arg(output_dir) + .arg("--bevy-features") + .arg(bevy_features.join(",")); + } } cmd @@ -355,6 +366,12 @@ struct GlobalArgs { )] coverage: bool, + #[clap(skip)] + override_workspace_dir: Option, + + #[clap(skip)] + override_toolchain: Option, + #[clap( long, short, @@ -380,6 +397,20 @@ impl GlobalArgs { } } + pub fn with_workspace_dir(self, dir: PathBuf) -> Self { + Self { + override_workspace_dir: Some(dir), + ..self + } + } + + pub fn with_toolchain(self, toolchain: String) -> Self { + Self { + override_toolchain: Some(toolchain), + ..self + } + } + pub fn with_features(self, features: Features) -> Self { Self { features, ..self } } @@ -437,6 +468,10 @@ impl Macro { format!("[{}]", Macro::VARIANTS.join("|")).into() } } +#[derive(Debug, Clone, serde::Serialize)] +struct CodegenTemplateArgs { + self_is_bms_lua: bool, +} #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, clap::Subcommand, strum::AsRefStr)] #[clap( @@ -488,6 +523,22 @@ enum Xtasks { #[clap(long)] no_rust_docs: bool, }, + /// Run code generation + Codegen { + /// output the generated code to the given directory + #[clap( + long, + default_value = "./crates/bevy_mod_scripting_functions/src/bevy_bindings/" + )] + output_dir: PathBuf, + + #[clap( + long, + default_value = "bevy_asset,bevy_animation,bevy_core_pipeline,bevy_ui,bevy_pbr,bevy_render,bevy_text,bevy_sprite,file_watcher,multi_threaded", + help = "The features to enable for the bevy crate" + )] + bevy_features: Vec, + }, /// Build the main workspace, and then run all tests Test { /// Run tests containing the given name only @@ -578,13 +629,18 @@ impl Xtasks { let json = serde_json::to_string_pretty(&rows)?; return Ok(json); } + Xtasks::Codegen { + output_dir, + bevy_features, + } => Self::codegen(app_settings, output_dir, bevy_features), }?; Ok("".into()) } - fn cargo_metadata() -> Result { - let cargo_manifest_path = std::env::var("CARGO_MANIFEST_PATH").unwrap(); + /// Reads the metadata from the main workspace + fn main_workspace_cargo_metadata() -> Result { + let cargo_manifest_path = std::env::var("MAIN_CARGO_MANIFEST_PATH").unwrap(); let mut cmd = cargo_metadata::MetadataCommand::new(); cmd.manifest_path(cargo_manifest_path); @@ -592,14 +648,26 @@ impl Xtasks { Ok(out) } - fn workspace_dir() -> Result { - let metadata = Self::cargo_metadata()?; + fn workspace_dir(app_settings: &GlobalArgs) -> Result { + if let Some(dir) = &app_settings.override_workspace_dir { + return Ok(dir.into()); + } + + let metadata = Self::main_workspace_cargo_metadata()?; let workspace_root = metadata.workspace_root; Ok(workspace_root.into()) } - fn relative_workspace_dir>(dir: P) -> Result { - let workspace_dir = Self::workspace_dir()?; + fn codegen_crate_dir(app_settings: &GlobalArgs) -> Result { + let workspace_dir = Self::workspace_dir(app_settings)?; + Ok(workspace_dir.join("crates").join("bevy_api_gen")) + } + + fn relative_workspace_dir>( + app_settings: &GlobalArgs, + dir: P, + ) -> Result { + let workspace_dir = Self::workspace_dir(app_settings)?; Ok(workspace_dir.join(dir)) } @@ -612,6 +680,7 @@ impl Xtasks { } fn run_system_command>>( + app_settings: &GlobalArgs, command: &str, context: &str, add_args: I, @@ -620,8 +689,8 @@ impl Xtasks { info!("Running system command: {}", command); let working_dir = match dir { - Some(d) => Self::relative_workspace_dir(d)?, - None => Self::workspace_dir()?, + Some(d) => Self::relative_workspace_dir(app_settings, d)?, + None => Self::workspace_dir(app_settings)?, }; let mut cmd = Command::new(command); @@ -660,9 +729,14 @@ impl Xtasks { info!("Running workspace command {coverage_mode}: {command}"); let mut args = vec![]; + + if let Some(ref toolchain) = app_settings.override_toolchain { + args.push(format!("+{}", toolchain)); + } + args.push(command.to_owned()); - if command != "fmt" { + if command != "fmt" && command != "bevy-api-gen" { // fmt doesn't care about features, workspaces or profiles args.push("--workspace".to_owned()); @@ -693,8 +767,8 @@ impl Xtasks { })); let working_dir = match dir { - Some(d) => Self::relative_workspace_dir(d)?, - None => Self::workspace_dir()?, + Some(d) => Self::relative_workspace_dir(app_settings, d)?, + None => Self::workspace_dir(app_settings)?, }; let mut cmd = Command::new("cargo"); @@ -761,34 +835,200 @@ impl Xtasks { Ok(()) } - fn check_codegen_crate(_app_settings: GlobalArgs, _ide_mode: bool) -> Result<()> { + fn check_codegen_crate(app_settings: GlobalArgs, ide_mode: bool) -> Result<()> { + let toolchain = Self::read_rust_toolchain(&Self::codegen_crate_dir(&app_settings)?); + // set the working directory to the codegen crate - // let crates_path = Self::relative_workspace_dir(PathBuf::from("crates"))?; - // let codegen_crate_path = crates_path.join("bevy_api_gen"); - - // let mut clippy_args = vec!["+nightly-2024-12-15", "clippy"]; - // if ide_mode { - // clippy_args.push("--message-format=json"); - // } - // clippy_args.extend(vec!["--all-targets", "--", "-D", "warnings"]); - - // Self::run_system_command( - // "cargo", - // "Failed to run clippy on codegen crate", - // clippy_args, - // Some(&codegen_crate_path), - // )?; + let app_settings = app_settings + .clone() + .with_workspace_dir(Self::codegen_crate_dir(&app_settings)?) + .with_toolchain(toolchain) + .with_features(Features::new(vec![])); // TODO: support features for codegen crate if any + + let mut clippy_args = vec![]; + if ide_mode { + clippy_args.push("--message-format=json"); + } + clippy_args.extend(vec!["--all-targets", "--", "-D", "warnings"]); + + Self::run_workspace_command( + &app_settings, + "clippy", + "Failed to run clippy on codegen crate", + clippy_args, + None, + )?; // TODO: for now do nothing, it's difficult to get rust analyzer to accept the nightly version Ok(()) } + /// reads rust-toolchain.toml file at the given directory and returns the toolchain string + fn read_rust_toolchain(path: &Path) -> String { + let rust_toolchain_path = path.join("rust-toolchain.toml"); + + let rust_toolchain = std::fs::read_to_string(rust_toolchain_path) + .expect("Could not read rust_toolchain.toml"); + + // parse the toml file + let toml: toml::Value = + toml::from_str(&rust_toolchain).expect("Could not parse rust_toolchain.toml"); + + let toolchain = toml + .get("toolchain") + .expect("Could not find toolchain in rust_toolchain.toml"); + let channel = toolchain + .get("channel") + .expect("Could not find channel in rust_toolchain.toml"); + let channel = channel + .as_str() + .expect("Channel in rust_toolchain.toml is not a string"); + + // set the toolchain + channel.to_string() + } + + fn codegen( + app_settings: GlobalArgs, + output_dir: PathBuf, + bevy_features: Vec, + ) -> Result<()> { + let main_workspace_app_settings = app_settings; + let output_dir = Self::relative_workspace_dir(&main_workspace_app_settings, output_dir)?; + let bevy_dir = + Self::relative_workspace_dir(&main_workspace_app_settings, "target/codegen/bevy")?; + let bevy_target_dir = bevy_dir.join("target"); + // clear the bevy target dir if it exists + info!("Clearing bevy target dir: {:?}", bevy_target_dir); + if bevy_target_dir.exists() { + std::fs::remove_dir_all(&bevy_target_dir)?; + } + + let api_gen_dir = Self::codegen_crate_dir(&main_workspace_app_settings)?; + let codegen_app_settings = main_workspace_app_settings + .clone() + .with_workspace_dir(api_gen_dir.clone()); + + let bevy_repo_app_settings = main_workspace_app_settings + .clone() + .with_workspace_dir(bevy_dir.clone()) + .with_toolchain(Self::read_rust_toolchain(&api_gen_dir)); + + // run cargo install + Self::run_system_command( + &codegen_app_settings, + "cargo", + "Failed to install bevy_api_gen", + vec!["install", "--path", "."], + None, + )?; + + let metadata = Self::main_workspace_cargo_metadata()?; + let bevy_version = metadata + .packages + .iter() + .find(|p| p.name == "bevy") + .expect("Could not find bevy package in metadata") + .version + .clone(); + // create directories if they don't already exist + std::fs::create_dir_all(&bevy_dir)?; + std::fs::create_dir_all(&output_dir)?; + + // git clone bevy repo + let _ = Self::run_system_command( + &bevy_repo_app_settings, + "git", + "Failed to clone bevy repo", + vec![ + "clone", + "https://github.com/bevyengine/bevy", + "--branch", + format!("v{}", bevy_version).as_str(), + "--depth", + "1", + ".", + ], + None, + ); + + // fetch the tags + Self::run_system_command( + &bevy_repo_app_settings, + "git", + "Failed to fetch bevy tags", + vec!["fetch", "--tags"], + Some(&bevy_dir), + )?; + + // checkout the version tag + Self::run_system_command( + &bevy_repo_app_settings, + "git", + "Failed to checkout bevy tag", + vec!["checkout", format!("v{}", bevy_version).as_str()], + Some(&bevy_dir), + )?; + + // run bevy_api_gen + let template_args = CodegenTemplateArgs { + self_is_bms_lua: true, + }; + + let template_args = serde_json::to_string(&template_args)?; + let bms_core_path = Self::workspace_dir(&main_workspace_app_settings)? + .join("crates/bevy_mod_scripting_core") + .to_path_buf(); + + Self::run_workspace_command( + &bevy_repo_app_settings, + "bevy-api-gen", + "Failed to run bevy-api-gen generate", + vec![ + "generate", + "--bms-core-path", + bms_core_path.to_str().unwrap(), + "--output", + output_dir.to_str().unwrap(), + "--template-args", + template_args.as_str(), + "--features", + bevy_features.join(",").as_str(), + "-v", + ], + Some(&bevy_dir), + )?; + + // collect + Self::run_workspace_command( + &bevy_repo_app_settings, + "bevy-api-gen", + "Failed to run bevy-api-gen generate", + vec![ + "collect", + "--bms-core-path", + bms_core_path.to_str().unwrap(), + "--output", + output_dir.to_str().unwrap(), + "--template-args", + template_args.as_str(), + "-v", + ], + Some(&bevy_dir), + )?; + + Ok(()) + } + fn check(app_settings: GlobalArgs, ide_mode: bool, kind: CheckKind) -> Result<()> { match kind { CheckKind::All => { - Self::check_main_workspace(app_settings.clone(), ide_mode)?; - Self::check_codegen_crate(app_settings, ide_mode)?; + let err_main = Self::check_main_workspace(app_settings.clone(), ide_mode); + let err_codegen = Self::check_codegen_crate(app_settings.clone(), ide_mode); + + err_main?; + err_codegen?; } CheckKind::Main => { Self::check_main_workspace(app_settings, ide_mode)?; @@ -804,7 +1044,7 @@ impl Xtasks { // find [package.metadata."docs.rs"] key in Cargo.toml if !no_rust_docs { info!("Building rust docs"); - let metadata = Self::cargo_metadata()?; + let metadata = Self::main_workspace_cargo_metadata()?; let package = metadata .packages @@ -860,6 +1100,7 @@ impl Xtasks { let args = if !open { vec!["build"] } else { vec!["serve"] }; Self::run_system_command( + &app_settings, "mdbook", "Failed to build or serve mdbook docs", args, @@ -874,7 +1115,8 @@ impl Xtasks { // std::env::set_var("CARGO_INCREMENTAL", "0"); Self::append_rustflags("-Cinstrument-coverage"); - let target_dir = std::env::var("CARGO_TARGET_DIR").unwrap_or_else(|_| "target".to_owned()); + let target_dir = + std::env::var("MAIN_CARGO_TARGET_DIR").unwrap_or_else(|_| "target".to_owned()); let coverage_dir = std::path::PathBuf::from(target_dir).join("coverage"); let coverage_file = coverage_dir.join("cargo-test-%p-%m.profraw"); @@ -904,6 +1146,7 @@ impl Xtasks { // generate coverage report and lcov file if app_settings.coverage { Self::run_system_command( + &app_settings, "grcov", "Generating html coverage report", vec![ @@ -925,6 +1168,7 @@ impl Xtasks { )?; Self::run_system_command( + &app_settings, "grcov", "Failed to generate coverage report", vec![ @@ -1067,9 +1311,10 @@ impl Xtasks { Ok(()) } - fn init(_app_settings: GlobalArgs) -> Result<()> { + fn init(app_settings: GlobalArgs) -> Result<()> { // install cargo mdbook Self::run_system_command( + &app_settings, "cargo", "Failed to install mdbook", vec!["install", "mdbook"], @@ -1078,35 +1323,138 @@ impl Xtasks { // install grcov Self::run_system_command( + &app_settings, "cargo", "Failed to install grcov", vec!["install", "grcov"], None, )?; - // install llvm-tools and clippy + // install nightly toolchaing for bevy api gen + let toolchain = Self::read_rust_toolchain(&Self::codegen_crate_dir(&app_settings)?); + Self::run_system_command( + &app_settings, + "rustup", + "Failed to install nightly toolchain", + vec!["toolchain", "install", toolchain.as_str()], + None, + )?; + + let rustup_components_args = [ + "component", + "add", + "rust-src", + "rustc-dev", + "clippy", + "llvm-tools-preview", + ]; + + // install components for the stable and nightly toolchains Self::run_system_command( + &app_settings, "rustup", "Failed to install rust components", - vec![ - "component", - "add", - "rust-src", - "rustc-dev", - "clippy", - "llvm-tools-preview", - ], + rustup_components_args, None, )?; + // add components on nightly toolchain + Self::run_system_command( + &app_settings, + "rustup", + "Failed to install nightly components", + rustup_components_args + .iter() + .chain(["--toolchain", toolchain.as_str()].iter()), + Some(Path::new(".")), + )?; + + // create .vscode settings + // read from templates at compile time + let vscode_settings = include_str!("../templates/settings.json.tera"); + let mut tera = tera::Tera::default(); + let mut context = tera::Context::new(); + let workspace_dir = Self::workspace_dir(&app_settings)?; + let json_workspace_dir = serde_json::to_string(&workspace_dir)?; // make sure this works as a json string + context.insert("dir", &json_workspace_dir.trim_matches('\"')); + + let templated_settings = tera.render_str(vscode_settings, &context)?; + let templated_settings_json = Self::read_json_with_comments(templated_settings.as_bytes()) + .with_context(|| "reading templated vscode settings")?; + let vscode_dir = Self::relative_workspace_dir(&app_settings, ".vscode")?; + std::fs::create_dir_all(&vscode_dir)?; + let vscode_settings_path = vscode_dir.join("settings.json"); + + // if the file already exists, merge the settings otherwise create it + info!( + "Merging vscode settings at {:?}. With overrides generated by template.", + vscode_settings_path + ); + if vscode_settings_path.exists() { + let existing_settings = std::fs::read_to_string(&vscode_settings_path)?; + let mut existing_settings = Self::read_json_with_comments(existing_settings.as_bytes()) + .with_context(|| "reading existing vscode settings file")?; + Self::merge_json(templated_settings_json, &mut existing_settings); + let merged_settings = serde_json::to_string_pretty(&existing_settings)?; + std::fs::write(&vscode_settings_path, merged_settings)?; + } else { + std::fs::write(&vscode_settings_path, templated_settings)?; + } + Ok(()) } + + fn read_json_with_comments(bytes: &[u8]) -> Result { + let stripped = StripComments::new(bytes); + let mut reader = serde_json::Deserializer::from_reader(stripped); + let value = serde_json::Value::deserialize(&mut reader) + .with_context(|| format!("deserializing json:\n{}", String::from_utf8_lossy(bytes)))?; + Ok(value) + } + + /// Override the target json file with some overrides. Will replace values if they already exist, or insert them otherwise. + fn merge_json(overrides: serde_json::Value, target: &mut serde_json::Value) { + if let (serde_json::Value::Object(overrides), serde_json::Value::Object(target)) = + (overrides, target) + { + for (key, value) in overrides { + // simply replace + info!("Replacing json key: {} with value: {}", key, value); + target.insert(key.clone(), value.clone()); + } + } else { + warn!("Could not merge json, overrides and target are not objects"); + } + } +} + +/// Because we are likely already runnnig in the context of a cargo invocation, +/// some environment variables may be set that we don't want to inherit. +/// Set them to MAIN_CARGO_ so that we can reference them but so they dont get inherited by further cargo commands +fn pop_cargo_env() -> Result<()> { + let env = std::env::vars().collect::>(); + for (key, value) in env.iter() { + if key.starts_with("CARGO_") { + let new_key = format!("MAIN_{}", key); + std::env::set_var(new_key, value); + std::env::remove_var(key); + } + } + + // unset some other variables + let remove_vars = ["RUSTUP_TOOLCHAIN"]; + for var in remove_vars.iter() { + std::env::remove_var(var); + } + + Ok(()) } fn try_main() -> Result<()> { pretty_env_logger::formatted_builder() .filter_level(LevelFilter::Info) .init(); + pop_cargo_env()?; let args = App::try_parse()?; let out = args.subcmd.run(args.global_args)?; // push any output to stdout @@ -1119,7 +1467,7 @@ fn try_main() -> Result<()> { fn main() { if let Err(e) = try_main() { - eprintln!("{}", e); + eprintln!("{:?}", e); std::process::exit(1); } } diff --git a/crates/xtask/templates/settings.json.tera b/crates/xtask/templates/settings.json.tera index 2d90818a..e7927a91 100644 --- a/crates/xtask/templates/settings.json.tera +++ b/crates/xtask/templates/settings.json.tera @@ -1,31 +1,11 @@ { - "lldb.displayFormat": "auto", - "lldb.showDisassembly": "never", - "lldb.dereferencePointers": true, - "lldb.consoleMode": "commands", - "[rust]": { - "editor.formatOnSave": true, - "editor.formatOnSaveMode": "file", - "editor.defaultFormatter": "rust-lang.rust-analyzer" - }, "rust-analyzer.rustc.source": "discover", "rust-analyzer.linkedProjects": [ - "./crates/bevy_api_gen/Cargo.toml", + "{{ dir }}/crates/bevy_api_gen/Cargo.toml", "Cargo.toml" ], "rust-analyzer.check.invocationStrategy": "per_workspace", - "rust-analyzer.check.invocationLocation": "workspace", "rust-analyzer.check.overrideCommand": [ - "cargo xtask check" - ], - "rust-analyzer.cargo.buildScripts.overrideCommand": [ - "cargo xtask check" - ], - "rust-analyzer.showUnlinkedFileNotification": false, - "rust-analyzer.runnables.extraTestBinaryArgs": [ - "--show-output" - ], - "rust-analyzer.runnables.extraArgs": [ - "--profile=release-with-debug" + "{{ dir }}/check.sh" ] } \ No newline at end of file diff --git a/docs/src/Development/setup.md b/docs/src/Development/setup.md index fffe7856..e777f9c7 100644 --- a/docs/src/Development/setup.md +++ b/docs/src/Development/setup.md @@ -6,27 +6,8 @@ this crate contains a work in progress `xtask` setup which in theory should allo cargo xtask init ``` -However at the moment it does not generate IDE specific files for you, so you will need to do that manually. +This command currently supports the following IDE's -## VScode +- [VSCode](https://code.visualstudio.com/) -For vscode you will want to enter the following into your `settings.json` - -```json -{ - "rust-analyzer.rustc.source": "discover", - "rust-analyzer.linkedProjects": [ - // "./crates/bevy_api_gen/Cargo.toml", uncommenting this is currently not fully supported with xtask + vscode, rust analyzer bugs out a lot sadly - "Cargo.toml", - ], - "rust-analyzer.check.invocationStrategy": "once", - "rust-analyzer.check.overrideCommand": [ - "/absolute-path-to-this-project/bevy_mod_scripting/check.sh" - ], - "rust-analyzer.cargo.buildScripts.overrideCommand": [ - "/absolute-path-to-this-project/bevy_mod_scripting/check.sh" - ], -} -``` - -If you are on windows you might need to create an equivalent `check.exe` to run `cargo xtask check --ide-mode` in the root directory of this workspace. +If you'd like to add support for another IDE, please feel free to open a PR!