diff --git a/.github/instructions/documentation.instructions.md b/.github/instructions/documentation.instructions.md new file mode 100644 index 0000000000..54e8573bc1 --- /dev/null +++ b/.github/instructions/documentation.instructions.md @@ -0,0 +1,95 @@ +--- +applyTo: docs/, **/*.md +--- + +# Documentation Instructions + +The `/docs` folder contain documentation for the project as well as release notes. + +Newer release notes should be added to `/docs/src/ReleaseNotes/`. + +When making changes to the documentation, please ensure that you follow these guidelines: +- Use clear and concise language, focusing on EXAMPLES and practical usage. +- Use these naming conventions: + - Use lowercase letters and hyphens for file names (e.g., `my-documentation-file.md`). + - for migration guides use the format `0.0.1-to-0.0.2.md`. + - for release notes use the format `0.0.1.md`. + + +# Release Notes Instructions + +Release notes should highlight the major highlights of each release, while leaving the breaking changes for migration guides. + +When creating release notes, please follow these guidelines: +- Include links to relevant issues or pull requests when applicable. +- YOU MUST use the following heading structure: + - `# Version - Short Description` + - `## Summary` + - `### ` for each major theme or change + - `### Other Changes` (if applicable) for smaller changes worth mentioning + - `## Migration Guide` (if applicable) providing a link to the detailed migration guide. + + +# Migration Guide Instructions + +When creating migration guides, please follow these guidelines: +- Provide step-by-step instructions for updating projects to the new version. +- Each breaking change should come under a heading related to the change i.e. `### ScriptAsset removed` +- Include code snippets to illustrate changes. +- Use diff format when talking about concrete changes to specific structures or traits. +- Include links to relevant issues or pull requests when applicable. +- Generally each pull request has a migration guide section, which must be taken into account and expanded on when writing relevant migration guides. + + +# Examples + +## Release Notes Example + +```markdown +# 0.15.0 - Asset Handles and Context Policies + +This release focuses on aligning `bevy_mod_scripting` with modern Bevy practices, most notably by switching to `Handle` for script management. This change simplifies the API, removes boilerplate, and makes script handling more idiomatic. + +## Summary + +### Asset-First Workflow +Scripts are now treated as first-class Bevy assets. The old `ScriptId` (which was a string) has been replaced by `AssetId`, and you'll primarily interact with scripts via `Handle`. + +```rust,ignore +// New way +let handle: Handle = asset_server.load("my_script.lua"); +commands.spawn(ScriptComponent(vec![handle])); +``` + +Scripts are now only evaluated when they are attached to a `ScriptComponent` or added to `StaticScripts`, which means you have more control over when and how scripts are executed. + +### Other Changes +- **`Recipients` Enum:** The `Recipients` enum for events has been redesigned to align with the new context policies, offering `AllScripts` and `AllContexts` variants, and removing some variants which don't fit the new model. If you need the old behaviour, you can simply query the ECS first before sending events. +- **API Cleanup:** Several types and traits were removed or simplified, including `ScriptAssetSettings`, `AssetPathToScriptIdMapper`, and `ScriptMetadataStore`, as they are no longer needed with the new asset-based approach. + +## Migration Guide +This release contains significant breaking changes. Please refer to the migration guide for detailed instructions on updating your project. + +- [Migration Guide: 0.14 to 0.15](https://makspll.github.io/bevy_mod_scripting/Migration/0.14-to-0.15.html) + +``` + +## Migration Guide Example + +```markdown +# Migration Guide: to + +## Changes to pre handling callbacks + +This change affects the parameters for the `context_pre_handling_initializers` +```diff +- context_pre_handling_initializers: vec![|script_id, entity, context| { ++ context_pre_handling_initializers: vec![|context_key, context| { +``` +and `context_initializers`: +```diff +- context_initializers: vec![|script_id, context| { ++ context_initializers: vec![|context_key, context| { +``` + +``` diff --git a/.github/instructions/general.instructions.md b/.github/instructions/general.instructions.md new file mode 100644 index 0000000000..85dd7736b9 --- /dev/null +++ b/.github/instructions/general.instructions.md @@ -0,0 +1,40 @@ +--- +applyTo: ** +--- + +# Repository Instructions + +## High-Level Structure + +### Core Components +- **bevy_mod_scripting** - Main workspace crate that re-exports key functionality. +- **bevy_mod_scripting_core** - Core framework with language-agnostic scripting functionality +- **bevy_mod_scripting_asset** - Handles script assets, loading, and language detection +- **bevy_mod_scripting_derive** - Procedural macros for generating bindings +- **bevy_mod_scripting_functions** - Core Bevy function bindings, and plugin managing various binding crates via features. + +### Language Implementations +- **bevy_mod_scripting_lua** - Lua language implementation +- **bevy_mod_scripting_rhai** - Rhai language implementation + +### Binding Crates +- Multiple **bevy_*_bms_bindings** crates (e.g., transform, asset, pbr, etc.) that provide specific Bevy module bindings +- These are automatically generated via the `/codegen` tools, per bevy release + +### Development Tools +- **xtask** - Custom task runner for development workflows +- **codegen** - Code generation tools for generating bindings from Bevy's API +- **docs** - Documentation built with mdbook +- **docs/src/ReleaseNotes** - Release notes and migration guides + +## Key Features + +1. **Script Management** - Loading, hot reloading, and lifecycle management via Bevy's asset system +2. **Flexible Bindings** - Attach bindings to any Reflect-implementing types +3. **Dynamic Systems** - Create ECS systems from scripts that run in parallel +4. **Component Creation** - Register and use components from scripts +5. **Multiple Language Support** - Currently supports Lua and Rhai + + +## Xtask Commands +- `cargo xtask check` - Builds the project and runs clippy diff --git a/assets/lua_to_rhai_test_conversion_prompt.md b/.github/instructions/rhai.instructions.md similarity index 98% rename from assets/lua_to_rhai_test_conversion_prompt.md rename to .github/instructions/rhai.instructions.md index 176e924560..c048e06269 100644 --- a/assets/lua_to_rhai_test_conversion_prompt.md +++ b/.github/instructions/rhai.instructions.md @@ -1,5 +1,6 @@ -// perfect application of AI -// helps proompting LLMs to do good for this project +--- +applyTo: **/.rhai +--- # Convert lua to rhai script Convert the current test to a rhai test. below are examples and instructions on the conversions necessary: diff --git a/Cargo.toml b/Cargo.toml index ce81a4f190..cc9902f9c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,6 +99,8 @@ bevy_mod_scripting_rhai = { workspace = true, optional = true } bevy_mod_scripting_functions = { workspace = true } bevy_mod_scripting_derive = { workspace = true } bevy_mod_scripting_asset = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } +bevy_mod_scripting_display = { workspace = true } [workspace.dependencies] # local crates @@ -112,7 +114,8 @@ ladfile_builder = { path = "crates/ladfile_builder", version = "0.5.1" } bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.15.1", default-features = false } bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.15.1", default-features = false } bevy_mod_scripting_asset = { path = "crates/bevy_mod_scripting_asset", version = "0.15.1", default-features = false } - +bevy_mod_scripting_bindings = { path = "crates/bevy_mod_scripting_bindings", version = "0.15.1", default-features = false } +bevy_mod_scripting_display = { path = "crates/bevy_mod_scripting_display", version = "0.15.1", default-features = false } # bevy bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.15.1" } @@ -190,7 +193,7 @@ itertools = { version = "0.14", default-features = false } fixedbitset = { version = "0.5", default-features = false } variadics_please = { version = "1.1.0", default-features = false } anyhow = { version = "1.0", default-features = false } - +indent_write = { version = "2", default-features = false, features = ["std"] } # development and testing @@ -245,6 +248,8 @@ members = [ "crates/bevy_system_reflection", "crates/bindings/*", "crates/bevy_mod_scripting_asset", + "crates/bevy_mod_scripting_bindings", + "crates/bevy_mod_scripting_display", ] resolver = "2" exclude = ["codegen", "crates/macro_tests", "xtask"] diff --git a/assets/tests/add_system/added_systems_run_in_parallel.lua b/assets/tests/add_system/added_systems_run_in_parallel.lua index 32ac6ee2a6..db2421ea49 100644 --- a/assets/tests/add_system/added_systems_run_in_parallel.lua +++ b/assets/tests/add_system/added_systems_run_in_parallel.lua @@ -26,7 +26,7 @@ digraph { node_1 [label="bevy_asset::assets::Assets::asset_events"]; node_2 [label="bevy_asset::assets::Assets<()>::asset_events"]; node_3 [label="bevy_asset::assets::Assets::asset_events"]; - node_4 [label="bevy_mod_scripting_core::bindings::allocator::garbage_collector"]; + node_4 [label="bevy_mod_scripting_bindings::allocator::garbage_collector"]; node_5 [label="script_integration_test_harness::dummy_before_post_update_system"]; node_6 [label="script_integration_test_harness::dummy_post_update_system"]; node_7 [label="on_test_post_update"]; diff --git a/assets/tests/add_system/added_systems_run_in_parallel.rhai b/assets/tests/add_system/added_systems_run_in_parallel.rhai index cad12e36f5..c080633633 100644 --- a/assets/tests/add_system/added_systems_run_in_parallel.rhai +++ b/assets/tests/add_system/added_systems_run_in_parallel.rhai @@ -25,7 +25,7 @@ digraph { node_1 [label="bevy_asset::assets::Assets::asset_events"]; node_2 [label="bevy_asset::assets::Assets<()>::asset_events"]; node_3 [label="bevy_asset::assets::Assets::asset_events"]; - node_4 [label="bevy_mod_scripting_core::bindings::allocator::garbage_collector"]; + node_4 [label="bevy_mod_scripting_bindings::allocator::garbage_collector"]; node_5 [label="script_integration_test_harness::dummy_before_post_update_system"]; node_6 [label="script_integration_test_harness::dummy_post_update_system"]; node_7 [label="on_test_post_update"]; diff --git a/assets/tests/construct/construct_tuple_struct.lua b/assets/tests/construct/construct_tuple_struct.lua index 06cc2f2550..060c90311f 100644 --- a/assets/tests/construct/construct_tuple_struct.lua +++ b/assets/tests/construct/construct_tuple_struct.lua @@ -3,6 +3,5 @@ local constructed = construct(type, { _1 = 123 }) -print(constructed:display_value()) - -assert(constructed._1 == 123, "Value was constructed incorrectly, expected constructed.foo to be 123 but got " .. constructed._1) \ No newline at end of file +assert(constructed._1 == 123, + "Value was constructed incorrectly, expected constructed.foo to be 123 but got " .. constructed._1) diff --git a/assets/tests/display/print_value_by_default.lua b/assets/tests/display/print_value_by_default.lua new file mode 100644 index 0000000000..eb78ddcc00 --- /dev/null +++ b/assets/tests/display/print_value_by_default.lua @@ -0,0 +1,71 @@ +local vec = Vec3.new(1, 2, 3) + +assert(vec:display() == "Vec3 { x: 1.0, y: 2.0, z: 3.0 }", + "Vec3 display incorrect, expected Vec3 { x: 1.0, y: 2.0, z: 3.0 } but got " .. vec:display()) + + +-- multiline +local function strip_alloc_ids(s) + s = s:gsub("ReflectAllocationId%b()", "ReflectAllocationId()") + return s +end + +local expected_vec3_debug = [[ + ReflectReference { + base: ReflectBaseType { + type_id: TypeId( + "glam::Vec3", + ), + base_id: Owned( + ReflectAllocationId(*anything*), + ), + }, + reflect_path: ParsedPath( + [], + ), +} +]] +-- normalize allocation ids before comparison so tests don't fail on runtime-generated ids +do + local actual = vec:debug() + local expected = expected_vec3_debug + actual = strip_alloc_ids(actual) + expected = strip_alloc_ids(expected) + assert_str_eq(actual, expected) +end + + +local test_resource = world.get_resource(types.TestResource) + +local expected_test_resource_debug = [[ +ReflectReference { + base: ReflectBaseType { + type_id: TypeId( + "test_utils::test_data::TestResource", + ), + base_id: Resource( + ComponentId( + "test_utils::test_data::TestResource", + ), + ), + }, + reflect_path: ParsedPath( + [], + ), +} +]] + +-- normalize allocation ids before comparison so tests don't fail on runtime-generated ids +do + local actual = test_resource:debug() + local expected = expected_test_resource_debug + actual = strip_alloc_ids(actual) + expected = strip_alloc_ids(expected) + assert_str_eq(actual, expected, + "TestResource debug incorrect, expected " .. expected .. " but got " .. actual) +end + + +assert_str_eq(test_resource:display(), "TestResource { bytes: [0, 1, 2, 3, 4, 5] }", + "TestResource display incorrect, expected TestResource { bytes: [0, 1, 2, 3, 4, 5] } but got " .. + test_resource:display()) diff --git a/assets/tests/functions/contains_reflect_reference_functions.lua b/assets/tests/functions/contains_reflect_reference_functions.lua index 73554fd73c..db4a02918b 100644 --- a/assets/tests/functions/contains_reflect_reference_functions.lua +++ b/assets/tests/functions/contains_reflect_reference_functions.lua @@ -19,4 +19,5 @@ for _, function_ref in pairs(functions) do table.insert(available_names, function_ref.name) end -assert(contains(available_names, "display_ref"), "functions should contain display_ref, but got: " .. table.concat(available_names, ", ")) \ No newline at end of file +assert(contains(available_names, "display"), + "functions should contain display, but got: " .. table.concat(available_names, ", ")) diff --git a/assets/tests/functions/contains_reflect_reference_functions.rhai b/assets/tests/functions/contains_reflect_reference_functions.rhai index f83b980c99..76fd76778e 100644 --- a/assets/tests/functions/contains_reflect_reference_functions.rhai +++ b/assets/tests/functions/contains_reflect_reference_functions.rhai @@ -11,4 +11,4 @@ for function_ref in functions { available_names.push(function_ref.name); } -assert("display_ref" in available_names, "functions should contain display_ref, but got: " + available_names); \ No newline at end of file +assert("display" in available_names, "functions should contain display, but got: " + available_names); \ No newline at end of file diff --git a/assets/tests/get_type_by_name/registered_component_returns_correct_type.lua b/assets/tests/get_type_by_name/registered_component_returns_correct_type.lua index fe71b07b83..b9afd53c72 100644 --- a/assets/tests/get_type_by_name/registered_component_returns_correct_type.lua +++ b/assets/tests/get_type_by_name/registered_component_returns_correct_type.lua @@ -11,9 +11,12 @@ local received = { } assert(type ~= nil, 'Type not found') -assert(received.type_name == expected.type_name, 'type_name mismatch, expected: ' .. expected.type_name .. ', got: ' .. received.type_name) -assert(received.short_name == expected.short_name, 'short_name mismatch, expected: ' .. expected.short_name .. ', got: ' .. received.short_name) +assert(received.type_name == expected.type_name, + 'type_name mismatch, expected: ' .. expected.type_name .. ', got: ' .. received.type_name) +assert(received.short_name == expected.short_name, + 'short_name mismatch, expected: ' .. expected.short_name .. ', got: ' .. received.short_name) -local type_ref = type:display_ref() +local type_ref = type:display() -- check contains ScriptComponentRegistration -assert(string.find(type_ref, "ScriptComponentRegistration") ~= nil, "ScriptComponentRegistration not found in type_ref. got: " .. type_ref) \ No newline at end of file +assert(string.find(type_ref, "ScriptComponentRegistration") ~= nil, + "ScriptComponentRegistration not found in type_ref. got: " .. type_ref) diff --git a/assets/tests/get_type_by_name/registered_resource_returns_correct_type.lua b/assets/tests/get_type_by_name/registered_resource_returns_correct_type.lua index d3bcf46d36..47318fe33a 100644 --- a/assets/tests/get_type_by_name/registered_resource_returns_correct_type.lua +++ b/assets/tests/get_type_by_name/registered_resource_returns_correct_type.lua @@ -11,8 +11,11 @@ local received = { } assert(type ~= nil, 'Type not found') -assert(received.type_name == expected.type_name, 'type_name mismatch, expected: ' .. expected.type_name .. ', got: ' .. received.type_name) -assert(received.short_name == expected.short_name, 'short_name mismatch, expected: ' .. expected.short_name .. ', got: ' .. received.short_name) -local type_ref = type:display_ref() +assert(received.type_name == expected.type_name, + 'type_name mismatch, expected: ' .. expected.type_name .. ', got: ' .. received.type_name) +assert(received.short_name == expected.short_name, + 'short_name mismatch, expected: ' .. expected.short_name .. ', got: ' .. received.short_name) +local type_ref = type:display() -- check contains ScriptResourceRegistration -assert(string.find(type_ref, "ScriptResourceRegistration") ~= nil, "ScriptResourceRegistration not found in type_ref. got: " .. type_ref) \ No newline at end of file +assert(string.find(type_ref, "ScriptResourceRegistration") ~= nil, + "ScriptResourceRegistration not found in type_ref. got: " .. type_ref) diff --git a/assets/tests/remove_resource/no_resource_data_errors.lua b/assets/tests/remove_resource/no_resource_data_errors.lua index 0b5a4a3923..3753d4d169 100644 --- a/assets/tests/remove_resource/no_resource_data_errors.lua +++ b/assets/tests/remove_resource/no_resource_data_errors.lua @@ -1,6 +1,5 @@ - local type = world._get_mock_resource_type() -assert_throws(function () +assert_throws(function() world.remove_resource(type) -end, "Missing type data ReflectResource for type: Unregistered.TypeId.*") +end, "Missing type data ReflectResource for type: Unregistered Type.*") diff --git a/assets/tests/remove_resource/no_resource_data_errors.rhai b/assets/tests/remove_resource/no_resource_data_errors.rhai index c69d9dc6d6..12078a27a1 100644 --- a/assets/tests/remove_resource/no_resource_data_errors.rhai +++ b/assets/tests/remove_resource/no_resource_data_errors.rhai @@ -3,4 +3,4 @@ let type = world._get_mock_resource_type.call(); assert_throws(||{ world.remove_resource.call(type) -}, "Missing type data ReflectResource for type: Unregistered.TypeId.*"); +}, "Missing type data ReflectResource for type: Unregistered Type.*"); diff --git a/benches/benchmarks.rs b/benches/benchmarks.rs index e4e90436b0..4440f67f81 100644 --- a/benches/benchmarks.rs +++ b/benches/benchmarks.rs @@ -10,7 +10,7 @@ use bevy::{ }, reflect::Reflect, }; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ FromScript, IntoScript, Mut, Ref, ReflectReference, ScriptValue, Val, }; use criterion::{ diff --git a/codegen/Cargo.bootstrap.toml b/codegen/Cargo.bootstrap.toml index 6885d4c344..90374660ef 100644 --- a/codegen/Cargo.bootstrap.toml +++ b/codegen/Cargo.bootstrap.toml @@ -5,7 +5,7 @@ version = "0.1.0" edition = "2024" [dependencies] -bevy_mod_scripting_core = { path = "{{BMS_CORE_PATH}}" } +bevy_mod_scripting_bindings = { path = "{{BMS_BINDINGS_PATH}}" } bevy_reflect = { version = "0.16.0", features = [ "smol_str", "glam", diff --git a/codegen/src/args.rs b/codegen/src/args.rs index 637d1ae2fb..9380af33f4 100644 --- a/codegen/src/args.rs +++ b/codegen/src/args.rs @@ -60,9 +60,9 @@ pub struct Args { #[arg(global = true, long)] pub template_args: Option, - /// The path to the bevy_mod_scripting_core crate, used to bootstrap necessary traits + /// The path to the bevy_mod_scripting_bindings crate, used to bootstrap necessary traits #[arg(global = true, long, default_value = ".")] - pub bms_core_path: Utf8PathBuf, + pub bms_bindings_path: Utf8PathBuf, /// Crates to exclude from code generation #[arg( diff --git a/codegen/src/bin/main.rs b/codegen/src/bin/main.rs index 11a4fc1ed0..9481a18d0b 100644 --- a/codegen/src/bin/main.rs +++ b/codegen/src/bin/main.rs @@ -16,7 +16,7 @@ use log::{debug, error, info}; use strum::VariantNames; use tera::Context; -const BOOTSTRAP_DEPS: [&str; 2] = ["bevy_reflect", "bevy_mod_scripting_core"]; +const BOOTSTRAP_DEPS: [&str; 2] = ["bevy_reflect", "bevy_mod_scripting_bindings"]; fn main() { // parse this here to early exit on wrong args @@ -176,7 +176,7 @@ fn main() { debug!("Bootstrap directory: {}", &temp_dir.as_path().display()); - write_bootstrap_files(args.bms_core_path, temp_dir.as_path()); + write_bootstrap_files(args.bms_bindings_path, temp_dir.as_path()); let bootstrap_rlibs = build_bootstrap(temp_dir.as_path(), &plugin_target_dir.join("bootstrap")); @@ -200,7 +200,7 @@ fn main() { ) }; } else { - panic!("Could not find 'libmlua' artifact among bootstrap crate artifacts, stopping."); + panic!("Could not find all bootstrap rlibs, found: {bootstrap_rlibs:?}"); } debug!("Running bevy_api_gen main cargo command"); @@ -355,15 +355,16 @@ fn find_bootstrap_dir() -> PathBuf { } /// Generate bootstrapping crate files -fn write_bootstrap_files(bms_core_path: Utf8PathBuf, path: &Path) { - const BMS_CORE_PATH_PLACEHOLDER: &str = "{{BMS_CORE_PATH}}"; +fn write_bootstrap_files(bms_bindings_path: Utf8PathBuf, path: &Path) { + const BMS_BINDINGS_PATH_PLACEHOLDER: &str = "{{BMS_BINDINGS_PATH}}"; // write manifest file 'Cargo.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()); + manifest_content = + manifest_content.replace(BMS_BINDINGS_PATH_PLACEHOLDER, bms_bindings_path.as_str()); let manifest_path = path.join("Cargo.toml"); diff --git a/codegen/src/context.rs b/codegen/src/context.rs index bdc893f67d..6120402b31 100644 --- a/codegen/src/context.rs +++ b/codegen/src/context.rs @@ -86,14 +86,10 @@ impl ReflectType<'_> { } } -pub(crate) const DEF_PATHS_BMS_FROM_SCRIPT: [&str; 2] = [ - "bevy_mod_scripting_core::bindings::FromScript", - "bindings::FromScript", -]; -pub(crate) const DEF_PATHS_BMS_INTO_SCRIPT: [&str; 2] = [ - "bevy_mod_scripting_core::bindings::IntoScript", - "bindings::IntoScript", -]; +pub(crate) const DEF_PATHS_BMS_FROM_SCRIPT: [&str; 2] = + ["bevy_mod_scripting_bindings::FromScript", "FromScript"]; +pub(crate) const DEF_PATHS_BMS_INTO_SCRIPT: [&str; 2] = + ["bevy_mod_scripting_bindings::IntoScript", "IntoScript"]; pub(crate) const DEF_PATHS_REFLECT: [&str; 2] = ["bevy_reflect::PartialReflect", "reflect::PartialReflect"]; diff --git a/codegen/src/modifying_file_loader.rs b/codegen/src/modifying_file_loader.rs index 3c720f8866..07f2075fbe 100644 --- a/codegen/src/modifying_file_loader.rs +++ b/codegen/src/modifying_file_loader.rs @@ -29,7 +29,7 @@ impl FileLoader for ModifyingFileLoader { // we make it pub so in case we are re-exporting this crate we won't run into private re-export issues for (crate_, excluded_files) in &[ ("bevy_reflect", vec!["crates/bevy_reflect/src/lib.rs"]), - ("bevy_mod_scripting_core", vec![]), + ("bevy_mod_scripting_bindings", vec![]), ] { if !f.contains(&format!("extern crate {crate_}")) && !excluded_files diff --git a/codegen/src/template.rs b/codegen/src/template.rs index 3b4a54ffa8..e271c90450 100644 --- a/codegen/src/template.rs +++ b/codegen/src/template.rs @@ -25,9 +25,6 @@ pub static TEMPLATE_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/templates"); Deserialize, )] pub enum TemplateKind { - // Note: order here matters, macros need to be loaded first as they are used in other templates - #[strum(to_string = "macros.tera")] - Macros, #[strum(to_string = "mod.tera")] SharedModule, #[strum(to_string = "crate.tera")] diff --git a/codegen/templates/footer.tera b/codegen/templates/footer.tera index eb3380773f..a9d37435e7 100644 --- a/codegen/templates/footer.tera +++ b/codegen/templates/footer.tera @@ -11,7 +11,7 @@ pub struct {{ "ScriptingPlugin" | prefix_cratename | convert_case(case="upper_ca #[script_bindings( remote, name = "{{ item.ident | convert_case(case="snake") }}_functions", - bms_core_path="bevy_mod_scripting_core", + bms_bindings_path="bevy_mod_scripting_bindings", generated )] impl {{item.import_path}} { diff --git a/codegen/templates/header.tera b/codegen/templates/header.tera index 74cce3c55b..e5fbb05c0a 100644 --- a/codegen/templates/header.tera +++ b/codegen/templates/header.tera @@ -2,11 +2,9 @@ #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] -use bevy_mod_scripting_core::{ - bindings::{ - ReflectReference, - function::{from::{Ref, Mut, Val}, namespace::{NamespaceBuilder}} - } +use bevy_mod_scripting_bindings::{ + ReflectReference, + function::{from::{Ref, Mut, Val}, namespace::{NamespaceBuilder}} }; use bevy_ecs::{prelude::*}; use bevy_app::{App, Plugin}; diff --git a/codegen/templates/macros.tera b/codegen/templates/macros.tera deleted file mode 100644 index 561dee898f..0000000000 --- a/codegen/templates/macros.tera +++ /dev/null @@ -1,46 +0,0 @@ -{% macro vector_index(num_type) %} -#[lua(metamethod="Index")] -fn index(self, idx: usize) -> LuaIdentityProxy<{{ num_type }}> { - _self[idx - 1] -} -{% endmacro vector_index %} - -{% macro vector_newindex(num_type) %} -#[lua(metamethod="NewIndex")] -fn index(&mut self, idx: usize, val: {{ num_type }}) -> () { - _self[idx - 1] = val -} -{% endmacro vector_newindex %} - -{% macro matrix_index(col_type, mat_type, bms_core_path) %} -#[lua(metamethod="Index", with_context, no_proxy)] -fn index(_self: Self, idx: usize, lua: &tealr::mlu::mlua::Lua) -> Result { - let mut curr_ref = _self.0; - - let path = match idx { - 1 => "x_axis", - 2 => "y_axis", - 3 => "z_axis", - 4 => "w_axis", - _ => "unknown_axis" - }; - - let parsed_path = ::bevy_reflect::ParsedPath::parse_static(path).expect("invariant"); - curr_ref.index_path(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_reflection(parsed_path)); - crate::bindings::reference::LuaReflectReference(curr_ref).to_lua_proxy(lua) -} -{% endmacro matrix_index %} - -{% macro debug_as_to_string() %} -#[lua(metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -{% endmacro debug_as_to_string %} - -{% macro display_as_to_string() %} -#[lua(metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -{% endmacro debug_as_to_string %} \ No newline at end of file diff --git a/crates/bevy_mod_scripting_bindings/Cargo.toml b/crates/bevy_mod_scripting_bindings/Cargo.toml new file mode 100644 index 0000000000..a51a4eeb95 --- /dev/null +++ b/crates/bevy_mod_scripting_bindings/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "bevy_mod_scripting_bindings" +version = "0.15.1" +authors = ["Maksymilian Mozolewski "] +edition = "2024" +license = "MIT OR Apache-2.0" +description = "Core traits and structures required for other parts of bevy_mod_scripting" +repository = "https://github.com/makspll/bevy_mod_scripting" +homepage = "https://github.com/makspll/bevy_mod_scripting" +categories = ["game-development"] +readme = "readme.md" + + +[dependencies] +bevy_mod_scripting_asset = { workspace = true } +bevy_mod_scripting_derive = { workspace = true } +bevy_mod_scripting_display = { workspace = true } +bevy_system_reflection = { workspace = true } +bevy_diagnostic = { workspace = true } +bevy_ecs = { workspace = true } +bevy_reflect = { workspace = true } +bevy_log = { workspace = true } +bevy_app = { workspace = true } +bevy_platform = { workspace = true } +parking_lot = { workspace = true } +smallvec = { workspace = true } +itertools = { workspace = true } +profiling = { workspace = true } +bevy_asset = { workspace = true } +variadics_please = { workspace = true } + +[dev-dependencies] +pretty_assertions = { workspace = true } +test_utils = { workspace = true } + +[lints] +workspace = true diff --git a/crates/bevy_mod_scripting_core/src/bindings/access_map.rs b/crates/bevy_mod_scripting_bindings/src/access_map.rs similarity index 94% rename from crates/bevy_mod_scripting_core/src/bindings/access_map.rs rename to crates/bevy_mod_scripting_bindings/src/access_map.rs index 41afa96c21..f43b88f6a6 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/access_map.rs +++ b/crates/bevy_mod_scripting_bindings/src/access_map.rs @@ -1,5 +1,7 @@ //! A map of access claims used to safely and dynamically access the world. +use bevy_mod_scripting_derive::DebugWithTypeInfo; +use bevy_mod_scripting_display::{DisplayWithTypeInfo, GetTypeInfo, WithTypeInfo}; use bevy_platform::collections::{HashMap, HashSet}; use ::bevy_ecs::{component::ComponentId, world::unsafe_world_cell::UnsafeWorldCell}; @@ -83,7 +85,8 @@ impl AccessMapKey for u64 { } /// Describes kinds of base value we are accessing via reflection -#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] +#[derive(PartialEq, Eq, Copy, Clone, Hash, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub enum ReflectAccessKind { /// Accessing a component or resource ComponentOrResource, @@ -95,12 +98,37 @@ pub enum ReflectAccessKind { /// Describes the id pointing to the base value we are accessing via reflection, for components and resources this is the ComponentId /// for script owned values this is an allocationId, this is used to ensure we have permission to access the value. -#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] +#[derive(PartialEq, Eq, Copy, Clone, Hash, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub struct ReflectAccessId { pub(crate) kind: ReflectAccessKind, pub(crate) id: u64, } +impl DisplayWithTypeInfo for ReflectAccessId { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + match self.kind { + ReflectAccessKind::ComponentOrResource => { + write!( + f, + "Component or resource: {}", + WithTypeInfo(&ComponentId::new(self.id as usize)) + ) + } + ReflectAccessKind::Allocation => write!( + f, + "Allocation to: {}", + WithTypeInfo(&ReflectAllocationId::new(self.id)) + ), + ReflectAccessKind::Global => write!(f, "World(Global)"), + } + } +} + #[profiling::all_functions] impl AccessMapKey for ReflectAccessId { fn as_index(&self) -> u64 { @@ -761,15 +789,15 @@ impl DisplayCodeLocation for Option> { /// A macro for claiming access to a value for reading macro_rules! with_access_read { ($access_map:expr, $id:expr, $msg:expr, $body:block) => {{ - if !$crate::bindings::access_map::DynamicSystemMeta::claim_read_access($access_map, $id) { + if !$crate::access_map::DynamicSystemMeta::claim_read_access($access_map, $id) { Err($crate::error::InteropError::cannot_claim_access( $id, - $crate::bindings::access_map::DynamicSystemMeta::access_location($access_map, $id), + $crate::access_map::DynamicSystemMeta::access_location($access_map, $id), $msg, )) } else { let result = $body; - $crate::bindings::access_map::DynamicSystemMeta::release_access($access_map, $id); + $crate::access_map::DynamicSystemMeta::release_access($access_map, $id); Ok(result) } }}; @@ -779,15 +807,15 @@ pub(crate) use with_access_read; /// A macro for claiming access to a value for writing macro_rules! with_access_write { ($access_map:expr, $id:expr, $msg:expr, $body:block) => { - if !$crate::bindings::access_map::DynamicSystemMeta::claim_write_access($access_map, $id) { + if !$crate::access_map::DynamicSystemMeta::claim_write_access($access_map, $id) { Err($crate::error::InteropError::cannot_claim_access( $id, - $crate::bindings::access_map::DynamicSystemMeta::access_location($access_map, $id), + $crate::access_map::DynamicSystemMeta::access_location($access_map, $id), $msg, )) } else { let result = $body; - $crate::bindings::access_map::DynamicSystemMeta::release_access($access_map, $id); + $crate::access_map::DynamicSystemMeta::release_access($access_map, $id); Ok(result) } }; @@ -797,19 +825,19 @@ pub(crate) use with_access_write; /// A macro for claiming global access macro_rules! with_global_access { ($access_map:expr, $msg:expr, $body:block) => { - if !$crate::bindings::access_map::DynamicSystemMeta::claim_global_access($access_map) { + if !$crate::access_map::DynamicSystemMeta::claim_global_access($access_map) { Err($crate::error::InteropError::cannot_claim_access( - $crate::bindings::access_map::ReflectAccessId::for_global(), - $crate::bindings::access_map::DynamicSystemMeta::access_location( + $crate::access_map::ReflectAccessId::for_global(), + $crate::access_map::DynamicSystemMeta::access_location( $access_map, - $crate::bindings::access_map::ReflectAccessId::for_global(), + $crate::access_map::ReflectAccessId::for_global(), ), $msg, )) } else { #[allow(clippy::redundant_closure_call)] let result = (|| $body)(); - $crate::bindings::access_map::DynamicSystemMeta::release_global_access($access_map); + $crate::access_map::DynamicSystemMeta::release_global_access($access_map); Ok(result) } }; diff --git a/crates/bevy_mod_scripting_core/src/bindings/allocator.rs b/crates/bevy_mod_scripting_bindings/src/allocator.rs similarity index 89% rename from crates/bevy_mod_scripting_core/src/bindings/allocator.rs rename to crates/bevy_mod_scripting_bindings/src/allocator.rs index efe9f8ca2a..8dcc163b0c 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/allocator.rs +++ b/crates/bevy_mod_scripting_bindings/src/allocator.rs @@ -7,6 +7,10 @@ use ::{ bevy_reflect::PartialReflect, }; use bevy_ecs::{resource::Resource, system::ResMut}; +use bevy_mod_scripting_derive::DebugWithTypeInfo; +use bevy_mod_scripting_display::{ + DebugWithTypeInfo, DebugWithTypeInfoBuilder, DisplayWithTypeInfo, +}; use bevy_platform::collections::HashMap; use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard}; use std::{ @@ -25,9 +29,21 @@ pub const ALLOCATOR_TOTAL_DIAG_PATH: DiagnosticPath = pub const ALLOCATOR_TOTAL_COLLECTED_DIAG_PATH: DiagnosticPath = DiagnosticPath::const_new("scripting_allocator_total_collected"); -#[derive(Clone, Debug)] /// Unique identifier for an allocation +#[derive(Clone, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub struct ReflectAllocationId(pub(crate) Arc); + +impl DisplayWithTypeInfo for ReflectAllocationId { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn bevy_mod_scripting_display::GetTypeInfo>, + ) -> std::fmt::Result { + write!(f, "{}", self.id()) + } +} + impl ReflectAllocationId { /// Returns the id of the allocation pub fn id(&self) -> u64 { @@ -94,12 +110,23 @@ impl Drop for OwningPtr { } } } - // yikes, the indirection. I need this to store boxed values too though -#[derive(Debug)] + /// A boxed [`PartialReflect`] value pub struct ReflectAllocation(Box>); +impl DebugWithTypeInfo for ReflectAllocation { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn bevy_mod_scripting_display::GetTypeInfo>, + ) -> std::fmt::Result { + f.debug_tuple_with_type_info("ReflectAllocation") + .field(&((self.0.get() as *mut ()) as usize)) + .finish() + } +} + // unsafe impl Send for ReflectAllocation {} unsafe impl Sync for ReflectAllocation {} @@ -131,7 +158,8 @@ impl Display for ReflectAllocationId { } /// Wrapper around a [`ReflectAllocator`] which can be freely copied and shared between threads -#[derive(Debug, Resource, Clone)] +#[derive(Resource, Clone, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub struct AppReflectAllocator { pub(crate) allocator: Arc>, } @@ -158,7 +186,8 @@ impl AppReflectAllocator { /// Allocator used to allocate and deallocate `dyn PartialReflect` values /// Used to be able to ensure we have a "common root" for values allocated outside the world. -#[derive(Default, Debug)] +#[derive(Default, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub struct ReflectAllocator { // TODO: experiment with object pools, sparse set etc. allocations: HashMap, diff --git a/crates/bevy_mod_scripting_core/src/docgen/info.rs b/crates/bevy_mod_scripting_bindings/src/docgen/info.rs similarity index 85% rename from crates/bevy_mod_scripting_core/src/docgen/info.rs rename to crates/bevy_mod_scripting_bindings/src/docgen/info.rs index c8601fb0cf..fa83a7344f 100644 --- a/crates/bevy_mod_scripting_core/src/docgen/info.rs +++ b/crates/bevy_mod_scripting_bindings/src/docgen/info.rs @@ -1,7 +1,9 @@ //! Information about functions and their arguments. -use crate::bindings::function::arg_meta::ArgMeta; -use crate::bindings::function::namespace::Namespace; +use crate::function::arg_meta::ArgMeta; +use crate::function::namespace::Namespace; +use bevy_mod_scripting_derive::DebugWithTypeInfo; +use bevy_mod_scripting_display::{DisplayWithTypeInfo, GetTypeInfo, WithTypeInfo}; use bevy_reflect::Reflect; use std::{any::TypeId, borrow::Cow}; @@ -13,7 +15,8 @@ pub trait GetFunctionInfo { fn get_function_info(&self, name: Cow<'static, str>, namespace: Namespace) -> FunctionInfo; } -#[derive(Debug, Clone, Reflect)] +#[derive(Clone, Reflect, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] /// Information about a function. pub struct FunctionInfo { /// The name of the function. @@ -107,7 +110,8 @@ impl FunctionInfo { } } -#[derive(Debug, Clone, Reflect)] +#[derive(Clone, Reflect, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] /// Information about a function argument. pub struct FunctionArgInfo { /// The name of the argument. @@ -121,6 +125,21 @@ pub struct FunctionArgInfo { pub type_info: Option, } +impl DisplayWithTypeInfo for FunctionArgInfo { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + if let Some(name) = &self.name { + write!(f, "{name}: ")?; + } + let type_id = self.type_id; + WithTypeInfo(&type_id).display_with_type_info(f, type_info_provider)?; + Ok(()) + } +} + #[profiling::all_functions] impl FunctionArgInfo { /// Create a new function argument info with a name. @@ -143,7 +162,8 @@ impl FunctionArgInfo { } } -#[derive(Debug, Clone, Reflect)] +#[derive(Clone, Reflect, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] /// Information about a function return value. pub struct FunctionReturnInfo { /// The type of the return value. @@ -159,6 +179,18 @@ impl Default for FunctionReturnInfo { } } +impl DisplayWithTypeInfo for FunctionReturnInfo { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + let type_id = self.type_id; + WithTypeInfo(&type_id).display_with_type_info(f, type_info_provider)?; + Ok(()) + } +} + #[profiling::all_functions] impl FunctionReturnInfo { /// Create a new function return info for a specific type. @@ -196,8 +228,8 @@ variadics_please::all_tuples!(impl_documentable, 0, 13, T); #[cfg(test)] mod test { use crate::{ - bindings::function::from::{Mut, Ref, Val}, docgen::typed_through::UntypedWrapperKind, + function::from::{Mut, Ref, Val}, }; use super::*; diff --git a/crates/bevy_mod_scripting_bindings/src/docgen/mod.rs b/crates/bevy_mod_scripting_bindings/src/docgen/mod.rs new file mode 100644 index 0000000000..8dbe780ef5 --- /dev/null +++ b/crates/bevy_mod_scripting_bindings/src/docgen/mod.rs @@ -0,0 +1,6 @@ +//! Documentation generation for scripting languages. + +pub mod info; +pub mod typed_through; + +pub use {info::*, typed_through::*}; diff --git a/crates/bevy_mod_scripting_core/src/docgen/typed_through.rs b/crates/bevy_mod_scripting_bindings/src/docgen/typed_through.rs similarity index 95% rename from crates/bevy_mod_scripting_core/src/docgen/typed_through.rs rename to crates/bevy_mod_scripting_bindings/src/docgen/typed_through.rs index 995eae56cd..b56bc2b5f1 100644 --- a/crates/bevy_mod_scripting_core/src/docgen/typed_through.rs +++ b/crates/bevy_mod_scripting_bindings/src/docgen/typed_through.rs @@ -3,23 +3,19 @@ use std::{ffi::OsString, path::PathBuf}; +use bevy_mod_scripting_derive::DebugWithTypeInfo; use bevy_platform::collections::HashMap; use bevy_reflect::{TypeInfo, Typed}; use crate::{ - bindings::{ - ReflectReference, - function::{ - from::{Mut, Ref, Union, Val}, - script_function::{ - DynamicScriptFunction, DynamicScriptFunctionMut, FunctionCallContext, - }, - }, - script_value::ScriptValue, + ReflectReference, + function::{ + from::{Mut, Ref, Union, Val}, + script_function::{DynamicScriptFunction, DynamicScriptFunctionMut, FunctionCallContext}, }, - error::InteropError, - reflection_extensions::TypeInfoExtensions, + script_value::ScriptValue, }; +use crate::{error::InteropError, reflection_extensions::TypeInfoExtensions}; /// All Through types follow one rule: /// - A through type can not contain a nested through type. It must always contain a fully typed inner type. @@ -30,7 +26,8 @@ use crate::{ /// i.e. `Ref`, `Mut` and `Val` wrappers are `leaf` types, and can not contain other `leaf` types. /// /// This is to keep the implementations of this trait simple, and to ultimately depend on the `TypeInfo` trait for the actual type information. -#[derive(Debug, Clone)] +#[derive(Clone, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub enum ThroughTypeInfo { /// A wrapper around a typed type, which itself is not a `Typed` type. UntypedWrapper { @@ -45,7 +42,8 @@ pub enum ThroughTypeInfo { TypeInfo(&'static TypeInfo), } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, PartialEq, Eq, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] /// The kind of untyped wrapper. pub enum UntypedWrapperKind { /// A reference wrapper. @@ -57,7 +55,8 @@ pub enum UntypedWrapperKind { } /// The kind of typed wrapper. -#[derive(Debug, Clone)] +#[derive(Clone, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub enum TypedWrapperKind { /// A union of many possible types Union(Vec), diff --git a/crates/bevy_mod_scripting_bindings/src/error.rs b/crates/bevy_mod_scripting_bindings/src/error.rs new file mode 100644 index 0000000000..99ef6a8361 --- /dev/null +++ b/crates/bevy_mod_scripting_bindings/src/error.rs @@ -0,0 +1,625 @@ +//! Error types for the bindings +use crate::{ + Namespace, ReflectBaseType, ReflectReference, access_map::ReflectAccessId, + script_value::ScriptValue, +}; +use bevy_ecs::entity::Entity; +use bevy_mod_scripting_derive::DebugWithTypeInfo; +use bevy_mod_scripting_display::{ + DebugWithTypeInfo, DisplayWithTypeInfo, GetTypeInfo, OrFakeId, PrintReflectAsDebug, + WithTypeInfo, +}; +use bevy_reflect::{ApplyError, PartialReflect, Reflect, ReflectPathError}; +use std::{any::TypeId, borrow::Cow, error::Error, fmt::Display, panic::Location, sync::Arc}; + +/// A wrapper around a reflect value to implement various traits useful for error reporting. +#[derive(Clone)] +pub struct ReflectWrapper(Arc); + +impl bevy_mod_scripting_display::DebugWithTypeInfo for ReflectWrapper { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + PrintReflectAsDebug(&*self.0).to_string_with_type_info(f, type_info_provider) + } +} + +impl DisplayWithTypeInfo for ReflectWrapper { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + // TODO: different display? + PrintReflectAsDebug(&*self.0).to_string_with_type_info(f, type_info_provider) + } +} + +/// An error that occurred in an external library. +#[derive(Clone)] +pub struct ExternalError(pub Arc); + +impl bevy_mod_scripting_display::DebugWithTypeInfo for ExternalError { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + write!(f, "External error: {}", self.0) + } +} + +impl DisplayWithTypeInfo for ExternalError { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + write!(f, "External error: {}", self.0) + } +} + +/// An error occurring when converting between rust and a script context. +#[derive(Clone, Reflect, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] +#[reflect(opaque)] +pub enum InteropError { + /// The given feature is not implemented + NotImplemented, + /// A script value was of the wrong type + ValueMismatch { + /// The value with the wrong type + value: Box, + /// The expected type + expected: Box, + }, + /// The length of a list like structure was wrong + LengthMismatch { + /// The expected length + expected: usize, + /// The actual length + got: usize, + }, + /// Something failed when converting from a reflect + FailedFromReflect { + /// The type id of the reflect + type_id: Box>, + /// The reason for the failure + reason: Box, + }, + /// A type mismatch occurred + TypeMismatch { + /// The expected type + expected: Box, + /// The actual type + got: Box>, + }, + /// A type mismatch occurred, but with a string representation of the expected type + StringTypeMismatch { + /// The expected type + expected: Box, + /// The actual type + got: Box>, + }, + /// Could not claim access to a value + CannotClaimAccess { + /// The id of the access + base: Box, + /// The location of the access + location: Box>>, + /// The context of the access + context: Box>, + }, + /// An invariant was broken + Invariant(Box), + /// An unregistered component or resource type was used + UnregisteredComponentOrResourceType { + /// The name of the type + type_name: Box>, + }, + /// An unsupported operation was performed + UnsupportedOperation { + /// The base type of the operation + base: Box>, + /// The value of the operation + value: Box>, + /// The operation + operation: Box, + }, + /// Some type data was missing + MissingTypeData { + /// The type id of the missing data + type_id: Box, + /// The missing type data + type_data: Box, + }, + /// An entity was missing + MissingEntity(Entity), + + /// An error occurred in a function + FunctionInteropError { + /// The name of the function + function_name: Box, + /// The namespace of the function + on: Box, + /// The error that occurred + error: Box, + }, + /// An error occurred when converting a function argument + FunctionArgConversionError { + /// The argument that failed to convert + argument: Box, + /// The error that occurred + error: Box, + }, + /// The number of arguments in a function call was wrong + ArgumentCountMismatch { + /// The expected number of arguments + expected: usize, + /// The actual number of arguments + got: usize, + }, + /// A garbage collected allocation was used + GarbageCollectedAllocation { + /// The reference to the allocation + reference: Box, + }, + /// An unregistered reflect base was used + UnregisteredReflectBase { + /// The base that was unregistered + base: Box, + }, + /// An error occurred when using a reflection path + ReflectionPathError { + /// The error that occurred + error: Box, + /// The reflected value + reflected: Option>, + }, + /// Could not downcast a reference + CouldNotDowncastReference { + /// The type to downcast to + to: Box, + /// The reference to downcast + reference: Box, + }, + /// A schedule was missing + MissingSchedule { + /// The name of the schedule + schedule_name: &'static str, + }, + /// An invalid index was used + InvalidIndex { + /// The index that was invalid + index: Box, + /// The reason the index was invalid + reason: Box, + }, + /// The world was missing + MissingWorld, + /// An external error occurred + External(ExternalError), + /// an error enriched with some contextual information + WithContext( + /// The context to add + Box>, + /// The error to add context to + Box, + ), +} + +impl InteropError { + /// Strips outer context layers from the error, returning all contexts and the base error + pub fn unwrap_context(self) -> (Vec>, InteropError) { + let mut contexts = Vec::new(); + let mut current = self; + while let InteropError::WithContext(context, err) = current { + contexts.push(*context); + current = *err; + } + (contexts, current) + } + + /// Adds context to an existing error + pub fn with_context(self, context: impl Into>) -> Self { + Self::WithContext(Box::new(context.into()), Box::new(self)) + } + + /// Creates a new external error. + pub fn external(error: impl std::error::Error + Send + Sync + 'static) -> Self { + Self::External(ExternalError(Arc::new(error))) + } + + /// Creates a new external error from a boxed error. + pub fn external_boxed(error: Box) -> Self { + Self::External(ExternalError(Arc::from(error))) + } + + /// Creates a new external error from a static string. + pub fn str(reason: &'static str) -> Self { + Self::External(ExternalError(Arc::from(Box::< + dyn std::error::Error + Send + Sync + 'static, + >::from(reason)))) + } + + /// Creates a new external error from a string. + pub fn string(reason: String) -> Self { + Self::External(ExternalError(Arc::from(Box::< + dyn std::error::Error + Send + Sync + 'static, + >::from(reason)))) + } + + /// Creates a new value mismatch error. + pub fn value_mismatch(expected: TypeId, value: ScriptValue) -> Self { + Self::ValueMismatch { + value: Box::new(value), + expected: Box::new(expected), + } + } + + /// Creates a new length mismatch error. + pub fn length_mismatch(expected: usize, got: usize) -> Self { + Self::LengthMismatch { expected, got } + } + + /// Creates a new failed from reflect error. + pub fn failed_from_reflect(type_id: Option, reason: impl Display) -> Self { + Self::FailedFromReflect { + type_id: Box::new(type_id), + reason: Box::new(reason.to_string()), + } + } + + /// Creates a new type mismatch error. + pub fn type_mismatch(expected: TypeId, got: Option) -> Self { + Self::TypeMismatch { + expected: Box::new(expected), + got: Box::new(got), + } + } + + /// Creates a new string type mismatch error. + pub fn string_type_mismatch(expected: String, got: Option) -> Self { + Self::StringTypeMismatch { + expected: Box::new(expected), + got: Box::new(got), + } + } + + /// Creates a new cannot claim access error. + pub fn cannot_claim_access( + base: ReflectAccessId, + location: Option>, + context: impl Into>, + ) -> Self { + Self::CannotClaimAccess { + base: Box::new(base), + location: Box::new(location), + context: Box::new(context.into()), + } + } + + /// Creates a new invariant error. + pub fn invariant(reason: impl Into) -> Self { + Self::Invariant(Box::new(reason.into())) + } + + /// Creates a new unregistered component or resource type error. + pub fn unregistered_component_or_resource_type( + type_name: impl Into>, + ) -> Self { + Self::UnregisteredComponentOrResourceType { + type_name: Box::new(type_name.into()), + } + } + + /// Creates a new unsupported operation error. + pub fn unsupported_operation( + base: Option, + value: Option>, + op: impl Display, + ) -> Self { + Self::UnsupportedOperation { + base: Box::new(base), + value: Box::new(value.map(|v| ReflectWrapper(Arc::from(v)))), + operation: Box::new(op.to_string()), + } + } + + /// Creates a new missing type data error. + pub fn missing_type_data(type_id: TypeId, type_data: String) -> Self { + Self::MissingTypeData { + type_id: Box::new(type_id), + type_data: Box::new(type_data), + } + } + + /// Creates a new missing entity error. + pub fn missing_entity(entity: Entity) -> Self { + Self::MissingEntity(entity) + } + + /// Creates a new reflect apply error. + pub fn reflect_apply_error(e: ApplyError) -> Self { + Self::External(ExternalError(Arc::new(e))) + } + + /// Creates a new function interop error. + pub fn function_interop_error( + function_name: impl Display, + on: Namespace, + error: InteropError, + ) -> Self { + Self::FunctionInteropError { + function_name: Box::new(function_name.to_string()), + on: Box::new(on), + error: Box::new(error), + } + } + + /// Thrown when an error happens during argument conversion in a function call + pub fn function_arg_conversion_error(argument: String, error: InteropError) -> Self { + Self::FunctionArgConversionError { + argument: Box::new(argument), + error: Box::new(error), + } + } + + /// Thrown when the number of arguments in a function call does not match. + pub fn argument_count_mismatch(expected: usize, got: usize) -> Self { + Self::ArgumentCountMismatch { expected, got } + } + + /// Creates a new garbage collected allocation error. + pub fn garbage_collected_allocation(reference: ReflectReference) -> Self { + Self::GarbageCollectedAllocation { + reference: Box::new(reference), + } + } + + /// Creates a new unregistered base error. + pub fn unregistered_base(base: ReflectBaseType) -> Self { + Self::UnregisteredReflectBase { + base: Box::new(base), + } + } + + /// Creates a new reflection path error. + pub fn reflection_path_error<'a>( + error: ReflectPathError<'a>, + reflected: Option, + ) -> Self { + Self::ReflectionPathError { + error: Box::new(error.to_string()), + reflected: reflected.map(Box::new), + } + } + + /// Creates a new could not downcast error. + pub fn could_not_downcast(reference: ReflectReference, to: TypeId) -> Self { + Self::CouldNotDowncastReference { + to: Box::new(to), + reference: Box::new(reference), + } + } + + /// Creates a new missing schedule error. + pub fn missing_schedule(schedule_name: &'static str) -> Self { + Self::MissingSchedule { schedule_name } + } + + /// Creates a new invalid index error. + pub fn invalid_index(index: ScriptValue, reason: impl Into) -> Self { + Self::InvalidIndex { + index: Box::new(index), + reason: Box::new(reason.into()), + } + } + + /// Creates a new missing world error. + pub fn missing_world() -> Self { + Self::MissingWorld + } + + /// Creates a new missing function error. + pub fn missing_function(function_name: impl Display, on: Namespace) -> Self { + Self::FunctionInteropError { + function_name: Box::new(function_name.to_string()), + on: Box::new(on), + error: Box::new(InteropError::str("Function not found")), + } + } +} + +impl std::fmt::Display for InteropError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{}", WithTypeInfo(self)) + } +} + +impl std::error::Error for InteropError {} + +impl DisplayWithTypeInfo for InteropError { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + match self { + InteropError::NotImplemented => { + write!(f, "This feature is not implemented") + } + InteropError::ValueMismatch { value, expected } => { + write!( + f, + "Value type mismatch: expected {}, got {}", + WithTypeInfo(expected), + WithTypeInfo(value) + ) + } + InteropError::LengthMismatch { expected, got } => { + write!(f, "Length mismatch: expected {expected}, got {got}") + } + InteropError::FailedFromReflect { type_id, reason } => { + write!( + f, + "Failed to convert from reflect {}: {}", + WithTypeInfo(&type_id.as_ref().or_fake_id()), + reason + ) + } + InteropError::TypeMismatch { expected, got } => { + write!( + f, + "Type mismatch: expected {}, got {}", + WithTypeInfo(expected), + WithTypeInfo(&got.as_ref().or_fake_id()) + ) + } + InteropError::StringTypeMismatch { expected, got } => { + write!( + f, + "Type mismatch: expected {}, got {}", + expected, + WithTypeInfo(&got.as_ref().or_fake_id()) + ) + } + InteropError::CannotClaimAccess { + base, + location, + context, + } => { + if let Some(location) = location.as_ref() { + write!( + f, + "Cannot claim access to {} at {}:{}:{}: {}", + WithTypeInfo(base), + location.file(), + location.line(), + location.column(), + context + ) + } else { + write!( + f, + "Cannot claim access to {}: {}", + WithTypeInfo(base), + context + ) + } + } + InteropError::Invariant(i) => { + write!(f, "Invariant broken: {i}") + } + InteropError::UnregisteredComponentOrResourceType { type_name } => { + write!(f, "Unregistered component or resource type: {type_name}") + } + InteropError::UnsupportedOperation { + base, + value, + operation, + } => { + write!( + f, + "Unsupported operation on {}{}: {}", + WithTypeInfo(&base.as_ref().or_fake_id()), + if let Some(value) = value.as_ref() { + format!(" with value {}", WithTypeInfo(value)) + } else { + "".to_string() + }, + operation + ) + } + InteropError::MissingTypeData { type_id, type_data } => { + write!( + f, + "Missing type data {} for type: {}", + type_data, + WithTypeInfo(type_id) + ) + } + InteropError::MissingEntity(entity) => { + if *entity == Entity::PLACEHOLDER || entity.index() == 0 { + write!( + f, + "Invalid entity: {entity}. Are you trying to use an entity in a callback in which it's unavailable?" + ) + } else { + write!(f, "Missing or invalid entity: {entity}") + } + } + InteropError::FunctionInteropError { + function_name, + on, + error, + } => { + write!( + f, + "Error in function {} on {}: {}", + function_name, + WithTypeInfo(on), + error + ) + } + InteropError::FunctionArgConversionError { argument, error } => { + write!( + f, + "Error converting argument {}: {}", + argument, + WithTypeInfo(error) + ) + } + InteropError::ArgumentCountMismatch { expected, got } => { + write!(f, "Argument count mismatch: expected {expected}, got {got}") + } + InteropError::GarbageCollectedAllocation { reference } => { + write!( + f, + "Garbage collected allocation used: {}", + WithTypeInfo(reference) + ) + } + InteropError::UnregisteredReflectBase { base } => { + write!(f, "Unregistered reflect base: {}", WithTypeInfo(base)) + } + InteropError::ReflectionPathError { error, reflected } => { + write!( + f, + "Reflection path error: {}{}", + error, + if let Some(reflected) = reflected.as_ref() { + format!(", on value {}", WithTypeInfo(reflected)) + } else { + "".to_string() + } + ) + } + InteropError::CouldNotDowncastReference { to, reference } => { + write!( + f, + "Could not downcast reference {} to type {}", + WithTypeInfo(reference), + WithTypeInfo(to) + ) + } + InteropError::MissingSchedule { schedule_name } => { + write!(f, "Missing schedule: {schedule_name}") + } + InteropError::InvalidIndex { index, reason } => { + write!(f, "Invalid index {}: {}", WithTypeInfo(index), reason) + } + InteropError::MissingWorld => { + write!(f, "Missing world") + } + InteropError::External(external_error) => { + write!(f, "External error: {}", WithTypeInfo(external_error)) + } + InteropError::WithContext(cow, interop_error) => { + write!(f, "{}: {}", cow, WithTypeInfo(interop_error)) + } + } + } +} diff --git a/crates/bevy_mod_scripting_core/src/bindings/function/arg_meta.rs b/crates/bevy_mod_scripting_bindings/src/function/arg_meta.rs similarity index 97% rename from crates/bevy_mod_scripting_core/src/bindings/function/arg_meta.rs rename to crates/bevy_mod_scripting_bindings/src/function/arg_meta.rs index b79fac1015..5cc0849ced 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/function/arg_meta.rs +++ b/crates/bevy_mod_scripting_bindings/src/function/arg_meta.rs @@ -4,11 +4,7 @@ use std::{ffi::OsString, path::PathBuf}; use bevy_platform::collections::HashMap; -use crate::{ - bindings::{ReflectReference, ScriptValue}, - docgen::TypedThrough, - error::InteropError, -}; +use crate::{ReflectReference, ScriptValue, docgen::TypedThrough, error::InteropError}; use super::{ from::{FromScript, Mut, Ref, Union, Val}, diff --git a/crates/bevy_mod_scripting_core/src/bindings/function/from.rs b/crates/bevy_mod_scripting_bindings/src/function/from.rs similarity index 98% rename from crates/bevy_mod_scripting_core/src/bindings/function/from.rs rename to crates/bevy_mod_scripting_bindings/src/function/from.rs index 3cb1d933cd..c12872fb88 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/function/from.rs +++ b/crates/bevy_mod_scripting_bindings/src/function/from.rs @@ -1,9 +1,7 @@ //! This module contains the [`FromScript`] trait and its implemenations. use crate::{ - ScriptValue, - bindings::{ReflectReference, WorldGuard, access_map::ReflectAccessId}, - error::InteropError, + ReflectReference, ScriptValue, WorldGuard, access_map::ReflectAccessId, error::InteropError, }; use bevy_platform::collections::HashMap; use bevy_reflect::{FromReflect, Reflect}; @@ -571,7 +569,7 @@ macro_rules! impl_from_script_tuple { fn from_script(value: ScriptValue, world: WorldGuard<'_>) -> Result { match value { ScriptValue::List(list) => { - let expected_arg_count = $crate::bindings::function::script_function::count!( $($ty)* ); + let expected_arg_count = $crate::function::script_function::count!( $($ty)* ); if list.len() != expected_arg_count { return Err(InteropError::length_mismatch(expected_arg_count, list.len())); } diff --git a/crates/bevy_mod_scripting_core/src/bindings/function/from_ref.rs b/crates/bevy_mod_scripting_bindings/src/function/from_ref.rs similarity index 98% rename from crates/bevy_mod_scripting_core/src/bindings/function/from_ref.rs rename to crates/bevy_mod_scripting_bindings/src/function/from_ref.rs index dd07092f94..0de59834f1 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/function/from_ref.rs +++ b/crates/bevy_mod_scripting_bindings/src/function/from_ref.rs @@ -1,9 +1,7 @@ //! Contains the [`FromScriptRef`] trait and its implementations. use crate::{ - ScriptValue, - bindings::{FromScript, WorldGuard, match_by_type}, - error::InteropError, + FromScript, ScriptValue, WorldGuard, error::InteropError, match_by_type, reflection_extensions::TypeInfoExtensions, }; use bevy_reflect::{ diff --git a/crates/bevy_mod_scripting_core/src/bindings/function/into.rs b/crates/bevy_mod_scripting_bindings/src/function/into.rs similarity index 98% rename from crates/bevy_mod_scripting_core/src/bindings/function/into.rs rename to crates/bevy_mod_scripting_bindings/src/function/into.rs index c56c9c5821..a644c98b20 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/function/into.rs +++ b/crates/bevy_mod_scripting_bindings/src/function/into.rs @@ -1,10 +1,7 @@ //! Implementations of the [`IntoScript`] trait for various types. use super::{DynamicScriptFunction, DynamicScriptFunctionMut, Union, Val}; -use crate::{ - bindings::{ReflectReference, ScriptValue, WorldGuard}, - error::InteropError, -}; +use crate::{ReflectReference, ScriptValue, WorldGuard, error::InteropError}; use bevy_platform::collections::HashMap; use bevy_reflect::Reflect; use std::{borrow::Cow, ffi::OsString, path::PathBuf}; diff --git a/crates/bevy_mod_scripting_core/src/bindings/function/into_ref.rs b/crates/bevy_mod_scripting_bindings/src/function/into_ref.rs similarity index 94% rename from crates/bevy_mod_scripting_core/src/bindings/function/into_ref.rs rename to crates/bevy_mod_scripting_bindings/src/function/into_ref.rs index 8d29f45722..33ef0473ef 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/function/into_ref.rs +++ b/crates/bevy_mod_scripting_bindings/src/function/into_ref.rs @@ -2,16 +2,15 @@ use std::{borrow::Cow, ffi::OsString, path::PathBuf}; +use bevy_mod_scripting_display::OrFakeId; use bevy_reflect::{Access, PartialReflect}; use crate::{ - bindings::{function::into::IntoScript, ReflectReference, WorldGuard}, - error::InteropError, - reflection_extensions::{PartialReflectExt, TypeIdExtensions}, - ScriptValue, + ReflectReference, ScriptValue, WorldGuard, error::InteropError, function::into::IntoScript, + reflection_extensions::PartialReflectExt, }; -/// Converts a value represented by a reference into a [`crate::bindings::function::ScriptValue`]. +/// Converts a value represented by a reference into a [`crate::function::ScriptValue`]. /// Instead of a direct conversion, the trait tries to peek into the value behind the reference and find out the most suitable representation. /// /// Type Erased version of [`super::from::FromScript`]. @@ -19,7 +18,7 @@ use crate::{ /// - Primitives are converted to simple values /// - Container types are converted to references (so the references persist after accesses inside them) pub trait IntoScriptRef { - /// Converts a value represented by a reference into a [`crate::bindings::function::ScriptValue`]. + /// Converts a value represented by a reference into a [`crate::function::ScriptValue`]. fn into_script_ref( self_: ReflectReference, world: WorldGuard, diff --git a/crates/bevy_mod_scripting_core/src/bindings/function/magic_functions.rs b/crates/bevy_mod_scripting_bindings/src/function/magic_functions.rs similarity index 90% rename from crates/bevy_mod_scripting_core/src/bindings/function/magic_functions.rs rename to crates/bevy_mod_scripting_bindings/src/function/magic_functions.rs index 430f0047f8..54387fe8e0 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/function/magic_functions.rs +++ b/crates/bevy_mod_scripting_bindings/src/function/magic_functions.rs @@ -1,22 +1,23 @@ //! All the switchable special functions used by language implementors use super::{FromScriptRef, FunctionCallContext, IntoScriptRef}; -use crate::{ - bindings::{ReflectReference, ReflectionPathExt, ScriptValue}, - error::InteropError, - reflection_extensions::TypeIdExtensions, -}; +use crate::{ReflectReference, ReflectionPathExt, ScriptValue, error::InteropError}; +use bevy_mod_scripting_derive::DebugWithTypeInfo; +use bevy_mod_scripting_display::OrFakeId; use bevy_reflect::{ParsedPath, PartialReflect}; /// A list of magic methods, these only have one replacable implementation, and apply to all `ReflectReferences`. /// It's up to the language implementer to call these in the right order (after any type specific overrides). /// /// These live in a separate mini registry since they are so commonly needed. This helps us avoid needless hashing and lookups as well as script value conversions -#[derive(Debug)] +#[derive(DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub struct MagicFunctions { /// Indexer function + #[debug_with_type_info(skip)] pub get: fn(FunctionCallContext, ReflectReference, ScriptValue) -> Result, /// Indexer setter function + #[debug_with_type_info(skip)] pub set: fn( FunctionCallContext, ReflectReference, @@ -103,7 +104,7 @@ impl MagicFunctions { let other = >::from_script_ref(target_type_id, value, world.clone())?; r.try_apply(other.as_partial_reflect()) - .map_err(|e| InteropError::external_error(Box::new(e)))?; + .map_err(InteropError::reflect_apply_error)?; Ok::<_, InteropError>(()) })? } diff --git a/crates/bevy_mod_scripting_core/src/bindings/function/mod.rs b/crates/bevy_mod_scripting_bindings/src/function/mod.rs similarity index 89% rename from crates/bevy_mod_scripting_core/src/bindings/function/mod.rs rename to crates/bevy_mod_scripting_bindings/src/function/mod.rs index 8d239ae12e..c309d18131 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/function/mod.rs +++ b/crates/bevy_mod_scripting_bindings/src/function/mod.rs @@ -1,16 +1,24 @@ //! Abstractions to do with dynamic script functions -crate::private::export_all_in_modules! { - arg_meta, - from, - from_ref, - into, - into_ref, - namespace, - script_function, - type_dependencies, - magic_functions -} +pub mod arg_meta; +pub mod from; +pub mod from_ref; +pub mod into; +pub mod into_ref; +pub mod magic_functions; +pub mod namespace; +pub mod script_function; +pub mod type_dependencies; + +pub use arg_meta::*; +pub use from::*; +pub use from_ref::*; +pub use into::*; +pub use into_ref::*; +pub use magic_functions::*; +pub use namespace::*; +pub use script_function::*; +pub use type_dependencies::*; #[cfg(test)] #[allow(dead_code)] @@ -20,7 +28,7 @@ mod test { use bevy_platform::collections::HashMap; use bevy_reflect::{FromReflect, GetTypeRegistration, Reflect, Typed}; - use crate::bindings::{ + use crate::{ function::{ from::{Ref, Union, Val}, namespace::IntoNamespace, @@ -28,15 +36,15 @@ mod test { }, script_value::ScriptValue, }; + use bevy_ecs::prelude::AppTypeRegistry; use super::arg_meta::{ScriptArgument, ScriptReturn, TypedScriptArgument, TypedScriptReturn}; - use bevy_ecs::prelude::AppTypeRegistry; #[test] fn test_macro_generates_correct_registrator_function() { #[derive(Reflect)] struct TestStruct; - #[script_bindings(bms_core_path = "crate", name = "test_fn")] + #[script_bindings(bms_bindings_path = "crate", name = "test_fn")] impl TestStruct { /// My docs !! fn test_fn(_self: Ref, mut _arg1: usize) {} @@ -198,11 +206,8 @@ mod test { #[test] fn test_dynamic_functions() { - test_is_valid_arg_and_return::< - crate::bindings::function::script_function::DynamicScriptFunction, - >(); - test_is_valid_arg_and_return::< - crate::bindings::function::script_function::DynamicScriptFunctionMut, - >(); + test_is_valid_arg_and_return::(); + test_is_valid_arg_and_return::( + ); } } diff --git a/crates/bevy_mod_scripting_core/src/bindings/function/namespace.rs b/crates/bevy_mod_scripting_bindings/src/function/namespace.rs similarity index 84% rename from crates/bevy_mod_scripting_core/src/bindings/function/namespace.rs rename to crates/bevy_mod_scripting_bindings/src/function/namespace.rs index 65d08c02e9..b9108d4809 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/function/namespace.rs +++ b/crates/bevy_mod_scripting_bindings/src/function/namespace.rs @@ -1,17 +1,20 @@ //! A module for managing namespaces for functions use crate::{ - bindings::function::script_function::{AppScriptFunctionRegistry, ScriptFunction}, docgen::info::GetFunctionInfo, + function::script_function::{AppScriptFunctionRegistry, ScriptFunction}, }; use ::bevy_reflect::{GetTypeRegistration, Reflect}; use bevy_ecs::{reflect::AppTypeRegistry, world::World}; +use bevy_mod_scripting_derive::DebugWithTypeInfo; +use bevy_mod_scripting_display::{DisplayWithTypeInfo, GetTypeInfo, WithTypeInfo}; use std::{any::TypeId, borrow::Cow, marker::PhantomData}; use super::type_dependencies::GetFunctionTypeDependencies; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Reflect)] /// A namespace for functions +#[derive(Clone, Copy, PartialEq, Eq, Hash, Default, Reflect, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub enum Namespace { /// The function is registered in the global namespace, i.e. with no namespace. /// In practice functions in this namespace should be callable directly by their name, i.e. `my_function()` @@ -154,3 +157,24 @@ impl<'a, S: IntoNamespace> NamespaceBuilder<'a, S> { self } } + +impl From for Namespace { + fn from(value: TypeId) -> Self { + Namespace::OnType(value) + } +} + +impl DisplayWithTypeInfo for Namespace { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + match self { + Namespace::Global => f.write_str("Global Namespace"), + Namespace::OnType(type_id) => { + write!(f, "Namespace for type {}", WithTypeInfo(type_id)) + } + } + } +} diff --git a/crates/bevy_mod_scripting_core/src/bindings/function/script_function.rs b/crates/bevy_mod_scripting_bindings/src/function/script_function.rs similarity index 88% rename from crates/bevy_mod_scripting_core/src/bindings/function/script_function.rs rename to crates/bevy_mod_scripting_bindings/src/function/script_function.rs index eac4f4606a..75d57a04f1 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/function/script_function.rs +++ b/crates/bevy_mod_scripting_bindings/src/function/script_function.rs @@ -2,15 +2,13 @@ use super::MagicFunctions; use super::{from::FromScript, into::IntoScript, namespace::Namespace}; -use crate::bindings::function::arg_meta::ArgMeta; use crate::docgen::info::{FunctionInfo, GetFunctionInfo}; -use crate::{ - ScriptValue, - bindings::{ThreadWorldContainer, WorldContainer, WorldGuard}, - error::InteropError, -}; +use crate::function::arg_meta::ArgMeta; +use crate::{ScriptValue, ThreadWorldContainer, WorldContainer, WorldGuard, error::InteropError}; use bevy_ecs::prelude::Resource; use bevy_mod_scripting_asset::Language; +use bevy_mod_scripting_derive::DebugWithTypeInfo; +use bevy_mod_scripting_display::{DisplayWithTypeInfo, GetTypeInfo}; use bevy_platform::collections::HashMap; use bevy_reflect::Reflect; use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard}; @@ -72,24 +70,28 @@ impl FunctionCallContext { } } -#[derive(Reflect, Clone)] +#[derive(Reflect, Clone, DebugWithTypeInfo)] #[reflect(opaque)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] /// A dynamic script function. pub struct DynamicScriptFunction { /// The meta information about the function pub info: Arc, // TODO: info about the function, this is hard right now because of non 'static lifetimes in wrappers, we can't use TypePath etc + #[debug_with_type_info(skip)] func: Arc< dyn Fn(FunctionCallContext, VecDeque) -> ScriptValue + Send + Sync + 'static, >, } -#[derive(Reflect, Clone)] +#[derive(Reflect, Clone, DebugWithTypeInfo)] #[reflect(opaque)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] /// A dynamic mutable script function. pub struct DynamicScriptFunctionMut { /// The meta information about the function pub info: Arc, + #[debug_with_type_info(skip)] func: Arc< RwLock< // I'd rather consume an option or something instead of having the RWLock but I just wanna get this release out @@ -101,6 +103,48 @@ pub struct DynamicScriptFunctionMut { >, } +impl DisplayWithTypeInfo for DynamicScriptFunction { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + f.write_str("fn ")?; + let name = &self.info.name; + f.write_str(name)?; + f.write_str("(")?; + for arg in &self.info.arg_info { + arg.display_with_type_info(f, type_info_provider)?; + f.write_str(", ")?; + } + f.write_str(") -> ")?; + self.info + .return_info + .display_with_type_info(f, type_info_provider) + } +} + +impl DisplayWithTypeInfo for DynamicScriptFunctionMut { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + f.write_str("fn mut ")?; + let name = &self.info.name; + f.write_str(name)?; + f.write_str("(")?; + for arg in &self.info.arg_info { + arg.display_with_type_info(f, type_info_provider)?; + f.write_str(", ")?; + } + f.write_str(") -> ")?; + self.info + .return_info + .display_with_type_info(f, type_info_provider) + } +} + #[profiling::all_functions] impl DynamicScriptFunction { /// Call the function with the given arguments and caller context. @@ -186,22 +230,6 @@ impl PartialEq for DynamicScriptFunctionMut { } } -impl std::fmt::Debug for DynamicScriptFunction { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("DynamicScriptFunction") - .field("name", self.name()) - .finish() - } -} - -impl std::fmt::Debug for DynamicScriptFunctionMut { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("DynamicScriptFunctionMut") - .field("name", self.name()) - .finish() - } -} - impl From for DynamicScriptFunction where F: Fn(FunctionCallContext, VecDeque) -> ScriptValue + Send + Sync + 'static, @@ -231,7 +259,8 @@ where } /// Equivalent to [`AppFunctionRegistry`] but stores functions with a more convenient signature for scripting to avoid boxing every argument. -#[derive(Clone, Debug, Default, Resource)] +#[derive(Clone, Default, Resource, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub struct AppScriptFunctionRegistry(ScriptFunctionRegistryArc); impl Deref for AppScriptFunctionRegistry { @@ -248,7 +277,8 @@ impl DerefMut for AppScriptFunctionRegistry { } } -#[derive(Clone, Debug, Default)] +#[derive(Clone, Default, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] /// A thread-safe reference counted wrapper around a [`ScriptFunctionRegistry`] pub struct ScriptFunctionRegistryArc(pub Arc>); @@ -265,7 +295,8 @@ impl ScriptFunctionRegistryArc { } } -#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, PartialEq, Eq, Hash, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] /// A key used to identify a function in the registry pub struct FunctionKey { /// The name of the function @@ -274,7 +305,8 @@ pub struct FunctionKey { pub namespace: Namespace, } -#[derive(Debug, Default)] +#[derive(Default, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] /// A registry of dynamic script functions pub struct ScriptFunctionRegistry { functions: HashMap, @@ -510,7 +542,7 @@ impl ScriptFunctionRegistry { macro_rules! count { () => (0usize); - ( $x:tt $($xs:tt)* ) => (1usize + $crate::bindings::function::script_function::count!($($xs)*)); + ( $x:tt $($xs:tt)* ) => (1usize + $crate::function::script_function::count!($($xs)*)); } pub(crate) use count; @@ -683,14 +715,28 @@ mod test { ); assert!(out.is_err()); - assert_eq!( - out.unwrap_err(), - InteropError::function_interop_error( - " usize>>::into_dynamic_script_function::{{closure}}", - Namespace::Global, - InteropError::argument_count_mismatch(2, 1) - ) - ); + + let gotten = out.unwrap_err(); + let expected_function_name = " usize>>::into_dynamic_script_function::{{closure}}"; + let expected_namespace = Namespace::Global; + + if let InteropError::FunctionInteropError { + function_name, + on, + error, + } = gotten + { + assert_eq!(*function_name, expected_function_name); + assert_eq!(*on, expected_namespace); + if let InteropError::ArgumentCountMismatch { expected, got } = error.as_ref() { + assert_eq!(*expected, 2); + assert_eq!(*got, 1); + } else { + panic!("Expected ArgumentCountMismatch, got {error:?}"); + } + } else { + panic!("Expected FunctionInteropError, got {gotten:?}"); + } }); } @@ -699,7 +745,7 @@ mod test { #[derive(Component, Reflect)] struct Comp; - let fn_ = |_a: crate::bindings::function::from::Mut| 0usize; + let fn_ = |_a: crate::function::from::Mut| 0usize; let script_function = fn_.into_dynamic_script_function(); with_local_world(|| { diff --git a/crates/bevy_mod_scripting_core/src/bindings/function/type_dependencies.rs b/crates/bevy_mod_scripting_bindings/src/function/type_dependencies.rs similarity index 86% rename from crates/bevy_mod_scripting_core/src/bindings/function/type_dependencies.rs rename to crates/bevy_mod_scripting_bindings/src/function/type_dependencies.rs index dd5b85f8ff..32f9e6fd33 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/function/type_dependencies.rs +++ b/crates/bevy_mod_scripting_bindings/src/function/type_dependencies.rs @@ -5,10 +5,7 @@ use super::{ from::{Mut, Ref, Union, Val}, script_function::FunctionCallContext, }; -use crate::{ - bindings::{ReflectReference, ScriptValue}, - error::InteropError, -}; +use crate::{ReflectReference, ScriptValue, error::InteropError}; use bevy_mod_scripting_derive::impl_get_type_dependencies; use bevy_platform::collections::HashMap; use bevy_reflect::{FromReflect, GetTypeRegistration, TypeRegistry, Typed}; @@ -20,7 +17,7 @@ macro_rules! impl_get_type_dependencies_primitives { $( impl_get_type_dependencies!( #[derive(GetTypeDependencies)] - #[get_type_dependencies(bms_core_path="crate")] + #[get_type_dependencies(bms_bindings_path="crate")] struct $ty where {} ); )* @@ -79,7 +76,7 @@ pub trait GetTypeDependencies { impl_get_type_dependencies!( #[derive(GetTypeDependencies)] - #[get_type_dependencies(bms_core_path = "crate")] + #[get_type_dependencies(bms_bindings_path = "crate")] struct HashMap where K::Underlying: FromReflect + Eq + Hash + Typed, @@ -88,7 +85,7 @@ impl_get_type_dependencies!( impl_get_type_dependencies!( #[derive(GetTypeDependencies)] - #[get_type_dependencies(bms_core_path = "crate")] + #[get_type_dependencies(bms_bindings_path = "crate")] struct StdHashMap where K::Underlying: FromReflect + Eq + Hash + Typed, @@ -97,7 +94,7 @@ impl_get_type_dependencies!( impl_get_type_dependencies!( #[derive(GetTypeDependencies)] - #[get_type_dependencies(bms_core_path = "crate")] + #[get_type_dependencies(bms_bindings_path = "crate")] struct Result where T::Underlying: FromReflect + Typed, @@ -106,7 +103,7 @@ impl_get_type_dependencies!( impl_get_type_dependencies!( #[derive(GetTypeDependencies)] - #[get_type_dependencies(bms_core_path = "crate")] + #[get_type_dependencies(bms_bindings_path = "crate")] struct Option where T::Underlying: FromReflect + Typed, {} @@ -114,7 +111,7 @@ impl_get_type_dependencies!( impl_get_type_dependencies!( #[derive(GetTypeDependencies)] - #[get_type_dependencies(bms_core_path = "crate")] + #[get_type_dependencies(bms_bindings_path = "crate")] struct Vec where T::Underlying: FromReflect + Typed, {} @@ -123,7 +120,7 @@ impl_get_type_dependencies!( impl_get_type_dependencies!( #[derive(GetTypeDependencies)] #[get_type_dependencies( - bms_core_path = "crate", + bms_bindings_path = "crate", underlying = "Result" )] struct Union @@ -134,31 +131,31 @@ impl_get_type_dependencies!( impl_get_type_dependencies!( #[derive(GetTypeDependencies)] - #[get_type_dependencies(bms_core_path = "crate", underlying = "T", dont_recurse)] + #[get_type_dependencies(bms_bindings_path = "crate", underlying = "T", dont_recurse)] struct Val {} ); impl_get_type_dependencies!( #[derive(GetTypeDependencies)] - #[get_type_dependencies(bms_core_path = "crate", underlying = "T", dont_recurse)] + #[get_type_dependencies(bms_bindings_path = "crate", underlying = "T", dont_recurse)] struct Ref<'a, T> {} ); impl_get_type_dependencies!( #[derive(GetTypeDependencies)] - #[get_type_dependencies(bms_core_path = "crate", underlying = "T", dont_recurse)] + #[get_type_dependencies(bms_bindings_path = "crate", underlying = "T", dont_recurse)] struct Mut<'a, T> {} ); impl_get_type_dependencies!( #[derive(GetTypeDependencies)] - #[get_type_dependencies(bms_core_path = "crate")] + #[get_type_dependencies(bms_bindings_path = "crate")] struct ReflectReference {} ); impl_get_type_dependencies!( #[derive(GetTypeDependencies)] - #[get_type_dependencies(bms_core_path = "crate")] + #[get_type_dependencies(bms_bindings_path = "crate")] struct FunctionCallContext {} ); @@ -175,7 +172,7 @@ where macro_rules! register_tuple_dependencies { ($($param:ident),*) => { - impl <$($param),*> $crate::bindings::GetTypeDependencies for ($($param,)*) where + impl <$($param),*> $crate::function::GetTypeDependencies for ($($param,)*) where $( $param: GetTypeDependencies, <$param>::Underlying: FromReflect + Typed + GetTypeRegistration, diff --git a/crates/bevy_mod_scripting_core/src/bindings/globals/core.rs b/crates/bevy_mod_scripting_bindings/src/globals/core.rs similarity index 95% rename from crates/bevy_mod_scripting_core/src/bindings/globals/core.rs rename to crates/bevy_mod_scripting_bindings/src/globals/core.rs index ae542af382..769d2b53bd 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/globals/core.rs +++ b/crates/bevy_mod_scripting_bindings/src/globals/core.rs @@ -13,14 +13,10 @@ use bevy_platform::collections::HashMap; use std::{cell::RefCell, sync::Arc}; use crate::{ - bindings::{ - ScriptComponentRegistration, ScriptResourceRegistration, ScriptTypeRegistration, - WorldGuard, - function::from::{Union, Val}, - }, - docgen::into_through_type_info, - error::InteropError, + ScriptComponentRegistration, ScriptResourceRegistration, ScriptTypeRegistration, WorldGuard, + function::from::{Union, Val}, }; +use crate::{docgen::into_through_type_info, error::InteropError}; use super::AppScriptGlobalsRegistry; @@ -102,7 +98,7 @@ fn register_static_core_globals(world: &mut World, filter: fn(&TypeRegistration) global_registry.register_dummy_typed::>>("script_asset", "the asset handle for this script. If the asset is ever unloaded, the handle will be less useful."); } -#[script_globals(bms_core_path = "crate", name = "core_globals")] +#[script_globals(bms_bindings_path = "crate", name = "core_globals")] impl CoreGlobals { /// A cache of types normally available through the `world.get_type_by_name` function. /// diff --git a/crates/bevy_mod_scripting_core/src/bindings/globals/mod.rs b/crates/bevy_mod_scripting_bindings/src/globals/mod.rs similarity index 98% rename from crates/bevy_mod_scripting_core/src/bindings/globals/mod.rs rename to crates/bevy_mod_scripting_bindings/src/globals/mod.rs index c1c983d235..b93ccda3ea 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/globals/mod.rs +++ b/crates/bevy_mod_scripting_bindings/src/globals/mod.rs @@ -9,13 +9,12 @@ use crate::{ docgen::{TypedThrough, into_through_type_info, typed_through::ThroughTypeInfo}, error::InteropError, }; -use ::{bevy_ecs::resource::Resource, bevy_platform::collections::HashMap, bevy_reflect::Typed}; use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard}; use std::{any::TypeId, borrow::Cow, sync::Arc}; +use {bevy_ecs::resource::Resource, bevy_platform::collections::HashMap, bevy_reflect::Typed}; -crate::private::export_all_in_modules! { - core -} +pub mod core; +pub use core::*; /// A send + sync wrapper around the [`ScriptGlobalsRegistry`]. #[derive(Default, Resource, Clone)] diff --git a/crates/bevy_mod_scripting_bindings/src/lib.rs b/crates/bevy_mod_scripting_bindings/src/lib.rs new file mode 100644 index 0000000000..b22483c870 --- /dev/null +++ b/crates/bevy_mod_scripting_bindings/src/lib.rs @@ -0,0 +1,33 @@ +//! Abstractions to help with creating bindings between bevy and scripting languages. + +pub mod access_map; +pub mod allocator; +pub mod docgen; +pub mod error; +pub mod function; +pub mod globals; +// pub mod pretty_print; +pub mod query; +pub mod reference; +pub mod reflection_extensions; +pub mod schedule; +pub mod script_component; +pub mod script_value; +pub mod type_data; +pub mod world; + +pub use access_map::*; +pub use allocator::*; +pub use docgen::*; +pub use error::*; +pub use function::*; +pub use globals::*; +// pub use pretty_print::*; +pub use query::*; +pub use reference::*; +pub use reflection_extensions::*; +pub use schedule::*; +pub use script_component::*; +pub use script_value::*; +pub use type_data::*; +pub use world::*; diff --git a/crates/bevy_mod_scripting_core/src/bindings/query.rs b/crates/bevy_mod_scripting_bindings/src/query.rs similarity index 94% rename from crates/bevy_mod_scripting_core/src/bindings/query.rs rename to crates/bevy_mod_scripting_bindings/src/query.rs index 749d6c7e07..899c470257 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/query.rs +++ b/crates/bevy_mod_scripting_bindings/src/query.rs @@ -32,10 +32,12 @@ pub struct ScriptTypeRegistration { /// /// Not to be confused with script registered dynamic components, although this can point to a script registered component. pub struct ScriptComponentRegistration { - pub(crate) registration: ScriptTypeRegistration, - pub(crate) component_id: ComponentId, + /// The type registration of the component + pub registration: ScriptTypeRegistration, + /// the component id of the component + pub component_id: ComponentId, /// whether this is a component registered BY a script - pub(crate) is_dynamic_script_component: bool, + pub is_dynamic_script_component: bool, } #[derive(Clone, Reflect, Debug)] @@ -43,8 +45,10 @@ pub struct ScriptComponentRegistration { /// /// In general think of this as a handle to a type. pub struct ScriptResourceRegistration { - pub(crate) registration: ScriptTypeRegistration, - pub(crate) resource_id: ComponentId, + /// the type registration of the resource + pub registration: ScriptTypeRegistration, + /// the component id of the resource + pub resource_id: ComponentId, } #[profiling::all_functions] @@ -249,9 +253,12 @@ impl std::fmt::Display for ScriptTypeRegistration { /// - componentA /// - componentB pub struct ScriptQueryBuilder { - pub(crate) components: Vec, - with: Vec, - without: Vec, + /// The components to query for. + pub components: Vec, + /// Components that must be present. + pub with: Vec, + /// Components that must not be present. + pub without: Vec, } #[profiling::all_functions] diff --git a/crates/bevy_mod_scripting_core/src/bindings/reference.rs b/crates/bevy_mod_scripting_bindings/src/reference.rs similarity index 87% rename from crates/bevy_mod_scripting_core/src/bindings/reference.rs rename to crates/bevy_mod_scripting_bindings/src/reference.rs index 1a4eb318fa..f470277022 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/reference.rs +++ b/crates/bevy_mod_scripting_bindings/src/reference.rs @@ -6,10 +6,9 @@ //! we need wrapper types which have owned and ref variants. use super::{WorldGuard, access_map::ReflectAccessId}; use crate::{ - ReflectAllocator, - bindings::{ReflectAllocationId, with_access_read, with_access_write}, - error::InteropError, - reflection_extensions::{PartialReflectExt, TypeIdExtensions}, + ReflectAllocationId, ReflectAllocator, ThreadWorldContainer, WorldContainer, + error::InteropError, reflection_extensions::PartialReflectExt, with_access_read, + with_access_write, }; use ::{ bevy_ecs::{ @@ -21,6 +20,10 @@ use ::{ }, }; use bevy_ecs::{component::Component, ptr::Ptr, resource::Resource}; +use bevy_mod_scripting_derive::DebugWithTypeInfo; +use bevy_mod_scripting_display::{ + DebugWithTypeInfo, DisplayWithTypeInfo, OrFakeId, PrintReflectAsDebug, WithTypeInfo, +}; use bevy_reflect::{Access, OffsetAccess, ReflectRef}; use std::{any::TypeId, fmt::Debug}; @@ -33,8 +36,9 @@ use std::{any::TypeId, fmt::Debug}; /// - The path, which specifies how to access the value from the base. /// /// Bindings defined on this type, apply to ALL references. -#[derive(Debug, Clone, PartialEq, Eq, Reflect)] +#[derive(Clone, PartialEq, Eq, Reflect, DebugWithTypeInfo)] #[reflect(Default, opaque)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] #[non_exhaustive] pub struct ReflectReference { /// The base type and id of the value we want to access @@ -45,6 +49,32 @@ pub struct ReflectReference { pub reflect_path: ParsedPath, } +impl DisplayWithTypeInfo for ReflectReference { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn bevy_mod_scripting_display::GetTypeInfo>, + ) -> std::fmt::Result { + // try to display the most information we can + if let Ok(world) = ThreadWorldContainer.try_get_world() { + if let Ok(r) = self.with_reflect(world, |s| { + PrintReflectAsDebug(s).to_string_with_type_info(f, type_info_provider) + }) { + return r; + } + } + + self.base.display_with_type_info(f, type_info_provider)?; + if !self.reflect_path.is_empty() { + f.write_str(" at path ")?; + self.reflect_path + .display_with_type_info(f, type_info_provider)?; + } + + Ok(()) + } +} + impl Default for ReflectReference { fn default() -> Self { Self { @@ -58,7 +88,7 @@ impl Default for ReflectReference { } /// Specifies where we should source the type id from when reflecting a ReflectReference -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum TypeIdSource { /// Use the type id the reference points to after walking the path Tail, @@ -67,7 +97,9 @@ pub enum TypeIdSource { /// Givent the Tail reference is a container type, use the type id of the keys of the container Key, } + #[profiling::all_functions] + impl ReflectReference { /// If this points to a variant of an enum, returns the name of the variant. pub fn variant_name(&self, world: WorldGuard) -> Result, InteropError> { @@ -163,6 +195,34 @@ impl ReflectReference { }) } + /// Create a new reference to component by id. + /// If the type id is incorrect, you will get runtime errors when trying to access the value. + pub fn new_component_ref_by_id( + entity: Entity, + component_id: ComponentId, + type_id: TypeId, + ) -> Self { + Self { + base: ReflectBaseType { + type_id, + base_id: ReflectBase::Component(entity, component_id), + }, + reflect_path: ParsedPath(Vec::default()), + } + } + + /// Create a new reference to resource by id. + /// If the type id is incorrect, you will get runtime errors when trying to access the value. + pub fn new_resource_ref_by_id(component_id: ComponentId, type_id: TypeId) -> Self { + Self { + base: ReflectBaseType { + type_id, + base_id: ReflectBase::Resource(component_id), + }, + reflect_path: ParsedPath(Vec::default()), + } + } + /// Indexes into the reflect path inside this reference. /// You can use [`Self::reflect`] and [`Self::reflect_mut`] to get the actual value. pub fn index_path>(&mut self, index: T) { @@ -403,7 +463,7 @@ impl ReflectReference { ) -> Result<&'a dyn PartialReflect, InteropError> { self.reflect_path .reflect_element(root) - .map_err(|e| InteropError::reflection_path_error(e.to_string(), Some(self.clone()))) + .map_err(|e| InteropError::reflection_path_error(e, Some(self.clone()))) } fn walk_path_mut<'a>( @@ -412,12 +472,13 @@ impl ReflectReference { ) -> Result<&'a mut dyn PartialReflect, InteropError> { self.reflect_path .reflect_element_mut(root) - .map_err(|e| InteropError::reflection_path_error(e.to_string(), Some(self.clone()))) + .map_err(|e| InteropError::reflection_path_error(e, Some(self.clone()))) } } -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd)] /// The type id and base id of the value we want to access +#[derive(Clone, PartialEq, Eq, PartialOrd, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub struct ReflectBaseType { /// The type id of the value we want to access /// This MUST always be inline with the type id we are pointing to @@ -426,6 +487,20 @@ pub struct ReflectBaseType { pub base_id: ReflectBase, } +impl DisplayWithTypeInfo for ReflectBaseType { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn bevy_mod_scripting_display::GetTypeInfo>, + ) -> std::fmt::Result { + f.write_str("base type ")?; + WithTypeInfo(&self.type_id).display_with_type_info(f, type_info_provider)?; + f.write_str(" of kind ")?; + self.base_id.display_with_type_info(f, type_info_provider)?; + Ok(()) + } +} + impl ReflectBaseType { #[inline] /// Returns the type id of the value pointed to by the base @@ -487,7 +562,8 @@ impl ReflectBaseType { } /// The Id of the kind of reflection base being pointed to -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd)] +#[derive(Clone, PartialEq, Eq, PartialOrd, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub enum ReflectBase { /// A component of an entity Component(Entity, ComponentId), @@ -497,6 +573,31 @@ pub enum ReflectBase { Owned(ReflectAllocationId), } +impl DisplayWithTypeInfo for ReflectBase { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn bevy_mod_scripting_display::GetTypeInfo>, + ) -> std::fmt::Result { + match self { + ReflectBase::Component(entity, component_id) => { + f.write_str("component ")?; + WithTypeInfo(component_id).display_with_type_info(f, type_info_provider)?; + f.write_str(" on entity ")?; + entity.fmt(f) + } + ReflectBase::Resource(component_id) => { + f.write_str("resource ")?; + WithTypeInfo(component_id).display_with_type_info(f, type_info_provider) + } + ReflectBase::Owned(id) => { + f.write_str("allocated value with id ")?; + WithTypeInfo(id).display_with_type_info(f, type_info_provider) + } + } + } +} + #[profiling::all_functions] impl ReflectBase { /// Retrieves the pointer to the underlying `dyn PartialReflect` object valid for the 'w lifteime of the world cell @@ -572,14 +673,16 @@ impl ReflectionPathExt for ParsedPath { /// Unlike a normal iterator, this one does not have a halting condition, it will keep returning elements forever. /// The iterator does not try to access the value, it just works out the next index/key to access. /// You will know you've reached the end when you get an error when trying to access the next element. -#[derive(Debug, Clone)] +#[derive(Clone, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub struct ReflectRefIter { pub(crate) base: ReflectReference, // TODO: support maps etc pub(crate) index: IterationKey, } -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, PartialEq, Eq, DebugWithTypeInfo)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] /// The key of the current iteration pub enum IterationKey { /// The current index @@ -647,9 +750,7 @@ mod test { component::Component, reflect::AppTypeRegistry, resource::Resource, world::World, }; - use crate::bindings::{ - AppReflectAllocator, function::script_function::AppScriptFunctionRegistry, - }; + use crate::{AppReflectAllocator, function::script_function::AppScriptFunctionRegistry}; use super::*; diff --git a/crates/bevy_mod_scripting_core/src/reflection_extensions.rs b/crates/bevy_mod_scripting_bindings/src/reflection_extensions.rs similarity index 97% rename from crates/bevy_mod_scripting_core/src/reflection_extensions.rs rename to crates/bevy_mod_scripting_bindings/src/reflection_extensions.rs index 18ef2a0cfa..cc7e7b4165 100644 --- a/crates/bevy_mod_scripting_core/src/reflection_extensions.rs +++ b/crates/bevy_mod_scripting_bindings/src/reflection_extensions.rs @@ -7,10 +7,7 @@ use std::{ use bevy_reflect::{PartialReflect, Reflect, ReflectFromReflect, ReflectMut, ReflectRef, TypeInfo}; -use crate::{ - bindings::{ReflectReference, WorldGuard}, - error::InteropError, -}; +use crate::{ReflectReference, WorldGuard, error::InteropError}; /// Extension trait for [`PartialReflect`] providing additional functionality for working with specific types. pub trait PartialReflectExt { @@ -104,23 +101,6 @@ pub trait PartialReflectExt { ) -> Result, InteropError>; } -/// Extension trait for [`TypeId`] providing additional functionality for working with type ids. -pub trait TypeIdExtensions { - /// Returns the type id if it is Some, otherwise returns a fake type id. - fn or_fake_id(&self) -> TypeId; -} - -pub(crate) struct FakeType; - -impl TypeIdExtensions for Option { - fn or_fake_id(&self) -> TypeId { - match self { - Some(t) => *t, - None => TypeId::of::(), - } - } -} - impl PartialReflectExt for T { fn is_type(&self, crate_name: Option<&str>, type_ident: &str) -> bool { self.get_represented_type_info().is_some_and(|v| { diff --git a/crates/bevy_mod_scripting_core/src/bindings/schedule.rs b/crates/bevy_mod_scripting_bindings/src/schedule.rs similarity index 92% rename from crates/bevy_mod_scripting_core/src/bindings/schedule.rs rename to crates/bevy_mod_scripting_bindings/src/schedule.rs index 1c25f5f5a2..b4d380616e 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/schedule.rs +++ b/crates/bevy_mod_scripting_bindings/src/schedule.rs @@ -1,7 +1,7 @@ //! Dynamic scheduling from scripts -use super::{WorldAccessGuard, script_system::ScriptSystemBuilder}; -use crate::{IntoScriptPluginParams, error::InteropError}; +use super::WorldAccessGuard; +use crate::error::InteropError; use ::{ bevy_app::{ First, FixedFirst, FixedLast, FixedMain, FixedPostUpdate, FixedPreUpdate, FixedUpdate, @@ -13,7 +13,6 @@ use ::{ }, }; use bevy_ecs::resource::Resource; -use bevy_log::debug; use bevy_platform::collections::HashMap; use bevy_system_reflection::{ReflectSchedule, ReflectSystem}; use parking_lot::RwLock; @@ -160,7 +159,12 @@ impl WorldAccessGuard<'_> { .get(*schedule.label()) .ok_or_else(|| InteropError::missing_schedule(schedule.identifier()))?; - let systems = schedule.systems()?; + let systems = schedule.systems().map_err(|_| { + InteropError::string(format!( + "failed to get systems from schedule '{:?}', schedule is not initialized.", + schedule.label() + )) + })?; Ok(systems .map(|(node_id, system)| ReflectSystem::from_system(system.as_ref(), node_id)) @@ -168,21 +172,21 @@ impl WorldAccessGuard<'_> { })? } - /// Creates a system from a system builder and inserts it into the given schedule - pub fn add_system( - &self, - schedule: &ReflectSchedule, - builder: ScriptSystemBuilder, - ) -> Result { - debug!( - "Adding script system '{}' for script '{}' to schedule '{}'", - builder.name, - builder.attachment, - schedule.identifier() - ); + // /// Creates a system from a system builder and inserts it into the given schedule + // pub fn add_system( + // &self, + // schedule: &ReflectSchedule, + // builder: ScriptSystemBuilder, + // ) -> Result { + // debug!( + // "Adding script system '{}' for script '{}' to schedule '{}'", + // builder.name, + // builder.attachment, + // schedule.identifier() + // ); - builder.build::

(self.clone(), schedule) - } + // builder.build::

(self.clone(), schedule) + // } } #[cfg(test)] @@ -192,7 +196,7 @@ impl WorldAccessGuard<'_> { reason = "tests are there but not working currently" )] mod tests { - use crate::config::{GetPluginThreadConfig, ScriptingPluginConfiguration}; + // use crate::config::{GetPluginThreadConfig, ScriptingPluginConfiguration}; use ::{ bevy_app::{App, Plugin, Update}, bevy_ecs::{ @@ -203,7 +207,7 @@ mod tests { std::{cell::OnceCell, rc::Rc}, }; - use test_utils::make_test_plugin; + // use test_utils::make_test_plugin; use super::*; @@ -237,7 +241,7 @@ mod tests { assert_eq!(system.identifier(), "test_system_generic"); assert_eq!( system.path(), - "bevy_mod_scripting_core::bindings::schedule::tests::test_system_generic" + "bevy_mod_scripting_bindings::schedule::tests::test_system_generic" ); let system = IntoSystem::into_system(test_system); @@ -246,11 +250,11 @@ mod tests { assert_eq!(system.identifier(), "test_system"); assert_eq!( system.path(), - "bevy_mod_scripting_core::bindings::schedule::tests::test_system" + "bevy_mod_scripting_bindings::schedule::tests::test_system" ); } - make_test_plugin!(crate); + // make_test_plugin!(crate); // #[test] // fn test_into_system_set_identical_for_real_and_reflect_set() { @@ -328,7 +332,7 @@ mod tests { }; // trim module path - let trim = "bevy_mod_scripting_core::bindings::schedule::tests::"; + let trim = "bevy_mod_scripting_bindings::schedule::tests::"; out.replace(trim, "") }; diff --git a/crates/bevy_mod_scripting_core/src/bindings/script_component.rs b/crates/bevy_mod_scripting_bindings/src/script_component.rs similarity index 99% rename from crates/bevy_mod_scripting_core/src/bindings/script_component.rs rename to crates/bevy_mod_scripting_bindings/src/script_component.rs index 18725f3d07..4bf333a114 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/script_component.rs +++ b/crates/bevy_mod_scripting_bindings/src/script_component.rs @@ -126,7 +126,7 @@ impl WorldAccessGuard<'_> { } /// A plugin to support dynamic script components -pub(crate) struct DynamicScriptComponentPlugin; +pub struct DynamicScriptComponentPlugin; impl Plugin for DynamicScriptComponentPlugin { fn build(&self, app: &mut App) { diff --git a/crates/bevy_mod_scripting_core/src/bindings/script_value.rs b/crates/bevy_mod_scripting_bindings/src/script_value.rs similarity index 73% rename from crates/bevy_mod_scripting_core/src/bindings/script_value.rs rename to crates/bevy_mod_scripting_bindings/src/script_value.rs index 93ed7e0b5c..45147a22f4 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/script_value.rs +++ b/crates/bevy_mod_scripting_bindings/src/script_value.rs @@ -1,5 +1,7 @@ //! This module contains the `ScriptValue` enum which is used to pass values between scripting languages and Rust. +use bevy_mod_scripting_derive::DebugWithTypeInfo; +use bevy_mod_scripting_display::{DisplayWithTypeInfo, GetTypeInfo, WithTypeInfo}; use bevy_platform::collections::HashMap; use bevy_reflect::{Access, OffsetAccess, ParsedPath, Reflect}; use std::borrow::Cow; @@ -13,8 +15,9 @@ use super::{ /// An abstraction of values that can be passed to and from scripts. /// This allows us to re-use logic between scripting languages. -#[derive(Debug, Clone, PartialEq, Reflect, Default)] +#[derive(Clone, Reflect, Default, DebugWithTypeInfo)] #[reflect(opaque)] +#[debug_with_type_info(bms_display_path = "bevy_mod_scripting_display")] pub enum ScriptValue { /// Represents the absence of a value. #[default] @@ -41,6 +44,68 @@ pub enum ScriptValue { Error(InteropError), } +impl DisplayWithTypeInfo for ScriptValue { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + match self { + ScriptValue::Unit => f.write_str("()"), + ScriptValue::Bool(v) => write!(f, "{v}"), + ScriptValue::Integer(v) => write!(f, "{v}"), + ScriptValue::Float(v) => write!(f, "{v}"), + ScriptValue::String(v) => write!(f, "{v}"), + ScriptValue::List(v) => { + f.write_str("[")?; + let mut first = true; + for item in v { + if !first { + f.write_str(", ")?; + } + first = false; + WithTypeInfo(item).display_with_type_info(f, type_info_provider)?; + } + f.write_str("]") + } + ScriptValue::Map(v) => { + f.write_str("{")?; + let mut first = true; + for (key, value) in v { + if !first { + f.write_str(", ")?; + } + first = false; + write!(f, "{key}: ")?; + WithTypeInfo(value).display_with_type_info(f, type_info_provider)?; + } + f.write_str("}") + } + ScriptValue::Reference(v) => v.display_with_type_info(f, type_info_provider), + ScriptValue::FunctionMut(v) => v.display_with_type_info(f, type_info_provider), + ScriptValue::Function(v) => v.display_with_type_info(f, type_info_provider), + ScriptValue::Error(e) => e.display_with_type_info(f, type_info_provider), + } + } +} + +impl PartialEq for ScriptValue { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::Unit, Self::Unit) => true, + (Self::Bool(l0), Self::Bool(r0)) => l0 == r0, + (Self::Integer(l0), Self::Integer(r0)) => l0 == r0, + (Self::Float(l0), Self::Float(r0)) => l0 == r0, + (Self::String(l0), Self::String(r0)) => l0 == r0, + (Self::List(l0), Self::List(r0)) => l0 == r0, + (Self::Map(l0), Self::Map(r0)) => l0 == r0, + (Self::Reference(l0), Self::Reference(r0)) => l0 == r0, + // explicitly don't compare functions and errors + _ => false, + } + } +} + #[profiling::all_functions] impl ScriptValue { /// Returns the contained string if this is a string variant otherwise returns the original value. @@ -193,9 +258,9 @@ impl TryFrom for ParsedPath { match cow { Cow::Borrowed(v) => ParsedPath::parse_static(v) - .map_err(|e| InteropError::reflection_path_error(e.to_string(), None))?, + .map_err(|e| InteropError::reflection_path_error(e, None))?, Cow::Owned(o) => ParsedPath::parse(&o) - .map_err(|e| InteropError::reflection_path_error(e.to_string(), None))?, + .map_err(|e| InteropError::reflection_path_error(e, None))?, } } ScriptValue::Reference(reflect_reference) => { diff --git a/crates/bevy_mod_scripting_core/src/bindings/type_data.rs b/crates/bevy_mod_scripting_bindings/src/type_data.rs similarity index 100% rename from crates/bevy_mod_scripting_core/src/bindings/type_data.rs rename to crates/bevy_mod_scripting_bindings/src/type_data.rs diff --git a/crates/bevy_mod_scripting_core/src/bindings/world.rs b/crates/bevy_mod_scripting_bindings/src/world.rs similarity index 95% rename from crates/bevy_mod_scripting_core/src/bindings/world.rs rename to crates/bevy_mod_scripting_bindings/src/world.rs index 4232e9cfda..f540c4ce6f 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/world.rs +++ b/crates/bevy_mod_scripting_bindings/src/world.rs @@ -17,20 +17,15 @@ use super::{ namespace::Namespace, script_function::{AppScriptFunctionRegistry, DynamicScriptFunction, FunctionCallContext}, }, - pretty_print::DisplayWithWorld, schedule::AppScheduleRegistry, script_value::ScriptValue, with_global_access, }; use crate::{ - bindings::{ - function::{from::FromScript, from_ref::FromScriptRef}, - with_access_read, with_access_write, - }, - commands::AddStaticScript, error::InteropError, + function::{from::FromScript, from_ref::FromScriptRef}, reflection_extensions::PartialReflectExt, - script::{ScriptAttachment, ScriptComponent}, + with_access_read, with_access_write, }; use ::{ bevy_app::AppExit, @@ -55,6 +50,7 @@ use bevy_ecs::{ world::WorldId, }; use bevy_mod_scripting_asset::ScriptAsset; +use bevy_mod_scripting_display::GetTypeInfo; use bevy_platform::collections::HashMap; use bevy_reflect::{TypeInfo, VariantInfo}; use bevy_system_reflection::ReflectSchedule; @@ -584,7 +580,12 @@ impl<'w> WorldAccessGuard<'w> { let name = name.into(); let overload_iter = match registry.iter_overloads(Namespace::OnType(type_id), name) { Ok(iter) => iter, - Err(name) => return Err(InteropError::missing_function(type_id, name.to_string())), + Err(name) => { + return Err(InteropError::missing_function( + name.to_string(), + Namespace::OnType(type_id), + )); + } }; let mut last_error = None; @@ -617,7 +618,14 @@ impl WorldAccessGuard<'_> { let default_data = type_registry .get_type_data::(type_id) .ok_or_else(|| { - InteropError::missing_data_in_constructor(type_id, descriptor) + InteropError::function_interop_error( + "construct", + Namespace::OnType(TypeId::of::()), + InteropError::string(format!( + "field missing and no default provided: '{}'", + descriptor.into() + )), + ) })?; return Ok(default_data.default().into_partial_reflect()); } @@ -773,16 +781,25 @@ impl WorldAccessGuard<'_> { TypeInfo::Enum(enum_info) => { // extract variant from "variant" let variant = payload.remove("variant").ok_or_else(|| { - InteropError::missing_data_in_constructor( - enum_info.type_id(), - "\"variant\" field for enum", + InteropError::function_interop_error( + "construct", + Namespace::OnType(TypeId::of::()), + InteropError::str("missing 'variant' field in enum constructor payload"), ) })?; let variant_name = String::from_script(variant, self.clone())?; let variant = enum_info.variant(&variant_name).ok_or_else(|| { - InteropError::invalid_enum_variant(enum_info.type_id(), variant_name.clone()) + InteropError::function_interop_error( + "construct", + Namespace::OnType(TypeId::of::()), + InteropError::string(format!( + "invalid variant name '{}' for enum '{}'", + variant_name, + enum_info.type_path() + )), + ) })?; let variant = match variant { @@ -862,22 +879,22 @@ impl WorldAccessGuard<'_> { self.with_resource(|r: &AssetServer| r.load_state(script.id())) } - /// Attaches a script - pub fn attach_script(&self, attachment: ScriptAttachment) -> Result<(), InteropError> { - match attachment { - ScriptAttachment::EntityScript(entity, handle) => { - // find existing script components on the entity - self.with_or_insert_component_mut(entity, |c: &mut ScriptComponent| { - c.0.push(handle.clone()) - })?; - } - ScriptAttachment::StaticScript(handle) => { - self.queue(AddStaticScript::new(handle))?; - } - }; + // /// Attaches a script + // pub fn attach_script(&self, attachment: ScriptAttachment) -> Result<(), InteropError> { + // match attachment { + // ScriptAttachment::EntityScript(entity, handle) => { + // // find existing script components on the entity + // self.with_or_insert_component_mut(entity, |c: &mut ScriptComponent| { + // c.0.push(handle.clone()) + // })?; + // } + // ScriptAttachment::StaticScript(handle) => { + // self.queue(AddStaticScript::new(handle))?; + // } + // }; - Ok(()) - } + // Ok(()) + // } /// Spawns a new entity in the world pub fn spawn(&self) -> Result { @@ -1111,7 +1128,7 @@ impl WorldAccessGuard<'_> { None, format!( "Resource {} does not have a type id. Such resources are not supported by BMS.", - resource_id.display_without_world() + component_info.name() ), ) })?, @@ -1321,6 +1338,24 @@ impl WorldContainer for ThreadWorldContainer { } } +impl GetTypeInfo for ThreadWorldContainer { + fn get_type_info(&self, type_id: TypeId) -> Option<&TypeInfo> { + let world = self.try_get_world().ok()?; + let registry = world.type_registry(); + let registry = registry.read(); + registry.get(type_id).map(|r| r.type_info()) + } + + fn get_component_info( + &self, + component_id: ComponentId, + ) -> Option<&bevy_ecs::component::ComponentInfo> { + let world = self.try_get_world().ok()?; + let cell = world.as_unsafe_world_cell().ok()?; + cell.components().get_info(component_id) + } +} + #[cfg(test)] mod test { use super::*; diff --git a/crates/bevy_mod_scripting_core/Cargo.toml b/crates/bevy_mod_scripting_core/Cargo.toml index 5d532387bd..f47c015f04 100644 --- a/crates/bevy_mod_scripting_core/Cargo.toml +++ b/crates/bevy_mod_scripting_core/Cargo.toml @@ -20,18 +20,13 @@ default = [] # if enabled enables documentation updating in optimized builds doc_always = [] -# if enabled enables some common mlua trait implementations -mlua_impls = ["mlua"] -rhai_impls = ["rhai"] [dependencies] bevy_mod_scripting_derive = { workspace = true } bevy_mod_scripting_asset = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_system_reflection = { workspace = true } - - -mlua = { workspace = true, optional = true } -rhai = { workspace = true, features = ["sync"], optional = true } +bevy_mod_scripting_display = { workspace = true } bevy_reflect = { workspace = true, default-features = false, features = [] } bevy_ecs = { workspace = true, default-features = false, features = [] } diff --git a/crates/bevy_mod_scripting_core/src/bindings/mod.rs b/crates/bevy_mod_scripting_core/src/bindings/mod.rs deleted file mode 100644 index d7402ec681..0000000000 --- a/crates/bevy_mod_scripting_core/src/bindings/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! Abstractions to help with creating bindings between bevy and scripting languages. - -crate::private::export_all_in_modules! { - access_map, - allocator, - function, - globals, - pretty_print, - query, - reference, - schedule, - script_system, - script_value, - world, - script_component, - type_data -} diff --git a/crates/bevy_mod_scripting_core/src/bindings/pretty_print.rs b/crates/bevy_mod_scripting_core/src/bindings/pretty_print.rs deleted file mode 100644 index 1f6eddb3a8..0000000000 --- a/crates/bevy_mod_scripting_core/src/bindings/pretty_print.rs +++ /dev/null @@ -1,820 +0,0 @@ -//! Pretty printing for reflect references and other types. - -use crate::reflection_extensions::{FakeType, TypeIdExtensions}; - -use crate::bindings::{ - ReflectAllocationId, ReflectBase, ReflectBaseType, ReflectReference, WorldGuard, - access_map::ReflectAccessId, script_value::ScriptValue, -}; -use ::{ - bevy_ecs::component::ComponentId, - bevy_reflect::{PartialReflect, ReflectRef}, -}; -use bevy_ecs::world::World; -use bevy_platform::collections::HashMap; -use bevy_reflect::VariantType; -use itertools::Itertools; -use std::{ - any::{Any, TypeId}, - borrow::Cow, -}; - -/// A utility for printing reflect references in a human readable format. -pub struct ReflectReferencePrinter { - pub(crate) reference: ReflectReference, -} - -#[derive(Clone, Copy, Debug)] -enum BracketType { - Square, - Curly, - Round, -} - -impl BracketType { - fn open(self) -> char { - match self { - BracketType::Square => '[', - BracketType::Curly => '{', - BracketType::Round => '(', - } - } - - fn close(self) -> char { - match self { - BracketType::Square => ']', - BracketType::Curly => '}', - BracketType::Round => ')', - } - } - - fn surrounded(self, output: &mut String, f: F) { - output.push(self.open()); - f(output); - output.push(self.close()); - } -} - -macro_rules! downcast_case { - ($id:ident, $out:ident, $t:path) => {{ - $out.push_str(stringify!($t)); - $out.push('('); - if let Some($id) = $id.as_partial_reflect().try_downcast_ref::<$t>() { - $out.push_str(&format!("{:?}", $id)); - } else { - $out.push_str(""); - } - $out.push(')'); - }}; -} - -impl ReflectReferencePrinter { - const UNREGISTERED_TYPE: &'static str = "Unregistered"; - const UNKNOWN_FIELD: &'static str = ""; - - /// Creates a new reflect reference printer - pub fn new(reference: ReflectReference) -> Self { - Self { reference } - } - - /// Given a reflect reference, prints the type path of the reference resolving the type names with short names. - /// I.e. `MyType(Component).field_name[0].field_name[1] -> FieldType::Name` - pub fn pretty_print(&self, world: Option) -> String { - let mut pretty_path = String::new(); - - pretty_path.push_str(" {type_path}")); - } - } else { - Self::pretty_print_base(&self.reference.base, None, &mut pretty_path); - } - pretty_path.push('>'); - pretty_path - } - - /// Prints the actual value of the reference. Tries to use best available method to print the value. - pub fn pretty_print_value(&self, world: Option) -> String { - let mut output = String::new(); - - match world { - Some(world) => { - // instead of relying on type registrations, simply traverse the reflection tree and print sensible values - self.reference - .with_reflect(world, |r| { - self.pretty_print_value_inner(r, &mut output); - }) - .unwrap_or_else(|e| { - output.push_str(&format!("")); - }); - } - None => { - output.push_str(""); - } - } - - output - } - - fn pretty_print_base(base: &ReflectBaseType, world: Option, out: &mut String) { - let type_id = base.type_id(); - let type_path = if let Some(world) = world { - type_id.display_with_world(world.clone()) - } else { - type_id.display_without_world() - }; - - let base_kind = match base.base_id { - ReflectBase::Component(e, _) => format!("Component on entity {e}"), - ReflectBase::Resource(_) => "Resource".to_owned(), - ReflectBase::Owned(ref id) => format!("Allocation({id})"), - }; - - out.push_str(&format!("{base_kind}({type_path})")); - } - - /// Pretty prints a value of an opaque type. - pub fn pretty_print_value_opaque(&self, v: &dyn PartialReflect, output: &mut String) { - let type_id = v - .get_represented_type_info() - .map(|t| t.type_id()) - .or_fake_id(); - - output.push_str("Reflect("); - match type_id { - id if id == TypeId::of::() => downcast_case!(v, output, usize), - id if id == TypeId::of::() => downcast_case!(v, output, isize), - id if id == TypeId::of::() => downcast_case!(v, output, f32), - id if id == TypeId::of::() => downcast_case!(v, output, f64), - id if id == TypeId::of::() => downcast_case!(v, output, u128), - id if id == TypeId::of::() => downcast_case!(v, output, u64), - id if id == TypeId::of::() => downcast_case!(v, output, u32), - id if id == TypeId::of::() => downcast_case!(v, output, u16), - id if id == TypeId::of::() => downcast_case!(v, output, u8), - id if id == TypeId::of::() => downcast_case!(v, output, i128), - id if id == TypeId::of::() => downcast_case!(v, output, i64), - id if id == TypeId::of::() => downcast_case!(v, output, i32), - id if id == TypeId::of::() => downcast_case!(v, output, i16), - id if id == TypeId::of::() => downcast_case!(v, output, i8), - id if id == TypeId::of::() => downcast_case!(v, output, String), - id if id == TypeId::of::() => { - downcast_case!(v, output, std::path::PathBuf) - } - id if id == TypeId::of::() => { - downcast_case!(v, output, std::ffi::OsString) - } - id if id == TypeId::of::>() => { - downcast_case!(v, output, Cow) - } - id if id == TypeId::of::() => downcast_case!(v, output, char), - id if id == TypeId::of::() => downcast_case!(v, output, bool), - id if id == TypeId::of::() => downcast_case!(v, output, ScriptValue), - _ => { - output.push_str( - v.get_represented_type_info() - .map(|t| t.type_path()) - .unwrap_or(Self::UNREGISTERED_TYPE), - ); - } - } - output.push(')'); - } - - fn pretty_print_key_values< - K: AsRef, - V: AsRef, - I: IntoIterator, V)>, - >( - bracket: BracketType, - i: I, - output: &mut String, - ) { - bracket.surrounded(output, |output| { - let mut iter = i.into_iter().peekable(); - while let Some((key, val)) = iter.next() { - if let Some(key) = key { - output.push_str(key.as_ref()); - output.push_str(": "); - } - output.push_str(val.as_ref()); - if iter.peek().is_some() { - output.push_str(", "); - } - } - }); - } - - fn pretty_print_value_struct< - 'k, - N: Iterator, - M: Iterator, - >( - &self, - field_names: N, - field_values: M, - output: &mut String, - ) { - let field_names = field_names.into_iter(); - let fields = field_values.into_iter(); - let fields_iter = fields.zip_longest(field_names).map(|e| { - let (val, name) = match e { - itertools::EitherOrBoth::Both(val, name) => (val, name), - itertools::EitherOrBoth::Left(val) => (val, Self::UNKNOWN_FIELD), - itertools::EitherOrBoth::Right(name) => (().as_partial_reflect(), name), - }; - let mut field_printed = String::new(); - self.pretty_print_value_inner(val, &mut field_printed); - (Some(name), field_printed) - }); - Self::pretty_print_key_values(BracketType::Curly, fields_iter, output); - } - - fn pretty_print_value_inner(&self, v: &dyn PartialReflect, output: &mut String) { - match v.reflect_ref() { - ReflectRef::Struct(s) => { - let field_names = s - .get_represented_struct_info() - .map(|info| info.field_names()) - .unwrap_or_default() - .iter(); - let field_values = s.iter_fields(); - - self.pretty_print_value_struct(field_names.copied(), field_values, output); - } - ReflectRef::TupleStruct(t) => { - let fields_iter = t.iter_fields().enumerate().map(|(i, val)| { - let mut field_printed = String::new(); - self.pretty_print_value_inner(val, &mut field_printed); - (Some(i.to_string()), field_printed) - }); - Self::pretty_print_key_values(BracketType::Round, fields_iter, output); - } - ReflectRef::Tuple(t) => { - let fields_iter = t.iter_fields().map(|val| { - let mut field_printed = String::new(); - self.pretty_print_value_inner(val, &mut field_printed); - (None::, field_printed) - }); - Self::pretty_print_key_values(BracketType::Round, fields_iter, output); - } - ReflectRef::List(l) => { - let fields_iter = l.iter().map(|val| { - let mut field_printed = String::new(); - self.pretty_print_value_inner(val, &mut field_printed); - (None::, field_printed) - }); - Self::pretty_print_key_values(BracketType::Square, fields_iter, output); - } - ReflectRef::Array(a) => { - let fields_iter = a.iter().map(|val| { - let mut field_printed = String::new(); - self.pretty_print_value_inner(val, &mut field_printed); - (None::, field_printed) - }); - Self::pretty_print_key_values(BracketType::Square, fields_iter, output); - } - ReflectRef::Map(m) => { - let fields_iter = m.iter().map(|(key, val)| { - let mut key_printed = String::new(); - self.pretty_print_value_inner(key, &mut key_printed); - - let mut field_printed = String::new(); - self.pretty_print_value_inner(val, &mut field_printed); - (Some(key_printed), field_printed) - }); - Self::pretty_print_key_values(BracketType::Curly, fields_iter, output); - } - ReflectRef::Set(s) => { - let fields_iter = s.iter().map(|val| { - let mut field_printed = String::new(); - self.pretty_print_value_inner(val, &mut field_printed); - (None::, field_printed) - }); - Self::pretty_print_key_values(BracketType::Curly, fields_iter, output); - } - ReflectRef::Enum(e) => { - output.push_str(&e.variant_path()); - let bracket_type = match e.variant_type() { - VariantType::Tuple => BracketType::Round, - _ => BracketType::Curly, - }; - let key_vals = e.iter_fields().map(|v| { - let mut field_printed = String::new(); - self.pretty_print_value_inner(v.value(), &mut field_printed); - (v.name(), field_printed) - }); - Self::pretty_print_key_values(bracket_type, key_vals, output); - } - ReflectRef::Opaque(o) => { - self.pretty_print_value_opaque(o, output); - } - // for function_reflection from bevy or other feature gated things - #[allow(unreachable_patterns)] - _ => { - output.push_str(&format!("{v:?}")); - } - } - } -} - -// /// Alais for [`DisplayWithWorldAndDummy`] + [`std::fmt::Display`], ideally display should warn that it's not the full representation. -// pub trait DisplayWithWorldAndDummy: DisplayWithWorld + std::fmt::Display {} -// impl DisplayWithWorldAndDummy for T {} - -/// For types which can't be pretty printed without world access. -/// Implementors should try to print the best value they can, and never panick. -pub trait DisplayWithWorld: std::fmt::Debug + AsAny { - /// # Warning - /// Display this type without world access. It is not recommended to use this method for anything other than debugging or necessary trait impl corners. - /// For many types this will just print type id's with no further information. - /// - /// Prefer using [`DisplayWithWorld::display_with_world`] or [`DisplayWithWorld::display_value_with_world`] instead. - fn display_without_world(&self) -> String; - - /// Display the `shallowest` representation of the type using world access. - /// For references this is the type path and the type of the value they are pointing to. - fn display_with_world(&self, world: WorldGuard) -> String; - - /// Display the most literal representation of the type using world access. - /// I.e. for references this would be the pointed to value itself. - fn display_value_with_world(&self, world: WorldGuard) -> String { - self.display_with_world(world) - } -} - -#[doc(hidden)] -pub trait AsAny: 'static { - fn as_any(&self) -> &dyn Any; -} - -#[doc(hidden)] -impl AsAny for T { - fn as_any(&self) -> &dyn Any { - self - } -} - -impl dyn DisplayWithWorld { - /// Downcasts the `DisplayWithWorld` trait object to a concrete type. - /// Trampoline function to allow downcasting of errors. - pub fn downcast_ref(&self) -> Option<&T> { - self.as_any().downcast_ref::() - } -} - -#[profiling::all_functions] -impl DisplayWithWorld for ReflectReference { - fn display_with_world(&self, world: WorldGuard) -> String { - ReflectReferencePrinter::new(self.clone()).pretty_print(Some(world)) - } - - fn display_value_with_world(&self, world: WorldGuard) -> String { - ReflectReferencePrinter::new(self.clone()).pretty_print_value(Some(world)) - } - - fn display_without_world(&self) -> String { - ReflectReferencePrinter::new(self.clone()).pretty_print(None) - } -} -#[profiling::all_functions] -impl DisplayWithWorld for ReflectBaseType { - fn display_with_world(&self, world: WorldGuard) -> String { - let mut string = String::new(); - ReflectReferencePrinter::pretty_print_base(self, Some(world), &mut string); - string - } - - fn display_value_with_world(&self, world: WorldGuard) -> String { - self.display_with_world(world) - } - - fn display_without_world(&self) -> String { - let mut string = String::new(); - ReflectReferencePrinter::pretty_print_base(self, None, &mut string); - string - } -} -#[profiling::all_functions] -impl DisplayWithWorld for ComponentId { - fn display_without_world(&self) -> String { - format!("ComponentOrResource({})", self.index()) - } - - fn display_with_world(&self, world: WorldGuard) -> String { - let component_name = world - .as_unsafe_world_cell() - .ok() - .and_then(|c| c.components().get_info(*self)) - .map(|info| info.name()); - - match component_name { - Some(n) => format!("ComponentOrResource({n})"), - None => "ComponentOrResource()".to_owned(), - } - } -} -#[profiling::all_functions] -impl DisplayWithWorld for ReflectAccessId { - fn display_without_world(&self) -> String { - match self.kind { - super::access_map::ReflectAccessKind::ComponentOrResource => { - let component_id = ComponentId::from(*self); - component_id.display_without_world() - } - super::access_map::ReflectAccessKind::Allocation => { - format!("Allocation({})", self.id) - } - super::access_map::ReflectAccessKind::Global => "Global".to_owned(), - } - } - - fn display_with_world(&self, world: WorldGuard) -> String { - match self.kind { - super::access_map::ReflectAccessKind::ComponentOrResource => { - let component_id = ComponentId::from(*self); - component_id.display_with_world(world) - } - super::access_map::ReflectAccessKind::Allocation => { - let allocation_id = ReflectAllocationId::from(*self); - let allocator = world.allocator(); - let allocator = allocator.read(); - let raid = ReflectAccessId::for_allocation(allocation_id.clone()); - - if world.claim_read_access(raid) { - if let Some(allocation) = allocator.get(&allocation_id) { - let ptr = allocation.get_ptr(); - let val = unsafe { &*ptr }; - let o = format!("Allocation({val:?})"); - unsafe { world.release_access(raid) }; - o - } else { - format!("Allocation({allocation_id})") - } - } else { - format!("Allocation({allocation_id})") - } - } - super::access_map::ReflectAccessKind::Global => "Global".to_owned(), - } - } -} -#[profiling::all_functions] -impl DisplayWithWorld for TypeId { - fn display_with_world(&self, world: WorldGuard) -> String { - if *self == TypeId::of::() { - return "Unknown Type".to_owned(); - } else if *self == TypeId::of::() { - // does not implement Reflect, so we do this manually - return "World".to_owned(); - } - - let type_registry = world.type_registry(); - let type_registry = type_registry.read(); - - type_registry - .get_type_info(*self) - .map(|t| t.type_path_table().path().to_owned()) - .unwrap_or_else(|| { - format!("{}({:?})", ReflectReferencePrinter::UNREGISTERED_TYPE, self) - }) - .to_string() - } - - fn display_value_with_world(&self, world: WorldGuard) -> String { - self.display_with_world(world) - } - - fn display_without_world(&self) -> String { - format!("{self:?}") - } -} -#[profiling::all_functions] -impl DisplayWithWorld for ScriptValue { - fn display_with_world(&self, world: WorldGuard) -> String { - match self { - ScriptValue::Reference(r) => r.display_with_world(world), - _ => self.display_value_with_world(world), - } - } - - fn display_value_with_world(&self, world: WorldGuard) -> String { - match self { - ScriptValue::Reference(r) => r.display_value_with_world(world), - ScriptValue::FunctionMut(f) => format!("FunctionMut({})", f.name()), - ScriptValue::Function(f) => format!("Function({})", f.name()), - ScriptValue::Unit => "()".to_owned(), - ScriptValue::Bool(b) => b.to_string(), - ScriptValue::Integer(i) => i.to_string(), - ScriptValue::Float(f) => f.to_string(), - ScriptValue::String(cow) => cow.to_string(), - ScriptValue::Error(script_error) => script_error.display_with_world(world), - ScriptValue::List(vec) => vec.display_with_world(world), - ScriptValue::Map(hash_map) => hash_map.display_with_world(world), - } - } - - fn display_without_world(&self) -> String { - match self { - ScriptValue::Unit => "()".to_owned(), - ScriptValue::Bool(b) => b.to_string(), - ScriptValue::Integer(i) => i.to_string(), - ScriptValue::Float(f) => f.to_string(), - ScriptValue::String(cow) => cow.to_string(), - ScriptValue::List(vec) => { - let mut string = String::new(); - ReflectReferencePrinter::pretty_print_key_values( - BracketType::Square, - vec.iter() - .map(|v| (None::, v.display_without_world())), - &mut string, - ); - string - } - ScriptValue::Reference(reflect_reference) => reflect_reference.display_without_world(), - ScriptValue::FunctionMut(dynamic_script_function_mut) => { - format!("Function({})", dynamic_script_function_mut.name()) - } - ScriptValue::Function(dynamic_script_function) => { - format!("Function({})", dynamic_script_function.name()) - } - ScriptValue::Error(interop_error) => interop_error.display_without_world(), - ScriptValue::Map(hash_map) => hash_map.display_without_world(), - } - } -} -#[profiling::all_functions] -impl DisplayWithWorld for Vec { - fn display_with_world(&self, world: WorldGuard) -> String { - let mut string = String::new(); - BracketType::Square.surrounded(&mut string, |string| { - for (i, v) in self.iter().enumerate() { - string.push_str(&v.display_with_world(world.clone())); - if i != self.len() - 1 { - string.push_str(", "); - } - } - }); - string - } - - fn display_value_with_world(&self, world: WorldGuard) -> String { - let mut string = String::new(); - BracketType::Square.surrounded(&mut string, |string| { - for (i, v) in self.iter().enumerate() { - string.push_str(&v.display_value_with_world(world.clone())); - if i != self.len() - 1 { - string.push_str(", "); - } - } - }); - string - } - - fn display_without_world(&self) -> String { - let mut string = String::new(); - BracketType::Square.surrounded(&mut string, |string| { - for (i, v) in self.iter().enumerate() { - string.push_str(&v.display_without_world()); - if i != self.len() - 1 { - string.push_str(", "); - } - } - }); - string - } -} -#[profiling::all_functions] -impl DisplayWithWorld for String { - fn display_with_world(&self, _world: WorldGuard) -> String { - self.to_string() - } - - fn display_value_with_world(&self, _world: WorldGuard) -> String { - self.to_string() - } - - fn display_without_world(&self) -> String { - self.to_string() - } -} - -/// Implements DisplayWithWorld for a HashMap-like type that has key-value pairs -/// and supports iter() and len() methods. -macro_rules! impl_display_with_world_for_map { - ($map_type:path) => { - #[profiling::all_functions] - impl DisplayWithWorld - for $map_type - { - fn display_with_world(&self, world: WorldGuard) -> String { - let mut string = String::new(); - BracketType::Curly.surrounded(&mut string, |string| { - for (i, (k, v)) in self.iter().enumerate() { - string.push_str(&k.display_with_world(world.clone())); - string.push_str(": "); - string.push_str(&v.display_with_world(world.clone())); - if i != self.len() - 1 { - string.push_str(", "); - } - } - }); - string - } - - fn display_value_with_world(&self, world: WorldGuard) -> String { - let mut string = String::new(); - BracketType::Curly.surrounded(&mut string, |string| { - for (i, (k, v)) in self.iter().enumerate() { - string.push_str(&k.display_value_with_world(world.clone())); - string.push_str(": "); - string.push_str(&v.display_value_with_world(world.clone())); - if i != self.len() - 1 { - string.push_str(", "); - } - } - }); - string - } - - fn display_without_world(&self) -> String { - let mut string = String::new(); - BracketType::Curly.surrounded(&mut string, |string| { - for (i, (k, v)) in self.iter().enumerate() { - string.push_str(&k.display_without_world()); - string.push_str(": "); - string.push_str(&v.display_without_world()); - if i != self.len() - 1 { - string.push_str(", "); - } - } - }); - string - } - } - }; -} - -impl_display_with_world_for_map!(HashMap); -impl_display_with_world_for_map!(std::collections::HashMap); - -#[cfg(test)] -mod test { - use bevy_ecs::reflect::AppTypeRegistry; - use bevy_reflect::Reflect; - - use crate::bindings::{ - AppReflectAllocator, ReflectAllocationId, - function::script_function::AppScriptFunctionRegistry, - }; - - use super::*; - - fn setup_world() -> World { - let mut world = World::default(); - - let type_registry = AppTypeRegistry::default(); - world.insert_resource(type_registry); - - let allocator = AppReflectAllocator::default(); - world.insert_resource(allocator); - - let script_function_registry = AppScriptFunctionRegistry::default(); - world.insert_resource(script_function_registry); - - world - } - - #[test] - fn test_type_id() { - let mut world = setup_world(); - let world = WorldGuard::new_exclusive(&mut world); - - let type_id = TypeId::of::(); - assert_eq!(type_id.display_with_world(world.clone()), "usize"); - assert_eq!(type_id.display_value_with_world(world.clone()), "usize"); - assert_eq!(type_id.display_without_world(), format!("{type_id:?}")); - - let type_id = TypeId::of::(); - assert_eq!(type_id.display_with_world(world.clone()), "Unknown Type"); - assert_eq!( - type_id.display_value_with_world(world.clone()), - "Unknown Type" - ); - assert_eq!(type_id.display_without_world(), format!("{type_id:?}")); - } - - #[test] - fn test_reflect_base_type() { - let mut world = setup_world(); - let world = WorldGuard::new_exclusive(&mut world); - - let type_id = TypeId::of::(); - - assert_eq!( - ReflectBaseType { - base_id: ReflectBase::Owned(ReflectAllocationId::new(0)), - type_id, - } - .display_with_world(world.clone()), - "Allocation(0)(usize)" - ); - - assert_eq!( - ReflectBaseType { - base_id: ReflectBase::Owned(ReflectAllocationId::new(0)), - type_id, - } - .display_value_with_world(world.clone()), - "Allocation(0)(usize)" - ); - - assert_eq!( - ReflectBaseType { - base_id: ReflectBase::Owned(ReflectAllocationId::new(0)), - type_id, - } - .display_without_world(), - format!("Allocation(0)({type_id:?})") - ); - } - - #[test] - fn test_reflect_reference() { - let mut world = setup_world(); - - let world = WorldGuard::new_exclusive(&mut world); - - let type_id = TypeId::of::(); - - let allocator = world.allocator(); - let mut allocator_write = allocator.write(); - let reflect_reference = ReflectReference::new_allocated(2usize, &mut allocator_write); - let id = match reflect_reference.base.base_id { - ReflectBase::Owned(ref id) => id.to_string(), - _ => panic!("Expected owned allocation"), - }; - - drop(allocator_write); - - assert_eq!( - reflect_reference.display_with_world(world.clone()), - format!(" usize>") - ); - - assert_eq!( - reflect_reference.display_value_with_world(world.clone()), - "Reflect(usize(2))" - ); - - assert_eq!( - reflect_reference.display_without_world(), - format!("") - ); - } - - #[test] - fn test_hashmap() { - let mut world = setup_world(); - let world = WorldGuard::new_exclusive(&mut world); - - let mut map = HashMap::new(); - map.insert("hello".to_owned(), ScriptValue::Bool(true)); - - assert_eq!(map.display_with_world(world.clone()), "{hello: true}"); - - assert_eq!(map.display_value_with_world(world.clone()), "{hello: true}"); - } - - #[test] - fn test_script_value_in_reference() { - let mut world = setup_world(); - let world = WorldGuard::new_exclusive(&mut world); - - #[derive(Reflect)] - struct Test { - val: ScriptValue, - } - - let test = Test { - val: ScriptValue::Bool(true), - }; - - let allocator = world.allocator(); - let mut allocator_write = allocator.write(); - - let reflect_reference = ReflectReference::new_allocated(test, &mut allocator_write); - drop(allocator_write); - assert_eq!( - reflect_reference.display_value_with_world(world.clone()), - "{val: Reflect(ScriptValue(Bool(true)))}" - ); - } -} diff --git a/crates/bevy_mod_scripting_core/src/commands.rs b/crates/bevy_mod_scripting_core/src/commands.rs index 3a734b2503..7f52845d15 100644 --- a/crates/bevy_mod_scripting_core/src/commands.rs +++ b/crates/bevy_mod_scripting_core/src/commands.rs @@ -4,9 +4,8 @@ use std::{marker::PhantomData, sync::Arc}; use crate::{ IntoScriptPluginParams, ScriptContext, - bindings::{ScriptValue, WorldGuard}, context::ScriptingLoader, - error::{InteropError, ScriptError}, + error::ScriptError, event::{ CallbackLabel, IntoCallbackLabel, OnScriptLoaded, OnScriptReloaded, OnScriptUnloaded, ScriptCallbackResponseEvent, ScriptEvent, @@ -18,6 +17,7 @@ use crate::{ use bevy_ecs::{system::Command, world::World}; use bevy_log::{error, info, trace}; use bevy_mod_scripting_asset::ScriptAsset; +use bevy_mod_scripting_bindings::{ScriptValue, WorldGuard}; use parking_lot::Mutex; use { bevy_asset::{Assets, Handle}, @@ -230,7 +230,7 @@ impl CreateOrUpdateScript

{ script_context .insert_arc(attachment, ctxt.clone()) .map_err(|_| { - ScriptError::new(String::from("No context policy applied")) + ScriptError::new_boxed(String::from("No context policy applied").into()) .with_context("creating new script and context") })?; @@ -263,9 +263,9 @@ impl CreateOrUpdateScript

{ let mut script_context = script_context.write(); script_context.insert_resident(attachment.clone()).map_err(|err| { - ScriptError::new(InteropError::invariant(format!( + ScriptError::new_boxed(format!( "expected context to be present, could not mark attachment as resident in context, {err:?}" - ))) + ).into()) })?; Self::after_load( @@ -507,9 +507,10 @@ impl RunScriptCallback

{ let ctxt = match ctxt { Some(ctxt) => ctxt, None => { - let err = ScriptError::new(InteropError::missing_context(self.attachment.clone())) - .with_script(self.attachment.script().display()) - .with_context(P::LANGUAGE); + let err = + ScriptError::new_boxed(String::from("No context found for script").into()) + .with_script(self.attachment.script().display()) + .with_context(P::LANGUAGE); handle_script_errors(guard, vec![err.clone()].into_iter()); return Err(err); } diff --git a/crates/bevy_mod_scripting_core/src/context.rs b/crates/bevy_mod_scripting_core/src/context.rs index 47355c6b37..8f25a68f05 100644 --- a/crates/bevy_mod_scripting_core/src/context.rs +++ b/crates/bevy_mod_scripting_core/src/context.rs @@ -1,13 +1,10 @@ //! Traits and types for managing script contexts. use bevy_ecs::world::WorldId; +use bevy_mod_scripting_bindings::{ThreadWorldContainer, WorldContainer, WorldGuard}; use crate::{ - IntoScriptPluginParams, - bindings::{ThreadWorldContainer, WorldContainer, WorldGuard}, - error::ScriptError, - extractors::GetPluginFor, - script::ScriptAttachment, + IntoScriptPluginParams, error::ScriptError, extractors::GetPluginFor, script::ScriptAttachment, }; /// A trait that all script contexts must implement. diff --git a/crates/bevy_mod_scripting_core/src/docgen/mod.rs b/crates/bevy_mod_scripting_core/src/docgen/mod.rs deleted file mode 100644 index 2434e99346..0000000000 --- a/crates/bevy_mod_scripting_core/src/docgen/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! Documentation generation for scripting languages. - -crate::private::export_all_in_modules! { - info, - typed_through -} diff --git a/crates/bevy_mod_scripting_core/src/error.rs b/crates/bevy_mod_scripting_core/src/error.rs index 14e6d8b9e9..68f5274982 100644 --- a/crates/bevy_mod_scripting_core/src/error.rs +++ b/crates/bevy_mod_scripting_core/src/error.rs @@ -1,44 +1,29 @@ //! Errors that can occur when interacting with the scripting system use std::{ - any::TypeId, - borrow::Cow, fmt::{Debug, Display}, ops::Deref, str::Utf8Error, sync::Arc, }; -use bevy_ecs::entity::Entity; +use bevy_mod_scripting_bindings::InteropError; -use ::{ - bevy_asset::{AssetPath, Handle}, - bevy_ecs::{ - component::ComponentId, - schedule::{ScheduleBuildError, ScheduleNotInitialized}, - }, - bevy_reflect::{PartialReflect, Reflect}, -}; - -use crate::{ - ScriptAsset, - bindings::{ - ReflectBaseType, ReflectReference, - access_map::{DisplayCodeLocation, ReflectAccessId}, - function::namespace::Namespace, - pretty_print::DisplayWithWorld, - script_value::ScriptValue, - }, - script::{ContextKey, DisplayProxy}, -}; +use ::bevy_reflect::Reflect; /// An error with an optional script Context -#[derive(Debug, Clone, PartialEq, Reflect)] +#[derive(Debug, Clone, Reflect)] #[reflect(opaque)] pub struct ScriptError(pub Arc); impl std::error::Error for ScriptError {} +impl Display for ScriptError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + impl Deref for ScriptError { type Target = ScriptErrorInner; @@ -55,120 +40,38 @@ pub struct ScriptErrorInner { /// The context in which the error occurred pub context: String, /// The error that occurred - pub reason: Arc, + pub reason: Arc>, } -#[derive(Debug)] -/// The kind of error that occurred -pub enum ErrorKind { - /// An error that can be displayed - Display(Box), - /// An error that can be displayed with a world - WithWorld(Box), -} - -impl DisplayWithWorld for ErrorKind { - fn display_with_world(&self, world: crate::bindings::WorldGuard) -> String { - match self { - ErrorKind::Display(e) => e.to_string(), - ErrorKind::WithWorld(e) => e.display_with_world(world), - } - } - - fn display_without_world(&self) -> String { - match self { - ErrorKind::Display(e) => e.to_string(), - ErrorKind::WithWorld(e) => e.display_without_world(), - } - } -} - -impl Display for ErrorKind { +impl Display for ScriptErrorInner { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.display_without_world()) - } -} - -impl PartialEq for ScriptErrorInner { - fn eq(&self, other: &Self) -> bool { - self.context == other.context + if let Some(script) = &self.script { + write!( + f, + "Script Error in script '{}': {}\nContext: {}", + script, self.reason, self.context + ) + } else { + write!( + f, + "Script Error: {}\nContext: {}", + self.reason, self.context + ) + } } } impl ScriptError { - /// Tried to downcast a script error to an interop error - pub fn downcast_interop_inner(&self) -> Option<&InteropErrorInner> { - match self.reason.as_ref() { - ErrorKind::WithWorld(display_with_world) => { - let any: &dyn DisplayWithWorld = display_with_world.as_ref(); - if let Some(interop_error) = any.downcast_ref::() { - Some(interop_error.inner()) - } else { - None - } - } - _ => None, - } - } - - #[cfg(feature = "mlua_impls")] - /// Destructures mlua error into a script error, taking care to preserve as much information as possible - pub fn from_mlua_error(error: mlua::Error) -> Self { - match error { - mlua::Error::CallbackError { traceback, cause } - if matches!(cause.as_ref(), mlua::Error::ExternalError(_)) => - { - let inner = cause.deref().clone(); - Self::from_mlua_error(inner).with_context(traceback) - } - e => { - if let Some(inner) = e.downcast_ref::() { - Self::new(inner.clone()) - } else if let Some(inner) = e.downcast_ref::() { - inner.clone() - } else { - Self::new_external(e) - } - } - } - } - - #[cfg(feature = "rhai_impls")] - /// destructures a rhai error into a script error, taking care to preserve as much information as possible - pub fn from_rhai_error(error: rhai::EvalAltResult) -> Self { - match error { - rhai::EvalAltResult::ErrorSystem(message, error) => { - if let Some(inner) = error.downcast_ref::() { - Self::new(inner.clone()) - } else if let Some(inner) = error.downcast_ref::() { - inner.clone() - } else { - Self::new_external_boxed(error).with_context(message) - } - } - _ => Self::new_external(error), - } - } - /// Creates a new script error with an external error - pub fn new_external(reason: impl std::error::Error + Send + Sync + 'static) -> Self { - Self::new_external_boxed(Box::new(reason)) + pub fn new(reason: impl std::error::Error + Send + Sync + 'static) -> Self { + Self::new_boxed(Box::new(reason)) } /// Creates a new script error with an external error - pub fn new_external_boxed(reason: Box) -> Self { + pub fn new_boxed(reason: Box) -> Self { Self(Arc::new(ScriptErrorInner { script: None, - reason: Arc::new(ErrorKind::Display(reason)), - context: Default::default(), - })) - } - - /// Creates a new script error with a reason - pub fn new(reason: impl DisplayWithWorld + Send + Sync + 'static) -> Self { - Self(Arc::new(ScriptErrorInner { - script: None, - reason: Arc::new(ErrorKind::WithWorld(Box::new(reason))), + reason: Arc::new(reason), context: Default::default(), })) } @@ -192,109 +95,6 @@ impl ScriptError { } } -impl std::fmt::Display for ScriptError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.display_without_world()) - } -} - -impl DisplayWithWorld for ScriptError { - fn display_with_world(&self, world: crate::bindings::WorldGuard) -> String { - if let Some(script) = &self.0.script { - format!( - "error in script `{}`: {}.\nContext:{}", - script, - self.0.reason.display_with_world(world), - self.0.context - ) - } else { - format!( - "error: {}.\nContext:{}", - self.0.reason.display_with_world(world), - self.0.context - ) - } - } - - fn display_without_world(&self) -> String { - if let Some(script) = &self.0.script { - format!( - "error in script `{}`: {}.\nContext:{}", - script, self.0.reason, self.0.context, - ) - } else { - format!("error: {}.\nContext:{}", self.0.reason, self.0.context) - } - } -} - -impl From for InteropError { - fn from(value: ScheduleBuildError) -> Self { - InteropError::external_error(Box::new(value)) - } -} - -impl From for InteropError { - fn from(value: ScheduleNotInitialized) -> Self { - InteropError::external_error(Box::new(value)) - } -} - -#[cfg(feature = "mlua_impls")] -impl From for mlua::Error { - fn from(value: ScriptError) -> Self { - mlua::Error::external(value) - } -} - -#[cfg(feature = "mlua_impls")] -impl From for mlua::Error { - fn from(value: InteropError) -> Self { - mlua::Error::external(value) - } -} - -#[cfg(feature = "mlua_impls")] -impl From for ScriptError { - fn from(value: mlua::Error) -> Self { - ScriptError::from_mlua_error(value) - } -} - -#[cfg(feature = "rhai_impls")] -impl From for ScriptError { - fn from(value: rhai::ParseError) -> Self { - ScriptError::new_external(value) - } -} - -#[cfg(feature = "rhai_impls")] -impl From> for ScriptError { - fn from(value: Box) -> Self { - ScriptError::from_rhai_error(*value) - } -} - -#[cfg(feature = "rhai_impls")] -impl From for Box { - fn from(value: ScriptError) -> Self { - Box::new(rhai::EvalAltResult::ErrorSystem( - "ScriptError".to_owned(), - Box::new(value), - )) - } -} - -#[cfg(feature = "rhai_impls")] -impl From for Box { - fn from(value: InteropError) -> Self { - Box::new(rhai::EvalAltResult::ErrorSystem( - "InteropError".to_owned(), - Box::new(value), - )) - } -} - #[derive(Clone, Debug, PartialEq)] /// An error thrown when a resource is missing pub struct MissingResourceError(&'static str); @@ -318,38 +118,20 @@ impl Display for MissingResourceError { impl std::error::Error for MissingResourceError {} -#[derive(Debug, Clone, PartialEq, Reflect)] -#[reflect(opaque)] -/// An error thrown when interoperating with scripting languages. -pub struct InteropError(Arc); - -impl std::error::Error for InteropError {} - -impl DisplayWithWorld for InteropError { - fn display_with_world(&self, world: crate::bindings::WorldGuard) -> String { - self.0.display_with_world(world) - } - - fn display_without_world(&self) -> String { - self.0.display_without_world() - } -} - -impl Display for InteropError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.display_without_world()) - } -} - impl From for ScriptError { fn from(val: InteropError) -> Self { - ScriptError::new(val) + let (ctxt, err) = val.unwrap_context(); + let mut err = ScriptError::new(err); + for ctxt in ctxt { + err = err.with_context(ctxt); + } + err } } impl From for ScriptError { fn from(val: Utf8Error) -> Self { - ScriptError::new_external(val) + ScriptError::new(val) } } @@ -368,1298 +150,3 @@ impl FlattenError for Result, Intero } } } - -impl InteropError { - /// Creates a new invariant error. Thrown when an invariant is violated. - pub fn invariant(message: impl Display) -> Self { - Self(Arc::new(InteropErrorInner::Invariant { - message: message.to_string(), - })) - } - - /// Thrown if a callback requires world access, but is unable to do so due - /// to the world not being reachable at all via any mechanism. - pub fn missing_world() -> Self { - Self(Arc::new(InteropErrorInner::MissingWorld)) - } - - /// Thrown if a callback requires world access, but is unable to do so due - /// to the world being dropped. I.e. Symptom of a script trying to persist a world reference somewhere. - pub fn stale_world_access() -> Self { - Self(Arc::new(InteropErrorInner::StaleWorldAccess)) - } - - /// Thrown if a base type is not registered with the reflection system - /// and therefore the reference cannot be dereferenced - pub fn unregistered_base(base: ReflectBaseType) -> Self { - Self(Arc::new(InteropErrorInner::UnregisteredBase { base })) - } - - /// Thrown if a base type is not registered with the reflection system - /// with the specific type data. - pub fn missing_type_data(type_id: TypeId, type_data: String) -> Self { - Self(Arc::new(InteropErrorInner::MissingTypeData { - type_id, - type_data, - })) - } - - /// Thrown if a type cannot be converted from reflect, this can happen if the type was unable to - /// re-construct itself from a dynamic value. - pub fn failed_from_reflect(type_id: Option, reason: impl Into) -> Self { - Self(Arc::new(InteropErrorInner::FailedFromReflect { - type_id, - reason: reason.into(), - })) - } - - /// Thrown if access to the given reflection base is required but cannot be claimed. - /// This is likely due to some other script already claiming access to the base. - pub fn cannot_claim_access( - base: ReflectAccessId, - location: Option>, - context: impl Into>, - ) -> Self { - Self(Arc::new(InteropErrorInner::CannotClaimAccess { - base, - location, - context: context.into(), - })) - } - - /// Thrown if a conversion into the given type is impossible. - /// Should be thrown with context on the other type if possible. - pub fn impossible_conversion(into: TypeId) -> Self { - Self(Arc::new(InteropErrorInner::ImpossibleConversion { into })) - } - - /// Thrown if a conversion was not fully completed, as a better conversion exists. - /// If a function might throw this error it should be handled by the caller. - /// - /// A user seeing this error is evidence of unfinished logic. - pub fn better_conversion_exists() -> Self { - Self(Arc::new(InteropErrorInner::BetterConversionExists { - context: std::any::type_name::().to_string(), - })) - } - - /// Thrown if a value was expected to be of one type but was of another - pub fn type_mismatch(expected: TypeId, got: Option) -> Self { - Self(Arc::new(InteropErrorInner::TypeMismatch { expected, got })) - } - - /// Identical to [`InteropError::type_mismatch`] but for more abstract types - pub fn string_type_mismatch(expected: String, got: Option) -> Self { - Self(Arc::new(InteropErrorInner::StringTypeMismatch { - expected, - got, - })) - } - - /// Thrown if a [`ScriptValue`] could not be converted to the expected type - pub fn value_mismatch(expected: TypeId, got: ScriptValue) -> Self { - Self(Arc::new(InteropErrorInner::ValueMismatch { expected, got })) - } - - /// Thrown if a downcast from a reflect reference to a specific type failed - pub fn could_not_downcast(from: ReflectReference, to: TypeId) -> Self { - Self(Arc::new(InteropErrorInner::CouldNotDowncast { from, to })) - } - - /// Thrown if a garbage collected allocation was attempted to be accessed - pub fn garbage_collected_allocation(reference: ReflectReference) -> Self { - Self(Arc::new(InteropErrorInner::GarbageCollectedAllocation { - reference, - })) - } - - /// Thrown if a reflection path is invalid - pub fn reflection_path_error(error: String, reference: Option) -> Self { - Self(Arc::new(InteropErrorInner::ReflectionPathError { - error, - reference, - })) - } - - /// Thrown if an operation is not supported on the given base type, optionally with a value argument that was used to carry it out - pub fn unsupported_operation( - base: Option, - value: Option>, - operation: impl Display, - ) -> Self { - Self(Arc::new(InteropErrorInner::UnsupportedOperation { - base, - value, - operation: operation.to_string(), - })) - } - - /// Thrown if an invalid index operation was attempted on a value - pub fn invalid_index(value: ScriptValue, reason: String) -> Self { - Self(Arc::new(InteropErrorInner::InvalidIndex { value, reason })) - } - - /// Thrown if an entity was missing or invalid - pub fn missing_entity(entity: Entity) -> Self { - Self(Arc::new(InteropErrorInner::MissingEntity { entity })) - } - - /// Thrown if a component was invalid - pub fn invalid_component(component_id: ComponentId) -> Self { - Self(Arc::new(InteropErrorInner::InvalidComponent { - component_id, - })) - } - - /// Thrown when an error happens in a function call. The inner error provides details on the error. - pub fn function_interop_error(function_name: &str, on: Namespace, error: InteropError) -> Self { - Self(Arc::new(InteropErrorInner::FunctionInteropError { - function_name: function_name.to_string(), - on, - error, - })) - } - - /// Thrown when an error happens during argument conversion in a function call - pub fn function_arg_conversion_error(argument: String, error: InteropError) -> Self { - Self(Arc::new(InteropErrorInner::FunctionArgConversionError { - argument, - error, - })) - } - - /// Thrown when a length mismatch occurs - pub fn length_mismatch(expected: usize, got: usize) -> Self { - Self(Arc::new(InteropErrorInner::LengthMismatch { - expected, - got, - })) - } - - /// Thrown when an error happens that is not covered by the other variants - pub fn external_error(error: Box) -> Self { - Self(Arc::new(InteropErrorInner::OtherError { error })) - } - - /// Thrown when a function is missing from the function registry - pub fn missing_function(on: TypeId, function_name: impl Display) -> Self { - Self(Arc::new(InteropErrorInner::MissingFunctionError { - on, - function_name: function_name.to_string(), - })) - } - - /// Thrown when an invalid access count is detected - pub fn invalid_access_count(count: usize, expected: usize, context: impl Display) -> Self { - Self(Arc::new(InteropErrorInner::InvalidAccessCount { - count, - expected, - context: context.to_string(), - })) - } - - /// Thrown when a component or resource type is not registered - pub fn unregistered_component_or_resource_type( - type_name: impl Into>, - ) -> Self { - Self(Arc::new( - InteropErrorInner::UnregisteredComponentOrResourceType { - type_name: type_name.into(), - }, - )) - } - - /// Thrown when constructing types and we find missing data needed to construct the type - pub fn missing_data_in_constructor( - type_id: TypeId, - missing_data_name: impl Into>, - ) -> Self { - Self(Arc::new(InteropErrorInner::MissingDataInConstructor { - type_id, - missing_data_name: missing_data_name.into(), - })) - } - - /// Thrown if an enum variant is invalid. - pub fn invalid_enum_variant(type_id: TypeId, variant_name: impl ToString) -> Self { - Self(Arc::new(InteropErrorInner::InvalidEnumVariant { - type_id, - variant_name: variant_name.to_string(), - })) - } - - /// Thrown when the number of arguments in a function call does not match. - pub fn argument_count_mismatch(expected: usize, got: usize) -> Self { - Self(Arc::new(InteropErrorInner::ArgumentCountMismatch { - expected, - got, - })) - } - - /// Thrown if a script could not be found when trying to call a synchronous callback or otherwise - pub fn missing_script(script_id: impl Into>) -> Self { - Self(Arc::new(InteropErrorInner::MissingScript { - script_id: Some(script_id.into()), - script_path: None, - })) - } - - /// Thrown if a script could not be found when trying to call a synchronous callback or otherwise - pub fn missing_script_by_path<'a>(script_id: impl Into>) -> Self { - Self(Arc::new(InteropErrorInner::MissingScript { - script_path: Some(script_id.into().to_string()), - script_id: None, - })) - } - - /// Thrown if the required context for an operation is missing. - pub fn missing_context(context_key: impl Into) -> Self { - Self(Arc::new(InteropErrorInner::MissingContext { - context_key: context_key.into(), - })) - } - - /// Thrown when a schedule is missing from the registry. - pub fn missing_schedule(schedule_name: impl Into>) -> Self { - Self(Arc::new(InteropErrorInner::MissingSchedule { - schedule_name: schedule_name.into(), - })) - } - - /// Returns the inner error - pub fn inner(&self) -> &InteropErrorInner { - &self.0 - } -} - -/// For errors to do with reflection, type conversions or other interop issues -#[derive(Debug)] -pub enum InteropErrorInner { - /// Thrown if a callback requires world access, but is unable to do so due - StaleWorldAccess, - /// Thrown if a callback requires world access, but is unable to do so due - MissingWorld, - /// Thrown if a script could not be found when trying to call a synchronous callback. - /// The path or id is used depending on which stage the script was in when the error occurred. - MissingScript { - /// The script path that was not found. - script_path: Option, - /// The script id that was not found. - script_id: Option>, - }, - /// Thrown if a base type is not registered with the reflection system - UnregisteredBase { - /// The base type that was not registered - base: ReflectBaseType, - }, - /// Thrown if a base type is not registered with the reflection system - MissingTypeData { - /// The type that was missing data - type_id: TypeId, - /// The type data that was missing - type_data: String, - }, - /// Thrown if a type cannot be converted from reflect - FailedFromReflect { - /// The type that failed to convert - type_id: Option, - /// The reason for the failure - reason: String, - }, - /// Thrown if access to the given reflection base is required but cannot be claimed - CannotClaimAccess { - /// The base that could not be claimed - base: ReflectAccessId, - /// The context in which the error occurred - context: Cow<'static, str>, - /// The location in the code where the blocking access is being held - location: Option>, - }, - /// thrown when the access count is invalid - InvalidAccessCount { - /// The count of accesses - count: usize, - /// The expected count - expected: usize, - /// The context in which the error occurred - context: String, - }, - /// Thrown if a conversion into the given type is impossible - ImpossibleConversion { - /// The type that the conversion was attempted into - into: TypeId, - }, - /// Thrown if a conversion was not fully completed, as a better conversion exists - BetterConversionExists { - /// The context in which the error occurred - context: String, - }, - /// Thrown if a value was expected to be of one type but was of another - TypeMismatch { - /// The type that was expected - expected: TypeId, - /// The type that was received - got: Option, - }, - /// Thrown if a value was expected to be of one type but was of another - StringTypeMismatch { - /// The type that was expected - expected: String, - /// The type that was received - got: Option, - }, - /// Thrown if a [`ScriptValue`] could not be converted to the expected type - ValueMismatch { - /// The type that was expected - expected: TypeId, - /// The value that was received - got: ScriptValue, - }, - /// Thrown if a length mismatch occurs - LengthMismatch { - /// The length that was expected - expected: usize, - /// The length that was received - got: usize, - }, - /// Thrown if a downcast from a reflect reference to a specific type failed - CouldNotDowncast { - /// The reference that was attempted to be downcast - from: ReflectReference, - /// The type that the downcast was attempted to - to: TypeId, - }, - /// Thrown if a garbage collected allocation was attempted to be accessed - GarbageCollectedAllocation { - /// The reference that was attempted to be accessed - reference: ReflectReference, - }, - /// Thrown if a reflection path is invalid - ReflectionPathError { - /// The error that occurred - error: String, - /// The reference that was attempted to be accessed - reference: Option, - }, - /// Thrown if an operation is not supported on the given base type - UnsupportedOperation { - /// The base that the operation was attempted on - base: Option, - /// The value that was used in the operation - value: Option>, - /// The operation that was attempted - operation: String, - }, - /// Thrown if an invalid index operation was attempted on a value - InvalidIndex { - /// The value that was attempted to be indexed - value: ScriptValue, - /// The reason for the invalid index - reason: String, - }, - /// Thrown if an entity was missing or invalid - MissingEntity { - /// The entity that was missing - entity: Entity, - }, - /// Thrown if a component was invalid - InvalidComponent { - /// The component that was invalid - component_id: ComponentId, - }, - /// Thrown when an error happens during argument conversion in a function call - MissingFunctionError { - /// The type that the function was attempted to be called on - on: TypeId, - /// The function that was attempted to be called - function_name: String, - }, - /// Thrown when an error happens in the context of a function call - FunctionInteropError { - /// The function that the error occurred in - function_name: String, - /// The namespace that the function was called on - on: Namespace, - /// The error that occurred - error: InteropError, - }, - /// Thrown when an error happens that is not covered by the other variants - FunctionArgConversionError { - /// The argument that was attempted to be converted - argument: String, - /// The error that occurred - error: InteropError, - }, - /// Thrown when an error happens that is not covered by the other variants - OtherError { - /// The error that occurred - error: Box, - }, - /// Thrown when a component or resource type is not registered - UnregisteredComponentOrResourceType { - /// The type that was not registered - type_name: Cow<'static, str>, - }, - /// Thrown when constructing types and we find missing data - MissingDataInConstructor { - /// The type id of the type we're constructing - type_id: TypeId, - /// the name of the missing data - missing_data_name: Cow<'static, str>, - }, - /// Thrown when an invariant is violated - Invariant { - /// The message that describes the invariant violation - message: String, - }, - /// New variant for invalid enum variant errors. - InvalidEnumVariant { - /// the enum type id - type_id: TypeId, - /// the variant - variant_name: String, - }, - /// Thrown when the number of arguments in a function call does not match. - ArgumentCountMismatch { - /// The number of arguments that were expected - expected: usize, - /// The number of arguments that were received - got: usize, - }, - /// Thrown if the required context for an operation is missing. - MissingContext { - /// The script that was attempting to access the context - context_key: ContextKey, - }, - /// Thrown when a schedule is missing from the registry. - MissingSchedule { - /// The name of the schedule that was missing - schedule_name: Cow<'static, str>, - }, -} - -/// For test purposes -impl PartialEq for InteropErrorInner { - fn eq(&self, _other: &Self) -> bool { - match (self, _other) { - ( - InteropErrorInner::MissingScript { - script_id: a, - script_path: b, - }, - InteropErrorInner::MissingScript { - script_id: c, - script_path: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::InvalidAccessCount { - count: a, - expected: b, - context: c, - }, - InteropErrorInner::InvalidAccessCount { - count: d, - expected: e, - context: f, - }, - ) => a == d && b == e && c == f, - (InteropErrorInner::StaleWorldAccess, InteropErrorInner::StaleWorldAccess) => true, - (InteropErrorInner::MissingWorld, InteropErrorInner::MissingWorld) => true, - ( - InteropErrorInner::UnregisteredBase { base: a }, - InteropErrorInner::UnregisteredBase { base: b }, - ) => a == b, - ( - InteropErrorInner::MissingTypeData { - type_id: a, - type_data: b, - }, - InteropErrorInner::MissingTypeData { - type_id: c, - type_data: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::FailedFromReflect { - type_id: a, - reason: b, - }, - InteropErrorInner::FailedFromReflect { - type_id: c, - reason: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::CannotClaimAccess { - base: a, - context: b, - location: c, - }, - InteropErrorInner::CannotClaimAccess { - base: d, - context: e, - location: f, - }, - ) => a == d && b == e && c == f, - ( - InteropErrorInner::ImpossibleConversion { into: a }, - InteropErrorInner::ImpossibleConversion { into: b }, - ) => a == b, - ( - InteropErrorInner::BetterConversionExists { context: a }, - InteropErrorInner::BetterConversionExists { context: b }, - ) => a == b, - ( - InteropErrorInner::TypeMismatch { - expected: a, - got: b, - }, - InteropErrorInner::TypeMismatch { - expected: c, - got: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::StringTypeMismatch { - expected: a, - got: b, - }, - InteropErrorInner::StringTypeMismatch { - expected: c, - got: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::ValueMismatch { - expected: a, - got: b, - }, - InteropErrorInner::ValueMismatch { - expected: c, - got: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::LengthMismatch { - expected: a, - got: b, - }, - InteropErrorInner::LengthMismatch { - expected: c, - got: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::CouldNotDowncast { from: a, to: b }, - InteropErrorInner::CouldNotDowncast { from: c, to: d }, - ) => a == c && b == d, - ( - InteropErrorInner::GarbageCollectedAllocation { reference: a }, - InteropErrorInner::GarbageCollectedAllocation { reference: b }, - ) => a == b, - ( - InteropErrorInner::ReflectionPathError { - error: a, - reference: b, - }, - InteropErrorInner::ReflectionPathError { - error: c, - reference: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::UnsupportedOperation { - base: a, - value: _b, - operation: c, - }, - InteropErrorInner::UnsupportedOperation { - base: d, - value: _e, - operation: f, - }, - ) => a == d && c == f, - ( - InteropErrorInner::InvalidIndex { - value: a, - reason: b, - }, - InteropErrorInner::InvalidIndex { - value: c, - reason: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::MissingEntity { entity: a }, - InteropErrorInner::MissingEntity { entity: b }, - ) => a == b, - ( - InteropErrorInner::InvalidComponent { component_id: a }, - InteropErrorInner::InvalidComponent { component_id: b }, - ) => a == b, - ( - InteropErrorInner::MissingFunctionError { - on: a, - function_name: _b, - }, - InteropErrorInner::MissingFunctionError { - on: c, - function_name: _d, - }, - ) => a == c, - ( - InteropErrorInner::FunctionInteropError { - function_name: a, - on: b, - error: c, - }, - InteropErrorInner::FunctionInteropError { - function_name: d, - on: e, - error: f, - }, - ) => a == d && b == e && c == f, - ( - InteropErrorInner::FunctionArgConversionError { - argument: a, - error: b, - }, - InteropErrorInner::FunctionArgConversionError { - argument: c, - error: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::OtherError { error: a }, - InteropErrorInner::OtherError { error: b }, - ) => a.to_string() == b.to_string(), - ( - InteropErrorInner::UnregisteredComponentOrResourceType { type_name: a }, - InteropErrorInner::UnregisteredComponentOrResourceType { type_name: b }, - ) => a == b, - ( - InteropErrorInner::Invariant { message: a }, - InteropErrorInner::Invariant { message: b }, - ) => a == b, - ( - InteropErrorInner::MissingDataInConstructor { - type_id: a, - missing_data_name: b, - }, - InteropErrorInner::MissingDataInConstructor { - type_id: c, - missing_data_name: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::InvalidEnumVariant { - type_id: a, - variant_name: b, - }, - InteropErrorInner::InvalidEnumVariant { - type_id: c, - variant_name: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::ArgumentCountMismatch { - expected: a, - got: b, - }, - InteropErrorInner::ArgumentCountMismatch { - expected: c, - got: d, - }, - ) => a == c && b == d, - ( - InteropErrorInner::MissingContext { context_key: b }, - InteropErrorInner::MissingContext { context_key: d }, - ) => b == d, - ( - InteropErrorInner::MissingSchedule { schedule_name: a }, - InteropErrorInner::MissingSchedule { schedule_name: b }, - ) => a == b, - _ => false, - } - } -} - -macro_rules! missing_function_error { - ($function_name:expr, $on:expr) => { - format!( - "Could not find function: {} for type: {}", - $function_name, $on - ) - }; -} - -macro_rules! unregistered_base { - ($base:expr) => { - format!("Unregistered base type: {}", $base) - }; -} - -macro_rules! cannot_claim_access { - ($base:expr, $location:expr, $ctxt:expr) => { - format!( - "Cannot claim access to base type: {}. The base is already claimed by something else in a way which prevents safe access. Location: {}. Context: {}", - $base, $location, $ctxt - ) - }; -} - -macro_rules! impossible_conversion { - ($into:expr) => { - format!("Cannot convert to type: {}", $into) - }; -} - -macro_rules! type_mismatch { - ($expected:expr, $got:expr) => { - format!("Type mismatch, expected: {}, got: {}", $expected, $got) - }; -} - -macro_rules! string_type_mismatch { - ($expected:expr, $got:expr) => { - format!("Type mismatch, expected: {}, got: {}", $expected, $got) - }; -} - -macro_rules! could_not_downcast { - ($from:expr, $to:expr) => { - format!("Could not downcast from: {} to: {}", $from, $to) - }; -} - -macro_rules! garbage_collected_allocation { - ($reference:expr) => { - format!( - "Allocation was garbage collected. Could not access reference: {} as a result.", - $reference - ) - }; -} - -macro_rules! reflection_path_error { - ($error:expr, $reference:expr) => { - format!( - "Error while reflecting path: {} on reference: {}", - $error, $reference - ) - }; -} - -macro_rules! missing_type_data { - ($type_data:expr, $type_id:expr) => { - format!( - "Missing type data {} for type: {}. Did you register the type correctly?", - $type_data, $type_id - ) - }; -} - -macro_rules! failed_from_reflect { - ($type_id:expr, $reason:expr) => { - format!( - "Failed to convert from reflect for type: {} with reason: {}", - $type_id, $reason - ) - }; -} - -macro_rules! value_mismatch { - ($expected:expr, $got:expr) => { - format!("Value mismatch, expected: {}, got: {}", $expected, $got) - }; -} - -macro_rules! unsupported_operation { - ($operation:expr, $base:expr, $value:expr) => { - format!( - "Unsupported operation: {} on base: {} with value: {:?}", - $operation, $base, $value - ) - }; -} - -macro_rules! invalid_index { - ($value:expr, $reason:expr) => { - format!("Invalid index for value: {}: {}", $value, $reason) - }; -} - -macro_rules! missing_entity { - ($entity:expr) => { - { - if ($entity.index() == 0) { - format!("Invalid entity: {}. Are you trying to use an entity in a callback in which it's unavailable?", $entity) - } else { - format!("Missing or invalid entity: {}", $entity) - } - } - }; -} - -macro_rules! invalid_component { - ($component_id:expr) => { - format!("Invalid component: {:?}", $component_id) - }; -} - -macro_rules! function_interop_error { - ($display_name:expr, $opt_on:expr, $error:expr) => { - format!( - "Error in function {} {}: {}", - $display_name, $opt_on, $error - ) - }; -} - -macro_rules! function_arg_conversion_error { - ($argument:expr, $error:expr) => { - format!("Error converting argument {}: {}", $argument, $error) - }; -} - -macro_rules! better_conversion_exists { - ($context:expr) => { - format!("Unfinished conversion in context of: {}. A better conversion exists but caller didn't handle the case.", $context) - }; -} - -macro_rules! length_mismatch { - ($expected:expr, $got:expr) => { - format!( - "Array/List Length mismatch, expected: {}, got: {}", - $expected, $got - ) - }; -} - -macro_rules! invalid_access_count { - ($expected:expr, $count:expr, $context:expr) => { - format!( - "Invalid access count, expected: {}, got: {}. {}", - $expected, $count, $context - ) - }; -} - -macro_rules! missing_data_in_constructor { - ($type_id:expr, $missing_data_name:expr) => { - format!( - "Missing data in constructor for type: {}. Missing data: {}", - $type_id, $missing_data_name - ) - }; -} - -macro_rules! invariant { - ($message:expr) => { - format!( - "An invariant has been broken. This is a bug in BMS, please report me! : {}", - $message - ) - }; -} - -macro_rules! unregistered_component_or_resource_type { - ($type_name:expr) => { - format!( - "Expected registered component/resource but got unregistered type: {}", - $type_name - ) - }; -} - -macro_rules! missing_script_for_callback { - ($script_id:expr, $script_path:expr) => { - format!( - "Could not find script {}. Is the script loaded?", - $script_id.map_or_else( - || $script_path.unwrap_or_default(), - |id| id.display().to_string() - ) - ) - }; -} - -// Define a single macro for the invalid enum variant error. -macro_rules! invalid_enum_variant_msg { - ($variant:expr, $enum_display:expr) => { - format!( - "Invalid enum variant: {} for enum: {}", - $variant, $enum_display - ) - }; -} - -// Define a single macro for the argument count mismatch error. -macro_rules! argument_count_mismatch_msg { - ($expected:expr, $got:expr) => { - format!( - "Argument count mismatch, expected: {}, got: {}", - $expected, $got - ) - }; -} - -macro_rules! missing_context_for_callback { - ($context_key:expr) => { - format!( - "Missing context for {}. Was the script loaded?.", - $context_key - ) - }; -} - -macro_rules! missing_schedule_error { - ($schedule:expr) => { - format!("Missing schedule: '{}'. This can happen if you try to access a schedule from within itself. Have all schedules been registered?", $schedule) - }; -} - -impl DisplayWithWorld for InteropErrorInner { - fn display_with_world(&self, world: crate::bindings::WorldGuard) -> String { - match self { - InteropErrorInner::MissingFunctionError { on, function_name } => { - missing_function_error!(function_name, on.display_with_world(world)) - }, - InteropErrorInner::UnregisteredBase { base } => { - unregistered_base!(base.display_with_world(world)) - } - InteropErrorInner::CannotClaimAccess { base, location, context } => { - cannot_claim_access!(base.display_with_world(world), location.display_location(), context) - } - InteropErrorInner::ImpossibleConversion { into } => { - impossible_conversion!(into.display_with_world(world)) - } - InteropErrorInner::TypeMismatch { expected, got } => { - type_mismatch!( - expected.display_with_world(world.clone()), - got.map(|t| t.display_with_world(world)) - .unwrap_or("None".to_owned()) - ) - } - InteropErrorInner::StringTypeMismatch { expected, got } => { - string_type_mismatch!( - expected, - got.map(|t| t.display_with_world(world)) - .unwrap_or("None".to_owned()) - ) - } - InteropErrorInner::CouldNotDowncast { from, to } => { - could_not_downcast!( - from.display_with_world(world.clone()), - to.display_with_world(world) - ) - } - InteropErrorInner::GarbageCollectedAllocation { reference } => { - garbage_collected_allocation!(reference.display_with_world(world)) - } - InteropErrorInner::ReflectionPathError { error, reference } => { - reflection_path_error!( - error, - reference - .as_ref() - .map(|r| r.display_with_world(world)) - .unwrap_or("None".to_owned()) - ) - } - InteropErrorInner::MissingTypeData { type_id, type_data } => { - missing_type_data!(type_data, type_id.display_with_world(world)) - } - InteropErrorInner::FailedFromReflect { type_id, reason } => { - failed_from_reflect!( - type_id - .map(|t| t.display_with_world(world)) - .unwrap_or("None".to_owned()), - reason - ) - } - InteropErrorInner::ValueMismatch { expected, got } => { - value_mismatch!( - expected.display_with_world(world.clone()), - got.display_with_world(world) - ) - } - InteropErrorInner::UnsupportedOperation { - base, - value, - operation, - } => { - unsupported_operation!( - operation, - base.map(|t| t.display_with_world(world)) - .unwrap_or("None".to_owned()), - value - ) - } - InteropErrorInner::InvalidIndex { value, reason } => { - invalid_index!(value.display_with_world(world), reason) - } - InteropErrorInner::MissingEntity { entity } => { - missing_entity!(entity) - } - InteropErrorInner::InvalidComponent { component_id } => { - invalid_component!(component_id) - } - InteropErrorInner::StaleWorldAccess => { - "Stale world access. The world has been dropped and a script tried to access it. Do not try to store or copy the world." - .to_owned() - } - InteropErrorInner::MissingWorld => { - "Missing world. The world was either not initialized, or invalidated.".to_owned() - }, - InteropErrorInner::FunctionInteropError { function_name, on, error } => { - let opt_on = match on { - Namespace::Global => "".to_owned(), - Namespace::OnType(type_id) => format!("on type: {}", type_id.display_with_world(world.clone())), - }; - let display_name = if function_name.starts_with("TypeId") { - function_name.split("::").last().unwrap_or_default() - } else { - function_name.as_str() - }; - function_interop_error!(display_name, opt_on, error.display_with_world(world)) - }, - InteropErrorInner::FunctionArgConversionError { argument, error } => { - function_arg_conversion_error!(argument, error.display_with_world(world)) - }, - InteropErrorInner::BetterConversionExists{ context } => { - better_conversion_exists!(context) - }, - InteropErrorInner::OtherError { error } => error.to_string(), - InteropErrorInner::LengthMismatch { expected, got } => { - length_mismatch!(expected, got) - }, - InteropErrorInner::InvalidAccessCount { count, expected, context } => { - invalid_access_count!(expected, count, context) - }, - InteropErrorInner::Invariant { message } => { - invariant!(message) - }, - InteropErrorInner::UnregisteredComponentOrResourceType { type_name } => { - unregistered_component_or_resource_type!(type_name) - }, - InteropErrorInner::MissingDataInConstructor { type_id, missing_data_name } => { - missing_data_in_constructor!(type_id.display_with_world(world), missing_data_name) - }, - InteropErrorInner::InvalidEnumVariant { type_id, variant_name } => { - invalid_enum_variant_msg!(variant_name, type_id.display_with_world(world)) - }, - InteropErrorInner::ArgumentCountMismatch { expected, got } => { - argument_count_mismatch_msg!(expected, got) - }, - InteropErrorInner::MissingScript { script_id, script_path } => { - missing_script_for_callback!(script_id.clone(), script_path.clone()) - }, - InteropErrorInner::MissingContext { context_key } => { - missing_context_for_callback!( - context_key - ) - }, - InteropErrorInner::MissingSchedule { schedule_name } => { - missing_schedule_error!(schedule_name) - }, - } - } - - // todo macro this, or use format strings to reduce duplication - fn display_without_world(&self) -> String { - match self { - InteropErrorInner::MissingFunctionError { on, function_name } => { - missing_function_error!(function_name, on.display_without_world()) - }, - InteropErrorInner::UnregisteredBase { base } => { - unregistered_base!(base.display_without_world()) - } - InteropErrorInner::CannotClaimAccess { base, location, context } => { - cannot_claim_access!(base.display_without_world(), location.display_location(), context) - } - InteropErrorInner::ImpossibleConversion { into } => { - impossible_conversion!(into.display_without_world()) - } - InteropErrorInner::TypeMismatch { expected, got } => { - type_mismatch!( - expected.display_without_world(), - got.map(|t| t.display_without_world()) - .unwrap_or("None".to_owned()) - ) - } - InteropErrorInner::StringTypeMismatch { expected, got } => { - string_type_mismatch!( - expected, - got.map(|t| t.display_without_world()) - .unwrap_or("None".to_owned()) - ) - } - InteropErrorInner::CouldNotDowncast { from, to } => { - could_not_downcast!( - from.display_without_world(), - to.display_without_world() - ) - } - InteropErrorInner::GarbageCollectedAllocation { reference } => { - garbage_collected_allocation!(reference.display_without_world()) - } - InteropErrorInner::ReflectionPathError { error, reference } => { - reflection_path_error!( - error, - reference - .as_ref() - .map(|r| r.display_without_world()) - .unwrap_or("None".to_owned()) - ) - } - InteropErrorInner::MissingTypeData { type_id, type_data } => { - missing_type_data!(type_data, type_id.display_without_world()) - } - InteropErrorInner::FailedFromReflect { type_id, reason } => { - failed_from_reflect!( - type_id - .map(|t| t.display_without_world()) - .unwrap_or("None".to_owned()), - reason - ) - } - InteropErrorInner::ValueMismatch { expected, got } => { - value_mismatch!( - expected.display_without_world(), - got.display_without_world() - ) - } - InteropErrorInner::UnsupportedOperation { - base, - value, - operation, - } => { - unsupported_operation!( - operation, - base.map(|t| t.display_without_world()) - .unwrap_or("None".to_owned()), - value - ) - } - InteropErrorInner::InvalidIndex { value, reason } => { - invalid_index!(value.display_without_world(), reason) - } - InteropErrorInner::MissingEntity { entity } => { - missing_entity!(entity) - } - InteropErrorInner::InvalidComponent { component_id } => { - invalid_component!(component_id) - } - InteropErrorInner::StaleWorldAccess => { - "Stale world access. The world has been dropped and a script tried to access it. Do not try to store or copy the world." - .to_owned() - } - InteropErrorInner::MissingWorld => { - "Missing world. The world was either not initialized, or invalidated.".to_owned() - }, - InteropErrorInner::FunctionInteropError { function_name, on, error } => { - let opt_on = match on { - Namespace::Global => "".to_owned(), - Namespace::OnType(type_id) => format!("on type: {}", type_id.display_without_world()), - }; - let display_name = if function_name.starts_with("TypeId") { - function_name.split("::").last().unwrap_or_default() - } else { - function_name.as_str() - }; - function_interop_error!(display_name, opt_on, error.display_without_world()) - }, - InteropErrorInner::FunctionArgConversionError { argument, error } => { - function_arg_conversion_error!(argument, error.display_without_world()) - }, - InteropErrorInner::BetterConversionExists{ context } => { - better_conversion_exists!(context) - }, - InteropErrorInner::OtherError { error } => error.to_string(), - InteropErrorInner::LengthMismatch { expected, got } => { - length_mismatch!(expected, got) - }, - InteropErrorInner::InvalidAccessCount { count, expected, context } => { - invalid_access_count!(expected, count, context) - }, - InteropErrorInner::Invariant { message } => { - invariant!(message) - }, - InteropErrorInner::UnregisteredComponentOrResourceType { type_name } => { - unregistered_component_or_resource_type!(type_name) - }, - InteropErrorInner::MissingDataInConstructor { type_id, missing_data_name } => { - missing_data_in_constructor!(type_id.display_without_world(), missing_data_name) - }, - InteropErrorInner::InvalidEnumVariant { type_id, variant_name } => { - invalid_enum_variant_msg!(variant_name, type_id.display_without_world()) - }, - InteropErrorInner::ArgumentCountMismatch { expected, got } => { - argument_count_mismatch_msg!(expected, got) - }, - InteropErrorInner::MissingScript { script_id, script_path } => { - missing_script_for_callback!(script_id.clone(), script_path.clone()) - }, - InteropErrorInner::MissingContext { context_key } => { - missing_context_for_callback!( - context_key - ) - }, - InteropErrorInner::MissingSchedule { schedule_name } => { - missing_schedule_error!(schedule_name) - }, - } - } -} - -/// Purely for purposes of the automatic [`GetTypeRegistration`] impl. -impl Default for InteropErrorInner { - fn default() -> Self { - InteropErrorInner::StaleWorldAccess - } -} - -#[cfg(test)] -mod test { - - use bevy_ecs::{reflect::AppTypeRegistry, world::World}; - - use super::*; - use crate::bindings::{ - AppReflectAllocator, WorldGuard, function::script_function::AppScriptFunctionRegistry, - }; - - #[test] - fn test_error_display() { - let error = - InteropError::failed_from_reflect(Some(TypeId::of::()), "reason".to_owned()); - let mut world = World::default(); - let type_registry = AppTypeRegistry::default(); - world.insert_resource(type_registry); - - let script_allocator = AppReflectAllocator::default(); - world.insert_resource(script_allocator); - - let script_function_registry = AppScriptFunctionRegistry::default(); - world.insert_resource(script_function_registry); - - let world_guard = WorldGuard::new_exclusive(&mut world); - assert_eq!( - error.display_with_world(world_guard), - format!( - "Failed to convert from reflect for type: {} with reason: reason", - std::any::type_name::() - ) - ); - - assert_eq!( - error.display_without_world(), - format!( - "Failed to convert from reflect for type: {:?} with reason: reason", - TypeId::of::() - ) - ); - } -} diff --git a/crates/bevy_mod_scripting_core/src/event.rs b/crates/bevy_mod_scripting_core/src/event.rs index 954b56438c..005014cfda 100644 --- a/crates/bevy_mod_scripting_core/src/event.rs +++ b/crates/bevy_mod_scripting_core/src/event.rs @@ -5,11 +5,11 @@ use std::sync::Arc; use ::{bevy_asset::Handle, bevy_ecs::entity::Entity, bevy_reflect::Reflect}; use bevy_ecs::event::Event; use bevy_mod_scripting_asset::Language; +use bevy_mod_scripting_bindings::ScriptValue; use parking_lot::Mutex; use crate::{ IntoScriptPluginParams, - bindings::script_value::ScriptValue, error::ScriptError, script::{ScriptAttachment, ScriptContext, ScriptId}, }; @@ -409,6 +409,7 @@ static FORBIDDEN_KEYWORDS: [&str; 82] = [ #[cfg(test)] mod test { + use super::*; use std::sync::Arc; use ::{ @@ -421,7 +422,6 @@ mod test { use super::FORBIDDEN_KEYWORDS; use crate::{ - bindings::ScriptValue, config::{GetPluginThreadConfig, ScriptingPluginConfiguration}, event::Recipients, script::{ContextPolicy, ScriptAttachment, ScriptContext}, diff --git a/crates/bevy_mod_scripting_core/src/extractors.rs b/crates/bevy_mod_scripting_core/src/extractors.rs index b0280efa0c..7bc1cdfa0a 100644 --- a/crates/bevy_mod_scripting_core/src/extractors.rs +++ b/crates/bevy_mod_scripting_core/src/extractors.rs @@ -2,6 +2,14 @@ //! //! These are designed to be used to pipe inputs into other systems which require them, while handling any configuration erorrs nicely. +use crate::{ + IntoScriptPluginParams, + context::Context, + error::ScriptError, + event::{CallbackLabel, IntoCallbackLabel}, + handler::ScriptingHandler, + script::ScriptAttachment, +}; use bevy_ecs::{ archetype::Archetype, component::{ComponentId, Tick}, @@ -10,21 +18,12 @@ use bevy_ecs::{ system::{SystemMeta, SystemParam, SystemParamValidationError}, world::{DeferredWorld, World, unsafe_world_cell::UnsafeWorldCell}, }; -use fixedbitset::FixedBitSet; - -use crate::{ - IntoScriptPluginParams, - bindings::{ - WorldAccessGuard, WorldGuard, access_map::ReflectAccessId, pretty_print::DisplayWithWorld, - script_value::ScriptValue, - }, - context::Context, - error::ScriptError, - event::{CallbackLabel, IntoCallbackLabel}, - handler::ScriptingHandler, - script::ScriptAttachment, +use bevy_mod_scripting_bindings::{ + WorldAccessGuard, WorldGuard, access_map::ReflectAccessId, script_value::ScriptValue, }; +use fixedbitset::FixedBitSet; + /// A reverse mapping from plugin context types to their plugin types. /// Useful in implementing generic traits on context types. pub trait GetPluginFor { @@ -135,14 +134,12 @@ unsafe impl SystemParam for WithWorldGuard<'_, '_, T> { if *is_write { if !guard.claim_write_access(*raid) { panic!( - "System tried to access set of system params which break rust aliasing rules. Aliasing access: {}", - (*raid).display_with_world(guard.clone()) + "System tried to access set of system params which break rust aliasing rules. Aliasing access: {raid:#?}", ); } } else if !guard.claim_read_access(*raid) { panic!( - "System tried to access set of system params which break rust aliasing rules. Aliasing access: {}", - (*raid).display_with_world(guard.clone()) + "System tried to access set of system params which break rust aliasing rules. Aliasing access: {raid:#?}", ); } } diff --git a/crates/bevy_mod_scripting_core/src/handler.rs b/crates/bevy_mod_scripting_core/src/handler.rs index 94b96c8443..5f9f8db912 100644 --- a/crates/bevy_mod_scripting_core/src/handler.rs +++ b/crates/bevy_mod_scripting_core/src/handler.rs @@ -1,13 +1,12 @@ //! Contains the logic for handling script callback events use bevy_ecs::world::WorldId; +use bevy_mod_scripting_bindings::{ + ScriptValue, ThreadWorldContainer, WorldAccessGuard, WorldContainer, WorldGuard, +}; use crate::extractors::CallContext; use crate::{ IntoScriptPluginParams, Language, - bindings::{ - ThreadWorldContainer, WorldAccessGuard, WorldContainer, WorldGuard, - pretty_print::DisplayWithWorld, script_value::ScriptValue, - }, error::ScriptError, event::{ CallbackLabel, IntoCallbackLabel, ScriptCallbackEvent, ScriptCallbackResponseEvent, @@ -114,10 +113,7 @@ pub(crate) fn event_handler_inner( let events = match events { Ok(events) => events, Err(err) => { - error!( - "Failed to read script callback events: {}", - err.display_with_world(guard) - ); + error!("Failed to read script callback events: {err}",); return; } }; @@ -174,10 +170,7 @@ pub fn send_callback_response(world: WorldGuard, response: ScriptCallbackRespons }); if let Err(err) = err { - error!( - "Failed to send script callback response: {}", - err.display_with_world(world.clone()) - ); + error!("Failed to send script callback response: {err}",); } } @@ -190,13 +183,10 @@ pub fn handle_script_errors + Clone>(world: Worl }); if let Err(err) = err { - error!( - "Failed to send script error events: {}", - err.display_with_world(world.clone()) - ); + error!("Failed to send script error events: {err}",); } for error in errors { - error!("{}", error.display_with_world(world.clone())); + error!("{error}"); } } diff --git a/crates/bevy_mod_scripting_core/src/lib.rs b/crates/bevy_mod_scripting_core/src/lib.rs index a65a844c73..e0b6de4798 100644 --- a/crates/bevy_mod_scripting_core/src/lib.rs +++ b/crates/bevy_mod_scripting_core/src/lib.rs @@ -3,7 +3,6 @@ //! Contains language agnostic systems and types for handling scripting in bevy. use crate::{ - bindings::MarkAsCore, config::{GetPluginThreadConfig, ScriptingPluginConfiguration}, context::{ContextLoadFn, ContextReloadFn}, event::ScriptErrorEvent, @@ -19,10 +18,11 @@ use bevy_ecs::{ }; use bevy_log::error; use bevy_mod_scripting_asset::{Language, LanguageExtensions, ScriptAsset, ScriptAssetLoader}; -use bindings::{ - AppReflectAllocator, DynamicScriptComponentPlugin, ReflectAllocator, ReflectReference, - ScriptTypeRegistration, function::script_function::AppScriptFunctionRegistry, - garbage_collector, schedule::AppScheduleRegistry, script_value::ScriptValue, + +use bevy_mod_scripting_bindings::{ + AppReflectAllocator, AppScheduleRegistry, AppScriptFunctionRegistry, + DynamicScriptComponentPlugin, MarkAsCore, ReflectReference, ScriptTypeRegistration, + ScriptValue, ThreadWorldContainer, garbage_collector, }; use commands::{AddStaticScript, RemoveStaticScript}; use context::{Context, ContextInitializer, ContextPreHandlingInitializer}; @@ -32,20 +32,16 @@ use runtime::{Runtime, RuntimeInitializer}; use script::{ContextPolicy, ScriptComponent, ScriptContext}; pub mod asset; -pub mod bindings; pub mod commands; pub mod config; pub mod context; -pub mod docgen; pub mod error; pub mod event; pub mod extractors; pub mod handler; -pub mod reflection_extensions; pub mod runtime; pub mod script; - -pub(crate) mod private; +pub mod script_system; #[derive(SystemSet, Hash, Debug, Eq, PartialEq, Clone)] /// Labels for various BMS systems @@ -332,6 +328,9 @@ impl Plugin for BMSScriptingInfrastructurePlugin { app.add_plugins(configure_asset_systems); + let _ = bevy_mod_scripting_display::GLOBAL_TYPE_INFO_PROVIDER + .set(|| Some(&ThreadWorldContainer)); + DynamicScriptComponentPlugin.build(app); } diff --git a/crates/bevy_mod_scripting_core/src/private/mod.rs b/crates/bevy_mod_scripting_core/src/private/mod.rs deleted file mode 100644 index 0e66f3ef74..0000000000 --- a/crates/bevy_mod_scripting_core/src/private/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -//! This module contains private functions and modules that are used internally by the crate. - -macro_rules! export_all_in_modules { - ( $( $module:ident ),* $(,)? ) => { - $( - pub mod $module; - )* - pub use { - $( $module::*, )* - }; - }; -} - -pub(crate) use export_all_in_modules; diff --git a/crates/bevy_mod_scripting_core/src/script/context_key.rs b/crates/bevy_mod_scripting_core/src/script/context_key.rs index 45f695441a..c21d340a95 100644 --- a/crates/bevy_mod_scripting_core/src/script/context_key.rs +++ b/crates/bevy_mod_scripting_core/src/script/context_key.rs @@ -121,7 +121,7 @@ impl fmt::Display for ContextKey { impl ContextKey { /// Creates an invalid context key, which should never exist. pub const INVALID: Self = Self { - entity: Some(Entity::from_raw(0)), + entity: Some(Entity::PLACEHOLDER), script: Some(Handle::Weak(AssetId::invalid())), }; diff --git a/crates/bevy_mod_scripting_core/src/script/script_context.rs b/crates/bevy_mod_scripting_core/src/script/script_context.rs index 1cef84fbda..4f11fc554b 100644 --- a/crates/bevy_mod_scripting_core/src/script/script_context.rs +++ b/crates/bevy_mod_scripting_core/src/script/script_context.rs @@ -437,6 +437,7 @@ mod tests { use crate::config::{GetPluginThreadConfig, ScriptingPluginConfiguration}; use bevy_app::{App, Plugin}; use bevy_asset::AssetIndex; + use bevy_mod_scripting_bindings::ScriptValue; use test_utils::make_test_plugin; use super::*; diff --git a/crates/bevy_mod_scripting_core/src/bindings/script_system.rs b/crates/bevy_mod_scripting_core/src/script_system.rs similarity index 83% rename from crates/bevy_mod_scripting_core/src/bindings/script_system.rs rename to crates/bevy_mod_scripting_core/src/script_system.rs index c8d50ac20e..320d5728cf 100644 --- a/crates/bevy_mod_scripting_core/src/bindings/script_system.rs +++ b/crates/bevy_mod_scripting_core/src/script_system.rs @@ -1,22 +1,12 @@ //! everything to do with dynamically added script systems -use super::{ - AppReflectAllocator, AppScriptComponentRegistry, ReflectBaseType, ReflectReference, - ScriptQueryBuilder, ScriptQueryResult, ScriptResourceRegistration, WorldAccessGuard, - WorldGuard, - access_map::ReflectAccessId, - function::{from::Val, into::IntoScript, script_function::AppScriptFunctionRegistry}, - schedule::AppScheduleRegistry, -}; -use crate::extractors::CallContext; use crate::{ IntoScriptPluginParams, - bindings::pretty_print::DisplayWithWorld, - error::InteropError, event::CallbackLabel, - extractors::get_all_access_ids, + extractors::{CallContext, get_all_access_ids}, script::{ScriptAttachment, ScriptContext}, }; + use ::{ bevy_ecs::{ archetype::{ArchetypeComponentId, ArchetypeGeneration}, @@ -28,15 +18,21 @@ use ::{ system::{IntoSystem, System, SystemParamValidationError}, world::{World, unsafe_world_cell::UnsafeWorldCell}, }, - bevy_reflect::{OffsetAccess, ParsedPath, Reflect}, + bevy_reflect::Reflect, }; use bevy_app::DynEq; use bevy_ecs::{ - schedule::{InternedSystemSet, IntoScheduleConfigs}, + schedule::{InternedSystemSet, IntoScheduleConfigs, Schedule, Schedules}, system::SystemIn, world::DeferredWorld, }; -use bevy_log::{error, info, warn_once}; +use bevy_log::{debug, error, info, warn_once}; +use bevy_mod_scripting_bindings::{ + AppReflectAllocator, AppScheduleRegistry, AppScriptComponentRegistry, + AppScriptFunctionRegistry, InteropError, IntoScript, ReflectAccessId, ReflectReference, + ScriptQueryBuilder, ScriptQueryResult, ScriptResourceRegistration, Val, WorldAccessGuard, + WorldGuard, +}; use bevy_system_reflection::{ReflectSchedule, ReflectSystem}; use std::{ any::TypeId, borrow::Cow, collections::HashSet, hash::Hash, marker::PhantomData, ops::Deref, @@ -184,10 +180,11 @@ impl ScriptSystemBuilder { // if this is slow, we can always just get the node id that way // and let the schedule initialize itself right before it gets run // for now I want to avoid not having the right ID as that'd be a pain - schedule.initialize(world)?; + schedule.initialize(world).map_err(InteropError::external)?; // now find the system let (node_id, system) = schedule - .systems()? + .systems() + .map_err(InteropError::external)? .find(|(_, b)| b.name().deref() == system_name) .ok_or_else(|| InteropError::invariant("After adding the system, it was not found in the schedule, could not return a reference to it"))?; Ok(ReflectSystem::from_system(system.as_ref(), node_id)) @@ -352,13 +349,7 @@ impl System for DynamicScriptSystem

{ component_id, type_id, } => { - let res_ref = ReflectReference { - base: super::ReflectBaseType { - type_id: *type_id, - base_id: super::ReflectBase::Resource(*component_id), - }, - reflect_path: ParsedPath::from(Vec::::default()), - }; + let res_ref = ReflectReference::new_resource_ref_by_id(*component_id, *type_id); payload.push(res_ref.into_script_inline_error(guard.clone())); } ScriptSystemParam::EntityQuery { query, components } => { @@ -371,15 +362,12 @@ impl System for DynamicScriptSystem

{ entity, components: components .iter() - .map(|(component_id, type_id)| ReflectReference { - base: ReflectBaseType { - type_id: *type_id, - base_id: super::ReflectBase::Component( - entity, - *component_id, - ), - }, - reflect_path: Vec::::default().into(), + .map(|(component_id, type_id)| { + ReflectReference::new_component_ref_by_id( + entity, + *component_id, + *type_id, + ) }) .collect(), }) @@ -411,11 +399,7 @@ impl System for DynamicScriptSystem

{ match result { Ok(_) => {} Err(err) => { - error!( - "Error in dynamic script system `{}`: {}", - self.name, - err.display_with_world(guard) - ) + error!("Error in dynamic script system `{}`: {:#?}", self.name, err) } } } else { @@ -579,6 +563,102 @@ impl System for DynamicScriptSystem

{ } } +/// A trait for managing script systems in schedules dynamically +pub trait ManageScriptSystems { + /// Temporarilly removes the given schedule from the world, and calls the given function on it, then re-inserts it. + /// + /// Useful for initializing schedules, or modifying systems + fn scope_schedule O>( + &self, + label: &ReflectSchedule, + f: F, + ) -> Result; + + /// Retrieves all the systems in a schedule + fn systems(&self, schedule: &ReflectSchedule) -> Result, InteropError>; + + /// Creates a system from a system builder and inserts it into the given schedule + fn add_system( + &self, + schedule: &ReflectSchedule, + builder: ScriptSystemBuilder, + ) -> Result; +} + +impl ManageScriptSystems for WorldGuard<'_> { + /// Temporarilly removes the given schedule from the world, and calls the given function on it, then re-inserts it. + /// + /// Useful for initializing schedules, or modifying systems + fn scope_schedule O>( + &self, + label: &ReflectSchedule, + f: F, + ) -> Result { + self.with_global_access(|world| { + let mut schedules = world.get_resource_mut::().ok_or_else(|| { + InteropError::unsupported_operation( + None, + None, + "accessing schedules in a world with no schedules", + ) + })?; + + let mut removed_schedule = schedules + .remove(*label.label()) + .ok_or_else(|| InteropError::missing_schedule(label.identifier()))?; + + let result = f(world, &mut removed_schedule); + + let mut schedules = world.get_resource_mut::().ok_or_else(|| { + InteropError::unsupported_operation( + None, + None, + "removing `Schedules` resource within a schedule scope", + ) + })?; + + assert!( + removed_schedule.label() == *label.label(), + "removed schedule label doesn't match the original" + ); + schedules.insert(removed_schedule); + + Ok(result) + })? + } + + /// Retrieves all the systems in a schedule + fn systems(&self, schedule: &ReflectSchedule) -> Result, InteropError> { + self.with_resource(|schedules: &Schedules| { + let schedule = schedules + .get(*schedule.label()) + .ok_or_else(|| InteropError::missing_schedule(schedule.identifier()))?; + + let systems = schedule.systems().map_err(InteropError::external)?; + + Ok(systems + .map(|(node_id, system)| ReflectSystem::from_system(system.as_ref(), node_id)) + .collect()) + })? + } + + /// Creates a system from a system builder and inserts it into the given schedule + fn add_system( + &self, + schedule: &ReflectSchedule, + builder: ScriptSystemBuilder, + ) -> Result { + debug!( + "Adding script system '{}' for script '{}' to schedule '{}'", + builder.name, + builder.attachment, + schedule.identifier() + ); + + builder.build::

(self.clone(), schedule) + } +} + #[cfg(test)] mod test { use ::{ @@ -590,6 +670,7 @@ mod test { schedule::{ScheduleLabel, Schedules}, }, }; + use bevy_mod_scripting_bindings::ScriptValue; use test_utils::make_test_plugin; use crate::{ @@ -606,7 +687,6 @@ mod test { #[test] fn test_script_system_with_existing_system_dependency_can_execute() { let mut app = App::new(); - #[derive(ScheduleLabel, Clone, Debug, Hash, PartialEq, Eq)] struct TestSchedule; diff --git a/crates/bevy_mod_scripting_derive/src/derive/debug_with_type_info.rs b/crates/bevy_mod_scripting_derive/src/derive/debug_with_type_info.rs new file mode 100644 index 0000000000..bb013424d2 --- /dev/null +++ b/crates/bevy_mod_scripting_derive/src/derive/debug_with_type_info.rs @@ -0,0 +1,231 @@ +use proc_macro2::{Span, TokenStream}; +use quote::format_ident; +use syn::{DeriveInput, Ident, parse_macro_input, parse_quote}; + +struct Args { + bms_display_path: syn::Path, + remote: bool, +} + +impl Args { + fn parse(input: &[syn::Attribute]) -> syn::Result { + let mut args = Args { + bms_display_path: parse_quote!(::bevy_mod_scripting::display), + remote: false, + }; + + for attr in input { + if attr.path().is_ident("debug_with_type_info") { + attr.parse_nested_meta(|meta| { + if meta.path.is_ident("bms_display_path") { + let value = meta.value()?; + let string: syn::LitStr = value.parse()?; + args.bms_display_path = string.parse()?; + Ok(()) + } else if meta.path.is_ident("remote") { + args.remote = true; + Ok(()) + } else { + Err(syn::Error::new_spanned( + meta.path, + "unknown attribute, allowed: bms_display_path,remote", + )) + } + })? + } + } + + Ok(args) + } +} + +pub fn debug_with_type_info(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let derive_input: DeriveInput = parse_macro_input!(input as DeriveInput); + + // parse the args + let args = match Args::parse(&derive_input.attrs) { + Ok(args) => args, + Err(e) => return e.to_compile_error().into(), + }; + + let bms_display_path = &args.bms_display_path; + + // use DebugStruct, DebugTuple, DebugMap, DebugList etc from bevy_mod_scripting_display + // from the trait DebugWithTypeInfoBuilder trait on the formatter in implementing Debug i.e.: + // Extension methods for `std::fmt::Formatter` which create builders that + // / format values using `DebugWithTypeInfo`. These helpers mirror the + // / standard formatter builders (`debug_struct`, `debug_tuple`, etc.) but + // / ensure that fields, entries and keys/values are displayed through the + // / `DebugWithTypeInfo` adapter. + // pub trait DebugWithTypeInfoBuilder<'a, 'b: 'a> { + // /// Start formatting a struct with the given name using type-aware + // /// field formatting. + // fn debug_struct_with_type_info(&'a mut self, name: &str) -> DebugStruct<'a, 'b>; + + // /// Start formatting a tuple-like value with the given name using + // /// type-aware element formatting. + // fn debug_tuple_with_type_info(&'a mut self, name: &str) -> DebugTuple<'a, 'b>; + + // /// Start formatting a list using type-aware entry formatting. + // fn debug_list_with_type_info(&'a mut self) -> DebugList<'a, 'b>; + + // /// Start formatting a set using type-aware entry formatting. + // fn debug_set_with_type_info(&'a mut self) -> DebugSet<'a, 'b>; + + // /// Start formatting a map using type-aware key/value formatting. + // fn debug_map_with_type_info(&'a mut self) -> DebugMap<'a, 'b>; + // } + + let name = derive_input.ident; + let name_str = name.to_string(); + let placeholder_ident = syn::Ident::new("_", Span::call_site()); + + let builder = match derive_input.data { + syn::Data::Struct(data_struct) => { + let self_ident = Ident::new("self", Span::call_site()); + build_from_fields( + Some(&self_ident), + &name_str, + bms_display_path, + &data_struct.fields, + ) + } + syn::Data::Enum(data_enum) => { + // we emit a match statement + let match_arms = data_enum.variants.into_iter().map(|variant| { + let variant_ident = &variant.ident; + let variant_name = variant.ident.to_string(); + let inner_builder = + build_from_fields(None, &variant_name, bms_display_path, &variant.fields); + + let destructuring = match &variant.fields { + syn::Fields::Named(fields) => { + let field_idents = fields + .named + .iter() + .map(|f| f.ident.as_ref().unwrap_or(&placeholder_ident)); + quote::quote! { { #(#field_idents),* } } + } + syn::Fields::Unit => quote::quote! {}, + syn::Fields::Unnamed(fields) => { + let field_idents = fields + .unnamed + .iter() + .enumerate() + .map(|(i, _)| format_ident!("_{}", i)); + quote::quote! { ( #(#field_idents),* ) } + } + }; + quote::quote! { + #name::#variant_ident #destructuring => #inner_builder + } + }); + quote::quote! { + match self { + #(#match_arms),* + } + } + } + syn::Data::Union(data_union) => { + return syn::Error::new_spanned( + data_union.union_token, + "DebugWithTypeInfo cannot be derived for unions", + ) + .to_compile_error() + .into(); + } + }; + let (impl_generics, ty_generics, where_clause) = derive_input.generics.split_for_impl(); + quote::quote! { + impl #impl_generics #bms_display_path::DebugWithTypeInfo for #name #ty_generics #where_clause { + fn to_string_with_type_info(&self, f: &mut std::fmt::Formatter<'_>, type_info_provider: Option<&dyn #bms_display_path::GetTypeInfo>) -> std::fmt::Result { + #builder + } + } + impl #impl_generics std::fmt::Debug for #name #ty_generics #where_clause { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Debug::fmt(&#bms_display_path::WithTypeInfo(self), f) + } + } + } + .into() +} + +fn build_from_fields( + self_ident: Option<&Ident>, + variant_name: &str, + bms_display_path: &syn::Path, + fields: &syn::Fields, +) -> TokenStream { + let member_args: Vec<_> = match fields { + syn::Fields::Named(fields_named) => fields_named.named.iter().map(|f| &f.attrs).collect(), + syn::Fields::Unnamed(fields_unnamed) => { + fields_unnamed.unnamed.iter().map(|f| &f.attrs).collect() + } + syn::Fields::Unit => Vec::new(), + }; + + let members = fields + .members() + .enumerate() + .filter(|(i, _)| { + // exclude fields with #[debug_with_type_info(skip)] + member_args + .get(*i) + .map(|attrs| { + !attrs.iter().any(|attr| { + let mut is_skipped = false; + attr.path().is_ident("debug_with_type_info") + && attr + .parse_nested_meta(|meta| { + is_skipped = meta.path.is_ident("skip"); + Ok(()) + }) + .is_ok() + && is_skipped + }) + }) + .unwrap_or(true) + }) + .map(|(_, m)| match m { + syn::Member::Named(ident) => { + let field_name = ident.to_string(); + if let Some(self_ident) = self_ident { + quote::quote! { + .field(#field_name, &#self_ident.#ident) + } + } else { + quote::quote! { + .field(#field_name, #ident) + } + } + } + syn::Member::Unnamed(index) => { + if let Some(self_ident) = self_ident { + quote::quote! { + .field(&#self_ident.#index) + } + } else { + let underscore_index = format_ident!("_{}", index); + quote::quote! { + .field(#underscore_index) + } + } + } + }); + + let builder_method = Ident::new( + match fields { + syn::Fields::Named(_) => "debug_struct_with_type_info", + syn::Fields::Unnamed(_) => "debug_tuple_with_type_info", + syn::Fields::Unit => "debug_tuple_with_type_info", + }, + Span::call_site(), + ); + + quote::quote! { + #bms_display_path::DebugWithTypeInfoBuilder::#builder_method(f, #variant_name) + #(#members)* + .finish() + } +} diff --git a/crates/bevy_mod_scripting_derive/src/derive/get_type_dependencies.rs b/crates/bevy_mod_scripting_derive/src/derive/get_type_dependencies.rs index 1cebf330b5..5df56c40dd 100644 --- a/crates/bevy_mod_scripting_derive/src/derive/get_type_dependencies.rs +++ b/crates/bevy_mod_scripting_derive/src/derive/get_type_dependencies.rs @@ -36,7 +36,7 @@ fn get_type_dependencies_from_input(derive_input: DeriveInput) -> TokenStream { Err(error) => return error.to_compile_error(), }; - let bms_core = &args.bms_core_path; + let bms_core = &args.bms_bindings_path; let (impl_generics, type_generics, impl_where) = derive_input.generics.split_for_impl(); @@ -89,7 +89,7 @@ fn get_type_dependencies_from_input(derive_input: DeriveInput) -> TokenStream { quote_spanned! {derive_input.ident.span()=> #[automatically_derived] #[allow(clippy::needless_lifetimes)] - impl #impl_generics #bms_core::bindings::GetTypeDependencies for #name #type_generics #impl_where + impl #impl_generics #bms_core::GetTypeDependencies for #name #type_generics #impl_where { type Underlying = #underlying; fn register_type_dependencies(registry: &mut TypeRegistry) { @@ -111,7 +111,7 @@ pub fn get_type_dependencies(input: TokenStream) -> TokenStream { } struct Args { - bms_core_path: syn::Path, + bms_bindings_path: syn::Path, underlying: Option, dont_recurse: bool, // bounds: Vec, @@ -119,7 +119,7 @@ struct Args { impl Args { fn parse(attrs: &[syn::Attribute]) -> syn::Result { - let mut bms_core_path = parse_quote!(::bevy_mod_scripting::core); + let mut bms_bindings_path = parse_quote!(::bevy_mod_scripting::bindings); let mut underlying = None; let mut dont_recurse = false; @@ -128,10 +128,10 @@ impl Args { // then parse its meta if attr.path().is_ident("get_type_dependencies") { attr.parse_nested_meta(|meta| { - if meta.path.is_ident("bms_core_path") { + if meta.path.is_ident("bms_bindings_path") { let value = meta.value()?; let string: syn::LitStr = value.parse()?; - bms_core_path = string.parse()?; + bms_bindings_path = string.parse()?; Ok(()) } else if meta.path.is_ident("underlying") { let value = meta.value()?; @@ -144,7 +144,7 @@ impl Args { } else { Err(syn::Error::new_spanned( meta.path, - "unknown attribute, allowed: bms_core_path, underlying", + "unknown attribute, allowed: bms_bindings_path, underlying", )) } })?; @@ -152,7 +152,7 @@ impl Args { } Ok(Self { - bms_core_path, + bms_bindings_path, underlying, dont_recurse, }) diff --git a/crates/bevy_mod_scripting_derive/src/derive/into_script.rs b/crates/bevy_mod_scripting_derive/src/derive/into_script.rs index 8135ca4430..6879f5d58d 100644 --- a/crates/bevy_mod_scripting_derive/src/derive/into_script.rs +++ b/crates/bevy_mod_scripting_derive/src/derive/into_script.rs @@ -13,10 +13,10 @@ pub fn into_script(input: TokenStream) -> TokenStream { let (impl_generics, type_generics, where_clause) = generics.split_for_impl(); quote! { - impl #impl_generics ::bevy_mod_scripting::core::bindings::function::into::IntoScript for #ident #type_generics #where_clause { - fn into_script(self, world: ::bevy_mod_scripting::core::bindings::WorldGuard) -> Result<::bevy_mod_scripting::core::bindings::script_value::ScriptValue, ::bevy_mod_scripting::core::error::InteropError> { - ::bevy_mod_scripting::core::bindings::function::into::IntoScript::into_script( - ::bevy_mod_scripting::core::bindings::function::from::Val(self), + impl #impl_generics ::bevy_mod_scripting::bindings::function::into::IntoScript for #ident #type_generics #where_clause { + fn into_script(self, world: ::bevy_mod_scripting::bindings::WorldGuard) -> Result<::bevy_mod_scripting::bindings::script_value::ScriptValue, ::bevy_mod_scripting::bindings::error::InteropError> { + ::bevy_mod_scripting::bindings::function::into::IntoScript::into_script( + ::bevy_mod_scripting::bindings::function::from::Val(self), world, ) } diff --git a/crates/bevy_mod_scripting_derive/src/derive/mod.rs b/crates/bevy_mod_scripting_derive/src/derive/mod.rs index 30835ff68a..60a3c7b9b7 100644 --- a/crates/bevy_mod_scripting_derive/src/derive/mod.rs +++ b/crates/bevy_mod_scripting_derive/src/derive/mod.rs @@ -1,3 +1,4 @@ +mod debug_with_type_info; mod get_type_dependencies; mod into_script; mod script_bindings; @@ -9,8 +10,9 @@ use quote::{ToTokens, quote_spanned}; use syn::{Ident, ImplItemFn, ItemImpl}; pub use self::{ - get_type_dependencies::get_type_dependencies, into_script::into_script, - script_bindings::script_bindings, script_globals::script_globals, typed_through::typed_through, + debug_with_type_info::debug_with_type_info, get_type_dependencies::get_type_dependencies, + into_script::into_script, script_bindings::script_bindings, script_globals::script_globals, + typed_through::typed_through, }; pub(crate) fn impl_fn_to_namespace_builder_registration(fun: &ImplItemFn) -> TokenStream { diff --git a/crates/bevy_mod_scripting_derive/src/derive/script_bindings.rs b/crates/bevy_mod_scripting_derive/src/derive/script_bindings.rs index dd5ae07844..14320398e1 100644 --- a/crates/bevy_mod_scripting_derive/src/derive/script_bindings.rs +++ b/crates/bevy_mod_scripting_derive/src/derive/script_bindings.rs @@ -42,7 +42,7 @@ pub fn script_bindings( }, }; - let bms_core_path = &args.bms_core_path; + let bms_bindings_path = &args.bms_bindings_path; let function_name = format_ident!("register_{}", args.name); let builder_function_name = if args.unregistered { @@ -56,17 +56,17 @@ pub fn script_bindings( let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry.register_type_data::<#type_ident_with_generics, #bms_core_path::bindings::MarkAsGenerated>(); + registry.register_type_data::<#type_ident_with_generics, #bms_bindings_path::MarkAsGenerated>(); } } else { Default::default() }; - let mark_as_core = if bms_core_path.is_ident("crate") || args.core { + let mark_as_core = if bms_bindings_path.is_ident("crate") || args.core { quote_spanned! {impl_span=> let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry.register_type_data::<#type_ident_with_generics, #bms_core_path::bindings::MarkAsCore>(); + registry.register_type_data::<#type_ident_with_generics, #bms_bindings_path::MarkAsCore>(); } } else { Default::default() @@ -76,7 +76,7 @@ pub fn script_bindings( quote_spanned! {impl_span=> let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry.register_type_data::<#type_ident_with_generics, #bms_core_path::bindings::MarkAsSignificant>(); + registry.register_type_data::<#type_ident_with_generics, #bms_bindings_path::MarkAsSignificant>(); } } else { Default::default() @@ -84,7 +84,7 @@ pub fn script_bindings( let out = quote_spanned! {impl_span=> #visibility fn #function_name(world: &mut World) { - #bms_core_path::bindings::function::namespace::NamespaceBuilder::<#type_ident_with_generics>::#builder_function_name(world) + #bms_bindings_path::function::namespace::NamespaceBuilder::<#type_ident_with_generics>::#builder_function_name(world) #(#function_registrations)*; #mark_as_generated @@ -104,7 +104,7 @@ struct Args { /// If true the original impl block will be ignored, and only the function registrations will be generated pub remote: bool, /// If set the path to override bms imports - pub bms_core_path: syn::Path, + pub bms_bindings_path: syn::Path, /// If true will use `new_unregistered` instead of `new` for the namespace builder pub unregistered: bool, /// If true registers a marker type against the type registry to state that the type is generated (if unregistered is not set) @@ -127,10 +127,10 @@ impl syn::parse::Parse for Args { let mut generated = false; let mut core = false; let mut significant = false; - let mut bms_core_path = + let mut bms_bindings_path = syn::Path::from(syn::Ident::new("bevy_mod_scripting", Span::call_site())); - bms_core_path.segments.push(syn::PathSegment { - ident: syn::Ident::new("core", Span::call_site()), + bms_bindings_path.segments.push(syn::PathSegment { + ident: syn::Ident::new("bindings", Span::call_site()), arguments: syn::PathArguments::None, }); let mut unknown_spans = Vec::default(); @@ -155,11 +155,11 @@ impl syn::parse::Parse for Args { } } syn::Meta::NameValue(name_value) => { - if name_value.path.is_ident("bms_core_path") + if name_value.path.is_ident("bms_bindings_path") && let syn::Expr::Lit(path) = &name_value.value && let syn::Lit::Str(lit_str) = &path.lit { - bms_core_path = syn::parse_str(&lit_str.value())?; + bms_bindings_path = syn::parse_str(&lit_str.value())?; continue; } else if name_value.path.is_ident("name") && let syn::Expr::Lit(path) = &name_value.value @@ -184,7 +184,7 @@ impl syn::parse::Parse for Args { Ok(Self { remote, - bms_core_path, + bms_bindings_path, name, unregistered, generated, diff --git a/crates/bevy_mod_scripting_derive/src/derive/script_globals.rs b/crates/bevy_mod_scripting_derive/src/derive/script_globals.rs index c5fe7acd32..c3877a616d 100644 --- a/crates/bevy_mod_scripting_derive/src/derive/script_globals.rs +++ b/crates/bevy_mod_scripting_derive/src/derive/script_globals.rs @@ -25,7 +25,7 @@ pub fn script_globals( } let function_name = format_ident!("register_{}", args.name); - let bms_core_path = &args.bms_core_path; + let bms_bindings_path = &args.bms_bindings_path; let visibility = match is_public_impl(&impl_block) { true => quote_spanned! {impl_span=> @@ -39,7 +39,7 @@ pub fn script_globals( let out = quote_spanned! {impl_span=> #visibility fn #function_name(world: &mut World) { - let registry = world.get_resource_or_init::<#bms_core_path::bindings::globals::AppScriptGlobalsRegistry>(); + let registry = world.get_resource_or_init::<#bms_bindings_path::globals::AppScriptGlobalsRegistry>(); let mut registry = registry.write(); registry @@ -54,7 +54,7 @@ struct Args { /// The name to use to suffix the generated function, i.e. `test_fn` will generate `register_test_fn pub name: syn::Ident, /// If set the path to override bms imports - pub bms_core_path: syn::Path, + pub bms_bindings_path: syn::Path, } impl syn::parse::Parse for Args { @@ -64,9 +64,9 @@ impl syn::parse::Parse for Args { syn::punctuated::Punctuated::::parse_terminated(input)?; let mut name = syn::Ident::new("functions", Span::call_site()); - let mut bms_core_path = + let mut bms_bindings_path = syn::Path::from(syn::Ident::new("bevy_mod_scripting", Span::call_site())); - bms_core_path.segments.push(syn::PathSegment { + bms_bindings_path.segments.push(syn::PathSegment { ident: syn::Ident::new("core", Span::call_site()), arguments: syn::PathArguments::None, }); @@ -74,11 +74,11 @@ impl syn::parse::Parse for Args { for pair in pairs { match &pair { syn::Meta::NameValue(name_value) => { - if name_value.path.is_ident("bms_core_path") + if name_value.path.is_ident("bms_bindings_path") && let syn::Expr::Lit(path) = &name_value.value && let syn::Lit::Str(lit_str) = &path.lit { - bms_core_path = syn::parse_str(&lit_str.value())?; + bms_bindings_path = syn::parse_str(&lit_str.value())?; continue; } else if name_value.path.is_ident("name") && let syn::Expr::Lit(path) = &name_value.value @@ -102,7 +102,7 @@ impl syn::parse::Parse for Args { } Ok(Self { - bms_core_path, + bms_bindings_path, name, }) } diff --git a/crates/bevy_mod_scripting_derive/src/derive/typed_through.rs b/crates/bevy_mod_scripting_derive/src/derive/typed_through.rs index d8213aeef4..2236fb242e 100644 --- a/crates/bevy_mod_scripting_derive/src/derive/typed_through.rs +++ b/crates/bevy_mod_scripting_derive/src/derive/typed_through.rs @@ -14,9 +14,9 @@ pub fn typed_through(input: TokenStream) -> TokenStream { let turbofish = type_generics.as_turbofish(); quote! { - impl #impl_generics ::bevy_mod_scripting::core::docgen::typed_through::TypedThrough for #ident #type_generics #where_clause { + impl #impl_generics ::bevy_mod_scripting::bindings::docgen::typed_through::TypedThrough for #ident #type_generics #where_clause { fn through_type_info() -> ::bevy_mod_scripting::core::docgen::typed_through::ThroughTypeInfo { - ::bevy_mod_scripting::core::docgen::typed_through::ThroughTypeInfo::TypeInfo(#ident #turbofish ::type_info()) + ::bevy_mod_scripting::bindings::docgen::typed_through::ThroughTypeInfo::TypeInfo(#ident #turbofish ::type_info()) } } } diff --git a/crates/bevy_mod_scripting_derive/src/lib.rs b/crates/bevy_mod_scripting_derive/src/lib.rs index b3a8620c6a..ac9daee6f8 100644 --- a/crates/bevy_mod_scripting_derive/src/lib.rs +++ b/crates/bevy_mod_scripting_derive/src/lib.rs @@ -23,7 +23,7 @@ pub fn into_script(input: proc_macro::TokenStream) -> proc_macro::TokenStream { /// Arguments: /// - `name`: the name to use to suffix the generated function, i.e. `test_fn` will generate `register_test_fn. Defaults to `functions` /// - `remote`: If true the original impl block will be ignored, and only the function registrations will be generated -/// - `bms_core_path`: If set the path to override bms imports, normally only used internally +/// - `bms_bindings_path`: If set the path to override bms imports, normally only used internally /// - `unregistered`: If set, will use `new_unregistered` instead of `new` for the namespace builder /// - `core`: If set, marks the type as `core` using the `MarkAsCore` type data /// - `significant`: If set, marks the type as `significant` using the `MarkAsSignificant` type data @@ -66,3 +66,14 @@ pub fn get_type_dependencies(input: proc_macro::TokenStream) -> proc_macro::Toke pub fn impl_get_type_dependencies(input: proc_macro::TokenStream) -> proc_macro::TokenStream { derive::get_type_dependencies(input.into()).into() } + +/// Derive macro for generating `Debug` implementations which include type information. +/// Uses the `DebugWithTypeInfoBuilder` trait from `bevy_mod_scripting_display` to +/// generate the debug output. +/// +/// Works the same way as the standard `Debug` derive macro, but delegates to +/// `WithTypeInfo` adapters for fields, entries and keys/values. +#[proc_macro_derive(DebugWithTypeInfo, attributes(debug_with_type_info))] +pub fn debug_with_type_info_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + derive::debug_with_type_info(input) +} diff --git a/crates/bevy_mod_scripting_display/Cargo.toml b/crates/bevy_mod_scripting_display/Cargo.toml new file mode 100644 index 0000000000..cb3ae721dd --- /dev/null +++ b/crates/bevy_mod_scripting_display/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "bevy_mod_scripting_display" +version = "0.15.1" +edition = "2024" +authors = ["Maksymilian Mozolewski "] +license = "MIT OR Apache-2.0" +description = "Necessary functionality for Lua support with bevy_mod_scripting" +repository = "https://github.com/makspll/bevy_mod_scripting" +homepage = "https://github.com/makspll/bevy_mod_scripting" +keywords = ["bevy", "gamedev", "scripting", "rhai"] +categories = ["game-development"] +readme = "readme.md" + +[dependencies] +bevy_reflect = { workspace = true } +bevy_ecs = { workspace = true, features = ["bevy_reflect"] } +bevy_platform = { workspace = true } +parking_lot = { workspace = true } + +[lints] +workspace = true diff --git a/crates/bevy_mod_scripting_display/src/impls/bevy_ecs.rs b/crates/bevy_mod_scripting_display/src/impls/bevy_ecs.rs new file mode 100644 index 0000000000..14533848fc --- /dev/null +++ b/crates/bevy_mod_scripting_display/src/impls/bevy_ecs.rs @@ -0,0 +1,42 @@ +use bevy_ecs::entity::Entity; + +use crate::*; + +impl_debug_with_type_info_via_debug!(Entity); +impl_display_with_type_info_via_display!(Entity); + +impl DebugWithTypeInfo for ComponentId { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + let name = type_info_provider + .and_then(|type_info_provider| { + type_info_provider + .get_component_info(*self) + .map(|info| info.name().to_string()) + }) + .unwrap_or_else(|| format!("Unregistered ComponentId - {self:?}")); + + f.debug_tuple("ComponentId").field(&name).finish() + } +} + +impl DisplayWithTypeInfo for ComponentId { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + let name = type_info_provider + .and_then(|type_info_provider| { + type_info_provider + .get_component_info(*self) + .map(|info| info.name().to_string()) + }) + .unwrap_or_else(|| format!("Unregistered ComponentId - {self:?}")); + + f.write_str(&name) + } +} diff --git a/crates/bevy_mod_scripting_display/src/impls/bevy_platform.rs b/crates/bevy_mod_scripting_display/src/impls/bevy_platform.rs new file mode 100644 index 0000000000..e0019d5445 --- /dev/null +++ b/crates/bevy_mod_scripting_display/src/impls/bevy_platform.rs @@ -0,0 +1,42 @@ +use crate::*; + +impl DebugWithTypeInfo + for bevy_platform::collections::HashMap +{ + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn crate::GetTypeInfo>, + ) -> std::fmt::Result { + f.debug_map_with_type_info() + .entries( + self.iter() + .map(|(k, v)| (k as &dyn DebugWithTypeInfo, v as &dyn DebugWithTypeInfo)), + ) + .finish() + } +} + +impl DebugWithTypeInfo for bevy_platform::collections::HashSet { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn crate::GetTypeInfo>, + ) -> std::fmt::Result { + f.debug_set_with_type_info() + .entries(self.iter().map(|v| v as &dyn DebugWithTypeInfo)) + .finish() + } +} + +impl DebugWithTypeInfo for bevy_platform::collections::HashTable { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn crate::GetTypeInfo>, + ) -> std::fmt::Result { + f.debug_set_with_type_info() + .entries(self.iter().map(|v| v as &dyn DebugWithTypeInfo)) + .finish() + } +} diff --git a/crates/bevy_mod_scripting_display/src/impls/bevy_reflect.rs b/crates/bevy_mod_scripting_display/src/impls/bevy_reflect.rs new file mode 100644 index 0000000000..8a811e4475 --- /dev/null +++ b/crates/bevy_mod_scripting_display/src/impls/bevy_reflect.rs @@ -0,0 +1,9 @@ +use bevy_reflect::ParsedPath; + +use crate::*; + +impl_debug_with_type_info_via_debug!(ParsedPath); +impl_debug_with_type_info_via_debug!(TypeInfo); +impl_debug_with_type_info_via_debug!(&'static TypeInfo); + +impl_display_with_type_info_via_display!(ParsedPath); diff --git a/crates/bevy_mod_scripting_display/src/impls/mod.rs b/crates/bevy_mod_scripting_display/src/impls/mod.rs new file mode 100644 index 0000000000..6a22bf2bb2 --- /dev/null +++ b/crates/bevy_mod_scripting_display/src/impls/mod.rs @@ -0,0 +1,5 @@ +mod bevy_ecs; +mod bevy_platform; +mod bevy_reflect; +mod parking_lock; +mod std; diff --git a/crates/bevy_mod_scripting_display/src/impls/parking_lock.rs b/crates/bevy_mod_scripting_display/src/impls/parking_lock.rs new file mode 100644 index 0000000000..0740a1b124 --- /dev/null +++ b/crates/bevy_mod_scripting_display/src/impls/parking_lock.rs @@ -0,0 +1,39 @@ +use parking_lot::RwLock; + +use crate::*; + +impl DebugWithTypeInfo for RwLock { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn crate::GetTypeInfo>, + ) -> std::fmt::Result { + if let Some(read) = self.try_read() { + f.debug_tuple_with_type_info("RwLock") + .field(&*read as &dyn DebugWithTypeInfo) + .finish() + } else { + f.debug_tuple_with_type_info("RwLock") + .field(&"") + .finish() + } + } +} + +impl DebugWithTypeInfo for parking_lot::Mutex { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn crate::GetTypeInfo>, + ) -> std::fmt::Result { + if let Some(guard) = self.try_lock() { + f.debug_tuple_with_type_info("Mutex") + .field(&*guard as &dyn DebugWithTypeInfo) + .finish() + } else { + f.debug_tuple_with_type_info("Mutex") + .field(&"") + .finish() + } + } +} diff --git a/crates/bevy_mod_scripting_display/src/impls/std.rs b/crates/bevy_mod_scripting_display/src/impls/std.rs new file mode 100644 index 0000000000..f254d6b1eb --- /dev/null +++ b/crates/bevy_mod_scripting_display/src/impls/std.rs @@ -0,0 +1,257 @@ +use std::{borrow::Cow, panic::Location, sync::Arc}; + +use crate::*; + +impl_debug_with_type_info_via_display!(String, &'_ str, Cow<'_, str>); +impl_debug_with_type_info_via_display!(u8, u16, u32, u64, u128, usize); +impl_debug_with_type_info_via_display!(i8, i16, i32, i64, i128, isize); +impl_debug_with_type_info_via_display!(f32, f64); +impl_debug_with_type_info_via_display!(bool, char); + +impl DebugWithTypeInfo for TypeId { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + if *self == TypeId::of::() { + return f.write_str("Unknown Type"); + } else if *self == TypeId::of::() { + // does not implement Reflect, so we do this manually + return f.write_str("World"); + } + + let name = if let Some(type_info_provider) = type_info_provider { + if let Some(type_info) = type_info_provider.get_type_info(*self) { + type_info.type_path_table().path().to_string() + } else { + format!("Unregistered Type - {self:?}") + } + } else { + format!("{self:?}") + }; + + f.debug_tuple("TypeId").field(&name).finish() + } +} + +impl DebugWithTypeInfo for Arc { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + (**self).to_string_with_type_info(f, type_info_provider) + } +} + +impl DebugWithTypeInfo for Box { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + (**self).to_string_with_type_info(f, type_info_provider) + } +} + +impl DebugWithTypeInfo for Option { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + match self { + Some(value) => f + .debug_tuple_with_type_info("Some") + .field(value as &dyn DebugWithTypeInfo) + .finish(), + None => f.debug_tuple_with_type_info("None").finish(), + } + } +} + +impl DebugWithTypeInfo for Result { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + match self { + Ok(v) => f + .debug_tuple_with_type_info("Ok") + .field(v as &dyn DebugWithTypeInfo) + .finish(), + Err(v) => f + .debug_tuple_with_type_info("Err") + .field(v as &dyn DebugWithTypeInfo) + .finish(), + } + } +} + +impl DebugWithTypeInfo for Vec { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + f.debug_list_with_type_info() + .entries(self.iter().map(|v| v as &dyn DebugWithTypeInfo)) + .finish() + } +} + +impl DebugWithTypeInfo + for std::collections::HashMap +{ + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + f.debug_map_with_type_info() + .entries( + self.iter() + .map(|(k, v)| (k as &dyn DebugWithTypeInfo, v as &dyn DebugWithTypeInfo)), + ) + .finish() + } +} + +impl DebugWithTypeInfo for std::collections::HashSet { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + f.debug_set_with_type_info() + .entries(self.iter().map(|v| v as &dyn DebugWithTypeInfo)) + .finish() + } +} + +impl DebugWithTypeInfo for std::collections::BTreeSet { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + f.debug_set_with_type_info() + .entries(self.iter().map(|v| v as &dyn DebugWithTypeInfo)) + .finish() + } +} + +impl DebugWithTypeInfo + for std::collections::BTreeMap +{ + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + f.debug_map_with_type_info() + .entries( + self.iter() + .map(|(k, v)| (k as &dyn DebugWithTypeInfo, v as &dyn DebugWithTypeInfo)), + ) + .finish() + } +} + +impl DebugWithTypeInfo for Location<'_> { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + f.debug_struct("Location") + .field("file", &self.file()) + .field("line", &self.line()) + .field("column", &self.column()) + .finish() + } +} + +// -- DisplayWithTypeInfo implementations -- +// For primitive/displayable types we delegate to their Display impls. +macro_rules! impl_display_with_type_info_via_display { + ($($t:ty),*) => { + $( + impl DisplayWithTypeInfo for $t { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + ::fmt(self, f) + } + } + )* + }; +} + +impl_display_with_type_info_via_display!(String, &'_ str, Cow<'_, str>); +impl_display_with_type_info_via_display!(u8, u16, u32, u64, u128, usize); +impl_display_with_type_info_via_display!(i8, i16, i32, i64, i128, isize); +impl_display_with_type_info_via_display!(f32, f64); +impl_display_with_type_info_via_display!(bool, char); + +impl DisplayWithTypeInfo for TypeId { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + if *self == TypeId::of::() { + return f.write_str("Unknown Type"); + } else if *self == TypeId::of::() { + return f.write_str("World"); + } + + let name = if let Some(type_info_provider) = type_info_provider { + if let Some(type_info) = type_info_provider.get_type_info(*self) { + type_info.type_path_table().path().to_string() + } else { + format!("Unregistered Type - {self:?}") + } + } else { + format!("{self:?}") + }; + + // Display should be prettier: just print the resolved name (no tuple/struct wrapper) + f.write_str(&name) + } +} + +impl DisplayWithTypeInfo for Arc { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + (**self).display_with_type_info(f, type_info_provider) + } +} + +impl DisplayWithTypeInfo for Box { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + (**self).display_with_type_info(f, type_info_provider) + } +} + +impl DisplayWithTypeInfo for Location<'_> { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + // prettier display: file:line:column + write!(f, "{}:{}:{}", self.file(), self.line(), self.column()) + } +} diff --git a/crates/bevy_mod_scripting_display/src/lib.rs b/crates/bevy_mod_scripting_display/src/lib.rs new file mode 100644 index 0000000000..7095d5e255 --- /dev/null +++ b/crates/bevy_mod_scripting_display/src/lib.rs @@ -0,0 +1,466 @@ +//! Abstractions for displaying reflect values, potentially with access to the type registry + +use std::{any::TypeId, ops::Deref}; +mod impls; +mod printer; +pub use printer::*; + +use bevy_ecs::{ + component::{ComponentId, ComponentInfo}, + reflect::AppTypeRegistry, + world::World, +}; +use bevy_reflect::{TypeInfo, TypeRegistry}; + +/// An abstraction for getting type information, potentially using the type registry. +pub trait GetTypeInfo { + /// Get a string representation of the type, potentially using the type registry. + fn get_type_info(&self, type_id: TypeId) -> Option<&TypeInfo>; + + /// Get component info for a given component id, if available + fn get_component_info(&self, component_id: ComponentId) -> Option<&ComponentInfo>; +} + +impl GetTypeInfo for TypeRegistry { + fn get_type_info(&self, type_id: TypeId) -> Option<&TypeInfo> { + self.get(type_id) + .map(|registration| registration.type_info()) + } + + fn get_component_info(&self, _component_id: ComponentId) -> Option<&ComponentInfo> { + None + } +} + +impl GetTypeInfo for World { + fn get_type_info(&self, type_id: TypeId) -> Option<&TypeInfo> { + self.get_resource::() + .and_then(|r| r.read().get_type_info(type_id)) + } + + fn get_component_info(&self, component_id: ComponentId) -> Option<&ComponentInfo> { + self.components().get_info(component_id) + } +} + +/// An trait for displaying values with access to type information +pub trait DisplayWithTypeInfo { + /// Format the value using the provided type info provider if available + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result; +} + +impl DisplayWithTypeInfo for WithTypeInfo<'_, T> { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + self.0.display_with_type_info(f, type_info_provider) + } +} + +impl std::fmt::Display for WithTypeInfo<'_, T> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let provider = GLOBAL_TYPE_INFO_PROVIDER + .get() + .and_then(|get_provider| get_provider()); + self.0.display_with_type_info(f, provider) + } +} + +/// An extension trait for displaying values with access to type information +/// implementations should respect the following formatter options: +/// - `#` - should display the value in a pretty-printed way if possible, if not provided a debug representation should be used instead +pub trait DebugWithTypeInfo { + /// Format the value using the provided type info provider if available + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result; +} + +/// A global type info provider that can be set once and used throughout the application +/// It does not do the retrieval itself, but provides a function that points to the retrieval mechanism. +pub static GLOBAL_TYPE_INFO_PROVIDER: std::sync::OnceLock< + fn() -> Option<&'static dyn GetTypeInfo>, +> = std::sync::OnceLock::new(); + +/// newtype adapter for opting into DisplayWithTypeInfo for any T: DisplayWithTypeInfo +/// Use as follows +/// ```rust,no_run +/// use bevy_mod_scripting_display::WithTypeInfo; +/// +/// let my_value = std::any::TypeId::of::(); +/// format!("{:?}", WithTypeInfo(&my_value)); // non-pretty print +/// format!("{:#?}", WithTypeInfo(&my_value)); // pretty print +/// ``` +pub struct WithTypeInfo<'a, T: ?Sized>(pub &'a T); + +impl<'a, T: DebugWithTypeInfo + ?Sized> WithTypeInfo<'a, T> { + /// Create a new WithTypeInfo wrapper + pub fn new(value: &'a T) -> Self { + Self(value) + } +} + +impl Deref for WithTypeInfo<'_, T> { + type Target = T; + + fn deref(&self) -> &Self::Target { + self.0 + } +} + +impl<'a, T: DebugWithTypeInfo + ?Sized> std::fmt::Debug for WithTypeInfo<'a, T> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let provider = GLOBAL_TYPE_INFO_PROVIDER + .get() + .and_then(|get_provider| get_provider()); + self.0.to_string_with_type_info(f, provider) + } +} + +impl DebugWithTypeInfo for WithTypeInfo<'_, T> { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + self.0.to_string_with_type_info(f, type_info_provider) + } +} + +struct FakeType; +/// A utility for getting a TypeId or a fake one if not present +pub trait OrFakeId { + /// Get the TypeId or a fake one if not present + fn or_fake_id(&self) -> TypeId; + + /// Get the fake TypeId + fn fake_id() -> TypeId { + TypeId::of::() + } +} + +impl OrFakeId for Option { + fn or_fake_id(&self) -> TypeId { + self.unwrap_or_else(TypeId::of::) + } +} + +trait SelfBuilder: Sized { + /// Apply a function to self and return the result + fn build_with Self>(self, f: F) -> Self; +} + +impl SelfBuilder for T { + fn build_with Self>(self, f: F) -> Self { + f(self) + } +} + +/// A utility for formatting structs but with type info available +/// Helper wrapper around `std::fmt::DebugStruct` that formats struct fields +/// using `DebugWithTypeInfo` so that type-aware formatting is available for +/// each field. +pub struct DebugStruct<'a, 'b: 'a> { + builder: std::fmt::DebugStruct<'a, 'b>, +} + +impl<'a, 'b: 'a> DebugStruct<'a, 'b> { + /// Create a new `DebugStruct` builder for a struct with the given name. + /// + /// The returned value can be used to add fields which implement + /// `DebugWithTypeInfo` and then finished to produce the final formatting + /// result. + pub fn new(f: &'a mut std::fmt::Formatter<'b>, name: &str) -> Self { + Self { + builder: f.debug_struct(name), + } + } + + /// Add a field to the struct being formatted. + /// + /// The `value` will be displayed using its `DebugWithTypeInfo` + /// implementation so that any available type information can be used. + pub fn field(&mut self, name: &str, value: &dyn DebugWithTypeInfo) -> &mut Self { + self.builder.field(name, &WithTypeInfo::new(value)); + self + } + + /// Finish building the struct formatter and write the output to the + /// underlying `Formatter`. + pub fn finish(&mut self) -> std::fmt::Result { + self.builder.finish() + } +} + +/// Helper wrapper around `std::fmt::DebugTuple` that formats tuple elements +/// using `DebugWithTypeInfo` so elements can render with optional type +/// information. +pub struct DebugTuple<'a, 'b: 'a> { + builder: std::fmt::DebugTuple<'a, 'b>, +} + +impl<'a, 'b: 'a> DebugTuple<'a, 'b> { + /// Create a new `DebugTuple` builder for a tuple-like value with the + /// given name. + pub fn new(f: &'a mut std::fmt::Formatter<'b>, name: &str) -> Self { + Self { + builder: f.debug_tuple(name), + } + } + + /// Add an element to the tuple being formatted. The element will be + /// formatted via its `DebugWithTypeInfo` implementation. + pub fn field(&mut self, value: &dyn DebugWithTypeInfo) -> &mut Self { + self.builder.field(&WithTypeInfo::new(value)); + self + } + + /// Finish building the tuple formatter and write the output to the + /// underlying `Formatter`. + pub fn finish(&mut self) -> std::fmt::Result { + self.builder.finish() + } +} + +/// Helper wrapper around `std::fmt::DebugList` which formats list entries +/// using `DebugWithTypeInfo` so each entry can use available type +/// information during formatting. +pub struct DebugList<'a, 'b: 'a> { + builder: std::fmt::DebugList<'a, 'b>, +} + +impl<'a, 'b: 'a> DebugList<'a, 'b> { + /// Create a new `DebugList` builder. + pub fn new(f: &'a mut std::fmt::Formatter<'b>) -> Self { + Self { + builder: f.debug_list(), + } + } + + /// Add a single entry to the list. The entry will be formatted via its + /// `DebugWithTypeInfo` implementation. + pub fn entry(&mut self, value: &dyn DebugWithTypeInfo) -> &mut Self { + self.builder.entry(&WithTypeInfo::new(value)); + self + } + + /// Add multiple entries from an iterator of `DebugWithTypeInfo` references. + pub fn entries>( + &mut self, + values: I, + ) -> &mut Self { + for value in values { + self.builder.entry(&WithTypeInfo::new(value)); + } + self + } + + /// Finish building the list formatter and write the output to the + /// underlying `Formatter`. + pub fn finish(&mut self) -> std::fmt::Result { + self.builder.finish() + } +} + +/// Helper wrapper around `std::fmt::DebugSet` that formats set entries +/// using `DebugWithTypeInfo` so entries can render with optional type +/// information. +pub struct DebugSet<'a, 'b: 'a> { + builder: std::fmt::DebugSet<'a, 'b>, +} + +impl<'a, 'b: 'a> DebugSet<'a, 'b> { + /// Create a new `DebugSet` builder. + pub fn new(f: &'a mut std::fmt::Formatter<'b>) -> Self { + Self { + builder: f.debug_set(), + } + } + + /// Add a single entry to the set. The entry will be formatted via its + /// `DebugWithTypeInfo` implementation. + pub fn entry(&mut self, value: &dyn DebugWithTypeInfo) -> &mut Self { + self.builder.entry(&WithTypeInfo::new(value)); + self + } + + /// Add multiple entries from an iterator of `DebugWithTypeInfo` references. + pub fn entries>( + &mut self, + values: I, + ) -> &mut Self { + for value in values { + self.builder.entry(&WithTypeInfo::new(value)); + } + self + } + + /// Finish building the set formatter and write the output to the + /// underlying `Formatter`. + pub fn finish(&mut self) -> std::fmt::Result { + self.builder.finish() + } +} + +/// Helper wrapper around `std::fmt::DebugMap` that formats map keys and +/// values using `DebugWithTypeInfo` so both sides of each entry can render +/// with optional type information. +pub struct DebugMap<'a, 'b: 'a> { + builder: std::fmt::DebugMap<'a, 'b>, +} + +impl<'a, 'b: 'a> DebugMap<'a, 'b> { + /// Create a new `DebugMap` builder. + pub fn new(f: &'a mut std::fmt::Formatter<'b>) -> Self { + Self { + builder: f.debug_map(), + } + } + + /// Add a single key/value entry to the map. Both key and value will be + /// formatted via their `DebugWithTypeInfo` implementations. + pub fn entry( + &mut self, + key: &dyn DebugWithTypeInfo, + value: &dyn DebugWithTypeInfo, + ) -> &mut Self { + self.builder + .entry(&WithTypeInfo::new(key), &WithTypeInfo::new(value)); + self + } + + /// Add multiple key/value entries from an iterator of pairs. + pub fn entries< + I: IntoIterator, + >( + &mut self, + values: I, + ) -> &mut Self { + for (key, value) in values { + self.builder + .entry(&WithTypeInfo::new(key), &WithTypeInfo::new(value)); + } + self + } + + /// Add a key to the map being formatted (used when constructing an + /// entry in separate steps). + pub fn key(&mut self, key: &dyn DebugWithTypeInfo) -> &mut Self { + self.builder.key(&WithTypeInfo::new(key)); + self + } + + /// Add a value to the map being formatted (used when constructing an + /// entry in separate steps). + pub fn value(&mut self, value: &dyn DebugWithTypeInfo) -> &mut Self { + self.builder.value(&WithTypeInfo::new(value)); + self + } + + /// Finish building the map formatter and write the output to the + /// underlying `Formatter`. + pub fn finish(&mut self) -> std::fmt::Result { + self.builder.finish() + } +} + +/// Extension methods for `std::fmt::Formatter` which create builders that +/// format values using `DebugWithTypeInfo`. These helpers mirror the +/// standard formatter builders (`debug_struct`, `debug_tuple`, etc.) but +/// ensure that fields, entries and keys/values are displayed through the +/// `DebugWithTypeInfo` adapter. +pub trait DebugWithTypeInfoBuilder<'a, 'b: 'a> { + /// Start formatting a struct with the given name using type-aware + /// field formatting. + fn debug_struct_with_type_info(&'a mut self, name: &str) -> DebugStruct<'a, 'b>; + + /// Start formatting a tuple-like value with the given name using + /// type-aware element formatting. + fn debug_tuple_with_type_info(&'a mut self, name: &str) -> DebugTuple<'a, 'b>; + + /// Start formatting a list using type-aware entry formatting. + fn debug_list_with_type_info(&'a mut self) -> DebugList<'a, 'b>; + + /// Start formatting a set using type-aware entry formatting. + fn debug_set_with_type_info(&'a mut self) -> DebugSet<'a, 'b>; + + /// Start formatting a map using type-aware key/value formatting. + fn debug_map_with_type_info(&'a mut self) -> DebugMap<'a, 'b>; +} + +impl<'a, 'b: 'a> DebugWithTypeInfoBuilder<'a, 'b> for std::fmt::Formatter<'b> { + fn debug_struct_with_type_info(&'a mut self, name: &str) -> DebugStruct<'a, 'b> { + DebugStruct::new(self, name) + } + fn debug_tuple_with_type_info(&'a mut self, name: &str) -> DebugTuple<'a, 'b> { + DebugTuple::new(self, name) + } + fn debug_list_with_type_info(&'a mut self) -> DebugList<'a, 'b> { + DebugList::new(self) + } + fn debug_set_with_type_info(&'a mut self) -> DebugSet<'a, 'b> { + DebugSet::new(self) + } + fn debug_map_with_type_info(&'a mut self) -> DebugMap<'a, 'b> { + DebugMap::new(self) + } +} + +macro_rules! impl_debug_with_type_info_via_debug { + ($t:ty) => { + impl $crate::DebugWithTypeInfo for $t { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn $crate::GetTypeInfo>, + ) -> std::fmt::Result { + std::fmt::Debug::fmt(self, f) + } + } + }; +} + +macro_rules! impl_debug_with_type_info_via_display { + ($($t:ty),*) => { + $( + impl DebugWithTypeInfo for $t { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + ::fmt(self, f) + } + } + )* + }; +} + +use impl_debug_with_type_info_via_debug; +use impl_debug_with_type_info_via_display; + +macro_rules! impl_display_with_type_info_via_display { + ($($t:ty),*) => { + $( + impl DisplayWithTypeInfo for $t { + fn display_with_type_info( + &self, + f: &mut std::fmt::Formatter<'_>, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + ::fmt(self, f) + } + } + )* + }; +} + +use impl_display_with_type_info_via_display; diff --git a/crates/bevy_mod_scripting_display/src/printer/mod.rs b/crates/bevy_mod_scripting_display/src/printer/mod.rs new file mode 100644 index 0000000000..1e9b54f67b --- /dev/null +++ b/crates/bevy_mod_scripting_display/src/printer/mod.rs @@ -0,0 +1,208 @@ +use bevy_reflect::{DynamicTypePath, PartialReflect, ReflectRef, VariantField}; + +use crate::*; + +/// Contains a strategy for printing a `Reflect` value as if it was its native `Debug` implementation. +pub struct ReflectPrinter<'f, 'b: 'f> { + pub(crate) formatter: &'f mut std::fmt::Formatter<'b>, + pub(crate) result: std::fmt::Result, +} + +impl<'f, 'b: 'f> ReflectPrinter<'f, 'b> { + /// Creates a new `ReflectPrinter` with the given formatter. + pub fn new(formatter: &'f mut std::fmt::Formatter<'b>) -> ReflectPrinter<'f, 'b> { + ReflectPrinter { + formatter, + result: Ok(()), + } + } + + /// Prints a `Reflect` value as if it was its native `Debug` implementation. + pub fn debug(&mut self, value: &dyn PartialReflect) -> std::fmt::Result { + // try to print the value as if it was its native Debug implementation + match value.reflect_ref() { + ReflectRef::Struct(s) => self + .formatter + .debug_struct_with_type_info(s.reflect_ident_or_short_path()) + .build_with(|mut b| { + for (i, field) in s.iter_fields().enumerate() { + b.field( + s.name_at(i).unwrap_or("unknown"), + &PrintReflectAsDebug(field), + ); + } + b + }) + .finish(), + ReflectRef::TupleStruct(s) => self + .formatter + .debug_tuple_with_type_info(s.reflect_ident_or_short_path()) + .build_with(|mut b| { + for field in s.iter_fields() { + b.field(&PrintReflectAsDebug(field)); + } + b + }) + .finish(), + ReflectRef::Tuple(t) => self + .formatter + .debug_tuple_with_type_info(t.reflect_ident_or_short_path()) + .build_with(|mut b| { + for field in t.iter_fields() { + b.field(&PrintReflectAsDebug(field)); + } + b + }) + .finish(), + ReflectRef::List(l) => self + .formatter + .debug_list_with_type_info() + .build_with(|mut b| { + for field in l.iter() { + b.entry(&PrintReflectAsDebug(field)); + } + b + }) + .finish(), + ReflectRef::Array(a) => self + .formatter + .debug_list_with_type_info() + .build_with(|mut b| { + for field in a.iter() { + b.entry(&PrintReflectAsDebug(field)); + } + b + }) + .finish(), + ReflectRef::Map(m) => self + .formatter + .debug_map_with_type_info() + .build_with(|mut b| { + for (k, v) in m.iter() { + b.entry(&PrintReflectAsDebug(k), &PrintReflectAsDebug(v)); + } + b + }) + .finish(), + ReflectRef::Set(s) => self + .formatter + .debug_set_with_type_info() + .build_with(|mut b| { + for v in s.iter() { + b.entry(&PrintReflectAsDebug(v)); + } + b + }) + .finish(), + ReflectRef::Enum(e) => { + let is_tuple = !matches!(e.variant_type(), bevy_reflect::VariantType::Struct); + let variant_path = e.variant_name(); + if is_tuple { + self.formatter + .debug_tuple_with_type_info(variant_path) + .build_with(|mut b| { + for f in e.iter_fields() { + if let VariantField::Tuple(v) = f { + b.field(&PrintReflectAsDebug(v)); + } + // should not be possible + } + b + }) + .finish() + } else { + self.formatter + .debug_struct_with_type_info(variant_path) + .build_with(|mut b| { + for f in e.iter_fields() { + if let VariantField::Struct(name, value) = f { + b.field(name, &PrintReflectAsDebug(value)); + } + // should not be possible + } + b + }) + .finish() + } + } + ReflectRef::Opaque(o) => o.debug(self.formatter), + } + } + + /// Finalizes the printing process and returns the result. + pub fn finish(self) -> std::fmt::Result { + self.result + } +} + +/// A helper trait to get either the ident or the path of a type. +trait GetIdentOrPath { + fn reflect_ident_or_short_path(&self) -> &str; +} + +impl GetIdentOrPath for T { + fn reflect_ident_or_short_path(&self) -> &str { + self.reflect_type_ident() + .unwrap_or_else(|| self.reflect_short_type_path()) + } +} + +/// A wrapper type that implements `Debug` for any `PartialReflect` by using `ReflectPrinter`. +pub struct PrintReflectAsDebug<'a>(pub &'a dyn PartialReflect); + +impl DebugWithTypeInfo for PrintReflectAsDebug<'_> { + fn to_string_with_type_info( + &self, + f: &mut std::fmt::Formatter, + _type_info_provider: Option<&dyn GetTypeInfo>, + ) -> std::fmt::Result { + ReflectPrinter::new(f).debug(self.0) + } +} + +impl std::fmt::Debug for PrintReflectAsDebug<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + WithTypeInfo(self).fmt(f) + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_reflect_printer() { + assert_eq!(format!("{:?}", PrintReflectAsDebug(&42u32)), "42"); + assert_eq!(format!("{:?}", PrintReflectAsDebug(&"asd")), "\"asd\""); + assert_eq!( + format!("{:?}", PrintReflectAsDebug(&vec![1, 2, 3])), + "[1, 2, 3]" + ); + assert_eq!( + format!("{:?}", PrintReflectAsDebug(&Some("value"))), + "Some(\"value\")" + ); + assert_eq!(format!("{:?}", PrintReflectAsDebug(&None::)), "None"); + assert_eq!( + format!("{:?}", PrintReflectAsDebug(&("a", 42, true))), + "(&str, i32, bool)(\"a\", 42, true)" + ); + assert_eq!( + format!( + "{:?}", + PrintReflectAsDebug(&bevy_platform::collections::HashMap::::from([( + 1, "a" + ),])) + ), + "{1: \"a\"}" + ); + assert_eq!( + format!("{:?}", PrintReflectAsDebug(&[1, 2, 3])), + "[1, 2, 3]" + ); + assert_eq!( + format!("{:?}", PrintReflectAsDebug(&Some(vec![1, 2, 3]))), + "Some([1, 2, 3])" + ); + } +} diff --git a/crates/bevy_mod_scripting_functions/Cargo.toml b/crates/bevy_mod_scripting_functions/Cargo.toml index 47b3d81b8c..d62c480331 100644 --- a/crates/bevy_mod_scripting_functions/Cargo.toml +++ b/crates/bevy_mod_scripting_functions/Cargo.toml @@ -43,6 +43,8 @@ rhai_bindings = ["bevy_mod_scripting_rhai"] [dependencies] profiling = { workspace = true } bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } +bevy_mod_scripting_display = { workspace = true } bevy_mod_scripting_asset = { workspace = true } bevy_mod_scripting_derive = { workspace = true } bevy_mod_scripting_lua = { path = "../languages/bevy_mod_scripting_lua", optional = true, version = "0.15.1" } diff --git a/crates/bevy_mod_scripting_functions/src/core.rs b/crates/bevy_mod_scripting_functions/src/core.rs index daf16b806c..8fc5c8bdaa 100644 --- a/crates/bevy_mod_scripting_functions/src/core.rs +++ b/crates/bevy_mod_scripting_functions/src/core.rs @@ -7,34 +7,27 @@ use std::ops::Deref; use bevy_app::App; use bevy_asset::{AssetServer, Handle}; use bevy_ecs::{entity::Entity, prelude::AppTypeRegistry, schedule::Schedules, world::World}; -use bevy_mod_scripting_core::{ - bindings::{ - function::{ - from::Union, namespace::GlobalNamespace, script_function::DynamicScriptFunctionMut, - }, - script_system::ScriptSystemBuilder, - }, - docgen::info::FunctionInfo, - script::ScriptAttachment, - *, -}; -use bevy_mod_scripting_derive::script_bindings; -use bevy_reflect::PartialReflect; -use bevy_system_reflection::{ReflectSchedule, ReflectSystem}; -use bindings::{ +use bevy_mod_scripting_bindings::{ + DynamicScriptFunctionMut, FunctionInfo, GlobalNamespace, InteropError, PartialReflectExt, ReflectReference, ScriptComponentRegistration, ScriptQueryBuilder, ScriptQueryResult, - ScriptResourceRegistration, ScriptTypeRegistration, ThreadWorldContainer, WorldContainer, + ScriptResourceRegistration, ScriptTypeRegistration, ThreadWorldContainer, Union, + WorldContainer, function::{ from::{Ref, Val}, from_ref::FromScriptRef, into_ref::IntoScriptRef, script_function::{FunctionCallContext, ScriptFunctionMut}, }, - pretty_print::DisplayWithWorld, script_value::ScriptValue, }; -use error::InteropError; -use reflection_extensions::{PartialReflectExt, TypeIdExtensions}; +use bevy_mod_scripting_core::{ + script::ScriptAttachment, + script_system::{ManageScriptSystems, ScriptSystemBuilder}, +}; +use bevy_mod_scripting_derive::script_bindings; +use bevy_mod_scripting_display::{OrFakeId, WithTypeInfo}; +use bevy_reflect::PartialReflect; +use bevy_system_reflection::{ReflectSchedule, ReflectSystem}; #[allow(unused_variables, reason = "feature flags")] pub fn register_bevy_bindings(app: &mut App) { @@ -86,7 +79,7 @@ pub fn register_bevy_bindings(app: &mut App) { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "world_functions", unregistered )] @@ -144,7 +137,9 @@ impl World { }; // do two things, check it actually exists - world.scope_schedule(&schedule, |world, schedule| schedule.initialize(world))??; + world + .scope_schedule(&schedule, |world, schedule| schedule.initialize(world))? + .map_err(InteropError::external)?; Ok(Some(schedule.into())) } @@ -521,7 +516,7 @@ impl World { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "reflect_reference_functions", core )] @@ -542,7 +537,7 @@ impl ReflectReference { reference.variant_name(world) } - /// Displays this reference without printing the exact contents. + /// Displays this reference and its contents if possible. /// /// This is useful for debugging and logging. /// @@ -551,16 +546,15 @@ impl ReflectReference { /// * `reference`: The reference to display. /// Returns: /// * `display`: The display string. - fn display_ref( - ctxt: FunctionCallContext, + fn display( + _ctxt: FunctionCallContext, reference: ReflectReference, ) -> Result { - profiling::function_scope!("display_ref"); - let world = ctxt.world()?; - Ok(reference.display_with_world(world)) + profiling::function_scope!("display"); + Ok(format!("{}", WithTypeInfo::new(&reference))) } - /// Displays the "value" of this reference + /// Displays a debug representation of this reference. /// /// This is useful for debugging and logging. /// @@ -569,13 +563,12 @@ impl ReflectReference { /// * `reference`: The reference to display. /// Returns: /// * `display`: The display string. - fn display_value( - ctxt: FunctionCallContext, + fn debug( + _ctxt: FunctionCallContext, reference: ReflectReference, ) -> Result { - profiling::function_scope!("display_value"); - let world = ctxt.world()?; - Ok(reference.display_value_with_world(world)) + profiling::function_scope!("debug"); + Ok(format!("{reference:#?}")) } /// Gets and clones the value under the specified key if the underlying type is a map type. @@ -849,7 +842,7 @@ impl ReflectReference { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "script_type_registration_functions", core )] @@ -879,7 +872,7 @@ impl ScriptTypeRegistration { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "script_component_registration_functions", core )] @@ -909,7 +902,7 @@ impl ScriptComponentRegistration { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "script_resource_registration_functions", core )] @@ -939,7 +932,7 @@ impl ScriptResourceRegistration { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "script_query_builder_functions", core )] @@ -1017,7 +1010,7 @@ impl ScriptQueryBuilder { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "script_query_result_functions", core )] @@ -1049,7 +1042,7 @@ impl ScriptQueryResult { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "reflect_schedule_functions", core )] @@ -1121,7 +1114,7 @@ impl ReflectSchedule { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "reflect_system_functions", core )] @@ -1149,7 +1142,7 @@ impl ReflectSystem { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "script_system_builder_functions", core )] @@ -1241,7 +1234,7 @@ impl ScriptSystemBuilder { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "script_attachment_functions", core )] @@ -1280,7 +1273,7 @@ impl ScriptAttachment { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "script_handle_functions", core )] @@ -1308,7 +1301,7 @@ impl Handle { #[script_bindings( remote, - bms_core_path = "bevy_mod_scripting_core", + bms_bindings_path = "bevy_mod_scripting_bindings", name = "global_namespace_functions", unregistered )] diff --git a/crates/bindings/bevy_a11y_bms_bindings/Cargo.toml b/crates/bindings/bevy_a11y_bms_bindings/Cargo.toml index ab00958a87..72682e6c44 100644 --- a/crates/bindings/bevy_a11y_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_a11y_bms_bindings/Cargo.toml @@ -9,33 +9,24 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_a11y = { version = "0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = true } +bevy_a11y = { version = "0.16.1", features = ["std", "bevy_reflect"], default-features = true} -bevy_app = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = false } +bevy_app = { version = "^0.16.1", features = ["std", "bevy_reflect"], default-features = false} -bevy_derive = { version = "^0.16.1", features = [], default-features = true } +bevy_derive = { version = "^0.16.1", features = [], default-features = true} + +bevy_ecs = { version = "^0.16.1", features = ["std", "bevy_reflect", "async_executor"], default-features = false} + +bevy_reflect = { version = "^0.16.1", features = ["std"], default-features = false} -bevy_ecs = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", - "async_executor", -], default-features = false } -bevy_reflect = { version = "^0.16.1", features = [ - "std", -], default-features = false } diff --git a/crates/bindings/bevy_a11y_bms_bindings/src/lib.rs b/crates/bindings/bevy_a11y_bms_bindings/src/lib.rs index ab46b96660..0bd6d37980 100644 --- a/crates/bindings/bevy_a11y_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_a11y_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyA11YScriptingPlugin; pub(crate) fn register_accessibility_requested_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_a11y::AccessibilityRequested, >::new(world) .register_documented( @@ -73,11 +73,11 @@ pub(crate) fn register_accessibility_requested_functions(world: &mut World) { registry .register_type_data::< ::bevy_a11y::AccessibilityRequested, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_manage_accessibility_updates_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_a11y::ManageAccessibilityUpdates, >::new(world) .register_documented( @@ -132,11 +132,11 @@ pub(crate) fn register_manage_accessibility_updates_functions(world: &mut World) registry .register_type_data::< ::bevy_a11y::ManageAccessibilityUpdates, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_accessibility_system_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_a11y::AccessibilitySystem, >::new(world) .register_documented( @@ -198,7 +198,7 @@ pub(crate) fn register_accessibility_system_functions(world: &mut World) { registry .register_type_data::< ::bevy_a11y::AccessibilitySystem, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyA11YScriptingPlugin { diff --git a/crates/bindings/bevy_animation_bms_bindings/Cargo.toml b/crates/bindings/bevy_animation_bms_bindings/Cargo.toml index f0871278f3..29420ce96a 100644 --- a/crates/bindings/bevy_animation_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_animation_bms_bindings/Cargo.toml @@ -9,55 +9,58 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_animation = { version = "0.16.1", features = [], default-features = true } +bevy_animation = { version = "0.16.1", features = [], default-features = true} -bevy_app = { version = "^0.16.1", features = [], default-features = true } +bevy_app = { version = "^0.16.1", features = [], default-features = true} -bevy_asset = { version = "^0.16.1", features = [], default-features = true } +bevy_asset = { version = "^0.16.1", features = [], default-features = true} -bevy_color = { version = "^0.16.2", features = [], default-features = true } +bevy_color = { version = "^0.16.2", features = [], default-features = true} -bevy_derive = { version = "^0.16.1", features = [], default-features = true } +bevy_derive = { version = "^0.16.1", features = [], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [], default-features = true } +bevy_ecs = { version = "^0.16.1", features = [], default-features = true} -bevy_log = { version = "^0.16.1", features = [], default-features = true } +bevy_log = { version = "^0.16.1", features = [], default-features = true} -bevy_math = { version = "^0.16.1", features = [], default-features = true } +bevy_math = { version = "^0.16.1", features = [], default-features = true} -bevy_mesh = { version = "^0.16.1", features = [], default-features = true } +bevy_mesh = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_render = { version = "^0.16.1", features = [], default-features = true } +bevy_render = { version = "^0.16.1", features = [], default-features = true} -bevy_time = { version = "^0.16.1", features = [], default-features = true } +bevy_time = { version = "^0.16.1", features = [], default-features = true} -bevy_transform = { version = "^0.16.1", features = [], default-features = true } +bevy_transform = { version = "^0.16.1", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } +bevy_utils = { version = "^0.16.1", features = [], default-features = true} -blake3 = { version = "^1.0", features = [], default-features = true } +blake3 = { version = "^1.0", features = [], default-features = true} -either = { version = "^1.13", features = [], default-features = true } +either = { version = "^1.13", features = [], default-features = true} -petgraph = { version = "^0.7", features = [], default-features = true } +petgraph = { version = "^0.7", features = [], default-features = true} -ron = { version = "^0.8", features = [], default-features = true } +ron = { version = "^0.8", features = [], default-features = true} -serde = { version = "^1", features = [], default-features = true } +serde = { version = "^1", features = [], default-features = true} -smallvec = { version = "^1", features = [], default-features = true } +smallvec = { version = "^1", features = [], default-features = true} + +thread_local = { version = "^1", features = [], default-features = true} + +uuid = { version = "^1.13.1", features = [], default-features = true} -thread_local = { version = "^1", features = [], default-features = true } -uuid = { version = "^1.13.1", features = [], default-features = true } diff --git a/crates/bindings/bevy_animation_bms_bindings/src/lib.rs b/crates/bindings/bevy_animation_bms_bindings/src/lib.rs index df35e678aa..3e09ae2549 100644 --- a/crates/bindings/bevy_animation_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_animation_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyAnimationScriptingPlugin; pub(crate) fn register_animation_node_type_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::graph::AnimationNodeType, >::new(world) .register_documented( @@ -39,11 +39,11 @@ pub(crate) fn register_animation_node_type_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::graph::AnimationNodeType, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_animation_graph_handle_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::graph::AnimationGraphHandle, >::new(world) .register_documented( @@ -105,11 +105,11 @@ pub(crate) fn register_animation_graph_handle_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::graph::AnimationGraphHandle, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_threaded_animation_graphs_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::graph::ThreadedAnimationGraphs, >::new(world); let registry = world.get_resource_or_init::(); @@ -117,11 +117,11 @@ pub(crate) fn register_threaded_animation_graphs_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::graph::ThreadedAnimationGraphs, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_animation_clip_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::prelude::AnimationClip, >::new(world) .register_documented( @@ -180,11 +180,11 @@ pub(crate) fn register_animation_clip_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::prelude::AnimationClip, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_animation_player_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::prelude::AnimationPlayer, >::new(world) .register_documented( @@ -264,11 +264,11 @@ pub(crate) fn register_animation_player_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::prelude::AnimationPlayer, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_animation_graph_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::graph::AnimationGraph, >::new(world) .register_documented( @@ -331,11 +331,11 @@ pub(crate) fn register_animation_graph_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::graph::AnimationGraph, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_animation_transitions_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::transition::AnimationTransitions, >::new(world) .register_documented( @@ -400,11 +400,11 @@ pub(crate) fn register_animation_transitions_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::transition::AnimationTransitions, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_animation_target_id_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::AnimationTargetId, >::new(world) .register_documented( @@ -483,11 +483,11 @@ pub(crate) fn register_animation_target_id_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::AnimationTargetId, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_animation_target_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::AnimationTarget, >::new(world) .register_documented( @@ -511,11 +511,11 @@ pub(crate) fn register_animation_target_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::AnimationTarget, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_repeat_animation_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::RepeatAnimation, >::new(world) .register_documented( @@ -577,11 +577,11 @@ pub(crate) fn register_repeat_animation_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::RepeatAnimation, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_active_animation_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::ActiveAnimation, >::new(world) .register_documented( @@ -776,11 +776,11 @@ pub(crate) fn register_active_animation_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::ActiveAnimation, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_weights_curve_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::gltf_curves::WeightsCurve, >::new(world) .register_documented( @@ -805,11 +805,11 @@ pub(crate) fn register_weights_curve_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::gltf_curves::WeightsCurve, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cubic_rotation_curve_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::gltf_curves::CubicRotationCurve, >::new(world) .register_documented( @@ -836,11 +836,11 @@ pub(crate) fn register_cubic_rotation_curve_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::gltf_curves::CubicRotationCurve, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_animation_graph_node_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::graph::AnimationGraphNode, >::new(world) .register_documented( @@ -865,11 +865,11 @@ pub(crate) fn register_animation_graph_node_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::graph::AnimationGraphNode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_threaded_animation_graph_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::graph::ThreadedAnimationGraph, >::new(world); let registry = world.get_resource_or_init::(); @@ -877,11 +877,11 @@ pub(crate) fn register_threaded_animation_graph_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::graph::ThreadedAnimationGraph, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_animation_transition_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_animation::transition::AnimationTransition, >::new(world) .register_documented( @@ -908,7 +908,7 @@ pub(crate) fn register_animation_transition_functions(world: &mut World) { registry .register_type_data::< ::bevy_animation::transition::AnimationTransition, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyAnimationScriptingPlugin { diff --git a/crates/bindings/bevy_asset_bms_bindings/Cargo.toml b/crates/bindings/bevy_asset_bms_bindings/Cargo.toml index 3174133729..f8614c048d 100644 --- a/crates/bindings/bevy_asset_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_asset_bms_bindings/Cargo.toml @@ -9,80 +9,72 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_asset = { version = "0.16.1", features = [ - "notify-debouncer-full", - "watch", - "file_watcher", - "multi_threaded", -], default-features = true } +bevy_asset = { version = "0.16.1", features = ["notify-debouncer-full", "watch", "file_watcher", "multi_threaded"], default-features = true} -async-broadcast = { version = "^0.7.2", features = [], default-features = true } +async-broadcast = { version = "^0.7.2", features = [], default-features = true} -async-fs = { version = "^2.0", features = [], default-features = true } +async-fs = { version = "^2.0", features = [], default-features = true} -async-lock = { version = "^3.0", features = [], default-features = true } +async-lock = { version = "^3.0", features = [], default-features = true} -atomicow = { version = "^1.0", features = [], default-features = true } +atomicow = { version = "^1.0", features = [], default-features = true} -bevy_app = { version = "^0.16.1", features = [], default-features = true } +bevy_app = { version = "^0.16.1", features = [], default-features = true} -bevy_asset_macros = { version = "^0.16.1", features = [ -], default-features = true } +bevy_asset_macros = { version = "^0.16.1", features = [], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [], default-features = true } +bevy_ecs = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_tasks = { version = "^0.16.1", features = [ - "multi_threaded", - "multi_threaded", -], default-features = false } +bevy_tasks = { version = "^0.16.1", features = ["multi_threaded", "multi_threaded"], default-features = false} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } +bevy_utils = { version = "^0.16.1", features = [], default-features = true} -bevy_window = { version = "^0.16.1", features = [], default-features = true } +bevy_window = { version = "^0.16.1", features = [], default-features = true} -bitflags = { version = "^2.3", features = [], default-features = true } +bitflags = { version = "^2.3", features = [], default-features = true} -blake3 = { version = "^1.5", features = [], default-features = true } +blake3 = { version = "^1.5", features = [], default-features = true} -crossbeam-channel = { version = "^0.5", features = [], default-features = true } +crossbeam-channel = { version = "^0.5", features = [], default-features = true} -disqualified = { version = "^1.0", features = [], default-features = true } +disqualified = { version = "^1.0", features = [], default-features = true} -either = { version = "^1.13", features = [], default-features = true } +either = { version = "^1.13", features = [], default-features = true} -futures-io = { version = "^0.3", features = [], default-features = true } +futures-io = { version = "^0.3", features = [], default-features = true} -futures-lite = { version = "^2.0.1", features = [], default-features = true } +futures-lite = { version = "^2.0.1", features = [], default-features = true} -js-sys = { version = "^0.3", features = [], default-features = true } +js-sys = { version = "^0.3", features = [], default-features = true} -notify-debouncer-full = { version = "^0.5.0", features = [ -], default-features = true } +notify-debouncer-full = { version = "^0.5.0", features = [], default-features = true} -parking_lot = { version = "^0.12", features = [], default-features = true } +parking_lot = { version = "^0.12", features = [], default-features = true} -ron = { version = "^0.8", features = [], default-features = true } +ron = { version = "^0.8", features = [], default-features = true} -serde = { version = "^1", features = [], default-features = true } +serde = { version = "^1", features = [], default-features = true} -stackfuture = { version = "^0.3", features = [], default-features = true } +stackfuture = { version = "^0.3", features = [], default-features = true} -uuid = { version = "^1.13.1", features = [], default-features = true } +uuid = { version = "^1.13.1", features = [], default-features = true} -wasm-bindgen = { version = "^0.2", features = [], default-features = true } +wasm-bindgen = { version = "^0.2", features = [], default-features = true} + +wasm-bindgen-futures = { version = "^0.4", features = [], default-features = true} + +web-sys = { version = "^0.3", features = [], default-features = true} -wasm-bindgen-futures = { version = "^0.4", features = [ -], default-features = true } -web-sys = { version = "^0.3", features = [], default-features = true } diff --git a/crates/bindings/bevy_asset_bms_bindings/src/lib.rs b/crates/bindings/bevy_asset_bms_bindings/src/lib.rs index d7d6d7d1e5..a7223709a3 100644 --- a/crates/bindings/bevy_asset_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_asset_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyAssetScriptingPlugin; pub(crate) fn register_asset_index_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_asset::AssetIndex, >::new(world) .register_documented( @@ -106,11 +106,11 @@ pub(crate) fn register_asset_index_functions(world: &mut World) { registry .register_type_data::< ::bevy_asset::AssetIndex, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_render_asset_usages_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_asset::RenderAssetUsages, >::new(world) .register_documented( @@ -534,7 +534,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) { registry .register_type_data::< ::bevy_asset::RenderAssetUsages, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyAssetScriptingPlugin { diff --git a/crates/bindings/bevy_color_bms_bindings/Cargo.toml b/crates/bindings/bevy_color_bms_bindings/Cargo.toml index 2892e7a54b..ecad6ee17d 100644 --- a/crates/bindings/bevy_color_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_color_bms_bindings/Cargo.toml @@ -9,32 +9,24 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_ecs = { workspace = true, features = ["std", "bevy_reflect"] } bevy_app = { workspace = true, features = ["std"] } bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_color = { version = "0.16.2", features = [ - "wgpu-types", - "alloc", - "std", - "bevy_reflect", - "encase", -], default-features = true } +bevy_color = { version = "0.16.2", features = ["std", "bevy_reflect", "encase", "alloc", "wgpu-types"], default-features = true} -bevy_math = { version = "^0.16.1", features = [ - "alloc", - "std", -], default-features = false } +bevy_math = { version = "^0.16.1", features = ["std", "alloc"], default-features = false} -bevy_reflect = { version = "^0.16.1", features = [ - "std", -], default-features = false } +bevy_reflect = { version = "^0.16.1", features = ["std"], default-features = false} + +bytemuck = { version = "^1", features = [], default-features = true} + +wgpu-types = { version = "^24", features = ["std"], default-features = false} -bytemuck = { version = "^1", features = [], default-features = true } -wgpu-types = { version = "^24", features = ["std"], default-features = false } diff --git a/crates/bindings/bevy_color_bms_bindings/src/lib.rs b/crates/bindings/bevy_color_bms_bindings/src/lib.rs index 7d8777c53b..76859d9761 100644 --- a/crates/bindings/bevy_color_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_color_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyColorScriptingPlugin; pub(crate) fn register_color_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_color::prelude::Color, >::new(world) .register_documented( @@ -538,11 +538,11 @@ pub(crate) fn register_color_functions(world: &mut World) { registry .register_type_data::< ::bevy_color::prelude::Color, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_srgba_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_color::prelude::Srgba, >::new(world) .register_documented( @@ -861,11 +861,11 @@ pub(crate) fn register_srgba_functions(world: &mut World) { registry .register_type_data::< ::bevy_color::prelude::Srgba, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_linear_rgba_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_color::prelude::LinearRgba, >::new(world) .register_documented( @@ -1111,11 +1111,11 @@ pub(crate) fn register_linear_rgba_functions(world: &mut World) { registry .register_type_data::< ::bevy_color::prelude::LinearRgba, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_hsla_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_color::prelude::Hsla, >::new(world) .register_documented( @@ -1252,11 +1252,11 @@ pub(crate) fn register_hsla_functions(world: &mut World) { registry .register_type_data::< ::bevy_color::prelude::Hsla, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_hsva_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_color::prelude::Hsva, >::new(world) .register_documented( @@ -1376,11 +1376,11 @@ pub(crate) fn register_hsva_functions(world: &mut World) { registry .register_type_data::< ::bevy_color::prelude::Hsva, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_hwba_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_color::prelude::Hwba, >::new(world) .register_documented( @@ -1500,11 +1500,11 @@ pub(crate) fn register_hwba_functions(world: &mut World) { registry .register_type_data::< ::bevy_color::prelude::Hwba, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_laba_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_color::prelude::Laba, >::new(world) .register_documented( @@ -1697,11 +1697,11 @@ pub(crate) fn register_laba_functions(world: &mut World) { registry .register_type_data::< ::bevy_color::prelude::Laba, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_lcha_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_color::prelude::Lcha, >::new(world) .register_documented( @@ -1838,11 +1838,11 @@ pub(crate) fn register_lcha_functions(world: &mut World) { registry .register_type_data::< ::bevy_color::prelude::Lcha, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_oklaba_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_color::prelude::Oklaba, >::new(world) .register_documented( @@ -2071,11 +2071,11 @@ pub(crate) fn register_oklaba_functions(world: &mut World) { registry .register_type_data::< ::bevy_color::prelude::Oklaba, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_oklcha_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_color::prelude::Oklcha, >::new(world) .register_documented( @@ -2212,11 +2212,11 @@ pub(crate) fn register_oklcha_functions(world: &mut World) { registry .register_type_data::< ::bevy_color::prelude::Oklcha, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_xyza_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_color::prelude::Xyza, >::new(world) .register_documented( @@ -2445,7 +2445,7 @@ pub(crate) fn register_xyza_functions(world: &mut World) { registry .register_type_data::< ::bevy_color::prelude::Xyza, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyColorScriptingPlugin { diff --git a/crates/bindings/bevy_core_pipeline_bms_bindings/Cargo.toml b/crates/bindings/bevy_core_pipeline_bms_bindings/Cargo.toml index 5854dab1c9..ce470d6b4c 100644 --- a/crates/bindings/bevy_core_pipeline_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_core_pipeline_bms_bindings/Cargo.toml @@ -9,64 +9,54 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_core_pipeline = { version = "0.16.1", features = [ - "smaa_luts", - "tonemapping_luts", - "webgl", -], default-features = true } +bevy_core_pipeline = { version = "0.16.1", features = ["smaa_luts", "tonemapping_luts", "webgl"], default-features = true} -bevy_app = { version = "^0.16.1", features = [], default-features = true } +bevy_app = { version = "^0.16.1", features = [], default-features = true} -bevy_asset = { version = "^0.16.1", features = [], default-features = true } +bevy_asset = { version = "^0.16.1", features = [], default-features = true} -bevy_color = { version = "^0.16.2", features = [], default-features = true } +bevy_color = { version = "^0.16.2", features = [], default-features = true} -bevy_derive = { version = "^0.16.1", features = [], default-features = true } +bevy_derive = { version = "^0.16.1", features = [], default-features = true} -bevy_diagnostic = { version = "^0.16.1", features = [ -], default-features = true } +bevy_diagnostic = { version = "^0.16.1", features = [], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [], default-features = true } +bevy_ecs = { version = "^0.16.1", features = [], default-features = true} -bevy_image = { version = "^0.16.1", features = [ - "ktx2", - "zstd", - "ktx2", - "zstd", -], default-features = false } +bevy_image = { version = "^0.16.1", features = ["ktx2", "zstd", "ktx2", "zstd"], default-features = false} -bevy_math = { version = "^0.16.1", features = [], default-features = true } +bevy_math = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_render = { version = "^0.16.1", features = [ - "ktx2", - "ktx2", -], default-features = false } +bevy_render = { version = "^0.16.1", features = ["ktx2", "ktx2"], default-features = false} -bevy_transform = { version = "^0.16.1", features = [], default-features = true } +bevy_transform = { version = "^0.16.1", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } +bevy_utils = { version = "^0.16.1", features = [], default-features = true} -bevy_window = { version = "^0.16.1", features = [], default-features = true } +bevy_window = { version = "^0.16.1", features = [], default-features = true} -bitflags = { version = "^2.3", features = [], default-features = true } +bitflags = { version = "^2.3", features = [], default-features = true} -bytemuck = { version = "^1", features = [], default-features = true } +bytemuck = { version = "^1", features = [], default-features = true} -nonmax = { version = "^0.5", features = [], default-features = true } +nonmax = { version = "^0.5", features = [], default-features = true} -radsort = { version = "^0.1", features = [], default-features = true } +radsort = { version = "^0.1", features = [], default-features = true} + +serde = { version = "^1", features = [], default-features = true} + +smallvec = { version = "^1", features = [], default-features = true} -serde = { version = "^1", features = [], default-features = true } -smallvec = { version = "^1", features = [], default-features = true } diff --git a/crates/bindings/bevy_core_pipeline_bms_bindings/src/lib.rs b/crates/bindings/bevy_core_pipeline_bms_bindings/src/lib.rs index 0a06a5051a..97e750849e 100644 --- a/crates/bindings/bevy_core_pipeline_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_core_pipeline_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyCorePipelineScriptingPlugin; pub(crate) fn register_skybox_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::Skybox, >::new(world) .register_documented( @@ -36,11 +36,11 @@ pub(crate) fn register_skybox_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::Skybox, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_camera_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::core_2d::Camera2d, >::new(world) .register_documented( @@ -66,11 +66,11 @@ pub(crate) fn register_camera_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::core_2d::Camera2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_camera_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::core_3d::Camera3d, >::new(world) .register_documented( @@ -96,11 +96,11 @@ pub(crate) fn register_camera_3_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::core_3d::Camera3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_deferred_prepass_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::prepass::DeferredPrepass, >::new(world); let registry = world.get_resource_or_init::(); @@ -108,11 +108,11 @@ pub(crate) fn register_deferred_prepass_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::prepass::DeferredPrepass, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_depth_prepass_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::prepass::DepthPrepass, >::new(world) .register_documented( @@ -137,11 +137,11 @@ pub(crate) fn register_depth_prepass_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::prepass::DepthPrepass, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_motion_vector_prepass_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::prepass::MotionVectorPrepass, >::new(world) .register_documented( @@ -168,11 +168,11 @@ pub(crate) fn register_motion_vector_prepass_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::prepass::MotionVectorPrepass, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_normal_prepass_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::prepass::NormalPrepass, >::new(world) .register_documented( @@ -197,11 +197,11 @@ pub(crate) fn register_normal_prepass_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::prepass::NormalPrepass, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_auto_exposure_compensation_curve_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::auto_exposure::AutoExposureCompensationCurve, >::new(world) .register_documented( @@ -234,11 +234,11 @@ pub(crate) fn register_auto_exposure_compensation_curve_functions(world: &mut Wo registry .register_type_data::< ::bevy_core_pipeline::auto_exposure::AutoExposureCompensationCurve, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_auto_exposure_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::auto_exposure::AutoExposure, >::new(world) .register_documented( @@ -265,11 +265,11 @@ pub(crate) fn register_auto_exposure_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::auto_exposure::AutoExposure, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_tonemapping_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::tonemapping::Tonemapping, >::new(world) .register_documented( @@ -350,11 +350,11 @@ pub(crate) fn register_tonemapping_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::tonemapping::Tonemapping, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_bloom_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::bloom::Bloom, >::new(world) .register_documented( @@ -378,11 +378,11 @@ pub(crate) fn register_bloom_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::bloom::Bloom, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_bloom_composite_mode_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::bloom::BloomCompositeMode, >::new(world) .register_documented( @@ -446,11 +446,11 @@ pub(crate) fn register_bloom_composite_mode_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::bloom::BloomCompositeMode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_bloom_prefilter_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::bloom::BloomPrefilter, >::new(world) .register_documented( @@ -475,11 +475,11 @@ pub(crate) fn register_bloom_prefilter_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::bloom::BloomPrefilter, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_contrast_adaptive_sharpening_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::contrast_adaptive_sharpening::ContrastAdaptiveSharpening, >::new(world) .register_documented( @@ -512,11 +512,11 @@ pub(crate) fn register_contrast_adaptive_sharpening_functions(world: &mut World) registry .register_type_data::< ::bevy_core_pipeline::contrast_adaptive_sharpening::ContrastAdaptiveSharpening, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_denoise_cas_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::contrast_adaptive_sharpening::DenoiseCas, >::new(world) .register_documented( @@ -545,11 +545,11 @@ pub(crate) fn register_denoise_cas_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::contrast_adaptive_sharpening::DenoiseCas, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_fxaa_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::fxaa::Fxaa, >::new(world) .register_documented( @@ -573,11 +573,11 @@ pub(crate) fn register_fxaa_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::fxaa::Fxaa, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_smaa_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::smaa::Smaa, >::new(world) .register_documented( @@ -601,11 +601,11 @@ pub(crate) fn register_smaa_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::smaa::Smaa, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_deband_dither_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::tonemapping::DebandDither, >::new(world) .register_documented( @@ -669,11 +669,11 @@ pub(crate) fn register_deband_dither_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::tonemapping::DebandDither, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_motion_blur_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::motion_blur::MotionBlur, >::new(world) .register_documented( @@ -698,11 +698,11 @@ pub(crate) fn register_motion_blur_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::motion_blur::MotionBlur, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_depth_of_field_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::dof::DepthOfField, >::new(world) .register_documented( @@ -728,11 +728,11 @@ pub(crate) fn register_depth_of_field_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::dof::DepthOfField, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_screen_space_transmission_quality_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::core_3d::ScreenSpaceTransmissionQuality, >::new(world) .register_documented( @@ -785,11 +785,11 @@ pub(crate) fn register_screen_space_transmission_quality_functions(world: &mut W registry .register_type_data::< ::bevy_core_pipeline::core_3d::ScreenSpaceTransmissionQuality, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_camera_3_d_depth_load_op_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::core_3d::Camera3dDepthLoadOp, >::new(world) .register_documented( @@ -816,11 +816,11 @@ pub(crate) fn register_camera_3_d_depth_load_op_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::core_3d::Camera3dDepthLoadOp, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_camera_3_d_depth_texture_usage_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::core_3d::Camera3dDepthTextureUsage, >::new(world) .register_documented( @@ -849,11 +849,11 @@ pub(crate) fn register_camera_3_d_depth_texture_usage_functions(world: &mut Worl registry .register_type_data::< ::bevy_core_pipeline::core_3d::Camera3dDepthTextureUsage, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_depth_of_field_mode_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::dof::DepthOfFieldMode, >::new(world) .register_documented( @@ -898,11 +898,11 @@ pub(crate) fn register_depth_of_field_mode_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::dof::DepthOfFieldMode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_temporal_anti_aliasing_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::experimental::taa::TemporalAntiAliasing, >::new(world) .register_documented( @@ -931,11 +931,11 @@ pub(crate) fn register_temporal_anti_aliasing_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::experimental::taa::TemporalAntiAliasing, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_sensitivity_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::fxaa::Sensitivity, >::new(world) .register_documented( @@ -997,11 +997,11 @@ pub(crate) fn register_sensitivity_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::fxaa::Sensitivity, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_order_independent_transparency_settings_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::oit::OrderIndependentTransparencySettings, >::new(world) .register_documented( @@ -1034,11 +1034,11 @@ pub(crate) fn register_order_independent_transparency_settings_functions(world: registry .register_type_data::< ::bevy_core_pipeline::oit::OrderIndependentTransparencySettings, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_chromatic_aberration_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::post_process::ChromaticAberration, >::new(world) .register_documented( @@ -1067,11 +1067,11 @@ pub(crate) fn register_chromatic_aberration_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::post_process::ChromaticAberration, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_smaa_preset_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_core_pipeline::smaa::SmaaPreset, >::new(world) .register_documented( @@ -1133,7 +1133,7 @@ pub(crate) fn register_smaa_preset_functions(world: &mut World) { registry .register_type_data::< ::bevy_core_pipeline::smaa::SmaaPreset, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyCorePipelineScriptingPlugin { diff --git a/crates/bindings/bevy_ecs_bms_bindings/Cargo.toml b/crates/bindings/bevy_ecs_bms_bindings/Cargo.toml index 6ae8392d46..bf5dd80161 100644 --- a/crates/bindings/bevy_ecs_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_ecs_bms_bindings/Cargo.toml @@ -9,75 +9,50 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_app = { workspace = true, features = ["std"] } bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_ecs = { version = "0.16.1", features = [ - "std", - "async_executor", - "multi_threaded", - "bevy_reflect", - "backtrace", - "serialize", -], default-features = true } +bevy_ecs = { version = "0.16.1", features = ["std", "bevy_reflect", "async_executor", "backtrace", "multi_threaded", "serialize"], default-features = true} -arrayvec = { version = "^0.7.4", features = ["std"], default-features = false } +arrayvec = { version = "^0.7.4", features = ["std"], default-features = false} -bevy_ecs_macros = { version = "^0.16.1", features = [ -], default-features = true } +bevy_ecs_macros = { version = "^0.16.1", features = [], default-features = true} -bevy_platform = { version = "^0.16.1", features = [ - "std", - "serialize", -], default-features = false } +bevy_platform = { version = "^0.16.1", features = ["std", "serialize"], default-features = false} -bevy_ptr = { version = "^0.16.1", features = [], default-features = true } +bevy_ptr = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [ - "std", -], default-features = false } +bevy_reflect = { version = "^0.16.1", features = ["std"], default-features = false} -bevy_tasks = { version = "^0.16.1", features = [ - "std", - "async_executor", - "multi_threaded", -], default-features = false } +bevy_tasks = { version = "^0.16.1", features = ["std", "async_executor", "multi_threaded"], default-features = false} -bevy_utils = { version = "^0.16.1", features = [ - "std", - "serde", -], default-features = false } +bevy_utils = { version = "^0.16.1", features = ["std", "serde"], default-features = false} -bitflags = { version = "^2.3", features = ["std"], default-features = false } +bitflags = { version = "^2.3", features = ["std"], default-features = false} -bumpalo = { version = "^3", features = [], default-features = true } +bumpalo = { version = "^3", features = [], default-features = true} -concurrent-queue = { version = "^2.5.0", features = [ - "std", - "std", -], default-features = false } +concurrent-queue = { version = "^2.5.0", features = ["std", "std"], default-features = false} -disqualified = { version = "^1.0", features = [ - "alloc", -], default-features = false } +disqualified = { version = "^1.0", features = ["alloc"], default-features = false} -fixedbitset = { version = "^0.5", features = ["std"], default-features = false } +fixedbitset = { version = "^0.5", features = ["std"], default-features = false} -indexmap = { version = "^2.5.0", features = [ - "std", - "serde", -], default-features = false } +indexmap = { version = "^2.5.0", features = ["std", "serde"], default-features = false} -log = { version = "^0.4", features = ["std"], default-features = false } +log = { version = "^0.4", features = ["std"], default-features = false} -nonmax = { version = "^0.5", features = ["std"], default-features = false } +nonmax = { version = "^0.5", features = ["std"], default-features = false} + +serde = { version = "^1", features = ["std"], default-features = false} + +smallvec = { version = "^1", features = [], default-features = true} -serde = { version = "^1", features = ["std"], default-features = false } -smallvec = { version = "^1", features = [], default-features = true } diff --git a/crates/bindings/bevy_ecs_bms_bindings/src/lib.rs b/crates/bindings/bevy_ecs_bms_bindings/src/lib.rs index 53269f7c5c..bd0502c5b5 100644 --- a/crates/bindings/bevy_ecs_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_ecs_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyEcsScriptingPlugin; pub(crate) fn register_entity_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::entity::Entity, >::new(world) .register_documented( @@ -143,11 +143,11 @@ pub(crate) fn register_entity_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::entity::Entity, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_child_of_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::hierarchy::ChildOf, >::new(world) .register_documented( @@ -243,11 +243,11 @@ pub(crate) fn register_child_of_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::hierarchy::ChildOf, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_children_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::hierarchy::Children, >::new(world) .register_documented( @@ -315,55 +315,55 @@ pub(crate) fn register_children_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::hierarchy::Children, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_name_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::name::Name, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_ecs::name::Name>| { - let output: Val<::bevy_ecs::name::Name> = { - { - let output: Val<::bevy_ecs::name::Name> = - <::bevy_ecs::name::Name as ::core::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ) - .register_documented( - "eq", - |_self: Ref<::bevy_ecs::name::Name>, other: Ref<::bevy_ecs::name::Name>| { - let output: bool = { - { - let output: bool = <::bevy_ecs::name::Name as ::core::cmp::PartialEq< - ::bevy_ecs::name::Name, - >>::eq(&_self, &other) - .into(); - output - } - }; - output - }, - "", - &["_self", "other"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_ecs::name::Name>| { + let output: Val<::bevy_ecs::name::Name> = { + { + let output: Val<::bevy_ecs::name::Name> = <::bevy_ecs::name::Name as ::core::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ) + .register_documented( + "eq", + |_self: Ref<::bevy_ecs::name::Name>, other: Ref<::bevy_ecs::name::Name>| { + let output: bool = { + { + let output: bool = <::bevy_ecs::name::Name as ::core::cmp::PartialEq< + ::bevy_ecs::name::Name, + >>::eq(&_self, &other) + .into(); + output + } + }; + output + }, + "", + &["_self", "other"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_ecs::name::Name, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_ecs::name::Name, bevy_mod_scripting_bindings::MarkAsGenerated>( + ); } pub(crate) fn register_on_add_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::world::OnAdd, >::new(world); let registry = world.get_resource_or_init::(); @@ -371,11 +371,11 @@ pub(crate) fn register_on_add_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::world::OnAdd, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_on_insert_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::world::OnInsert, >::new(world); let registry = world.get_resource_or_init::(); @@ -383,11 +383,11 @@ pub(crate) fn register_on_insert_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::world::OnInsert, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_on_remove_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::world::OnRemove, >::new(world); let registry = world.get_resource_or_init::(); @@ -395,11 +395,11 @@ pub(crate) fn register_on_remove_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::world::OnRemove, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_on_replace_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::world::OnReplace, >::new(world); let registry = world.get_resource_or_init::(); @@ -407,11 +407,11 @@ pub(crate) fn register_on_replace_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::world::OnReplace, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_component_id_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::component::ComponentId, >::new(world) .register_documented( @@ -507,11 +507,11 @@ pub(crate) fn register_component_id_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::component::ComponentId, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_default_query_filters_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::entity_disabling::DefaultQueryFilters, >::new(world) .register_documented( @@ -557,11 +557,11 @@ pub(crate) fn register_default_query_filters_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::entity_disabling::DefaultQueryFilters, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_tick_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::component::Tick, >::new(world) .register_documented( @@ -698,11 +698,11 @@ pub(crate) fn register_tick_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::component::Tick, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_component_ticks_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::component::ComponentTicks, >::new(world) .register_documented( @@ -811,11 +811,11 @@ pub(crate) fn register_component_ticks_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::component::ComponentTicks, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_entity_hash_set_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::entity::hash_set::EntityHashSet, >::new(world) .register_documented( @@ -943,11 +943,11 @@ pub(crate) fn register_entity_hash_set_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::entity::hash_set::EntityHashSet, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_identifier_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::identifier::Identifier, >::new(world) .register_documented( @@ -1060,11 +1060,11 @@ pub(crate) fn register_identifier_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::identifier::Identifier, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_entity_hash_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::entity::EntityHash, >::new(world) .register_documented( @@ -1088,11 +1088,11 @@ pub(crate) fn register_entity_hash_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::entity::EntityHash, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_disabled_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::entity_disabling::Disabled, >::new(world) .register_documented( @@ -1118,11 +1118,11 @@ pub(crate) fn register_disabled_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::entity_disabling::Disabled, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_removed_component_entity_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::removal_detection::RemovedComponentEntity, >::new(world) .register_documented( @@ -1149,11 +1149,11 @@ pub(crate) fn register_removed_component_entity_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::removal_detection::RemovedComponentEntity, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_system_id_marker_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::system::SystemIdMarker, >::new(world); let registry = world.get_resource_or_init::(); @@ -1161,11 +1161,11 @@ pub(crate) fn register_system_id_marker_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::system::SystemIdMarker, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_on_despawn_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_ecs::world::OnDespawn, >::new(world); let registry = world.get_resource_or_init::(); @@ -1173,7 +1173,7 @@ pub(crate) fn register_on_despawn_functions(world: &mut World) { registry .register_type_data::< ::bevy_ecs::world::OnDespawn, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyEcsScriptingPlugin { diff --git a/crates/bindings/bevy_gizmos_bms_bindings/Cargo.toml b/crates/bindings/bevy_gizmos_bms_bindings/Cargo.toml index ad51f55fdd..d8447a5a66 100644 --- a/crates/bindings/bevy_gizmos_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_gizmos_bms_bindings/Cargo.toml @@ -9,53 +9,48 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_gizmos = { version = "0.16.1", features = [ - "bevy_pbr", - "bevy_core_pipeline", - "bevy_render", - "bevy_sprite", - "webgl", -], default-features = false } +bevy_gizmos = { version = "0.16.1", features = ["bevy_pbr", "bevy_core_pipeline", "bevy_render", "bevy_sprite", "webgl"], default-features = false} -bevy_app = { version = "^0.16.1", features = [], default-features = true } +bevy_app = { version = "^0.16.1", features = [], default-features = true} -bevy_asset = { version = "^0.16.1", features = [], default-features = true } +bevy_asset = { version = "^0.16.1", features = [], default-features = true} -bevy_color = { version = "^0.16.2", features = [], default-features = true } +bevy_color = { version = "^0.16.2", features = [], default-features = true} -bevy_core_pipeline = { version = "^0.16.1", features = [ -], default-features = true } +bevy_core_pipeline = { version = "^0.16.1", features = [], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [], default-features = true } +bevy_ecs = { version = "^0.16.1", features = [], default-features = true} -bevy_gizmos_macros = { version = "^0.16.1", features = [ -], default-features = true } +bevy_gizmos_macros = { version = "^0.16.1", features = [], default-features = true} -bevy_image = { version = "^0.16.1", features = [], default-features = true } +bevy_image = { version = "^0.16.1", features = [], default-features = true} -bevy_math = { version = "^0.16.1", features = [], default-features = true } +bevy_math = { version = "^0.16.1", features = [], default-features = true} -bevy_pbr = { version = "^0.16.1", features = [], default-features = true } +bevy_pbr = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_render = { version = "^0.16.1", features = [], default-features = true } +bevy_render = { version = "^0.16.1", features = [], default-features = true} -bevy_sprite = { version = "^0.16.1", features = [], default-features = true } +bevy_sprite = { version = "^0.16.1", features = [], default-features = true} -bevy_time = { version = "^0.16.1", features = [], default-features = true } +bevy_time = { version = "^0.16.1", features = [], default-features = true} -bevy_transform = { version = "^0.16.1", features = [], default-features = true } +bevy_transform = { version = "^0.16.1", features = [], default-features = true} + +bevy_utils = { version = "^0.16.1", features = [], default-features = true} + +bytemuck = { version = "^1.0", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } -bytemuck = { version = "^1.0", features = [], default-features = true } diff --git a/crates/bindings/bevy_gizmos_bms_bindings/src/lib.rs b/crates/bindings/bevy_gizmos_bms_bindings/src/lib.rs index 0fc7d02f6f..4d5f5056f4 100644 --- a/crates/bindings/bevy_gizmos_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_gizmos_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyGizmosScriptingPlugin; pub(crate) fn register_aabb_gizmo_config_group_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::aabb::AabbGizmoConfigGroup, >::new(world) .register_documented( @@ -39,11 +39,11 @@ pub(crate) fn register_aabb_gizmo_config_group_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::aabb::AabbGizmoConfigGroup, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_show_aabb_gizmo_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::aabb::ShowAabbGizmo, >::new(world); let registry = world.get_resource_or_init::(); @@ -51,11 +51,11 @@ pub(crate) fn register_show_aabb_gizmo_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::aabb::ShowAabbGizmo, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_default_gizmo_config_group_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::config::DefaultGizmoConfigGroup, >::new(world); let registry = world.get_resource_or_init::(); @@ -63,11 +63,11 @@ pub(crate) fn register_default_gizmo_config_group_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::config::DefaultGizmoConfigGroup, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gizmo_config_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::config::GizmoConfig, >::new(world) .register_documented( @@ -91,11 +91,11 @@ pub(crate) fn register_gizmo_config_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::config::GizmoConfig, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gizmo_config_store_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::config::GizmoConfigStore, >::new(world); let registry = world.get_resource_or_init::(); @@ -103,11 +103,11 @@ pub(crate) fn register_gizmo_config_store_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::config::GizmoConfigStore, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gizmo_line_config_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::config::GizmoLineConfig, >::new(world) .register_documented( @@ -133,11 +133,11 @@ pub(crate) fn register_gizmo_line_config_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::config::GizmoLineConfig, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gizmo_line_joint_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::config::GizmoLineJoint, >::new(world) .register_documented( @@ -199,11 +199,11 @@ pub(crate) fn register_gizmo_line_joint_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::config::GizmoLineJoint, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gizmo_line_style_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::config::GizmoLineStyle, >::new(world) .register_documented( @@ -248,11 +248,11 @@ pub(crate) fn register_gizmo_line_style_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::config::GizmoLineStyle, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gizmo_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::retained::Gizmo, >::new(world) .register_documented( @@ -276,11 +276,11 @@ pub(crate) fn register_gizmo_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::retained::Gizmo, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_light_gizmo_color_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::light::LightGizmoColor, >::new(world) .register_documented( @@ -306,11 +306,11 @@ pub(crate) fn register_light_gizmo_color_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::light::LightGizmoColor, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_light_gizmo_config_group_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::light::LightGizmoConfigGroup, >::new(world) .register_documented( @@ -335,11 +335,11 @@ pub(crate) fn register_light_gizmo_config_group_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::light::LightGizmoConfigGroup, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_show_light_gizmo_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::light::ShowLightGizmo, >::new(world); let registry = world.get_resource_or_init::(); @@ -347,11 +347,11 @@ pub(crate) fn register_show_light_gizmo_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::light::ShowLightGizmo, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_erased_gizmo_config_group_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gizmos::config::ErasedGizmoConfigGroup, >::new(world) .register_documented( @@ -376,7 +376,7 @@ pub(crate) fn register_erased_gizmo_config_group_functions(world: &mut World) { registry .register_type_data::< ::bevy_gizmos::config::ErasedGizmoConfigGroup, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyGizmosScriptingPlugin { diff --git a/crates/bindings/bevy_gltf_bms_bindings/Cargo.toml b/crates/bindings/bevy_gltf_bms_bindings/Cargo.toml index c6914b170c..54e687c089 100644 --- a/crates/bindings/bevy_gltf_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_gltf_bms_bindings/Cargo.toml @@ -9,62 +9,62 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_gltf = { version = "0.16.1", features = [ - "bevy_animation", -], default-features = true } +bevy_gltf = { version = "0.16.1", features = ["bevy_animation"], default-features = true} -base64 = { version = "^0.22.0", features = [], default-features = true } +base64 = { version = "^0.22.0", features = [], default-features = true} -bevy_animation = { version = "^0.16.1", features = [], default-features = true } +bevy_animation = { version = "^0.16.1", features = [], default-features = true} -bevy_app = { version = "^0.16.1", features = [], default-features = true } +bevy_app = { version = "^0.16.1", features = [], default-features = true} -bevy_asset = { version = "^0.16.1", features = [], default-features = true } +bevy_asset = { version = "^0.16.1", features = [], default-features = true} -bevy_color = { version = "^0.16.2", features = [], default-features = true } +bevy_color = { version = "^0.16.2", features = [], default-features = true} -bevy_core_pipeline = { version = "^0.16.1", features = [ -], default-features = true } +bevy_core_pipeline = { version = "^0.16.1", features = [], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [], default-features = true } +bevy_ecs = { version = "^0.16.1", features = [], default-features = true} -bevy_image = { version = "^0.16.1", features = [], default-features = true } +bevy_image = { version = "^0.16.1", features = [], default-features = true} -bevy_math = { version = "^0.16.1", features = [], default-features = true } +bevy_math = { version = "^0.16.1", features = [], default-features = true} -bevy_mesh = { version = "^0.16.1", features = [], default-features = true } +bevy_mesh = { version = "^0.16.1", features = [], default-features = true} -bevy_pbr = { version = "^0.16.1", features = [], default-features = true } +bevy_pbr = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_render = { version = "^0.16.1", features = [], default-features = true } +bevy_render = { version = "^0.16.1", features = [], default-features = true} -bevy_scene = { version = "^0.16.1", features = [], default-features = true } +bevy_scene = { version = "^0.16.1", features = [], default-features = true} -bevy_tasks = { version = "^0.16.1", features = [], default-features = true } +bevy_tasks = { version = "^0.16.1", features = [], default-features = true} -bevy_transform = { version = "^0.16.1", features = [], default-features = true } +bevy_transform = { version = "^0.16.1", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } +bevy_utils = { version = "^0.16.1", features = [], default-features = true} -fixedbitset = { version = "^0.5", features = [], default-features = true } +fixedbitset = { version = "^0.5", features = [], default-features = true} -itertools = { version = "^0.14", features = [], default-features = true } +itertools = { version = "^0.14", features = [], default-features = true} -percent-encoding = { version = "^2.1", features = [], default-features = true } +percent-encoding = { version = "^2.1", features = [], default-features = true} -serde = { version = "^1.0", features = [], default-features = true } +serde = { version = "^1.0", features = [], default-features = true} + +serde_json = { version = "^1.0.140", features = [], default-features = true} + +smallvec = { version = "^1.11", features = [], default-features = true} -serde_json = { version = "^1.0.140", features = [], default-features = true } -smallvec = { version = "^1.11", features = [], default-features = true } diff --git a/crates/bindings/bevy_gltf_bms_bindings/src/lib.rs b/crates/bindings/bevy_gltf_bms_bindings/src/lib.rs index 88025840b4..3c4d746c5b 100644 --- a/crates/bindings/bevy_gltf_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_gltf_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyGltfScriptingPlugin; pub(crate) fn register_gltf_extras_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gltf::prelude::GltfExtras, >::new(world) .register_documented( @@ -37,11 +37,11 @@ pub(crate) fn register_gltf_extras_functions(world: &mut World) { registry .register_type_data::< ::bevy_gltf::prelude::GltfExtras, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gltf_scene_extras_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gltf::GltfSceneExtras, >::new(world) .register_documented( @@ -64,38 +64,40 @@ pub(crate) fn register_gltf_scene_extras_functions(world: &mut World) { registry .register_type_data::< ::bevy_gltf::GltfSceneExtras, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gltf_mesh_extras_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gltf::GltfMeshExtras, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_gltf::GltfMeshExtras>| { - let output: Val<::bevy_gltf::GltfMeshExtras> = { - { - let output: Val<::bevy_gltf::GltfMeshExtras> = - <::bevy_gltf::GltfMeshExtras as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_gltf::GltfMeshExtras>| { + let output: Val<::bevy_gltf::GltfMeshExtras> = { + { + let output: Val<::bevy_gltf::GltfMeshExtras> = <::bevy_gltf::GltfMeshExtras as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_gltf::GltfMeshExtras, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gltf_material_extras_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gltf::GltfMaterialExtras, >::new(world) .register_documented( @@ -119,11 +121,11 @@ pub(crate) fn register_gltf_material_extras_functions(world: &mut World) { registry .register_type_data::< ::bevy_gltf::GltfMaterialExtras, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gltf_material_name_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_gltf::GltfMaterialName, >::new(world) .register_documented( @@ -147,7 +149,7 @@ pub(crate) fn register_gltf_material_name_functions(world: &mut World) { registry .register_type_data::< ::bevy_gltf::GltfMaterialName, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyGltfScriptingPlugin { diff --git a/crates/bindings/bevy_image_bms_bindings/Cargo.toml b/crates/bindings/bevy_image_bms_bindings/Cargo.toml index 1e731e0cea..826811e988 100644 --- a/crates/bindings/bevy_image_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_image_bms_bindings/Cargo.toml @@ -9,57 +9,48 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_ecs = { workspace = true, features = ["std", "bevy_reflect"] } bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_image = { version = "0.16.1", features = [ - "hdr", - "ktx2", - "png", - "ruzstd", - "zstd", - "bevy_reflect", -], default-features = true } +bevy_image = { version = "0.16.1", features = ["bevy_reflect", "hdr", "ktx2", "png", "ruzstd", "zstd"], default-features = true} -bevy_app = { version = "^0.16.1", features = [], default-features = true } +bevy_app = { version = "^0.16.1", features = [], default-features = true} -bevy_asset = { version = "^0.16.1", features = [], default-features = true } +bevy_asset = { version = "^0.16.1", features = [], default-features = true} -bevy_color = { version = "^0.16.2", features = [], default-features = true } +bevy_color = { version = "^0.16.2", features = [], default-features = true} -bevy_math = { version = "^0.16.1", features = [ - "bevy_reflect", -], default-features = false } +bevy_math = { version = "^0.16.1", features = ["bevy_reflect"], default-features = false} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } +bevy_utils = { version = "^0.16.1", features = [], default-features = true} -bitflags = { version = "^2.3", features = [], default-features = true } +bitflags = { version = "^2.3", features = [], default-features = true} -bytemuck = { version = "^1.5", features = [], default-features = true } +bytemuck = { version = "^1.5", features = [], default-features = true} -futures-lite = { version = "^2.0.1", features = [], default-features = true } +futures-lite = { version = "^2.0.1", features = [], default-features = true} -guillotiere = { version = "^0.6.0", features = [], default-features = true } +guillotiere = { version = "^0.6.0", features = [], default-features = true} -half = { version = "^2.4.1", features = [], default-features = true } +half = { version = "^2.4.1", features = [], default-features = true} -image = { version = "^0.25.2", features = [ - "hdr", - "png", -], default-features = false } +image = { version = "^0.25.2", features = ["hdr", "png"], default-features = false} -ktx2 = { version = "^0.3.0", features = [], default-features = true } +ktx2 = { version = "^0.3.0", features = [], default-features = true} -rectangle-pack = { version = "^0.4", features = [], default-features = true } +rectangle-pack = { version = "^0.4", features = [], default-features = true} + +ruzstd = { version = "^0.8.0", features = [], default-features = true} + +serde = { version = "^1", features = [], default-features = true} -ruzstd = { version = "^0.8.0", features = [], default-features = true } -serde = { version = "^1", features = [], default-features = true } diff --git a/crates/bindings/bevy_image_bms_bindings/src/lib.rs b/crates/bindings/bevy_image_bms_bindings/src/lib.rs index 14e2e7e9e6..252a5e1c98 100644 --- a/crates/bindings/bevy_image_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_image_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyImageScriptingPlugin; pub(crate) fn register_texture_atlas_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_image::prelude::TextureAtlas, >::new(world) .register_documented( @@ -75,11 +75,11 @@ pub(crate) fn register_texture_atlas_functions(world: &mut World) { registry .register_type_data::< ::bevy_image::prelude::TextureAtlas, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_texture_atlas_layout_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_image::prelude::TextureAtlasLayout, >::new(world) .register_documented( @@ -213,11 +213,11 @@ pub(crate) fn register_texture_atlas_layout_functions(world: &mut World) { registry .register_type_data::< ::bevy_image::prelude::TextureAtlasLayout, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_image_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_image::prelude::Image, >::new(world) .register_documented( @@ -406,7 +406,7 @@ pub(crate) fn register_image_functions(world: &mut World) { registry .register_type_data::< ::bevy_image::prelude::Image, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyImageScriptingPlugin { diff --git a/crates/bindings/bevy_input_bms_bindings/Cargo.toml b/crates/bindings/bevy_input_bms_bindings/Cargo.toml index ed605afb9b..28287c6158 100644 --- a/crates/bindings/bevy_input_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_input_bms_bindings/Cargo.toml @@ -9,46 +9,28 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_input = { version = "0.16.1", features = [ - "std", - "bevy_reflect", - "smol_str", -], default-features = true } - - -bevy_app = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = false } - -bevy_ecs = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", - "async_executor", -], default-features = false } - -bevy_math = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = false } - -bevy_platform = { version = "^0.16.1", features = [ - "std", -], default-features = false } - -bevy_reflect = { version = "^0.16.1", features = [ - "std", - "smol_str", -], default-features = false } - -bevy_utils = { version = "^0.16.1", features = [ - "std", -], default-features = false } +bevy_input = { version = "0.16.1", features = ["std", "bevy_reflect", "smol_str"], default-features = true} + + +bevy_app = { version = "^0.16.1", features = ["std", "bevy_reflect"], default-features = false} + +bevy_ecs = { version = "^0.16.1", features = ["std", "bevy_reflect", "async_executor"], default-features = false} + +bevy_math = { version = "^0.16.1", features = ["std", "bevy_reflect"], default-features = false} + +bevy_platform = { version = "^0.16.1", features = ["std"], default-features = false} + +bevy_reflect = { version = "^0.16.1", features = ["std", "smol_str"], default-features = false} + +bevy_utils = { version = "^0.16.1", features = ["std"], default-features = false} + + diff --git a/crates/bindings/bevy_input_bms_bindings/src/lib.rs b/crates/bindings/bevy_input_bms_bindings/src/lib.rs index e5e31dd85f..786041ec21 100644 --- a/crates/bindings/bevy_input_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_input_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyInputScriptingPlugin; pub(crate) fn register_gamepad_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::Gamepad, >::new(world) .register_documented( @@ -169,11 +169,11 @@ pub(crate) fn register_gamepad_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::Gamepad, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gamepad_axis_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::GamepadAxis, >::new(world) .register_documented( @@ -235,11 +235,11 @@ pub(crate) fn register_gamepad_axis_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::GamepadAxis, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gamepad_button_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::GamepadButton, >::new(world) .register_documented( @@ -301,11 +301,11 @@ pub(crate) fn register_gamepad_button_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::GamepadButton, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gamepad_settings_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::GamepadSettings, >::new(world) .register_documented( @@ -331,11 +331,11 @@ pub(crate) fn register_gamepad_settings_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::GamepadSettings, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_key_code_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::keyboard::KeyCode, >::new(world) .register_documented( @@ -397,11 +397,11 @@ pub(crate) fn register_key_code_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::keyboard::KeyCode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mouse_button_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::mouse::MouseButton, >::new(world) .register_documented( @@ -463,11 +463,11 @@ pub(crate) fn register_mouse_button_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::mouse::MouseButton, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_touch_input_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::touch::TouchInput, >::new(world) .register_documented( @@ -510,11 +510,11 @@ pub(crate) fn register_touch_input_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::touch::TouchInput, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_keyboard_focus_lost_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::keyboard::KeyboardFocusLost, >::new(world) .register_documented( @@ -576,11 +576,11 @@ pub(crate) fn register_keyboard_focus_lost_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::keyboard::KeyboardFocusLost, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_keyboard_input_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::keyboard::KeyboardInput, >::new(world) .register_documented( @@ -642,11 +642,11 @@ pub(crate) fn register_keyboard_input_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::keyboard::KeyboardInput, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_accumulated_mouse_motion_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::mouse::AccumulatedMouseMotion, >::new(world) .register_documented( @@ -691,11 +691,11 @@ pub(crate) fn register_accumulated_mouse_motion_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::mouse::AccumulatedMouseMotion, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_accumulated_mouse_scroll_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::mouse::AccumulatedMouseScroll, >::new(world) .register_documented( @@ -740,11 +740,11 @@ pub(crate) fn register_accumulated_mouse_scroll_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::mouse::AccumulatedMouseScroll, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mouse_button_input_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::mouse::MouseButtonInput, >::new(world) .register_documented( @@ -806,11 +806,11 @@ pub(crate) fn register_mouse_button_input_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::mouse::MouseButtonInput, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mouse_motion_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::mouse::MouseMotion, >::new(world) .register_documented( @@ -853,11 +853,11 @@ pub(crate) fn register_mouse_motion_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::mouse::MouseMotion, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mouse_wheel_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::mouse::MouseWheel, >::new(world) .register_documented( @@ -900,11 +900,11 @@ pub(crate) fn register_mouse_wheel_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::mouse::MouseWheel, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gamepad_axis_changed_event_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::GamepadAxisChangedEvent, >::new(world) .register_documented( @@ -976,11 +976,11 @@ pub(crate) fn register_gamepad_axis_changed_event_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::GamepadAxisChangedEvent, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gamepad_button_changed_event_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::GamepadButtonChangedEvent, >::new(world) .register_documented( @@ -1054,11 +1054,11 @@ pub(crate) fn register_gamepad_button_changed_event_functions(world: &mut World) registry .register_type_data::< ::bevy_input::gamepad::GamepadButtonChangedEvent, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gamepad_button_state_changed_event_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::GamepadButtonStateChangedEvent, >::new(world) .register_documented( @@ -1147,11 +1147,11 @@ pub(crate) fn register_gamepad_button_state_changed_event_functions(world: &mut registry .register_type_data::< ::bevy_input::gamepad::GamepadButtonStateChangedEvent, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gamepad_connection_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::GamepadConnection, >::new(world) .register_documented( @@ -1196,11 +1196,11 @@ pub(crate) fn register_gamepad_connection_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::GamepadConnection, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gamepad_connection_event_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::GamepadConnectionEvent, >::new(world) .register_documented( @@ -1300,11 +1300,11 @@ pub(crate) fn register_gamepad_connection_event_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::GamepadConnectionEvent, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gamepad_event_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::GamepadEvent, >::new(world) .register_documented( @@ -1349,11 +1349,11 @@ pub(crate) fn register_gamepad_event_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::GamepadEvent, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gamepad_input_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::GamepadInput, >::new(world) .register_documented( @@ -1415,11 +1415,11 @@ pub(crate) fn register_gamepad_input_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::GamepadInput, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gamepad_rumble_request_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::GamepadRumbleRequest, >::new(world) .register_documented( @@ -1461,11 +1461,11 @@ pub(crate) fn register_gamepad_rumble_request_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::GamepadRumbleRequest, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_raw_gamepad_axis_changed_event_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::RawGamepadAxisChangedEvent, >::new(world) .register_documented( @@ -1537,11 +1537,11 @@ pub(crate) fn register_raw_gamepad_axis_changed_event_functions(world: &mut Worl registry .register_type_data::< ::bevy_input::gamepad::RawGamepadAxisChangedEvent, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_raw_gamepad_button_changed_event_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::RawGamepadButtonChangedEvent, >::new(world) .register_documented( @@ -1613,11 +1613,11 @@ pub(crate) fn register_raw_gamepad_button_changed_event_functions(world: &mut Wo registry .register_type_data::< ::bevy_input::gamepad::RawGamepadButtonChangedEvent, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_raw_gamepad_event_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::RawGamepadEvent, >::new(world) .register_documented( @@ -1662,11 +1662,11 @@ pub(crate) fn register_raw_gamepad_event_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::RawGamepadEvent, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pinch_gesture_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gestures::PinchGesture, >::new(world) .register_documented( @@ -1711,11 +1711,11 @@ pub(crate) fn register_pinch_gesture_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gestures::PinchGesture, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_rotation_gesture_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gestures::RotationGesture, >::new(world) .register_documented( @@ -1760,11 +1760,11 @@ pub(crate) fn register_rotation_gesture_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gestures::RotationGesture, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_double_tap_gesture_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gestures::DoubleTapGesture, >::new(world) .register_documented( @@ -1809,11 +1809,11 @@ pub(crate) fn register_double_tap_gesture_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gestures::DoubleTapGesture, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pan_gesture_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gestures::PanGesture, >::new(world) .register_documented( @@ -1856,11 +1856,11 @@ pub(crate) fn register_pan_gesture_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gestures::PanGesture, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_button_state_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::ButtonState, >::new(world) .register_documented( @@ -1937,11 +1937,11 @@ pub(crate) fn register_button_state_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::ButtonState, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_button_settings_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::ButtonSettings, >::new(world) .register_documented( @@ -2092,11 +2092,11 @@ pub(crate) fn register_button_settings_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::ButtonSettings, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_axis_settings_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::AxisSettings, >::new(world) .register_documented( @@ -2334,11 +2334,11 @@ pub(crate) fn register_axis_settings_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::AxisSettings, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_button_axis_settings_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::ButtonAxisSettings, >::new(world) .register_documented( @@ -2364,11 +2364,11 @@ pub(crate) fn register_button_axis_settings_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::ButtonAxisSettings, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_gamepad_rumble_intensity_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::gamepad::GamepadRumbleIntensity, >::new(world) .register_documented( @@ -2447,11 +2447,11 @@ pub(crate) fn register_gamepad_rumble_intensity_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::gamepad::GamepadRumbleIntensity, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_key_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::keyboard::Key, >::new(world) .register_documented( @@ -2513,11 +2513,11 @@ pub(crate) fn register_key_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::keyboard::Key, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_native_key_code_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::keyboard::NativeKeyCode, >::new(world) .register_documented( @@ -2579,11 +2579,11 @@ pub(crate) fn register_native_key_code_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::keyboard::NativeKeyCode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_native_key_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::keyboard::NativeKey, >::new(world) .register_documented( @@ -2645,11 +2645,11 @@ pub(crate) fn register_native_key_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::keyboard::NativeKey, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mouse_scroll_unit_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::mouse::MouseScrollUnit, >::new(world) .register_documented( @@ -2711,11 +2711,11 @@ pub(crate) fn register_mouse_scroll_unit_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::mouse::MouseScrollUnit, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_touch_phase_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::touch::TouchPhase, >::new(world) .register_documented( @@ -2777,11 +2777,11 @@ pub(crate) fn register_touch_phase_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::touch::TouchPhase, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_force_touch_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input::touch::ForceTouch, >::new(world) .register_documented( @@ -2824,7 +2824,7 @@ pub(crate) fn register_force_touch_functions(world: &mut World) { registry .register_type_data::< ::bevy_input::touch::ForceTouch, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyInputScriptingPlugin { diff --git a/crates/bindings/bevy_input_focus_bms_bindings/Cargo.toml b/crates/bindings/bevy_input_focus_bms_bindings/Cargo.toml index a5333d49c0..87c1854f6c 100644 --- a/crates/bindings/bevy_input_focus_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_input_focus_bms_bindings/Cargo.toml @@ -9,46 +9,28 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_input_focus = { version = "0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = true } - - -bevy_app = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = false } - -bevy_ecs = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", - "async_executor", -], default-features = false } - -bevy_input = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = false } - -bevy_math = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = false } - -bevy_reflect = { version = "^0.16.1", features = [ - "std", -], default-features = false } - -bevy_window = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = false } +bevy_input_focus = { version = "0.16.1", features = ["std", "bevy_reflect"], default-features = true} + + +bevy_app = { version = "^0.16.1", features = ["std", "bevy_reflect"], default-features = false} + +bevy_ecs = { version = "^0.16.1", features = ["std", "bevy_reflect", "async_executor"], default-features = false} + +bevy_input = { version = "^0.16.1", features = ["std", "bevy_reflect"], default-features = false} + +bevy_math = { version = "^0.16.1", features = ["std", "bevy_reflect"], default-features = false} + +bevy_reflect = { version = "^0.16.1", features = ["std"], default-features = false} + +bevy_window = { version = "^0.16.1", features = ["std", "bevy_reflect"], default-features = false} + + diff --git a/crates/bindings/bevy_input_focus_bms_bindings/src/lib.rs b/crates/bindings/bevy_input_focus_bms_bindings/src/lib.rs index e512dd3678..1030ab25b9 100644 --- a/crates/bindings/bevy_input_focus_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_input_focus_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyInputFocusScriptingPlugin; pub(crate) fn register_input_focus_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input_focus::InputFocus, >::new(world) .register_documented( @@ -93,11 +93,11 @@ pub(crate) fn register_input_focus_functions(world: &mut World) { registry .register_type_data::< ::bevy_input_focus::InputFocus, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_input_focus_visible_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input_focus::InputFocusVisible, >::new(world) .register_documented( @@ -123,11 +123,11 @@ pub(crate) fn register_input_focus_visible_functions(world: &mut World) { registry .register_type_data::< ::bevy_input_focus::InputFocusVisible, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_auto_focus_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input_focus::AutoFocus, >::new(world) .register_documented( @@ -151,11 +151,11 @@ pub(crate) fn register_auto_focus_functions(world: &mut World) { registry .register_type_data::< ::bevy_input_focus::AutoFocus, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_directional_navigation_map_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input_focus::directional_navigation::DirectionalNavigationMap, >::new(world) .register_documented( @@ -333,11 +333,11 @@ pub(crate) fn register_directional_navigation_map_functions(world: &mut World) { registry .register_type_data::< ::bevy_input_focus::directional_navigation::DirectionalNavigationMap, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_nav_neighbors_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input_focus::directional_navigation::NavNeighbors, >::new(world) .register_documented( @@ -409,11 +409,11 @@ pub(crate) fn register_nav_neighbors_functions(world: &mut World) { registry .register_type_data::< ::bevy_input_focus::directional_navigation::NavNeighbors, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_tab_index_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input_focus::tab_navigation::TabIndex, >::new(world) .register_documented( @@ -475,11 +475,11 @@ pub(crate) fn register_tab_index_functions(world: &mut World) { registry .register_type_data::< ::bevy_input_focus::tab_navigation::TabIndex, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_tab_group_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_input_focus::tab_navigation::TabGroup, >::new(world) .register_documented( @@ -536,7 +536,7 @@ pub(crate) fn register_tab_group_functions(world: &mut World) { registry .register_type_data::< ::bevy_input_focus::tab_navigation::TabGroup, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyInputFocusScriptingPlugin { diff --git a/crates/bindings/bevy_math_bms_bindings/Cargo.toml b/crates/bindings/bevy_math_bms_bindings/Cargo.toml index 83eb5a560c..da94c64de2 100644 --- a/crates/bindings/bevy_math_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_math_bms_bindings/Cargo.toml @@ -9,49 +9,32 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_ecs = { workspace = true, features = ["std", "bevy_reflect"] } bevy_app = { workspace = true, features = ["std"] } bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_math = { version = "0.16.1", features = [ - "alloc", - "std", - "rand", - "curve", - "bevy_reflect", -], default-features = true } +bevy_math = { version = "0.16.1", features = ["std", "rand", "curve", "alloc", "bevy_reflect"], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [ - "std", -], default-features = false } +bevy_reflect = { version = "^0.16.1", features = ["std"], default-features = false} -derive_more = { version = "^1", features = ["std"], default-features = false } +derive_more = { version = "^1", features = ["std"], default-features = false} -glam = { version = "^0.29.3", features = [ - "std", - "rand", -], default-features = false } +glam = { version = "^0.29.3", features = ["std", "rand"], default-features = false} -itertools = { version = "^0.14.0", features = [ - "use_alloc", - "use_std", -], default-features = false } +itertools = { version = "^0.14.0", features = ["use_std", "use_alloc"], default-features = false} -rand = { version = "^0.8", features = [ - "alloc", - "std", -], default-features = false } +rand = { version = "^0.8", features = ["std", "alloc"], default-features = false} -rand_distr = { version = "^0.4.3", features = [ - "alloc", - "std", -], default-features = false } +rand_distr = { version = "^0.4.3", features = ["std", "alloc"], default-features = false} + +smallvec = { version = "^1.11", features = [], default-features = true} + +variadics_please = { version = "^1.1", features = [], default-features = true} -smallvec = { version = "^1.11", features = [], default-features = true } -variadics_please = { version = "^1.1", features = [], default-features = true } diff --git a/crates/bindings/bevy_math_bms_bindings/src/lib.rs b/crates/bindings/bevy_math_bms_bindings/src/lib.rs index 6ff37a071d..fff6a798ec 100644 --- a/crates/bindings/bevy_math_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_math_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,122 +13,129 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyMathScriptingPlugin; pub(crate) fn register_aspect_ratio_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::AspectRatio, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_math::AspectRatio>| { - let output: Val<::bevy_math::AspectRatio> = { - { - let output: Val<::bevy_math::AspectRatio> = - <::bevy_math::AspectRatio as ::core::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ) - .register_documented( - "eq", - |_self: Ref<::bevy_math::AspectRatio>, other: Ref<::bevy_math::AspectRatio>| { - let output: bool = { - { - let output: bool = <::bevy_math::AspectRatio as ::core::cmp::PartialEq< - ::bevy_math::AspectRatio, - >>::eq(&_self, &other) - .into(); - output - } - }; - output - }, - "", - &["_self", "other"], - ) - .register_documented( - "inverse", - |_self: Ref<::bevy_math::AspectRatio>| { - let output: Val<::bevy_math::AspectRatio> = { - { - let output: Val<::bevy_math::AspectRatio> = - ::bevy_math::AspectRatio::inverse(&_self).into(); - output - } - }; - output - }, - " Returns the inverse of this aspect ratio (height/width).", - &["_self"], - ) - .register_documented( - "is_landscape", - |_self: Ref<::bevy_math::AspectRatio>| { - let output: bool = { - { - let output: bool = ::bevy_math::AspectRatio::is_landscape(&_self).into(); - output - } - }; - output - }, - " Returns true if the aspect ratio represents a landscape orientation.", - &["_self"], - ) - .register_documented( - "is_portrait", - |_self: Ref<::bevy_math::AspectRatio>| { - let output: bool = { - { - let output: bool = ::bevy_math::AspectRatio::is_portrait(&_self).into(); - output - } - }; - output - }, - " Returns true if the aspect ratio represents a portrait orientation.", - &["_self"], - ) - .register_documented( - "is_square", - |_self: Ref<::bevy_math::AspectRatio>| { - let output: bool = { - { - let output: bool = ::bevy_math::AspectRatio::is_square(&_self).into(); - output - } - }; - output - }, - " Returns true if the aspect ratio is exactly square.", - &["_self"], - ) - .register_documented( - "ratio", - |_self: Ref<::bevy_math::AspectRatio>| { - let output: f32 = { - { - let output: f32 = ::bevy_math::AspectRatio::ratio(&_self).into(); - output - } - }; - output - }, - " Returns the aspect ratio as a f32 value.", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_math::AspectRatio>| { + let output: Val<::bevy_math::AspectRatio> = { + { + let output: Val<::bevy_math::AspectRatio> = <::bevy_math::AspectRatio as ::core::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ) + .register_documented( + "eq", + |_self: Ref<::bevy_math::AspectRatio>, other: Ref<::bevy_math::AspectRatio>| { + let output: bool = { + { + let output: bool = <::bevy_math::AspectRatio as ::core::cmp::PartialEq< + ::bevy_math::AspectRatio, + >>::eq(&_self, &other) + .into(); + output + } + }; + output + }, + "", + &["_self", "other"], + ) + .register_documented( + "inverse", + |_self: Ref<::bevy_math::AspectRatio>| { + let output: Val<::bevy_math::AspectRatio> = { + { + let output: Val<::bevy_math::AspectRatio> = ::bevy_math::AspectRatio::inverse( + &_self, + ) + .into(); + output + } + }; + output + }, + " Returns the inverse of this aspect ratio (height/width).", + &["_self"], + ) + .register_documented( + "is_landscape", + |_self: Ref<::bevy_math::AspectRatio>| { + let output: bool = { + { + let output: bool = ::bevy_math::AspectRatio::is_landscape(&_self) + .into(); + output + } + }; + output + }, + " Returns true if the aspect ratio represents a landscape orientation.", + &["_self"], + ) + .register_documented( + "is_portrait", + |_self: Ref<::bevy_math::AspectRatio>| { + let output: bool = { + { + let output: bool = ::bevy_math::AspectRatio::is_portrait(&_self) + .into(); + output + } + }; + output + }, + " Returns true if the aspect ratio represents a portrait orientation.", + &["_self"], + ) + .register_documented( + "is_square", + |_self: Ref<::bevy_math::AspectRatio>| { + let output: bool = { + { + let output: bool = ::bevy_math::AspectRatio::is_square(&_self) + .into(); + output + } + }; + output + }, + " Returns true if the aspect ratio is exactly square.", + &["_self"], + ) + .register_documented( + "ratio", + |_self: Ref<::bevy_math::AspectRatio>| { + let output: f32 = { + { + let output: f32 = ::bevy_math::AspectRatio::ratio(&_self).into(); + output + } + }; + output + }, + " Returns the aspect ratio as a f32 value.", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_math::AspectRatio, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_compass_octant_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::CompassOctant, >::new(world) .register_documented( @@ -241,11 +248,11 @@ pub(crate) fn register_compass_octant_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::CompassOctant, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_compass_quadrant_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::CompassQuadrant, >::new(world) .register_documented( @@ -358,11 +365,11 @@ pub(crate) fn register_compass_quadrant_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::CompassQuadrant, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_isometry_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::Isometry2d, >::new(world) .register_documented( @@ -605,11 +612,11 @@ pub(crate) fn register_isometry_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::Isometry2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_isometry_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::Isometry3d, >::new(world) .register_documented( @@ -790,227 +797,195 @@ pub(crate) fn register_isometry_3_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::Isometry3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_ray_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< - ::bevy_math::Ray2d, - >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_math::Ray2d>| { - let output: Val<::bevy_math::Ray2d> = { - { - let output: Val<::bevy_math::Ray2d> = <::bevy_math::Ray2d as ::core::clone::Clone>::clone( - &_self, - ) - .into(); - output - } - }; - output - }, - "", - &["_self"], - ) - .register_documented( - "eq", - |_self: Ref<::bevy_math::Ray2d>, other: Ref<::bevy_math::Ray2d>| { - let output: bool = { - { - let output: bool = <::bevy_math::Ray2d as ::core::cmp::PartialEq< - ::bevy_math::Ray2d, - >>::eq(&_self, &other) - .into(); - output - } - }; - output - }, - "", - &["_self", "other"], - ) - .register_documented( - "get_point", - |_self: Ref<::bevy_math::Ray2d>, distance: f32| { - let output: Val<::bevy_math::prelude::Vec2> = { - { - let output: Val<::bevy_math::prelude::Vec2> = ::bevy_math::Ray2d::get_point( - &_self, - distance, - ) - .into(); - output - } - }; - output - }, - " Get a point at a given distance along the ray", - &["_self", "distance"], - ) - .register_documented( - "intersect_plane", - | - _self: Ref<::bevy_math::Ray2d>, - plane_origin: Val<::bevy_math::prelude::Vec2>, - plane: Val<::bevy_math::primitives::Plane2d>| - { - let output: ::core::option::Option = { - { - let output: ::core::option::Option = ::bevy_math::Ray2d::intersect_plane( - &_self, - plane_origin.into_inner(), - plane.into_inner(), - ) - .into(); - output - } - }; - output - }, - " Get the distance to a plane if the ray intersects it", - &["_self", "plane_origin", "plane"], - ) - .register_documented( - "new", - | - origin: Val<::bevy_math::prelude::Vec2>, - direction: Val<::bevy_math::prelude::Dir2>| - { - let output: Val<::bevy_math::Ray2d> = { - { - let output: Val<::bevy_math::Ray2d> = ::bevy_math::Ray2d::new( - origin.into_inner(), - direction.into_inner(), - ) - .into(); - output - } - }; - output - }, - " Create a new `Ray2d` from a given origin and direction", - &["origin", "direction"], - ); + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::<::bevy_math::Ray2d>::new( + world, + ) + .register_documented( + "clone", + |_self: Ref<::bevy_math::Ray2d>| { + let output: Val<::bevy_math::Ray2d> = { + { + let output: Val<::bevy_math::Ray2d> = + <::bevy_math::Ray2d as ::core::clone::Clone>::clone(&_self).into(); + output + } + }; + output + }, + "", + &["_self"], + ) + .register_documented( + "eq", + |_self: Ref<::bevy_math::Ray2d>, other: Ref<::bevy_math::Ray2d>| { + let output: bool = { + { + let output: bool = <::bevy_math::Ray2d as ::core::cmp::PartialEq< + ::bevy_math::Ray2d, + >>::eq(&_self, &other) + .into(); + output + } + }; + output + }, + "", + &["_self", "other"], + ) + .register_documented( + "get_point", + |_self: Ref<::bevy_math::Ray2d>, distance: f32| { + let output: Val<::bevy_math::prelude::Vec2> = { + { + let output: Val<::bevy_math::prelude::Vec2> = + ::bevy_math::Ray2d::get_point(&_self, distance).into(); + output + } + }; + output + }, + " Get a point at a given distance along the ray", + &["_self", "distance"], + ) + .register_documented( + "intersect_plane", + |_self: Ref<::bevy_math::Ray2d>, + plane_origin: Val<::bevy_math::prelude::Vec2>, + plane: Val<::bevy_math::primitives::Plane2d>| { + let output: ::core::option::Option = { + { + let output: ::core::option::Option = ::bevy_math::Ray2d::intersect_plane( + &_self, + plane_origin.into_inner(), + plane.into_inner(), + ) + .into(); + output + } + }; + output + }, + " Get the distance to a plane if the ray intersects it", + &["_self", "plane_origin", "plane"], + ) + .register_documented( + "new", + |origin: Val<::bevy_math::prelude::Vec2>, direction: Val<::bevy_math::prelude::Dir2>| { + let output: Val<::bevy_math::Ray2d> = { + { + let output: Val<::bevy_math::Ray2d> = + ::bevy_math::Ray2d::new(origin.into_inner(), direction.into_inner()).into(); + output + } + }; + output + }, + " Create a new `Ray2d` from a given origin and direction", + &["origin", "direction"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_math::Ray2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_math::Ray2d, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_ray_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< - ::bevy_math::Ray3d, - >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_math::Ray3d>| { - let output: Val<::bevy_math::Ray3d> = { - { - let output: Val<::bevy_math::Ray3d> = <::bevy_math::Ray3d as ::core::clone::Clone>::clone( - &_self, - ) - .into(); - output - } - }; - output - }, - "", - &["_self"], - ) - .register_documented( - "eq", - |_self: Ref<::bevy_math::Ray3d>, other: Ref<::bevy_math::Ray3d>| { - let output: bool = { - { - let output: bool = <::bevy_math::Ray3d as ::core::cmp::PartialEq< - ::bevy_math::Ray3d, - >>::eq(&_self, &other) - .into(); - output - } - }; - output - }, - "", - &["_self", "other"], - ) - .register_documented( - "get_point", - |_self: Ref<::bevy_math::Ray3d>, distance: f32| { - let output: Val<::bevy_math::prelude::Vec3> = { - { - let output: Val<::bevy_math::prelude::Vec3> = ::bevy_math::Ray3d::get_point( - &_self, - distance, - ) - .into(); - output - } - }; - output - }, - " Get a point at a given distance along the ray", - &["_self", "distance"], - ) - .register_documented( - "intersect_plane", - | - _self: Ref<::bevy_math::Ray3d>, - plane_origin: Val<::bevy_math::prelude::Vec3>, - plane: Val<::bevy_math::primitives::InfinitePlane3d>| - { - let output: ::core::option::Option = { - { - let output: ::core::option::Option = ::bevy_math::Ray3d::intersect_plane( - &_self, - plane_origin.into_inner(), - plane.into_inner(), - ) - .into(); - output - } - }; - output - }, - " Get the distance to a plane if the ray intersects it", - &["_self", "plane_origin", "plane"], - ) - .register_documented( - "new", - | - origin: Val<::bevy_math::prelude::Vec3>, - direction: Val<::bevy_math::prelude::Dir3>| - { - let output: Val<::bevy_math::Ray3d> = { - { - let output: Val<::bevy_math::Ray3d> = ::bevy_math::Ray3d::new( - origin.into_inner(), - direction.into_inner(), - ) - .into(); - output - } - }; - output - }, - " Create a new `Ray3d` from a given origin and direction", - &["origin", "direction"], - ); + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::<::bevy_math::Ray3d>::new( + world, + ) + .register_documented( + "clone", + |_self: Ref<::bevy_math::Ray3d>| { + let output: Val<::bevy_math::Ray3d> = { + { + let output: Val<::bevy_math::Ray3d> = + <::bevy_math::Ray3d as ::core::clone::Clone>::clone(&_self).into(); + output + } + }; + output + }, + "", + &["_self"], + ) + .register_documented( + "eq", + |_self: Ref<::bevy_math::Ray3d>, other: Ref<::bevy_math::Ray3d>| { + let output: bool = { + { + let output: bool = <::bevy_math::Ray3d as ::core::cmp::PartialEq< + ::bevy_math::Ray3d, + >>::eq(&_self, &other) + .into(); + output + } + }; + output + }, + "", + &["_self", "other"], + ) + .register_documented( + "get_point", + |_self: Ref<::bevy_math::Ray3d>, distance: f32| { + let output: Val<::bevy_math::prelude::Vec3> = { + { + let output: Val<::bevy_math::prelude::Vec3> = + ::bevy_math::Ray3d::get_point(&_self, distance).into(); + output + } + }; + output + }, + " Get a point at a given distance along the ray", + &["_self", "distance"], + ) + .register_documented( + "intersect_plane", + |_self: Ref<::bevy_math::Ray3d>, + plane_origin: Val<::bevy_math::prelude::Vec3>, + plane: Val<::bevy_math::primitives::InfinitePlane3d>| { + let output: ::core::option::Option = { + { + let output: ::core::option::Option = ::bevy_math::Ray3d::intersect_plane( + &_self, + plane_origin.into_inner(), + plane.into_inner(), + ) + .into(); + output + } + }; + output + }, + " Get the distance to a plane if the ray intersects it", + &["_self", "plane_origin", "plane"], + ) + .register_documented( + "new", + |origin: Val<::bevy_math::prelude::Vec3>, direction: Val<::bevy_math::prelude::Dir3>| { + let output: Val<::bevy_math::Ray3d> = { + { + let output: Val<::bevy_math::Ray3d> = + ::bevy_math::Ray3d::new(origin.into_inner(), direction.into_inner()).into(); + output + } + }; + output + }, + " Create a new `Ray3d` from a given origin and direction", + &["origin", "direction"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_math::Ray3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_math::Ray3d, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_rot_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::Rot2, >::new(world) .register_documented( @@ -1460,13 +1435,10 @@ pub(crate) fn register_rot_2_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_math::Rot2, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_math::Rot2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_dir_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::prelude::Dir2, >::new(world) .register_documented( @@ -1747,11 +1719,11 @@ pub(crate) fn register_dir_2_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::prelude::Dir2, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_dir_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::prelude::Dir3, >::new(world) .register_documented( @@ -1923,11 +1895,11 @@ pub(crate) fn register_dir_3_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::prelude::Dir3, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_dir_3_a_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::prelude::Dir3A, >::new(world) .register_documented( @@ -2099,11 +2071,11 @@ pub(crate) fn register_dir_3_a_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::prelude::Dir3A, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_i_rect_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::prelude::IRect, >::new(world) .register_documented( @@ -2477,11 +2449,11 @@ pub(crate) fn register_i_rect_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::prelude::IRect, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_rect_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::prelude::Rect, >::new(world) .register_documented( @@ -2859,11 +2831,11 @@ pub(crate) fn register_rect_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::prelude::Rect, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_u_rect_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::prelude::URect, >::new(world) .register_documented( @@ -3237,23 +3209,20 @@ pub(crate) fn register_u_rect_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::prelude::URect, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_affine_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< - ::bevy_math::Affine3, - >::new(world); + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::<::bevy_math::Affine3>::new( + world, + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_math::Affine3, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_math::Affine3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_aabb_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::bounding::Aabb2d, >::new(world) .register_documented( @@ -3357,11 +3326,11 @@ pub(crate) fn register_aabb_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::bounding::Aabb2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_bounding_circle_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::bounding::BoundingCircle, >::new(world) .register_documented( @@ -3479,11 +3448,11 @@ pub(crate) fn register_bounding_circle_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::bounding::BoundingCircle, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_circle_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Circle, >::new(world) .register_documented( @@ -3583,11 +3552,11 @@ pub(crate) fn register_circle_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Circle, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_annulus_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Annulus, >::new(world) .register_documented( @@ -3705,11 +3674,11 @@ pub(crate) fn register_annulus_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Annulus, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_arc_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Arc2d, >::new(world) .register_documented( @@ -4022,11 +3991,11 @@ pub(crate) fn register_arc_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Arc2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_capsule_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Capsule2d, >::new(world) .register_documented( @@ -4099,11 +4068,11 @@ pub(crate) fn register_capsule_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Capsule2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_circular_sector_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::CircularSector, >::new(world) .register_documented( @@ -4373,11 +4342,11 @@ pub(crate) fn register_circular_sector_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::CircularSector, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_circular_segment_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::CircularSegment, >::new(world) .register_documented( @@ -4647,11 +4616,11 @@ pub(crate) fn register_circular_segment_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::CircularSegment, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_ellipse_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Ellipse, >::new(world) .register_documented( @@ -4799,11 +4768,11 @@ pub(crate) fn register_ellipse_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Ellipse, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_line_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Line2d, >::new(world) .register_documented( @@ -4846,11 +4815,11 @@ pub(crate) fn register_line_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Line2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_plane_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Plane2d, >::new(world) .register_documented( @@ -4912,11 +4881,11 @@ pub(crate) fn register_plane_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Plane2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_rectangle_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Rectangle, >::new(world) .register_documented( @@ -5072,11 +5041,11 @@ pub(crate) fn register_rectangle_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Rectangle, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_regular_polygon_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::RegularPolygon, >::new(world) .register_documented( @@ -5258,11 +5227,11 @@ pub(crate) fn register_regular_polygon_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::RegularPolygon, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_rhombus_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Rhombus, >::new(world) .register_documented( @@ -5429,11 +5398,11 @@ pub(crate) fn register_rhombus_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Rhombus, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_segment_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Segment2d, >::new(world) .register_documented( @@ -5894,11 +5863,11 @@ pub(crate) fn register_segment_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Segment2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_triangle_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Triangle2d, >::new(world) .register_documented( @@ -6051,11 +6020,11 @@ pub(crate) fn register_triangle_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Triangle2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_aabb_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::bounding::Aabb3d, >::new(world) .register_documented( @@ -6111,11 +6080,11 @@ pub(crate) fn register_aabb_3_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::bounding::Aabb3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_bounding_sphere_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::bounding::BoundingSphere, >::new(world) .register_documented( @@ -6189,11 +6158,11 @@ pub(crate) fn register_bounding_sphere_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::bounding::BoundingSphere, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_sphere_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Sphere, >::new(world) .register_documented( @@ -6293,11 +6262,11 @@ pub(crate) fn register_sphere_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Sphere, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cuboid_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Cuboid, >::new(world) .register_documented( @@ -6454,11 +6423,11 @@ pub(crate) fn register_cuboid_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Cuboid, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cylinder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Cylinder, >::new(world) .register_documented( @@ -6560,11 +6529,11 @@ pub(crate) fn register_cylinder_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Cylinder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_capsule_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Capsule3d, >::new(world) .register_documented( @@ -6637,11 +6606,11 @@ pub(crate) fn register_capsule_3_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Capsule3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cone_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Cone, >::new(world) .register_documented( @@ -6772,11 +6741,11 @@ pub(crate) fn register_cone_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Cone, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_conical_frustum_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::ConicalFrustum, >::new(world) .register_documented( @@ -6821,11 +6790,11 @@ pub(crate) fn register_conical_frustum_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::ConicalFrustum, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_infinite_plane_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::InfinitePlane3d, >::new(world) .register_documented( @@ -6912,11 +6881,11 @@ pub(crate) fn register_infinite_plane_3_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::InfinitePlane3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_line_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Line3d, >::new(world) .register_documented( @@ -6959,11 +6928,11 @@ pub(crate) fn register_line_3_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Line3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_segment_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Segment3d, >::new(world) .register_documented( @@ -7356,11 +7325,11 @@ pub(crate) fn register_segment_3_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Segment3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_torus_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Torus, >::new(world) .register_documented( @@ -7457,11 +7426,11 @@ pub(crate) fn register_torus_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Torus, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_triangle_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Triangle3d, >::new(world) .register_documented( @@ -7648,11 +7617,11 @@ pub(crate) fn register_triangle_3_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Triangle3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_ray_cast_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::bounding::RayCast2d, >::new(world) .register_documented( @@ -7761,11 +7730,11 @@ pub(crate) fn register_ray_cast_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::bounding::RayCast2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_aabb_cast_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::bounding::AabbCast2d, >::new(world) .register_documented( @@ -7853,11 +7822,11 @@ pub(crate) fn register_aabb_cast_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::bounding::AabbCast2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_bounding_circle_cast_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::bounding::BoundingCircleCast, >::new(world) .register_documented( @@ -7951,11 +7920,11 @@ pub(crate) fn register_bounding_circle_cast_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::bounding::BoundingCircleCast, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_ray_cast_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::bounding::RayCast3d, >::new(world) .register_documented( @@ -8042,11 +8011,11 @@ pub(crate) fn register_ray_cast_3_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::bounding::RayCast3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_aabb_cast_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::bounding::AabbCast3d, >::new(world) .register_documented( @@ -8110,11 +8079,11 @@ pub(crate) fn register_aabb_cast_3_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::bounding::AabbCast3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_bounding_sphere_cast_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::bounding::BoundingSphereCast, >::new(world) .register_documented( @@ -8183,11 +8152,11 @@ pub(crate) fn register_bounding_sphere_cast_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::bounding::BoundingSphereCast, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_interval_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::curve::interval::Interval, >::new(world) .register_documented( @@ -8391,11 +8360,11 @@ pub(crate) fn register_interval_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::curve::interval::Interval, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_float_ord_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::FloatOrd, >::new(world) .register_documented( @@ -8520,13 +8489,11 @@ pub(crate) fn register_float_ord_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_math::FloatOrd, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_math::FloatOrd, bevy_mod_scripting_bindings::MarkAsGenerated>( + ); } pub(crate) fn register_plane_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Plane3d, >::new(world) .register_documented( @@ -8592,11 +8559,11 @@ pub(crate) fn register_plane_3_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Plane3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_tetrahedron_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::primitives::Tetrahedron, >::new(world) .register_documented( @@ -8700,11 +8667,11 @@ pub(crate) fn register_tetrahedron_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::primitives::Tetrahedron, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_ease_function_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::curve::easing::EaseFunction, >::new(world) .register_documented( @@ -8749,11 +8716,11 @@ pub(crate) fn register_ease_function_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::curve::easing::EaseFunction, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_jump_at_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_math::curve::easing::JumpAt, >::new(world) .register_documented( @@ -8815,7 +8782,7 @@ pub(crate) fn register_jump_at_functions(world: &mut World) { registry .register_type_data::< ::bevy_math::curve::easing::JumpAt, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyMathScriptingPlugin { diff --git a/crates/bindings/bevy_mesh_bms_bindings/Cargo.toml b/crates/bindings/bevy_mesh_bms_bindings/Cargo.toml index caa82b12d8..5d269b3060 100644 --- a/crates/bindings/bevy_mesh_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_mesh_bms_bindings/Cargo.toml @@ -9,40 +9,42 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_app = { workspace = true, features = ["std"] } bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_mesh = { version = "0.16.1", features = [], default-features = true } +bevy_mesh = { version = "0.16.1", features = [], default-features = true} -bevy_asset = { version = "^0.16.1", features = [], default-features = true } +bevy_asset = { version = "^0.16.1", features = [], default-features = true} -bevy_derive = { version = "^0.16.1", features = [], default-features = true } +bevy_derive = { version = "^0.16.1", features = [], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [], default-features = true } +bevy_ecs = { version = "^0.16.1", features = [], default-features = true} -bevy_image = { version = "^0.16.1", features = [], default-features = true } +bevy_image = { version = "^0.16.1", features = [], default-features = true} -bevy_math = { version = "^0.16.1", features = [], default-features = true } +bevy_math = { version = "^0.16.1", features = [], default-features = true} -bevy_mikktspace = { version = "^0.16.1", features = [ -], default-features = true } +bevy_mikktspace = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_transform = { version = "^0.16.1", features = [], default-features = true } +bevy_transform = { version = "^0.16.1", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } +bevy_utils = { version = "^0.16.1", features = [], default-features = true} -bitflags = { version = "^2.3", features = [], default-features = true } +bitflags = { version = "^2.3", features = [], default-features = true} -bytemuck = { version = "^1.5", features = [], default-features = true } +bytemuck = { version = "^1.5", features = [], default-features = true} + +hexasphere = { version = "^15.0", features = [], default-features = true} + +serde = { version = "^1", features = [], default-features = true} -hexasphere = { version = "^15.0", features = [], default-features = true } -serde = { version = "^1", features = [], default-features = true } diff --git a/crates/bindings/bevy_mesh_bms_bindings/src/lib.rs b/crates/bindings/bevy_mesh_bms_bindings/src/lib.rs index 1e940d9d1a..c9e7179f3a 100644 --- a/crates/bindings/bevy_mesh_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_mesh_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyMeshScriptingPlugin; pub(crate) fn register_indices_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::Indices, >::new(world) .register_documented( @@ -79,13 +79,10 @@ pub(crate) fn register_indices_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_mesh::Indices, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_mesh::Indices, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_mesh_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::Mesh, >::new(world) .register_documented( @@ -583,13 +580,10 @@ pub(crate) fn register_mesh_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_mesh::Mesh, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_mesh::Mesh, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_morph_weights_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::morph::MorphWeights, >::new(world) .register_documented( @@ -613,11 +607,11 @@ pub(crate) fn register_morph_weights_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::morph::MorphWeights, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mesh_morph_weights_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::morph::MeshMorphWeights, >::new(world) .register_documented( @@ -658,11 +652,11 @@ pub(crate) fn register_mesh_morph_weights_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::morph::MeshMorphWeights, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_circle_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::CircleMeshBuilder, >::new(world) .register_documented( @@ -722,11 +716,11 @@ pub(crate) fn register_circle_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::CircleMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_circular_mesh_uv_mode_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::CircularMeshUvMode, >::new(world) .register_documented( @@ -771,11 +765,11 @@ pub(crate) fn register_circular_mesh_uv_mode_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::CircularMeshUvMode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_circular_sector_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::CircularSectorMeshBuilder, >::new(world) .register_documented( @@ -867,11 +861,11 @@ pub(crate) fn register_circular_sector_mesh_builder_functions(world: &mut World) registry .register_type_data::< ::bevy_mesh::primitives::CircularSectorMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_circular_segment_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::CircularSegmentMeshBuilder, >::new(world) .register_documented( @@ -963,11 +957,11 @@ pub(crate) fn register_circular_segment_mesh_builder_functions(world: &mut World registry .register_type_data::< ::bevy_mesh::primitives::CircularSegmentMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_regular_polygon_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::RegularPolygonMeshBuilder, >::new(world) .register_documented( @@ -1014,11 +1008,11 @@ pub(crate) fn register_regular_polygon_mesh_builder_functions(world: &mut World) registry .register_type_data::< ::bevy_mesh::primitives::RegularPolygonMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_ellipse_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::EllipseMeshBuilder, >::new(world) .register_documented( @@ -1080,11 +1074,11 @@ pub(crate) fn register_ellipse_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::EllipseMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_annulus_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::AnnulusMeshBuilder, >::new(world) .register_documented( @@ -1146,11 +1140,11 @@ pub(crate) fn register_annulus_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::AnnulusMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_rhombus_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::RhombusMeshBuilder, >::new(world) .register_documented( @@ -1193,11 +1187,11 @@ pub(crate) fn register_rhombus_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::RhombusMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_triangle_2_d_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::Triangle2dMeshBuilder, >::new(world) .register_documented( @@ -1249,11 +1243,11 @@ pub(crate) fn register_triangle_2_d_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::Triangle2dMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_rectangle_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::RectangleMeshBuilder, >::new(world) .register_documented( @@ -1296,11 +1290,11 @@ pub(crate) fn register_rectangle_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::RectangleMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_capsule_2_d_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::Capsule2dMeshBuilder, >::new(world) .register_documented( @@ -1362,11 +1356,11 @@ pub(crate) fn register_capsule_2_d_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::Capsule2dMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_capsule_uv_profile_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::CapsuleUvProfile, >::new(world) .register_documented( @@ -1392,11 +1386,11 @@ pub(crate) fn register_capsule_uv_profile_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::CapsuleUvProfile, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_capsule_3_d_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::Capsule3dMeshBuilder, >::new(world) .register_documented( @@ -1516,11 +1510,11 @@ pub(crate) fn register_capsule_3_d_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::Capsule3dMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cone_anchor_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::ConeAnchor, >::new(world) .register_documented( @@ -1544,11 +1538,11 @@ pub(crate) fn register_cone_anchor_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::ConeAnchor, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cone_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::ConeMeshBuilder, >::new(world) .register_documented( @@ -1631,11 +1625,11 @@ pub(crate) fn register_cone_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::ConeMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_conical_frustum_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::ConicalFrustumMeshBuilder, >::new(world) .register_documented( @@ -1730,11 +1724,11 @@ pub(crate) fn register_conical_frustum_mesh_builder_functions(world: &mut World) registry .register_type_data::< ::bevy_mesh::primitives::ConicalFrustumMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cuboid_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::CuboidMeshBuilder, >::new(world) .register_documented( @@ -1760,11 +1754,11 @@ pub(crate) fn register_cuboid_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::CuboidMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cylinder_anchor_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::CylinderAnchor, >::new(world) .register_documented( @@ -1790,11 +1784,11 @@ pub(crate) fn register_cylinder_anchor_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::CylinderAnchor, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cylinder_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::CylinderMeshBuilder, >::new(world) .register_documented( @@ -1912,11 +1906,11 @@ pub(crate) fn register_cylinder_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::CylinderMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_plane_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::PlaneMeshBuilder, >::new(world) .register_documented( @@ -2055,11 +2049,11 @@ pub(crate) fn register_plane_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::PlaneMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_sphere_kind_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::SphereKind, >::new(world) .register_documented( @@ -2083,11 +2077,11 @@ pub(crate) fn register_sphere_kind_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::SphereKind, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_sphere_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::SphereMeshBuilder, >::new(world) .register_documented( @@ -2174,11 +2168,11 @@ pub(crate) fn register_sphere_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::SphereMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_tetrahedron_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::TetrahedronMeshBuilder, >::new(world) .register_documented( @@ -2205,11 +2199,11 @@ pub(crate) fn register_tetrahedron_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::TetrahedronMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_torus_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::TorusMeshBuilder, >::new(world) .register_documented( @@ -2288,11 +2282,11 @@ pub(crate) fn register_torus_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::TorusMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_triangle_3_d_mesh_builder_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::primitives::Triangle3dMeshBuilder, >::new(world) .register_documented( @@ -2319,11 +2313,11 @@ pub(crate) fn register_triangle_3_d_mesh_builder_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::primitives::Triangle3dMeshBuilder, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_skinned_mesh_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_mesh::skinning::SkinnedMesh, >::new(world) .register_documented( @@ -2347,7 +2341,7 @@ pub(crate) fn register_skinned_mesh_functions(world: &mut World) { registry .register_type_data::< ::bevy_mesh::skinning::SkinnedMesh, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyMeshScriptingPlugin { diff --git a/crates/bindings/bevy_pbr_bms_bindings/Cargo.toml b/crates/bindings/bevy_pbr_bms_bindings/Cargo.toml index 158342c930..ffd6f32579 100644 --- a/crates/bindings/bevy_pbr_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_pbr_bms_bindings/Cargo.toml @@ -9,59 +9,60 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_pbr = { version = "0.16.1", features = ["webgl"], default-features = true } +bevy_pbr = { version = "0.16.1", features = ["webgl"], default-features = true} -bevy_app = { version = "^0.16.1", features = [], default-features = true } +bevy_app = { version = "^0.16.1", features = [], default-features = true} -bevy_asset = { version = "^0.16.1", features = [], default-features = true } +bevy_asset = { version = "^0.16.1", features = [], default-features = true} -bevy_color = { version = "^0.16.2", features = [], default-features = true } +bevy_color = { version = "^0.16.2", features = [], default-features = true} -bevy_core_pipeline = { version = "^0.16.1", features = [ -], default-features = true } +bevy_core_pipeline = { version = "^0.16.1", features = [], default-features = true} -bevy_derive = { version = "^0.16.1", features = [], default-features = true } +bevy_derive = { version = "^0.16.1", features = [], default-features = true} -bevy_diagnostic = { version = "^0.16.1", features = [ -], default-features = true } +bevy_diagnostic = { version = "^0.16.1", features = [], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [], default-features = true } +bevy_ecs = { version = "^0.16.1", features = [], default-features = true} -bevy_image = { version = "^0.16.1", features = [], default-features = true } +bevy_image = { version = "^0.16.1", features = [], default-features = true} -bevy_math = { version = "^0.16.1", features = [], default-features = true } +bevy_math = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_render = { version = "^0.16.1", features = [], default-features = true } +bevy_render = { version = "^0.16.1", features = [], default-features = true} -bevy_transform = { version = "^0.16.1", features = [], default-features = true } +bevy_transform = { version = "^0.16.1", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } +bevy_utils = { version = "^0.16.1", features = [], default-features = true} -bevy_window = { version = "^0.16.1", features = [], default-features = true } +bevy_window = { version = "^0.16.1", features = [], default-features = true} -bitflags = { version = "^2.3", features = [], default-features = true } +bitflags = { version = "^2.3", features = [], default-features = true} -bytemuck = { version = "^1", features = [], default-features = true } +bytemuck = { version = "^1", features = [], default-features = true} -fixedbitset = { version = "^0.5", features = [], default-features = true } +fixedbitset = { version = "^0.5", features = [], default-features = true} -nonmax = { version = "^0.5", features = [], default-features = true } +nonmax = { version = "^0.5", features = [], default-features = true} -offset-allocator = { version = "^0.2", features = [], default-features = true } +offset-allocator = { version = "^0.2", features = [], default-features = true} -radsort = { version = "^0.1", features = [], default-features = true } +radsort = { version = "^0.1", features = [], default-features = true} + +smallvec = { version = "^1.6", features = [], default-features = true} + +static_assertions = { version = "^1", features = [], default-features = true} -smallvec = { version = "^1.6", features = [], default-features = true } -static_assertions = { version = "^1", features = [], default-features = true } diff --git a/crates/bindings/bevy_pbr_bms_bindings/src/lib.rs b/crates/bindings/bevy_pbr_bms_bindings/src/lib.rs index 8c99b1e361..efcc781654 100644 --- a/crates/bindings/bevy_pbr_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_pbr_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyPbrScriptingPlugin; pub(crate) fn register_fog_volume_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::FogVolume, >::new(world) .register_documented( @@ -36,67 +36,69 @@ pub(crate) fn register_fog_volume_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_pbr::FogVolume, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_pbr::FogVolume, bevy_mod_scripting_bindings::MarkAsGenerated>( + ); } pub(crate) fn register_volumetric_fog_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::VolumetricFog, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_pbr::VolumetricFog>| { - let output: Val<::bevy_pbr::VolumetricFog> = { - { - let output: Val<::bevy_pbr::VolumetricFog> = - <::bevy_pbr::VolumetricFog as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_pbr::VolumetricFog>| { + let output: Val<::bevy_pbr::VolumetricFog> = { + { + let output: Val<::bevy_pbr::VolumetricFog> = <::bevy_pbr::VolumetricFog as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_pbr::VolumetricFog, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_volumetric_light_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::VolumetricLight, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_pbr::VolumetricLight>| { - let output: Val<::bevy_pbr::VolumetricLight> = { - { - let output: Val<::bevy_pbr::VolumetricLight> = - <::bevy_pbr::VolumetricLight as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_pbr::VolumetricLight>| { + let output: Val<::bevy_pbr::VolumetricLight> = { + { + let output: Val<::bevy_pbr::VolumetricLight> = <::bevy_pbr::VolumetricLight as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_pbr::VolumetricLight, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_distance_fog_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::prelude::DistanceFog, >::new(world) .register_documented( @@ -120,11 +122,11 @@ pub(crate) fn register_distance_fog_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::prelude::DistanceFog, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_fog_falloff_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::prelude::FogFalloff, >::new(world) .register_documented( @@ -331,11 +333,11 @@ pub(crate) fn register_fog_falloff_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::prelude::FogFalloff, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_ambient_light_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::prelude::AmbientLight, >::new(world) .register_documented( @@ -359,11 +361,11 @@ pub(crate) fn register_ambient_light_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::prelude::AmbientLight, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_directional_light_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::prelude::DirectionalLight, >::new(world) .register_documented( @@ -389,11 +391,11 @@ pub(crate) fn register_directional_light_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::prelude::DirectionalLight, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_point_light_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::prelude::PointLight, >::new(world) .register_documented( @@ -417,11 +419,11 @@ pub(crate) fn register_point_light_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::prelude::PointLight, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_spot_light_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::prelude::SpotLight, >::new(world) .register_documented( @@ -445,11 +447,11 @@ pub(crate) fn register_spot_light_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::prelude::SpotLight, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_environment_map_light_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::prelude::EnvironmentMapLight, >::new(world) .register_documented( @@ -475,11 +477,11 @@ pub(crate) fn register_environment_map_light_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::prelude::EnvironmentMapLight, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_light_probe_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::prelude::LightProbe, >::new(world) .register_documented( @@ -518,11 +520,11 @@ pub(crate) fn register_light_probe_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::prelude::LightProbe, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_parallax_mapping_method_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::prelude::ParallaxMappingMethod, >::new(world) .register_documented( @@ -584,11 +586,11 @@ pub(crate) fn register_parallax_mapping_method_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::prelude::ParallaxMappingMethod, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_standard_material_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::prelude::StandardMaterial, >::new(world) .register_documented( @@ -653,11 +655,11 @@ pub(crate) fn register_standard_material_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::prelude::StandardMaterial, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_screen_space_ambient_occlusion_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::ScreenSpaceAmbientOcclusion, >::new(world) .register_documented( @@ -702,11 +704,11 @@ pub(crate) fn register_screen_space_ambient_occlusion_functions(world: &mut Worl registry .register_type_data::< ::bevy_pbr::ScreenSpaceAmbientOcclusion, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_screen_space_reflections_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::ScreenSpaceReflections, >::new(world) .register_documented( @@ -730,11 +732,11 @@ pub(crate) fn register_screen_space_reflections_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::ScreenSpaceReflections, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cascade_shadow_config_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::CascadeShadowConfig, >::new(world) .register_documented( @@ -758,11 +760,11 @@ pub(crate) fn register_cascade_shadow_config_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::CascadeShadowConfig, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cascades_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::Cascades, >::new(world) .register_documented( @@ -785,13 +787,10 @@ pub(crate) fn register_cascades_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_pbr::Cascades, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_pbr::Cascades, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_cascades_visible_entities_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::CascadesVisibleEntities, >::new(world) .register_documented( @@ -815,11 +814,11 @@ pub(crate) fn register_cascades_visible_entities_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::CascadesVisibleEntities, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_visible_mesh_entities_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::VisibleMeshEntities, >::new(world) .register_documented( @@ -843,38 +842,40 @@ pub(crate) fn register_visible_mesh_entities_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::VisibleMeshEntities, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cluster_config_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::ClusterConfig, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_pbr::ClusterConfig>| { - let output: Val<::bevy_pbr::ClusterConfig> = { - { - let output: Val<::bevy_pbr::ClusterConfig> = - <::bevy_pbr::ClusterConfig as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_pbr::ClusterConfig>| { + let output: Val<::bevy_pbr::ClusterConfig> = { + { + let output: Val<::bevy_pbr::ClusterConfig> = <::bevy_pbr::ClusterConfig as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_pbr::ClusterConfig, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cubemap_visible_entities_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::CubemapVisibleEntities, >::new(world) .register_documented( @@ -898,11 +899,11 @@ pub(crate) fn register_cubemap_visible_entities_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::CubemapVisibleEntities, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_directional_light_shadow_map_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::DirectionalLightShadowMap, >::new(world) .register_documented( @@ -928,11 +929,11 @@ pub(crate) fn register_directional_light_shadow_map_functions(world: &mut World) registry .register_type_data::< ::bevy_pbr::DirectionalLightShadowMap, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_not_shadow_caster_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::NotShadowCaster, >::new(world); let registry = world.get_resource_or_init::(); @@ -940,11 +941,11 @@ pub(crate) fn register_not_shadow_caster_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::NotShadowCaster, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_not_shadow_receiver_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::NotShadowReceiver, >::new(world); let registry = world.get_resource_or_init::(); @@ -952,11 +953,11 @@ pub(crate) fn register_not_shadow_receiver_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::NotShadowReceiver, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_point_light_shadow_map_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::PointLightShadowMap, >::new(world) .register_documented( @@ -980,11 +981,11 @@ pub(crate) fn register_point_light_shadow_map_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::PointLightShadowMap, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_shadow_filtering_method_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::ShadowFilteringMethod, >::new(world) .register_documented( @@ -1046,11 +1047,11 @@ pub(crate) fn register_shadow_filtering_method_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::ShadowFilteringMethod, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_default_opaque_renderer_method_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::DefaultOpaqueRendererMethod, >::new(world) .register_documented( @@ -1136,11 +1137,11 @@ pub(crate) fn register_default_opaque_renderer_method_functions(world: &mut Worl registry .register_type_data::< ::bevy_pbr::DefaultOpaqueRendererMethod, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_wireframe_material_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::wireframe::WireframeMaterial, >::new(world) .register_documented( @@ -1166,11 +1167,11 @@ pub(crate) fn register_wireframe_material_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::wireframe::WireframeMaterial, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_no_wireframe_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::wireframe::NoWireframe, >::new(world) .register_documented( @@ -1232,11 +1233,11 @@ pub(crate) fn register_no_wireframe_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::wireframe::NoWireframe, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_wireframe_config_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::wireframe::WireframeConfig, >::new(world) .register_documented( @@ -1262,11 +1263,11 @@ pub(crate) fn register_wireframe_config_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::wireframe::WireframeConfig, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_wireframe_color_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::wireframe::WireframeColor, >::new(world) .register_documented( @@ -1292,11 +1293,11 @@ pub(crate) fn register_wireframe_color_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::wireframe::WireframeColor, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_wireframe_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::wireframe::Wireframe, >::new(world) .register_documented( @@ -1358,11 +1359,11 @@ pub(crate) fn register_wireframe_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::wireframe::Wireframe, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mesh_3_d_wireframe_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::wireframe::Mesh3dWireframe, >::new(world) .register_documented( @@ -1424,54 +1425,56 @@ pub(crate) fn register_mesh_3_d_wireframe_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::wireframe::Mesh3dWireframe, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_atmosphere_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::Atmosphere, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_pbr::Atmosphere>| { - let output: Val<::bevy_pbr::Atmosphere> = { - { - let output: Val<::bevy_pbr::Atmosphere> = - <::bevy_pbr::Atmosphere as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ) - .register_documented( - "with_density_multiplier", - |_self: Val<::bevy_pbr::Atmosphere>, mult: f32| { - let output: Val<::bevy_pbr::Atmosphere> = { - { - let output: Val<::bevy_pbr::Atmosphere> = - ::bevy_pbr::Atmosphere::with_density_multiplier(_self.into_inner(), mult) + .register_documented( + "clone", + |_self: Ref<::bevy_pbr::Atmosphere>| { + let output: Val<::bevy_pbr::Atmosphere> = { + { + let output: Val<::bevy_pbr::Atmosphere> = <::bevy_pbr::Atmosphere as ::std::clone::Clone>::clone( + &_self, + ) .into(); - output - } - }; - output - }, - "", - &["_self", "mult"], - ); + output + } + }; + output + }, + "", + &["_self"], + ) + .register_documented( + "with_density_multiplier", + |_self: Val<::bevy_pbr::Atmosphere>, mult: f32| { + let output: Val<::bevy_pbr::Atmosphere> = { + { + let output: Val<::bevy_pbr::Atmosphere> = ::bevy_pbr::Atmosphere::with_density_multiplier( + _self.into_inner(), + mult, + ) + .into(); + output + } + }; + output + }, + "", + &["_self", "mult"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_pbr::Atmosphere, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_pbr::Atmosphere, bevy_mod_scripting_bindings::MarkAsGenerated>( + ); } pub(crate) fn register_atmosphere_settings_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::AtmosphereSettings, >::new(world) .register_documented( @@ -1495,65 +1498,69 @@ pub(crate) fn register_atmosphere_settings_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::AtmosphereSettings, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cluster_far_z_mode_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::ClusterFarZMode, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_pbr::ClusterFarZMode>| { - let output: Val<::bevy_pbr::ClusterFarZMode> = { - { - let output: Val<::bevy_pbr::ClusterFarZMode> = - <::bevy_pbr::ClusterFarZMode as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_pbr::ClusterFarZMode>| { + let output: Val<::bevy_pbr::ClusterFarZMode> = { + { + let output: Val<::bevy_pbr::ClusterFarZMode> = <::bevy_pbr::ClusterFarZMode as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_pbr::ClusterFarZMode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cluster_z_config_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::ClusterZConfig, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_pbr::ClusterZConfig>| { - let output: Val<::bevy_pbr::ClusterZConfig> = { - { - let output: Val<::bevy_pbr::ClusterZConfig> = - <::bevy_pbr::ClusterZConfig as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_pbr::ClusterZConfig>| { + let output: Val<::bevy_pbr::ClusterZConfig> = { + { + let output: Val<::bevy_pbr::ClusterZConfig> = <::bevy_pbr::ClusterZConfig as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_pbr::ClusterZConfig, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_clustered_decal_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::decal::clustered::ClusteredDecal, >::new(world) .register_documented( @@ -1578,11 +1585,11 @@ pub(crate) fn register_clustered_decal_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::decal::clustered::ClusteredDecal, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_irradiance_volume_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::irradiance_volume::IrradianceVolume, >::new(world) .register_documented( @@ -1609,11 +1616,11 @@ pub(crate) fn register_irradiance_volume_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::irradiance_volume::IrradianceVolume, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_render_visible_mesh_entities_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::RenderVisibleMeshEntities, >::new(world) .register_documented( @@ -1639,11 +1646,11 @@ pub(crate) fn register_render_visible_mesh_entities_functions(world: &mut World) registry .register_type_data::< ::bevy_pbr::RenderVisibleMeshEntities, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_render_cubemap_visible_entities_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::RenderCubemapVisibleEntities, >::new(world) .register_documented( @@ -1669,11 +1676,11 @@ pub(crate) fn register_render_cubemap_visible_entities_functions(world: &mut Wor registry .register_type_data::< ::bevy_pbr::RenderCubemapVisibleEntities, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_render_cascades_visible_entities_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::RenderCascadesVisibleEntities, >::new(world) .register_documented( @@ -1699,11 +1706,11 @@ pub(crate) fn register_render_cascades_visible_entities_functions(world: &mut Wo registry .register_type_data::< ::bevy_pbr::RenderCascadesVisibleEntities, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_forward_decal_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::decal::ForwardDecal, >::new(world); let registry = world.get_resource_or_init::(); @@ -1711,11 +1718,11 @@ pub(crate) fn register_forward_decal_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::decal::ForwardDecal, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_opaque_renderer_method_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::OpaqueRendererMethod, >::new(world) .register_documented( @@ -1758,40 +1765,35 @@ pub(crate) fn register_opaque_renderer_method_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::OpaqueRendererMethod, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cascade_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< - ::bevy_pbr::Cascade, - >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_pbr::Cascade>| { - let output: Val<::bevy_pbr::Cascade> = { - { - let output: Val<::bevy_pbr::Cascade> = <::bevy_pbr::Cascade as ::std::clone::Clone>::clone( - &_self, - ) - .into(); - output - } - }; - output - }, - "", - &["_self"], - ); + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::<::bevy_pbr::Cascade>::new( + world, + ) + .register_documented( + "clone", + |_self: Ref<::bevy_pbr::Cascade>| { + let output: Val<::bevy_pbr::Cascade> = { + { + let output: Val<::bevy_pbr::Cascade> = + <::bevy_pbr::Cascade as ::std::clone::Clone>::clone(&_self).into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_pbr::Cascade, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_pbr::Cascade, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_transmitted_shadow_receiver_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::TransmittedShadowReceiver, >::new(world); let registry = world.get_resource_or_init::(); @@ -1799,11 +1801,11 @@ pub(crate) fn register_transmitted_shadow_receiver_functions(world: &mut World) registry .register_type_data::< ::bevy_pbr::TransmittedShadowReceiver, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_lightmap_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::Lightmap, >::new(world) .register_documented( @@ -1826,13 +1828,10 @@ pub(crate) fn register_lightmap_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_pbr::Lightmap, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_pbr::Lightmap, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_material_binding_id_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::MaterialBindingId, >::new(world) .register_documented( @@ -1856,11 +1855,11 @@ pub(crate) fn register_material_binding_id_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::MaterialBindingId, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_material_bind_group_slot_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::MaterialBindGroupSlot, >::new(world) .register_documented( @@ -1903,11 +1902,11 @@ pub(crate) fn register_material_bind_group_slot_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::MaterialBindGroupSlot, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_material_bind_group_index_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::MaterialBindGroupIndex, >::new(world) .register_documented( @@ -1969,11 +1968,11 @@ pub(crate) fn register_material_bind_group_index_functions(world: &mut World) { registry .register_type_data::< ::bevy_pbr::MaterialBindGroupIndex, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_uv_channel_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::UvChannel, >::new(world) .register_documented( @@ -2030,13 +2029,11 @@ pub(crate) fn register_uv_channel_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_pbr::UvChannel, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_pbr::UvChannel, bevy_mod_scripting_bindings::MarkAsGenerated>( + ); } pub(crate) fn register_screen_space_ambient_occlusion_quality_level_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_pbr::ScreenSpaceAmbientOcclusionQualityLevel, >::new(world) .register_documented( @@ -2100,7 +2097,7 @@ pub(crate) fn register_screen_space_ambient_occlusion_quality_level_functions(wo registry .register_type_data::< ::bevy_pbr::ScreenSpaceAmbientOcclusionQualityLevel, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyPbrScriptingPlugin { diff --git a/crates/bindings/bevy_picking_bms_bindings/Cargo.toml b/crates/bindings/bevy_picking_bms_bindings/Cargo.toml index 80fa46fbe4..c58573f977 100644 --- a/crates/bindings/bevy_picking_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_picking_bms_bindings/Cargo.toml @@ -9,45 +9,46 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_picking = { version = "0.16.1", features = [ - "bevy_mesh_picking_backend", -], default-features = true } +bevy_picking = { version = "0.16.1", features = ["bevy_mesh_picking_backend"], default-features = true} -bevy_app = { version = "^0.16.1", features = [], default-features = true } +bevy_app = { version = "^0.16.1", features = [], default-features = true} -bevy_asset = { version = "^0.16.1", features = [], default-features = true } +bevy_asset = { version = "^0.16.1", features = [], default-features = true} -bevy_derive = { version = "^0.16.1", features = [], default-features = true } +bevy_derive = { version = "^0.16.1", features = [], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [], default-features = true } +bevy_ecs = { version = "^0.16.1", features = [], default-features = true} -bevy_input = { version = "^0.16.1", features = [], default-features = true } +bevy_input = { version = "^0.16.1", features = [], default-features = true} -bevy_math = { version = "^0.16.1", features = [], default-features = true } +bevy_math = { version = "^0.16.1", features = [], default-features = true} -bevy_mesh = { version = "^0.16.1", features = [], default-features = true } +bevy_mesh = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_render = { version = "^0.16.1", features = [], default-features = true } +bevy_render = { version = "^0.16.1", features = [], default-features = true} -bevy_time = { version = "^0.16.1", features = [], default-features = true } +bevy_time = { version = "^0.16.1", features = [], default-features = true} -bevy_transform = { version = "^0.16.1", features = [], default-features = true } +bevy_transform = { version = "^0.16.1", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } +bevy_utils = { version = "^0.16.1", features = [], default-features = true} -bevy_window = { version = "^0.16.1", features = [], default-features = true } +bevy_window = { version = "^0.16.1", features = [], default-features = true} + +crossbeam-channel = { version = "^0.5", features = [], default-features = true} + +uuid = { version = "^1.13.1", features = [], default-features = true} -crossbeam-channel = { version = "^0.5", features = [], default-features = true } -uuid = { version = "^1.13.1", features = [], default-features = true } diff --git a/crates/bindings/bevy_picking_bms_bindings/src/lib.rs b/crates/bindings/bevy_picking_bms_bindings/src/lib.rs index 890d41a5da..0a336cf46c 100644 --- a/crates/bindings/bevy_picking_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_picking_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyPickingScriptingPlugin; pub(crate) fn register_ray_cast_backfaces_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::mesh_picking::ray_cast::RayCastBackfaces, >::new(world) .register_documented( @@ -42,11 +42,11 @@ pub(crate) fn register_ray_cast_backfaces_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::mesh_picking::ray_cast::RayCastBackfaces, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_ray_cast_visibility_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::mesh_picking::ray_cast::RayCastVisibility, >::new(world) .register_documented( @@ -75,11 +75,11 @@ pub(crate) fn register_ray_cast_visibility_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::mesh_picking::ray_cast::RayCastVisibility, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mesh_picking_camera_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::mesh_picking::MeshPickingCamera, >::new(world) .register_documented( @@ -106,11 +106,11 @@ pub(crate) fn register_mesh_picking_camera_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::mesh_picking::MeshPickingCamera, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mesh_picking_settings_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::mesh_picking::MeshPickingSettings, >::new(world); let registry = world.get_resource_or_init::(); @@ -118,11 +118,11 @@ pub(crate) fn register_mesh_picking_settings_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::mesh_picking::MeshPickingSettings, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pointer_input_plugin_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::input::prelude::PointerInputPlugin, >::new(world) .register_documented( @@ -149,11 +149,11 @@ pub(crate) fn register_pointer_input_plugin_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::input::prelude::PointerInputPlugin, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pointer_button_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::pointer::PointerButton, >::new(world) .register_documented( @@ -215,11 +215,11 @@ pub(crate) fn register_pointer_button_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::pointer::PointerButton, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pickable_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::backend::prelude::Pickable, >::new(world) .register_documented( @@ -281,11 +281,11 @@ pub(crate) fn register_pickable_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::backend::prelude::Pickable, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_picking_plugin_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::prelude::PickingPlugin, >::new(world) .register_documented( @@ -311,11 +311,11 @@ pub(crate) fn register_picking_plugin_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::prelude::PickingPlugin, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pointer_input_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::pointer::PointerInput, >::new(world) .register_documented( @@ -405,11 +405,11 @@ pub(crate) fn register_pointer_input_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::pointer::PointerInput, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pointer_hits_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::backend::prelude::PointerHits, >::new(world) .register_documented( @@ -434,11 +434,11 @@ pub(crate) fn register_pointer_hits_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::backend::prelude::PointerHits, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_picking_interaction_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::hover::PickingInteraction, >::new(world) .register_documented( @@ -500,11 +500,11 @@ pub(crate) fn register_picking_interaction_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::hover::PickingInteraction, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pointer_id_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::backend::prelude::PointerId, >::new(world) .register_documented( @@ -634,11 +634,11 @@ pub(crate) fn register_pointer_id_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::backend::prelude::PointerId, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pointer_location_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::backend::prelude::PointerLocation, >::new(world) .register_documented( @@ -704,11 +704,11 @@ pub(crate) fn register_pointer_location_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::backend::prelude::PointerLocation, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pointer_press_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::pointer::PointerPress, >::new(world) .register_documented( @@ -838,11 +838,11 @@ pub(crate) fn register_pointer_press_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::pointer::PointerPress, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pointer_interaction_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::pointer::PointerInteraction, >::new(world) .register_documented( @@ -867,11 +867,11 @@ pub(crate) fn register_pointer_interaction_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::pointer::PointerInteraction, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_ray_id_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::backend::ray::RayId, >::new(world) .register_documented( @@ -954,11 +954,11 @@ pub(crate) fn register_ray_id_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::backend::ray::RayId, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cancel_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::Cancel, >::new(world) .register_documented( @@ -999,11 +999,11 @@ pub(crate) fn register_cancel_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::Cancel, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_click_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::Click, >::new(world) .register_documented( @@ -1044,11 +1044,11 @@ pub(crate) fn register_click_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::Click, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pressed_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::Pressed, >::new(world) .register_documented( @@ -1090,11 +1090,11 @@ pub(crate) fn register_pressed_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::Pressed, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_drag_drop_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::DragDrop, >::new(world) .register_documented( @@ -1137,11 +1137,11 @@ pub(crate) fn register_drag_drop_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::DragDrop, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_drag_end_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::DragEnd, >::new(world) .register_documented( @@ -1183,11 +1183,11 @@ pub(crate) fn register_drag_end_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::DragEnd, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_drag_enter_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::DragEnter, >::new(world) .register_documented( @@ -1230,11 +1230,11 @@ pub(crate) fn register_drag_enter_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::DragEnter, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_drag_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::Drag, >::new(world) .register_documented( @@ -1274,11 +1274,11 @@ pub(crate) fn register_drag_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::Drag, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_drag_leave_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::DragLeave, >::new(world) .register_documented( @@ -1321,11 +1321,11 @@ pub(crate) fn register_drag_leave_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::DragLeave, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_drag_over_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::DragOver, >::new(world) .register_documented( @@ -1368,11 +1368,11 @@ pub(crate) fn register_drag_over_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::DragOver, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_drag_start_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::DragStart, >::new(world) .register_documented( @@ -1415,11 +1415,11 @@ pub(crate) fn register_drag_start_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::DragStart, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_move_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::Move, >::new(world) .register_documented( @@ -1459,55 +1459,60 @@ pub(crate) fn register_move_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::Move, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_out_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::Out, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_picking::events::Out>| { - let output: Val<::bevy_picking::events::Out> = { - { - let output: Val<::bevy_picking::events::Out> = - <::bevy_picking::events::Out as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ) - .register_documented( - "eq", - |_self: Ref<::bevy_picking::events::Out>, other: Ref<::bevy_picking::events::Out>| { - let output: bool = { - { - let output: bool = <::bevy_picking::events::Out as ::std::cmp::PartialEq< - ::bevy_picking::events::Out, - >>::eq(&_self, &other) - .into(); - output - } - }; - output - }, - "", - &["_self", "other"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_picking::events::Out>| { + let output: Val<::bevy_picking::events::Out> = { + { + let output: Val<::bevy_picking::events::Out> = <::bevy_picking::events::Out as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ) + .register_documented( + "eq", + | + _self: Ref<::bevy_picking::events::Out>, + other: Ref<::bevy_picking::events::Out>| + { + let output: bool = { + { + let output: bool = <::bevy_picking::events::Out as ::std::cmp::PartialEq< + ::bevy_picking::events::Out, + >>::eq(&_self, &other) + .into(); + output + } + }; + output + }, + "", + &["_self", "other"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_picking::events::Out, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_over_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::Over, >::new(world) .register_documented( @@ -1547,11 +1552,11 @@ pub(crate) fn register_over_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::Over, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_released_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::Released, >::new(world) .register_documented( @@ -1594,11 +1599,11 @@ pub(crate) fn register_released_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::Released, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_scroll_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::Scroll, >::new(world) .register_documented( @@ -1639,11 +1644,11 @@ pub(crate) fn register_scroll_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::Scroll, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_hit_data_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::backend::prelude::HitData, >::new(world) .register_documented( @@ -1688,11 +1693,11 @@ pub(crate) fn register_hit_data_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::backend::prelude::HitData, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_location_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::pointer::Location, >::new(world) .register_documented( @@ -1735,11 +1740,11 @@ pub(crate) fn register_location_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::pointer::Location, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_pointer_action_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::pointer::PointerAction, >::new(world) .register_documented( @@ -1765,11 +1770,11 @@ pub(crate) fn register_pointer_action_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::pointer::PointerAction, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_drag_entry_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::events::DragEntry, >::new(world) .register_documented( @@ -1812,11 +1817,11 @@ pub(crate) fn register_drag_entry_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::events::DragEntry, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_simplified_mesh_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::mesh_picking::ray_cast::SimplifiedMesh, >::new(world) .register_documented( @@ -1845,11 +1850,11 @@ pub(crate) fn register_simplified_mesh_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::mesh_picking::ray_cast::SimplifiedMesh, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_ray_mesh_hit_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::mesh_picking::ray_cast::RayMeshHit, >::new(world) .register_documented( @@ -1876,11 +1881,11 @@ pub(crate) fn register_ray_mesh_hit_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::mesh_picking::ray_cast::RayMeshHit, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_backfaces_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::mesh_picking::ray_cast::Backfaces, >::new(world) .register_documented( @@ -1907,11 +1912,11 @@ pub(crate) fn register_backfaces_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::mesh_picking::ray_cast::Backfaces, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_press_direction_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_picking::pointer::PressDirection, >::new(world) .register_documented( @@ -1973,7 +1978,7 @@ pub(crate) fn register_press_direction_functions(world: &mut World) { registry .register_type_data::< ::bevy_picking::pointer::PressDirection, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyPickingScriptingPlugin { diff --git a/crates/bindings/bevy_reflect_bms_bindings/Cargo.toml b/crates/bindings/bevy_reflect_bms_bindings/Cargo.toml index 9e08c82b68..0df424f0b2 100644 --- a/crates/bindings/bevy_reflect_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_reflect_bms_bindings/Cargo.toml @@ -9,53 +9,40 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_ecs = { workspace = true, features = ["std", "bevy_reflect"] } bevy_app = { workspace = true, features = ["std"] } bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_reflect = { version = "0.16.1", features = [ - "glam", - "uuid", - "smol_str", - "std", - "smallvec", - "debug", - "debug_stack", -], default-features = true } +bevy_reflect = { version = "0.16.1", features = ["glam", "uuid", "smol_str", "std", "smallvec", "debug", "debug_stack"], default-features = true} -assert_type_match = { version = "^0.1.1", features = [ -], default-features = true } +assert_type_match = { version = "^0.1.1", features = [], default-features = true} -bevy_platform = { version = "^0.16.1", features = [ - "std", -], default-features = false } +bevy_platform = { version = "^0.16.1", features = ["std"], default-features = false} -bevy_ptr = { version = "^0.16.1", features = [], default-features = true } +bevy_ptr = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect_derive = { version = "^0.16.1", features = [ -], default-features = true } +bevy_reflect_derive = { version = "^0.16.1", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [ - "std", -], default-features = false } +bevy_utils = { version = "^0.16.1", features = ["std"], default-features = false} -downcast-rs = { version = "^2", features = ["std"], default-features = false } +downcast-rs = { version = "^2", features = ["std"], default-features = false} -erased-serde = { version = "^0.4", features = [ - "std", -], default-features = false } +erased-serde = { version = "^0.4", features = ["std"], default-features = false} -glam = { version = "^0.29.3", features = ["std"], default-features = false } +glam = { version = "^0.29.3", features = ["std"], default-features = false} -serde = { version = "^1", features = ["std"], default-features = false } +serde = { version = "^1", features = ["std"], default-features = false} -smol_str = { version = "^0.2.0", features = ["std"], default-features = false } +smol_str = { version = "^0.2.0", features = ["std"], default-features = false} + +uuid = { version = "^1.13.1", features = ["std"], default-features = false} + +variadics_please = { version = "^1.1", features = [], default-features = true} -uuid = { version = "^1.13.1", features = ["std"], default-features = false } -variadics_please = { version = "^1.1", features = [], default-features = true } diff --git a/crates/bindings/bevy_reflect_bms_bindings/src/lib.rs b/crates/bindings/bevy_reflect_bms_bindings/src/lib.rs index f0a36a9b14..fd9911cea1 100644 --- a/crates/bindings/bevy_reflect_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_reflect_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyReflectScriptingPlugin; pub(crate) fn register_atomic_bool_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::sync::atomic::AtomicBool, >::new(world) .register_documented( @@ -55,11 +55,11 @@ pub(crate) fn register_atomic_bool_functions(world: &mut World) { registry .register_type_data::< ::core::sync::atomic::AtomicBool, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_atomic_i_16_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::sync::atomic::AtomicI16, >::new(world) .register_documented( @@ -101,11 +101,11 @@ pub(crate) fn register_atomic_i_16_functions(world: &mut World) { registry .register_type_data::< ::core::sync::atomic::AtomicI16, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_atomic_i_32_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::sync::atomic::AtomicI32, >::new(world) .register_documented( @@ -147,11 +147,11 @@ pub(crate) fn register_atomic_i_32_functions(world: &mut World) { registry .register_type_data::< ::core::sync::atomic::AtomicI32, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_atomic_i_64_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::sync::atomic::AtomicI64, >::new(world) .register_documented( @@ -193,11 +193,11 @@ pub(crate) fn register_atomic_i_64_functions(world: &mut World) { registry .register_type_data::< ::core::sync::atomic::AtomicI64, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_atomic_i_8_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::sync::atomic::AtomicI8, >::new(world) .register_documented( @@ -239,11 +239,11 @@ pub(crate) fn register_atomic_i_8_functions(world: &mut World) { registry .register_type_data::< ::core::sync::atomic::AtomicI8, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_atomic_isize_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::sync::atomic::AtomicIsize, >::new(world) .register_documented( @@ -285,11 +285,11 @@ pub(crate) fn register_atomic_isize_functions(world: &mut World) { registry .register_type_data::< ::core::sync::atomic::AtomicIsize, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_atomic_u_16_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::sync::atomic::AtomicU16, >::new(world) .register_documented( @@ -331,11 +331,11 @@ pub(crate) fn register_atomic_u_16_functions(world: &mut World) { registry .register_type_data::< ::core::sync::atomic::AtomicU16, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_atomic_u_32_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::sync::atomic::AtomicU32, >::new(world) .register_documented( @@ -377,11 +377,11 @@ pub(crate) fn register_atomic_u_32_functions(world: &mut World) { registry .register_type_data::< ::core::sync::atomic::AtomicU32, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_atomic_u_64_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::sync::atomic::AtomicU64, >::new(world) .register_documented( @@ -423,11 +423,11 @@ pub(crate) fn register_atomic_u_64_functions(world: &mut World) { registry .register_type_data::< ::core::sync::atomic::AtomicU64, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_atomic_u_8_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::sync::atomic::AtomicU8, >::new(world) .register_documented( @@ -469,11 +469,11 @@ pub(crate) fn register_atomic_u_8_functions(world: &mut World) { registry .register_type_data::< ::core::sync::atomic::AtomicU8, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_atomic_usize_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::sync::atomic::AtomicUsize, >::new(world) .register_documented( @@ -515,11 +515,11 @@ pub(crate) fn register_atomic_usize_functions(world: &mut World) { registry .register_type_data::< ::core::sync::atomic::AtomicUsize, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_duration_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::time::Duration, >::new(world) .register_documented( @@ -1093,13 +1093,11 @@ pub(crate) fn register_duration_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::core::time::Duration, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::core::time::Duration, bevy_mod_scripting_bindings::MarkAsGenerated>( + ); } pub(crate) fn register_instant_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::std::time::Instant, >::new(world) .register_documented( @@ -1275,13 +1273,10 @@ pub(crate) fn register_instant_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::std::time::Instant, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::std::time::Instant, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_range_full_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::ops::RangeFull, >::new(world) .register_documented( @@ -1338,13 +1333,11 @@ pub(crate) fn register_range_full_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::core::ops::RangeFull, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::core::ops::RangeFull, bevy_mod_scripting_bindings::MarkAsGenerated>( + ); } pub(crate) fn register_type_id_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::any::TypeId, >::new(world) .register_documented( @@ -1401,13 +1394,10 @@ pub(crate) fn register_type_id_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::core::any::TypeId, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::core::any::TypeId, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_quat_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::Quat, >::new(world) .register_documented( @@ -2265,11 +2255,10 @@ pub(crate) fn register_quat_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::Quat, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::Quat, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_vec_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::Vec3, >::new(world) .register_documented( @@ -3957,11 +3946,10 @@ pub(crate) fn register_vec_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::Vec3, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::Vec3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_socket_addr_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::core::net::SocketAddr, >::new(world) .register_documented( @@ -4082,11 +4070,11 @@ pub(crate) fn register_socket_addr_functions(world: &mut World) { registry .register_type_data::< ::core::net::SocketAddr, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_i_vec_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::IVec2, >::new(world) .register_documented( @@ -5351,11 +5339,10 @@ pub(crate) fn register_i_vec_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::IVec2, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::IVec2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_i_vec_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::IVec3, >::new(world) .register_documented( @@ -6636,11 +6623,10 @@ pub(crate) fn register_i_vec_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::IVec3, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::IVec3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_i_vec_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::IVec4, >::new(world) .register_documented( @@ -7888,11 +7874,10 @@ pub(crate) fn register_i_vec_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::IVec4, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::IVec4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_i_8_vec_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::I8Vec2, >::new(world) .register_documented( @@ -9157,11 +9142,10 @@ pub(crate) fn register_i_8_vec_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::I8Vec2, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::I8Vec2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_i_8_vec_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::I8Vec3, >::new(world) .register_documented( @@ -10441,11 +10425,10 @@ pub(crate) fn register_i_8_vec_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::I8Vec3, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::I8Vec3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_i_8_vec_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::I8Vec4, >::new(world) .register_documented( @@ -11692,11 +11675,10 @@ pub(crate) fn register_i_8_vec_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::I8Vec4, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::I8Vec4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_i_16_vec_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::I16Vec2, >::new(world) .register_documented( @@ -12973,12 +12955,10 @@ pub(crate) fn register_i_16_vec_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::I16Vec2, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::I16Vec2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_i_16_vec_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::I16Vec3, >::new(world) .register_documented( @@ -14272,12 +14252,10 @@ pub(crate) fn register_i_16_vec_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::I16Vec3, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::I16Vec3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_i_16_vec_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::I16Vec4, >::new(world) .register_documented( @@ -15541,12 +15519,10 @@ pub(crate) fn register_i_16_vec_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::I16Vec4, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::I16Vec4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_i_64_vec_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::I64Vec2, >::new(world) .register_documented( @@ -16823,12 +16799,10 @@ pub(crate) fn register_i_64_vec_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::I64Vec2, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::I64Vec2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_i_64_vec_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::I64Vec3, >::new(world) .register_documented( @@ -18122,12 +18096,10 @@ pub(crate) fn register_i_64_vec_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::I64Vec3, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::I64Vec3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_i_64_vec_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::I64Vec4, >::new(world) .register_documented( @@ -19391,12 +19363,10 @@ pub(crate) fn register_i_64_vec_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::I64Vec4, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::I64Vec4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_u_vec_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::UVec2, >::new(world) .register_documented( @@ -20450,11 +20420,10 @@ pub(crate) fn register_u_vec_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::UVec2, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::UVec2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_u_vec_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::UVec3, >::new(world) .register_documented( @@ -21577,11 +21546,10 @@ pub(crate) fn register_u_vec_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::UVec3, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::UVec3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_u_vec_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::UVec4, >::new(world) .register_documented( @@ -22671,11 +22639,10 @@ pub(crate) fn register_u_vec_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::UVec4, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::UVec4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_u_8_vec_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::U8Vec2, >::new(world) .register_documented( @@ -23729,11 +23696,10 @@ pub(crate) fn register_u_8_vec_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::U8Vec2, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::U8Vec2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_u_8_vec_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::U8Vec3, >::new(world) .register_documented( @@ -24855,11 +24821,10 @@ pub(crate) fn register_u_8_vec_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::U8Vec3, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::U8Vec3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_u_8_vec_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::U8Vec4, >::new(world) .register_documented( @@ -25948,11 +25913,10 @@ pub(crate) fn register_u_8_vec_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::U8Vec4, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::U8Vec4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_u_16_vec_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::U16Vec2, >::new(world) .register_documented( @@ -27018,12 +26982,10 @@ pub(crate) fn register_u_16_vec_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::U16Vec2, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::U16Vec2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_u_16_vec_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::U16Vec3, >::new(world) .register_documented( @@ -28159,12 +28121,10 @@ pub(crate) fn register_u_16_vec_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::U16Vec3, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::U16Vec3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_u_16_vec_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::U16Vec4, >::new(world) .register_documented( @@ -29270,12 +29230,10 @@ pub(crate) fn register_u_16_vec_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::U16Vec4, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::U16Vec4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_u_64_vec_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::U64Vec2, >::new(world) .register_documented( @@ -30341,12 +30299,10 @@ pub(crate) fn register_u_64_vec_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::U64Vec2, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::U64Vec2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_u_64_vec_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::U64Vec3, >::new(world) .register_documented( @@ -31482,12 +31438,10 @@ pub(crate) fn register_u_64_vec_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::U64Vec3, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::U64Vec3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_u_64_vec_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::U64Vec4, >::new(world) .register_documented( @@ -32593,12 +32547,10 @@ pub(crate) fn register_u_64_vec_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::U64Vec4, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::U64Vec4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_vec_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::Vec2, >::new(world) .register_documented( @@ -34318,11 +34270,10 @@ pub(crate) fn register_vec_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::Vec2, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::Vec2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_vec_3_a_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::Vec3A, >::new(world) .register_documented( @@ -36035,11 +35986,10 @@ pub(crate) fn register_vec_3_a_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::Vec3A, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::Vec3A, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_vec_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::Vec4, >::new(world) .register_documented( @@ -37657,11 +37607,10 @@ pub(crate) fn register_vec_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::Vec4, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::Vec4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_b_vec_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::BVec2, >::new(world) .register_documented( @@ -37832,11 +37781,10 @@ pub(crate) fn register_b_vec_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::BVec2, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::BVec2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_b_vec_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::BVec3, >::new(world) .register_documented( @@ -38008,11 +37956,10 @@ pub(crate) fn register_b_vec_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::BVec3, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::BVec3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_b_vec_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::BVec4, >::new(world) .register_documented( @@ -38184,11 +38131,10 @@ pub(crate) fn register_b_vec_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::BVec4, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::BVec4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_d_vec_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::DVec2, >::new(world) .register_documented( @@ -39916,11 +39862,10 @@ pub(crate) fn register_d_vec_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::DVec2, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::DVec2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_d_vec_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::DVec3, >::new(world) .register_documented( @@ -41631,11 +41576,10 @@ pub(crate) fn register_d_vec_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::DVec3, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::DVec3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_d_vec_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::DVec4, >::new(world) .register_documented( @@ -43261,11 +43205,10 @@ pub(crate) fn register_d_vec_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::DVec4, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::DVec4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_mat_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::Mat2, >::new(world) .register_documented( @@ -43853,11 +43796,10 @@ pub(crate) fn register_mat_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::Mat2, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::Mat2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_mat_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::Mat3, >::new(world) .register_documented( @@ -44678,11 +44620,10 @@ pub(crate) fn register_mat_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::Mat3, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::Mat3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_mat_3_a_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::Mat3A, >::new(world) .register_documented( @@ -45510,11 +45451,10 @@ pub(crate) fn register_mat_3_a_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::Mat3A, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::Mat3A, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_mat_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::Mat4, >::new(world) .register_documented( @@ -46640,11 +46580,10 @@ pub(crate) fn register_mat_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::Mat4, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::Mat4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_d_mat_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::DMat2, >::new(world) .register_documented( @@ -47203,11 +47142,10 @@ pub(crate) fn register_d_mat_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::DMat2, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::DMat2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_d_mat_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::DMat3, >::new(world) .register_documented( @@ -48000,11 +47938,10 @@ pub(crate) fn register_d_mat_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::DMat3, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::DMat3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_d_mat_4_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::DMat4, >::new(world) .register_documented( @@ -49074,11 +49011,10 @@ pub(crate) fn register_d_mat_4_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::DMat4, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::DMat4, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_affine_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::Affine2, >::new(world) .register_documented( @@ -49480,12 +49416,10 @@ pub(crate) fn register_affine_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::Affine2, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::Affine2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_affine_3_a_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::Affine3A, >::new(world) .register_documented( @@ -50044,12 +49978,10 @@ pub(crate) fn register_affine_3_a_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::Affine3A, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::Affine3A, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_d_affine_2_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::DAffine2, >::new(world) .register_documented( @@ -50421,12 +50353,10 @@ pub(crate) fn register_d_affine_2_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::DAffine2, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::DAffine2, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_d_affine_3_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::DAffine3, >::new(world) .register_documented( @@ -50957,12 +50887,10 @@ pub(crate) fn register_d_affine_3_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::DAffine3, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::DAffine3, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_d_quat_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::DQuat, >::new(world) .register_documented( @@ -51770,11 +51698,10 @@ pub(crate) fn register_d_quat_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::DQuat, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::DQuat, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_euler_rot_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::EulerRot, >::new(world) .register_documented( @@ -51830,12 +51757,10 @@ pub(crate) fn register_euler_rot_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::EulerRot, bevy_mod_scripting_core::bindings::MarkAsGenerated>( - ); + registry.register_type_data::<::glam::EulerRot, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_b_vec_3_a_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::BVec3A, >::new(world) .register_documented( @@ -51993,11 +51918,10 @@ pub(crate) fn register_b_vec_3_a_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::BVec3A, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::BVec3A, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_b_vec_4_a_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::glam::BVec4A, >::new(world) .register_documented( @@ -52155,11 +52079,10 @@ pub(crate) fn register_b_vec_4_a_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::glam::BVec4A, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::glam::BVec4A, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_smol_str_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::smol_str::SmolStr, >::new(world) .register_documented( @@ -52259,13 +52182,10 @@ pub(crate) fn register_smol_str_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::smol_str::SmolStr, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::smol_str::SmolStr, bevy_mod_scripting_bindings::MarkAsGenerated>(); } pub(crate) fn register_uuid_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::uuid::Uuid, >::new(world) .register_documented( @@ -52589,8 +52509,7 @@ pub(crate) fn register_uuid_functions(world: &mut World) { ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); - registry - .register_type_data::<::uuid::Uuid, bevy_mod_scripting_core::bindings::MarkAsGenerated>(); + registry.register_type_data::<::uuid::Uuid, bevy_mod_scripting_bindings::MarkAsGenerated>(); } impl Plugin for BevyReflectScriptingPlugin { fn build(&self, app: &mut App) { diff --git a/crates/bindings/bevy_render_bms_bindings/Cargo.toml b/crates/bindings/bevy_render_bms_bindings/Cargo.toml index 6902cf2c01..c0ea6fbf68 100644 --- a/crates/bindings/bevy_render_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_render_bms_bindings/Cargo.toml @@ -9,104 +9,92 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_render = { version = "0.16.1", features = [ - "hdr", - "ktx2", - "multi_threaded", - "webgl", -], default-features = true } +bevy_render = { version = "0.16.1", features = ["hdr", "ktx2", "multi_threaded", "webgl"], default-features = true} -async-channel = { version = "^2.3.0", features = [], default-features = true } +async-channel = { version = "^2.3.0", features = [], default-features = true} -bevy_app = { version = "^0.16.1", features = [], default-features = true } +bevy_app = { version = "^0.16.1", features = [], default-features = true} -bevy_asset = { version = "^0.16.1", features = [], default-features = true } +bevy_asset = { version = "^0.16.1", features = [], default-features = true} -bevy_color = { version = "^0.16.2", features = [], default-features = true } +bevy_color = { version = "^0.16.2", features = [], default-features = true} -bevy_derive = { version = "^0.16.1", features = [], default-features = true } +bevy_derive = { version = "^0.16.1", features = [], default-features = true} -bevy_diagnostic = { version = "^0.16.1", features = [ -], default-features = true } +bevy_diagnostic = { version = "^0.16.1", features = [], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [], default-features = true } +bevy_ecs = { version = "^0.16.1", features = [], default-features = true} -bevy_encase_derive = { version = "^0.16.1", features = [ -], default-features = true } +bevy_encase_derive = { version = "^0.16.1", features = [], default-features = true} -bevy_image = { version = "^0.16.1", features = [ - "hdr", - "ktx2", -], default-features = false } +bevy_image = { version = "^0.16.1", features = ["hdr", "ktx2"], default-features = false} -bevy_math = { version = "^0.16.1", features = [], default-features = true } +bevy_math = { version = "^0.16.1", features = [], default-features = true} -bevy_mesh = { version = "^0.16.1", features = [], default-features = true } +bevy_mesh = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_render_macros = { version = "^0.16.1", features = [ -], default-features = true } +bevy_render_macros = { version = "^0.16.1", features = [], default-features = true} -bevy_tasks = { version = "^0.16.1", features = [ - "multi_threaded", - "multi_threaded", -], default-features = false } +bevy_tasks = { version = "^0.16.1", features = ["multi_threaded", "multi_threaded"], default-features = false} -bevy_time = { version = "^0.16.1", features = [], default-features = true } +bevy_time = { version = "^0.16.1", features = [], default-features = true} -bevy_transform = { version = "^0.16.1", features = [], default-features = true } +bevy_transform = { version = "^0.16.1", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } +bevy_utils = { version = "^0.16.1", features = [], default-features = true} -bevy_window = { version = "^0.16.1", features = [], default-features = true } +bevy_window = { version = "^0.16.1", features = [], default-features = true} -bitflags = { version = "^2", features = [], default-features = true } +bitflags = { version = "^2", features = [], default-features = true} -bytemuck = { version = "^1.5", features = [], default-features = true } +bytemuck = { version = "^1.5", features = [], default-features = true} -codespan-reporting = { version = "^0.11.0", features = [ -], default-features = true } +codespan-reporting = { version = "^0.11.0", features = [], default-features = true} -encase = { version = "^0.10", features = [], default-features = true } +encase = { version = "^0.10", features = [], default-features = true} -fixedbitset = { version = "^0.5", features = [], default-features = true } +fixedbitset = { version = "^0.5", features = [], default-features = true} -futures-lite = { version = "^2.0.1", features = [], default-features = true } +futures-lite = { version = "^2.0.1", features = [], default-features = true} -indexmap = { version = "^2", features = [], default-features = true } +indexmap = { version = "^2", features = [], default-features = true} -js-sys = { version = "^0.3", features = [], default-features = true } +js-sys = { version = "^0.3", features = [], default-features = true} -ktx2 = { version = "^0.3.0", features = [], default-features = true } +ktx2 = { version = "^0.3.0", features = [], default-features = true} -naga = { version = "^24", features = [], default-features = true } +naga = { version = "^24", features = [], default-features = true} -naga_oil = { version = "^0.17", features = [], default-features = true } +naga_oil = { version = "^0.17", features = [], default-features = true} -nonmax = { version = "^0.5", features = [], default-features = true } +nonmax = { version = "^0.5", features = [], default-features = true} -offset-allocator = { version = "^0.2", features = [], default-features = true } +offset-allocator = { version = "^0.2", features = [], default-features = true} -send_wrapper = { version = "^0.6.0", features = [], default-features = true } +send_wrapper = { version = "^0.6.0", features = [], default-features = true} -serde = { version = "^1", features = [], default-features = true } +serde = { version = "^1", features = [], default-features = true} -smallvec = { version = "^1.11", features = [], default-features = true } +smallvec = { version = "^1.11", features = [], default-features = true} -variadics_please = { version = "^1.1", features = [], default-features = true } +variadics_please = { version = "^1.1", features = [], default-features = true} -wasm-bindgen = { version = "^0.2", features = [], default-features = true } +wasm-bindgen = { version = "^0.2", features = [], default-features = true} + +web-sys = { version = "^0.3.67", features = [], default-features = true} + +wgpu = { version = "^24", features = ["webgl"], default-features = false} -web-sys = { version = "^0.3.67", features = [], default-features = true } -wgpu = { version = "^24", features = ["webgl"], default-features = false } diff --git a/crates/bindings/bevy_render_bms_bindings/src/lib.rs b/crates/bindings/bevy_render_bms_bindings/src/lib.rs index 8e8dd06eb0..497e919fb5 100644 --- a/crates/bindings/bevy_render_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_render_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyRenderScriptingPlugin; pub(crate) fn register_alpha_mode_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::alpha::AlphaMode, >::new(world) .register_documented( @@ -55,11 +55,11 @@ pub(crate) fn register_alpha_mode_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::alpha::AlphaMode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_camera_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::Camera, >::new(world) .register_documented( @@ -154,11 +154,11 @@ pub(crate) fn register_camera_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::Camera, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_clear_color_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::ClearColor, >::new(world) .register_documented( @@ -182,11 +182,11 @@ pub(crate) fn register_clear_color_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::ClearColor, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_clear_color_config_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::ClearColorConfig, >::new(world) .register_documented( @@ -212,11 +212,11 @@ pub(crate) fn register_clear_color_config_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::ClearColorConfig, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_orthographic_projection_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::OrthographicProjection, >::new(world) .register_documented( @@ -271,11 +271,11 @@ pub(crate) fn register_orthographic_projection_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::OrthographicProjection, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_perspective_projection_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::PerspectiveProjection, >::new(world) .register_documented( @@ -300,11 +300,11 @@ pub(crate) fn register_perspective_projection_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::PerspectiveProjection, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_projection_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::Projection, >::new(world) .register_documented( @@ -328,11 +328,11 @@ pub(crate) fn register_projection_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::Projection, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mesh_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::mesh::Mesh2d, >::new(world) .register_documented( @@ -394,11 +394,11 @@ pub(crate) fn register_mesh_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::mesh::Mesh2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mesh_3_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::mesh::Mesh3d, >::new(world) .register_documented( @@ -460,11 +460,11 @@ pub(crate) fn register_mesh_3_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::mesh::Mesh3d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_inherited_visibility_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::visibility::InheritedVisibility, >::new(world) .register_documented( @@ -545,102 +545,109 @@ pub(crate) fn register_inherited_visibility_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::visibility::InheritedVisibility, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_msaa_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::Msaa, >::new(world) - .register_documented( - "assert_receiver_is_total_eq", - |_self: Ref<::bevy_render::view::Msaa>| { - let output: () = { - { - let output: () = - <::bevy_render::view::Msaa as ::std::cmp::Eq>::assert_receiver_is_total_eq( - &_self, - ) - .into(); - output - } - }; - output - }, - "", - &["_self"], - ) - .register_documented( - "clone", - |_self: Ref<::bevy_render::view::Msaa>| { - let output: Val<::bevy_render::view::Msaa> = { - { - let output: Val<::bevy_render::view::Msaa> = - <::bevy_render::view::Msaa as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ) - .register_documented( - "eq", - |_self: Ref<::bevy_render::view::Msaa>, other: Ref<::bevy_render::view::Msaa>| { - let output: bool = { - { - let output: bool = <::bevy_render::view::Msaa as ::std::cmp::PartialEq< - ::bevy_render::view::Msaa, - >>::eq(&_self, &other) - .into(); - output - } - }; - output - }, - "", - &["_self", "other"], - ) - .register_documented( - "from_samples", - |samples: u32| { - let output: Val<::bevy_render::view::Msaa> = { - { - let output: Val<::bevy_render::view::Msaa> = - ::bevy_render::view::Msaa::from_samples(samples).into(); - output - } - }; - output - }, - "", - &["samples"], - ) - .register_documented( - "samples", - |_self: Ref<::bevy_render::view::Msaa>| { - let output: u32 = { - { - let output: u32 = ::bevy_render::view::Msaa::samples(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "assert_receiver_is_total_eq", + |_self: Ref<::bevy_render::view::Msaa>| { + let output: () = { + { + let output: () = <::bevy_render::view::Msaa as ::std::cmp::Eq>::assert_receiver_is_total_eq( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ) + .register_documented( + "clone", + |_self: Ref<::bevy_render::view::Msaa>| { + let output: Val<::bevy_render::view::Msaa> = { + { + let output: Val<::bevy_render::view::Msaa> = <::bevy_render::view::Msaa as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ) + .register_documented( + "eq", + | + _self: Ref<::bevy_render::view::Msaa>, + other: Ref<::bevy_render::view::Msaa>| + { + let output: bool = { + { + let output: bool = <::bevy_render::view::Msaa as ::std::cmp::PartialEq< + ::bevy_render::view::Msaa, + >>::eq(&_self, &other) + .into(); + output + } + }; + output + }, + "", + &["_self", "other"], + ) + .register_documented( + "from_samples", + |samples: u32| { + let output: Val<::bevy_render::view::Msaa> = { + { + let output: Val<::bevy_render::view::Msaa> = ::bevy_render::view::Msaa::from_samples( + samples, + ) + .into(); + output + } + }; + output + }, + "", + &["samples"], + ) + .register_documented( + "samples", + |_self: Ref<::bevy_render::view::Msaa>| { + let output: u32 = { + { + let output: u32 = ::bevy_render::view::Msaa::samples(&_self) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_render::view::Msaa, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_view_visibility_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::visibility::ViewVisibility, >::new(world) .register_documented( @@ -738,11 +745,11 @@ pub(crate) fn register_view_visibility_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::visibility::ViewVisibility, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_visibility_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::visibility::Visibility, >::new(world) .register_documented( @@ -855,11 +862,11 @@ pub(crate) fn register_visibility_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::visibility::Visibility, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_sync_to_render_world_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::sync_world::SyncToRenderWorld, >::new(world) .register_documented( @@ -884,11 +891,11 @@ pub(crate) fn register_sync_to_render_world_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::sync_world::SyncToRenderWorld, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_aabb_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::primitives::Aabb, >::new(world) .register_documented( @@ -1000,11 +1007,11 @@ pub(crate) fn register_aabb_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::primitives::Aabb, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cascades_frusta_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::primitives::CascadesFrusta, >::new(world) .register_documented( @@ -1030,11 +1037,11 @@ pub(crate) fn register_cascades_frusta_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::primitives::CascadesFrusta, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_cubemap_frusta_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::primitives::CubemapFrusta, >::new(world) .register_documented( @@ -1060,11 +1067,11 @@ pub(crate) fn register_cubemap_frusta_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::primitives::CubemapFrusta, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_frustum_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::primitives::Frustum, >::new(world) .register_documented( @@ -1181,11 +1188,11 @@ pub(crate) fn register_frustum_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::primitives::Frustum, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_occlusion_culling_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::experimental::occlusion_culling::OcclusionCulling, >::new(world) .register_documented( @@ -1218,11 +1225,11 @@ pub(crate) fn register_occlusion_culling_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::experimental::occlusion_culling::OcclusionCulling, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_camera_render_graph_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::CameraRenderGraph, >::new(world) .register_documented( @@ -1248,11 +1255,11 @@ pub(crate) fn register_camera_render_graph_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::CameraRenderGraph, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_camera_main_texture_usages_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::CameraMainTextureUsages, >::new(world) .register_documented( @@ -1279,11 +1286,11 @@ pub(crate) fn register_camera_main_texture_usages_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::CameraMainTextureUsages, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_exposure_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::Exposure, >::new(world) .register_documented( @@ -1325,11 +1332,11 @@ pub(crate) fn register_exposure_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::Exposure, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_temporal_jitter_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::TemporalJitter, >::new(world) .register_documented( @@ -1376,11 +1383,11 @@ pub(crate) fn register_temporal_jitter_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::TemporalJitter, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mip_bias_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::MipBias, >::new(world); let registry = world.get_resource_or_init::(); @@ -1388,11 +1395,11 @@ pub(crate) fn register_mip_bias_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::MipBias, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_manual_texture_view_handle_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::ManualTextureViewHandle, >::new(world) .register_documented( @@ -1456,11 +1463,11 @@ pub(crate) fn register_manual_texture_view_handle_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::ManualTextureViewHandle, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_color_grading_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::ColorGrading, >::new(world) .register_documented( @@ -1506,11 +1513,11 @@ pub(crate) fn register_color_grading_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::ColorGrading, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_render_layers_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::visibility::RenderLayers, >::new(world) .register_documented( @@ -1724,11 +1731,11 @@ pub(crate) fn register_render_layers_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::visibility::RenderLayers, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_render_visible_entities_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::visibility::RenderVisibleEntities, >::new(world) .register_documented( @@ -1757,11 +1764,11 @@ pub(crate) fn register_render_visible_entities_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::visibility::RenderVisibleEntities, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_visible_entities_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::visibility::VisibleEntities, >::new(world) .register_documented( @@ -1891,11 +1898,11 @@ pub(crate) fn register_visible_entities_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::visibility::VisibleEntities, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_viewport_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::Viewport, >::new(world) .register_documented( @@ -1941,11 +1948,11 @@ pub(crate) fn register_viewport_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::Viewport, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_sub_camera_view_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::SubCameraView, >::new(world) .register_documented( @@ -1990,11 +1997,11 @@ pub(crate) fn register_sub_camera_view_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::SubCameraView, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_render_target_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::RenderTarget, >::new(world) .register_documented( @@ -2018,11 +2025,11 @@ pub(crate) fn register_render_target_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::RenderTarget, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_image_render_target_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::ImageRenderTarget, >::new(world) .register_documented( @@ -2084,11 +2091,11 @@ pub(crate) fn register_image_render_target_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::ImageRenderTarget, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_normalized_render_target_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::NormalizedRenderTarget, >::new(world) .register_documented( @@ -2150,11 +2157,11 @@ pub(crate) fn register_normalized_render_target_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::NormalizedRenderTarget, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_custom_projection_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::CustomProjection, >::new(world) .register_documented( @@ -2180,11 +2187,11 @@ pub(crate) fn register_custom_projection_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::CustomProjection, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_scaling_mode_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::camera::ScalingMode, >::new(world) .register_documented( @@ -2208,11 +2215,11 @@ pub(crate) fn register_scaling_mode_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::camera::ScalingMode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_globals_uniform_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::globals::GlobalsUniform, >::new(world) .register_documented( @@ -2238,11 +2245,11 @@ pub(crate) fn register_globals_uniform_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::globals::GlobalsUniform, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_shader_storage_buffer_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::storage::ShaderStorageBuffer, >::new(world) .register_documented( @@ -2288,11 +2295,11 @@ pub(crate) fn register_shader_storage_buffer_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::storage::ShaderStorageBuffer, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_readback_complete_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::gpu_readback::ReadbackComplete, >::new(world); let registry = world.get_resource_or_init::(); @@ -2300,11 +2307,11 @@ pub(crate) fn register_readback_complete_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::gpu_readback::ReadbackComplete, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mesh_tag_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::mesh::MeshTag, >::new(world) .register_documented( @@ -2366,11 +2373,11 @@ pub(crate) fn register_mesh_tag_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::mesh::MeshTag, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_visibility_class_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::visibility::VisibilityClass, >::new(world) .register_documented( @@ -2397,11 +2404,11 @@ pub(crate) fn register_visibility_class_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::visibility::VisibilityClass, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_temporary_render_entity_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::sync_world::TemporaryRenderEntity, >::new(world) .register_documented( @@ -2428,11 +2435,11 @@ pub(crate) fn register_temporary_render_entity_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::sync_world::TemporaryRenderEntity, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_no_frustum_culling_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::visibility::NoFrustumCulling, >::new(world); let registry = world.get_resource_or_init::(); @@ -2440,11 +2447,11 @@ pub(crate) fn register_no_frustum_culling_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::visibility::NoFrustumCulling, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_color_grading_global_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::ColorGradingGlobal, >::new(world) .register_documented( @@ -2470,11 +2477,11 @@ pub(crate) fn register_color_grading_global_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::ColorGradingGlobal, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_color_grading_section_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::ColorGradingSection, >::new(world) .register_documented( @@ -2519,11 +2526,11 @@ pub(crate) fn register_color_grading_section_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::ColorGradingSection, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_visibility_range_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::visibility::VisibilityRange, >::new(world) .register_documented( @@ -2649,11 +2656,11 @@ pub(crate) fn register_visibility_range_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::visibility::VisibilityRange, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_screenshot_captured_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::window::screenshot::ScreenshotCaptured, >::new(world); let registry = world.get_resource_or_init::(); @@ -2661,11 +2668,11 @@ pub(crate) fn register_screenshot_captured_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::window::screenshot::ScreenshotCaptured, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_screenshot_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_render::view::window::screenshot::Screenshot, >::new(world) .register_documented( @@ -2725,7 +2732,7 @@ pub(crate) fn register_screenshot_functions(world: &mut World) { registry .register_type_data::< ::bevy_render::view::window::screenshot::Screenshot, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyRenderScriptingPlugin { diff --git a/crates/bindings/bevy_scene_bms_bindings/Cargo.toml b/crates/bindings/bevy_scene_bms_bindings/Cargo.toml index 3ff9045fa3..cde7d721d6 100644 --- a/crates/bindings/bevy_scene_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_scene_bms_bindings/Cargo.toml @@ -9,45 +9,38 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_scene = { version = "0.16.1", features = [ - "bevy_render", - "serialize", -], default-features = true } +bevy_scene = { version = "0.16.1", features = ["bevy_render", "serialize"], default-features = true} -bevy_app = { version = "^0.16.1", features = [], default-features = true } +bevy_app = { version = "^0.16.1", features = [], default-features = true} -bevy_asset = { version = "^0.16.1", features = [], default-features = true } +bevy_asset = { version = "^0.16.1", features = [], default-features = true} -bevy_derive = { version = "^0.16.1", features = [], default-features = true } +bevy_derive = { version = "^0.16.1", features = [], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [ - "serialize", -], default-features = false } +bevy_ecs = { version = "^0.16.1", features = ["serialize"], default-features = false} -bevy_platform = { version = "^0.16.1", features = [ - "serialize", -], default-features = false } +bevy_platform = { version = "^0.16.1", features = ["serialize"], default-features = false} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_render = { version = "^0.16.1", features = [], default-features = true } +bevy_render = { version = "^0.16.1", features = [], default-features = true} -bevy_transform = { version = "^0.16.1", features = [], default-features = true } +bevy_transform = { version = "^0.16.1", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } +bevy_utils = { version = "^0.16.1", features = [], default-features = true} + +serde = { version = "^1.0", features = [], default-features = true} + +uuid = { version = "^1.13.1", features = ["serde", "serde"], default-features = false} -serde = { version = "^1.0", features = [], default-features = true } -uuid = { version = "^1.13.1", features = [ - "serde", - "serde", -], default-features = false } diff --git a/crates/bindings/bevy_scene_bms_bindings/src/lib.rs b/crates/bindings/bevy_scene_bms_bindings/src/lib.rs index 088657d0b6..3ca1da2c6e 100644 --- a/crates/bindings/bevy_scene_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_scene_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevySceneScriptingPlugin; pub(crate) fn register_dynamic_scene_root_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_scene::prelude::DynamicSceneRoot, >::new(world) .register_documented( @@ -75,11 +75,11 @@ pub(crate) fn register_dynamic_scene_root_functions(world: &mut World) { registry .register_type_data::< ::bevy_scene::prelude::DynamicSceneRoot, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_scene_root_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_scene::prelude::SceneRoot, >::new(world) .register_documented( @@ -141,11 +141,11 @@ pub(crate) fn register_scene_root_functions(world: &mut World) { registry .register_type_data::< ::bevy_scene::prelude::SceneRoot, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_scene_instance_ready_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_scene::SceneInstanceReady, >::new(world) .register_documented( @@ -207,69 +207,70 @@ pub(crate) fn register_scene_instance_ready_functions(world: &mut World) { registry .register_type_data::< ::bevy_scene::SceneInstanceReady, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_instance_id_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_scene::InstanceId, >::new(world) - .register_documented( - "assert_receiver_is_total_eq", - |_self: Ref<::bevy_scene::InstanceId>| { - let output: () = { - { - let output: () = - <::bevy_scene::InstanceId as ::std::cmp::Eq>::assert_receiver_is_total_eq( - &_self, - ) - .into(); - output - } - }; - output - }, - "", - &["_self"], - ) - .register_documented( - "clone", - |_self: Ref<::bevy_scene::InstanceId>| { - let output: Val<::bevy_scene::InstanceId> = { - { - let output: Val<::bevy_scene::InstanceId> = - <::bevy_scene::InstanceId as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ) - .register_documented( - "eq", - |_self: Ref<::bevy_scene::InstanceId>, other: Ref<::bevy_scene::InstanceId>| { - let output: bool = { - { - let output: bool = <::bevy_scene::InstanceId as ::std::cmp::PartialEq< - ::bevy_scene::InstanceId, - >>::eq(&_self, &other) - .into(); - output - } - }; - output - }, - "", - &["_self", "other"], - ); + .register_documented( + "assert_receiver_is_total_eq", + |_self: Ref<::bevy_scene::InstanceId>| { + let output: () = { + { + let output: () = <::bevy_scene::InstanceId as ::std::cmp::Eq>::assert_receiver_is_total_eq( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ) + .register_documented( + "clone", + |_self: Ref<::bevy_scene::InstanceId>| { + let output: Val<::bevy_scene::InstanceId> = { + { + let output: Val<::bevy_scene::InstanceId> = <::bevy_scene::InstanceId as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ) + .register_documented( + "eq", + |_self: Ref<::bevy_scene::InstanceId>, other: Ref<::bevy_scene::InstanceId>| { + let output: bool = { + { + let output: bool = <::bevy_scene::InstanceId as ::std::cmp::PartialEq< + ::bevy_scene::InstanceId, + >>::eq(&_self, &other) + .into(); + output + } + }; + output + }, + "", + &["_self", "other"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_scene::InstanceId, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevySceneScriptingPlugin { diff --git a/crates/bindings/bevy_sprite_bms_bindings/Cargo.toml b/crates/bindings/bevy_sprite_bms_bindings/Cargo.toml index 0a48e7a04b..fec2dfb0e5 100644 --- a/crates/bindings/bevy_sprite_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_sprite_bms_bindings/Cargo.toml @@ -9,57 +9,54 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_sprite = { version = "0.16.1", features = [ - "bevy_picking", - "bevy_window", - "bevy_sprite_picking_backend", - "webgl", -], default-features = true } +bevy_sprite = { version = "0.16.1", features = ["bevy_picking", "bevy_window", "bevy_sprite_picking_backend", "webgl"], default-features = true} -bevy_app = { version = "^0.16.1", features = [], default-features = true } +bevy_app = { version = "^0.16.1", features = [], default-features = true} -bevy_asset = { version = "^0.16.1", features = [], default-features = true } +bevy_asset = { version = "^0.16.1", features = [], default-features = true} -bevy_color = { version = "^0.16.2", features = [], default-features = true } +bevy_color = { version = "^0.16.2", features = [], default-features = true} -bevy_core_pipeline = { version = "^0.16.1", features = [ -], default-features = true } +bevy_core_pipeline = { version = "^0.16.1", features = [], default-features = true} -bevy_derive = { version = "^0.16.1", features = [], default-features = true } +bevy_derive = { version = "^0.16.1", features = [], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [], default-features = true } +bevy_ecs = { version = "^0.16.1", features = [], default-features = true} -bevy_image = { version = "^0.16.1", features = [], default-features = true } +bevy_image = { version = "^0.16.1", features = [], default-features = true} -bevy_math = { version = "^0.16.1", features = [], default-features = true } +bevy_math = { version = "^0.16.1", features = [], default-features = true} -bevy_picking = { version = "^0.16.1", features = [], default-features = true } +bevy_picking = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_render = { version = "^0.16.1", features = [], default-features = true } +bevy_render = { version = "^0.16.1", features = [], default-features = true} -bevy_transform = { version = "^0.16.1", features = [], default-features = true } +bevy_transform = { version = "^0.16.1", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } +bevy_utils = { version = "^0.16.1", features = [], default-features = true} -bevy_window = { version = "^0.16.1", features = [], default-features = true } +bevy_window = { version = "^0.16.1", features = [], default-features = true} -bitflags = { version = "^2.3", features = [], default-features = true } +bitflags = { version = "^2.3", features = [], default-features = true} -bytemuck = { version = "^1", features = [], default-features = true } +bytemuck = { version = "^1", features = [], default-features = true} -fixedbitset = { version = "^0.5", features = [], default-features = true } +fixedbitset = { version = "^0.5", features = [], default-features = true} + +nonmax = { version = "^0.5", features = [], default-features = true} + +radsort = { version = "^0.1", features = [], default-features = true} -nonmax = { version = "^0.5", features = [], default-features = true } -radsort = { version = "^0.1", features = [], default-features = true } diff --git a/crates/bindings/bevy_sprite_bms_bindings/src/lib.rs b/crates/bindings/bevy_sprite_bms_bindings/src/lib.rs index 105d7713bd..2595f269c4 100644 --- a/crates/bindings/bevy_sprite_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_sprite_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevySpriteScriptingPlugin; pub(crate) fn register_sprite_picking_camera_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::prelude::SpritePickingCamera, >::new(world) .register_documented( @@ -38,11 +38,11 @@ pub(crate) fn register_sprite_picking_camera_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::prelude::SpritePickingCamera, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_sprite_picking_mode_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::prelude::SpritePickingMode, >::new(world) .register_documented( @@ -68,11 +68,11 @@ pub(crate) fn register_sprite_picking_mode_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::prelude::SpritePickingMode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_sprite_picking_settings_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::prelude::SpritePickingSettings, >::new(world); let registry = world.get_resource_or_init::(); @@ -80,11 +80,11 @@ pub(crate) fn register_sprite_picking_settings_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::prelude::SpritePickingSettings, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_sprite_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::prelude::Sprite, >::new(world) .register_documented( @@ -123,11 +123,11 @@ pub(crate) fn register_sprite_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::prelude::Sprite, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_sprite_image_mode_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::prelude::SpriteImageMode, >::new(world) .register_documented( @@ -189,11 +189,11 @@ pub(crate) fn register_sprite_image_mode_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::prelude::SpriteImageMode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_border_rect_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::prelude::BorderRect, >::new(world) .register_documented( @@ -273,11 +273,11 @@ pub(crate) fn register_border_rect_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::prelude::BorderRect, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_slice_scale_mode_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::prelude::SliceScaleMode, >::new(world) .register_documented( @@ -322,11 +322,11 @@ pub(crate) fn register_slice_scale_mode_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::prelude::SliceScaleMode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_texture_slicer_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::prelude::TextureSlicer, >::new(world) .register_documented( @@ -371,11 +371,11 @@ pub(crate) fn register_texture_slicer_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::prelude::TextureSlicer, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_color_material_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::prelude::ColorMaterial, >::new(world) .register_documented( @@ -401,11 +401,11 @@ pub(crate) fn register_color_material_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::prelude::ColorMaterial, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_scaling_mode_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::prelude::ScalingMode, >::new(world) .register_documented( @@ -448,11 +448,11 @@ pub(crate) fn register_scaling_mode_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::prelude::ScalingMode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_anchor_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::Anchor, >::new(world) .register_documented( @@ -509,57 +509,60 @@ pub(crate) fn register_anchor_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_sprite::Anchor, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_sprite::Anchor, bevy_mod_scripting_bindings::MarkAsGenerated>( + ); } pub(crate) fn register_alpha_mode_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::AlphaMode2d, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_sprite::AlphaMode2d>| { - let output: Val<::bevy_sprite::AlphaMode2d> = { - { - let output: Val<::bevy_sprite::AlphaMode2d> = - <::bevy_sprite::AlphaMode2d as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ) - .register_documented( - "eq", - |_self: Ref<::bevy_sprite::AlphaMode2d>, other: Ref<::bevy_sprite::AlphaMode2d>| { - let output: bool = { - { - let output: bool = <::bevy_sprite::AlphaMode2d as ::std::cmp::PartialEq< - ::bevy_sprite::AlphaMode2d, - >>::eq(&_self, &other) - .into(); - output - } - }; - output - }, - "", - &["_self", "other"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_sprite::AlphaMode2d>| { + let output: Val<::bevy_sprite::AlphaMode2d> = { + { + let output: Val<::bevy_sprite::AlphaMode2d> = <::bevy_sprite::AlphaMode2d as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ) + .register_documented( + "eq", + | + _self: Ref<::bevy_sprite::AlphaMode2d>, + other: Ref<::bevy_sprite::AlphaMode2d>| + { + let output: bool = { + { + let output: bool = <::bevy_sprite::AlphaMode2d as ::std::cmp::PartialEq< + ::bevy_sprite::AlphaMode2d, + >>::eq(&_self, &other) + .into(); + output + } + }; + output + }, + "", + &["_self", "other"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_sprite::AlphaMode2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_wireframe_2_d_material_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::Wireframe2dMaterial, >::new(world) .register_documented( @@ -583,11 +586,11 @@ pub(crate) fn register_wireframe_2_d_material_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::Wireframe2dMaterial, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_no_wireframe_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::NoWireframe2d, >::new(world) .register_documented( @@ -649,11 +652,11 @@ pub(crate) fn register_no_wireframe_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::NoWireframe2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_wireframe_2_d_config_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::Wireframe2dConfig, >::new(world) .register_documented( @@ -677,11 +680,11 @@ pub(crate) fn register_wireframe_2_d_config_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::Wireframe2dConfig, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_wireframe_2_d_color_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::Wireframe2dColor, >::new(world) .register_documented( @@ -705,11 +708,11 @@ pub(crate) fn register_wireframe_2_d_color_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::Wireframe2dColor, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_wireframe_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::Wireframe2d, >::new(world) .register_documented( @@ -771,11 +774,11 @@ pub(crate) fn register_wireframe_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::Wireframe2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_mesh_2_d_wireframe_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_sprite::Mesh2dWireframe, >::new(world) .register_documented( @@ -837,7 +840,7 @@ pub(crate) fn register_mesh_2_d_wireframe_functions(world: &mut World) { registry .register_type_data::< ::bevy_sprite::Mesh2dWireframe, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevySpriteScriptingPlugin { diff --git a/crates/bindings/bevy_text_bms_bindings/Cargo.toml b/crates/bindings/bevy_text_bms_bindings/Cargo.toml index db41312b3e..455929d5da 100644 --- a/crates/bindings/bevy_text_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_text_bms_bindings/Cargo.toml @@ -9,53 +9,54 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_text = { version = "0.16.1", features = [ - "default_font", -], default-features = true } +bevy_text = { version = "0.16.1", features = ["default_font"], default-features = true} -bevy_app = { version = "^0.16.1", features = [], default-features = true } +bevy_app = { version = "^0.16.1", features = [], default-features = true} -bevy_asset = { version = "^0.16.1", features = [], default-features = true } +bevy_asset = { version = "^0.16.1", features = [], default-features = true} -bevy_color = { version = "^0.16.2", features = [], default-features = true } +bevy_color = { version = "^0.16.2", features = [], default-features = true} -bevy_derive = { version = "^0.16.1", features = [], default-features = true } +bevy_derive = { version = "^0.16.1", features = [], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [], default-features = true } +bevy_ecs = { version = "^0.16.1", features = [], default-features = true} -bevy_image = { version = "^0.16.1", features = [], default-features = true } +bevy_image = { version = "^0.16.1", features = [], default-features = true} -bevy_log = { version = "^0.16.1", features = [], default-features = true } +bevy_log = { version = "^0.16.1", features = [], default-features = true} -bevy_math = { version = "^0.16.1", features = [], default-features = true } +bevy_math = { version = "^0.16.1", features = [], default-features = true} -bevy_reflect = { version = "^0.16.1", features = [], default-features = true } +bevy_reflect = { version = "^0.16.1", features = [], default-features = true} -bevy_render = { version = "^0.16.1", features = [], default-features = true } +bevy_render = { version = "^0.16.1", features = [], default-features = true} -bevy_sprite = { version = "^0.16.1", features = [], default-features = true } +bevy_sprite = { version = "^0.16.1", features = [], default-features = true} -bevy_transform = { version = "^0.16.1", features = [], default-features = true } +bevy_transform = { version = "^0.16.1", features = [], default-features = true} -bevy_utils = { version = "^0.16.1", features = [], default-features = true } +bevy_utils = { version = "^0.16.1", features = [], default-features = true} -bevy_window = { version = "^0.16.1", features = [], default-features = true } +bevy_window = { version = "^0.16.1", features = [], default-features = true} -cosmic-text = { version = "^0.13", features = [], default-features = true } +cosmic-text = { version = "^0.13", features = [], default-features = true} -serde = { version = "^1", features = [], default-features = true } +serde = { version = "^1", features = [], default-features = true} -smallvec = { version = "^1.13", features = [], default-features = true } +smallvec = { version = "^1.13", features = [], default-features = true} + +sys-locale = { version = "^0.3.0", features = [], default-features = true} + +unicode-bidi = { version = "^0.3.13", features = [], default-features = true} -sys-locale = { version = "^0.3.0", features = [], default-features = true } -unicode-bidi = { version = "^0.3.13", features = [], default-features = true } diff --git a/crates/bindings/bevy_text_bms_bindings/src/lib.rs b/crates/bindings/bevy_text_bms_bindings/src/lib.rs index f5229123cf..bb61288940 100644 --- a/crates/bindings/bevy_text_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_text_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyTextScriptingPlugin; pub(crate) fn register_justify_text_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::prelude::JustifyText, >::new(world) .register_documented( @@ -75,11 +75,11 @@ pub(crate) fn register_justify_text_functions(world: &mut World) { registry .register_type_data::< ::bevy_text::prelude::JustifyText, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_line_break_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::prelude::LineBreak, >::new(world) .register_documented( @@ -141,11 +141,11 @@ pub(crate) fn register_line_break_functions(world: &mut World) { registry .register_type_data::< ::bevy_text::prelude::LineBreak, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_text_2_d_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::prelude::Text2d, >::new(world) .register_documented( @@ -168,11 +168,11 @@ pub(crate) fn register_text_2_d_functions(world: &mut World) { registry .register_type_data::< ::bevy_text::prelude::Text2d, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_text_color_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::prelude::TextColor, >::new(world) .register_documented( @@ -214,11 +214,11 @@ pub(crate) fn register_text_color_functions(world: &mut World) { registry .register_type_data::< ::bevy_text::prelude::TextColor, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_text_font_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::prelude::TextFont, >::new(world) .register_documented( @@ -315,11 +315,11 @@ pub(crate) fn register_text_font_functions(world: &mut World) { registry .register_type_data::< ::bevy_text::prelude::TextFont, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_text_layout_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::prelude::TextLayout, >::new(world) .register_documented( @@ -473,11 +473,11 @@ pub(crate) fn register_text_layout_functions(world: &mut World) { registry .register_type_data::< ::bevy_text::prelude::TextLayout, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_text_span_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::prelude::TextSpan, >::new(world) .register_documented( @@ -501,38 +501,40 @@ pub(crate) fn register_text_span_functions(world: &mut World) { registry .register_type_data::< ::bevy_text::prelude::TextSpan, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_line_height_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::LineHeight, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_text::LineHeight>| { - let output: Val<::bevy_text::LineHeight> = { - { - let output: Val<::bevy_text::LineHeight> = - <::bevy_text::LineHeight as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_text::LineHeight>| { + let output: Val<::bevy_text::LineHeight> = { + { + let output: Val<::bevy_text::LineHeight> = <::bevy_text::LineHeight as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_text::LineHeight, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_text_bounds_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::TextBounds, >::new(world) .register_documented( @@ -609,11 +611,11 @@ pub(crate) fn register_text_bounds_functions(world: &mut World) { registry .register_type_data::< ::bevy_text::TextBounds, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_computed_text_block_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::ComputedTextBlock, >::new(world) .register_documented( @@ -655,38 +657,40 @@ pub(crate) fn register_computed_text_block_functions(world: &mut World) { registry .register_type_data::< ::bevy_text::ComputedTextBlock, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_text_entity_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::TextEntity, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_text::TextEntity>| { - let output: Val<::bevy_text::TextEntity> = { - { - let output: Val<::bevy_text::TextEntity> = - <::bevy_text::TextEntity as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_text::TextEntity>| { + let output: Val<::bevy_text::TextEntity> = { + { + let output: Val<::bevy_text::TextEntity> = <::bevy_text::TextEntity as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_text::TextEntity, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_font_smoothing_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::FontSmoothing, >::new(world) .register_documented( @@ -748,11 +752,11 @@ pub(crate) fn register_font_smoothing_functions(world: &mut World) { registry .register_type_data::< ::bevy_text::FontSmoothing, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_glyph_atlas_location_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::GlyphAtlasLocation, >::new(world) .register_documented( @@ -776,38 +780,40 @@ pub(crate) fn register_glyph_atlas_location_functions(world: &mut World) { registry .register_type_data::< ::bevy_text::GlyphAtlasLocation, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_glyph_atlas_info_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::GlyphAtlasInfo, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_text::GlyphAtlasInfo>| { - let output: Val<::bevy_text::GlyphAtlasInfo> = { - { - let output: Val<::bevy_text::GlyphAtlasInfo> = - <::bevy_text::GlyphAtlasInfo as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_text::GlyphAtlasInfo>| { + let output: Val<::bevy_text::GlyphAtlasInfo> = { + { + let output: Val<::bevy_text::GlyphAtlasInfo> = <::bevy_text::GlyphAtlasInfo as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_text::GlyphAtlasInfo, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_positioned_glyph_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::PositionedGlyph, >::new(world) .register_documented( @@ -830,34 +836,36 @@ pub(crate) fn register_positioned_glyph_functions(world: &mut World) { registry .register_type_data::< ::bevy_text::PositionedGlyph, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_text_layout_info_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_text::TextLayoutInfo, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_text::TextLayoutInfo>| { - let output: Val<::bevy_text::TextLayoutInfo> = { - { - let output: Val<::bevy_text::TextLayoutInfo> = - <::bevy_text::TextLayoutInfo as ::std::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_text::TextLayoutInfo>| { + let output: Val<::bevy_text::TextLayoutInfo> = { + { + let output: Val<::bevy_text::TextLayoutInfo> = <::bevy_text::TextLayoutInfo as ::std::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_text::TextLayoutInfo, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyTextScriptingPlugin { diff --git a/crates/bindings/bevy_time_bms_bindings/Cargo.toml b/crates/bindings/bevy_time_bms_bindings/Cargo.toml index bcddeca763..46495c3283 100644 --- a/crates/bindings/bevy_time_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_time_bms_bindings/Cargo.toml @@ -9,34 +9,24 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_time = { version = "0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = true } +bevy_time = { version = "0.16.1", features = ["std", "bevy_reflect"], default-features = true} -bevy_app = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = true } +bevy_app = { version = "^0.16.1", features = ["std", "bevy_reflect"], default-features = true} -bevy_ecs = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = false } +bevy_ecs = { version = "^0.16.1", features = ["std", "bevy_reflect"], default-features = false} + +bevy_platform = { version = "^0.16.1", features = ["std"], default-features = false} + +bevy_reflect = { version = "^0.16.1", features = ["std"], default-features = false} -bevy_platform = { version = "^0.16.1", features = [ - "std", -], default-features = false } -bevy_reflect = { version = "^0.16.1", features = [ - "std", -], default-features = false } diff --git a/crates/bindings/bevy_time_bms_bindings/src/lib.rs b/crates/bindings/bevy_time_bms_bindings/src/lib.rs index 24a04178b6..744f6fb367 100644 --- a/crates/bindings/bevy_time_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_time_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,61 +13,65 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyTimeScriptingPlugin; pub(crate) fn register_fixed_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_time::prelude::Fixed, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_time::prelude::Fixed>| { - let output: Val<::bevy_time::prelude::Fixed> = { - { - let output: Val<::bevy_time::prelude::Fixed> = - <::bevy_time::prelude::Fixed as ::core::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_time::prelude::Fixed>| { + let output: Val<::bevy_time::prelude::Fixed> = { + { + let output: Val<::bevy_time::prelude::Fixed> = <::bevy_time::prelude::Fixed as ::core::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_time::prelude::Fixed, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_real_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_time::prelude::Real, >::new(world) - .register_documented( - "clone", - |_self: Ref<::bevy_time::prelude::Real>| { - let output: Val<::bevy_time::prelude::Real> = { - { - let output: Val<::bevy_time::prelude::Real> = - <::bevy_time::prelude::Real as ::core::clone::Clone>::clone(&_self).into(); - output - } - }; - output - }, - "", - &["_self"], - ); + .register_documented( + "clone", + |_self: Ref<::bevy_time::prelude::Real>| { + let output: Val<::bevy_time::prelude::Real> = { + { + let output: Val<::bevy_time::prelude::Real> = <::bevy_time::prelude::Real as ::core::clone::Clone>::clone( + &_self, + ) + .into(); + output + } + }; + output + }, + "", + &["_self"], + ); let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry .register_type_data::< ::bevy_time::prelude::Real, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_timer_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_time::prelude::Timer, >::new(world) .register_documented( @@ -491,11 +495,11 @@ pub(crate) fn register_timer_functions(world: &mut World) { registry .register_type_data::< ::bevy_time::prelude::Timer, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_timer_mode_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_time::prelude::TimerMode, >::new(world) .register_documented( @@ -557,11 +561,11 @@ pub(crate) fn register_timer_mode_functions(world: &mut World) { registry .register_type_data::< ::bevy_time::prelude::TimerMode, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_virtual_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_time::prelude::Virtual, >::new(world) .register_documented( @@ -585,11 +589,11 @@ pub(crate) fn register_virtual_functions(world: &mut World) { registry .register_type_data::< ::bevy_time::prelude::Virtual, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_stopwatch_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_time::Stopwatch, >::new(world) .register_documented( @@ -788,10 +792,8 @@ pub(crate) fn register_stopwatch_functions(world: &mut World) { let registry = world.get_resource_or_init::(); let mut registry = registry.write(); registry - .register_type_data::< - ::bevy_time::Stopwatch, - bevy_mod_scripting_core::bindings::MarkAsGenerated, - >(); + .register_type_data::<::bevy_time::Stopwatch, bevy_mod_scripting_bindings::MarkAsGenerated>( + ); } impl Plugin for BevyTimeScriptingPlugin { fn build(&self, app: &mut App) { diff --git a/crates/bindings/bevy_transform_bms_bindings/Cargo.toml b/crates/bindings/bevy_transform_bms_bindings/Cargo.toml index 832579668e..74aad20fba 100644 --- a/crates/bindings/bevy_transform_bms_bindings/Cargo.toml +++ b/crates/bindings/bevy_transform_bms_bindings/Cargo.toml @@ -9,48 +9,28 @@ repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "rhai"] categories = ["game-development"] -readme = "README.md" +readme = "readme.md" [dependencies] bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } -bevy_transform = { version = "0.16.1", features = [ - "std", - "async_executor", - "alloc", - "bevy_log", - "bevy-support", - "bevy_reflect", -], default-features = true } - - -bevy_app = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = false } - -bevy_ecs = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = false } - -bevy_math = { version = "^0.16.1", features = [ - "std", - "bevy_reflect", -], default-features = false } - -bevy_reflect = { version = "^0.16.1", features = [ - "std", -], default-features = false } - -bevy_tasks = { version = "^0.16.1", features = [ - "std", - "async_executor", -], default-features = false } - -bevy_utils = { version = "^0.16.1", features = [ - "std", -], default-features = false } +bevy_transform = { version = "0.16.1", features = ["std", "bevy-support", "bevy_reflect", "async_executor", "alloc", "bevy_log"], default-features = true} + + +bevy_app = { version = "^0.16.1", features = ["std", "bevy_reflect"], default-features = false} + +bevy_ecs = { version = "^0.16.1", features = ["std", "bevy_reflect"], default-features = false} + +bevy_math = { version = "^0.16.1", features = ["std", "bevy_reflect"], default-features = false} + +bevy_reflect = { version = "^0.16.1", features = ["std"], default-features = false} + +bevy_tasks = { version = "^0.16.1", features = ["std", "async_executor"], default-features = false} + +bevy_utils = { version = "^0.16.1", features = ["std"], default-features = false} + + diff --git a/crates/bindings/bevy_transform_bms_bindings/src/lib.rs b/crates/bindings/bevy_transform_bms_bindings/src/lib.rs index 69f813261a..93df8ca88b 100644 --- a/crates/bindings/bevy_transform_bms_bindings/src/lib.rs +++ b/crates/bindings/bevy_transform_bms_bindings/src/lib.rs @@ -3,7 +3,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ ReflectReference, function::{ from::{Mut, Ref, Val}, @@ -13,7 +13,7 @@ use bevy_mod_scripting_core::bindings::{ use bevy_mod_scripting_derive::script_bindings; pub struct BevyTransformScriptingPlugin; pub(crate) fn register_global_transform_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_transform::components::GlobalTransform, >::new(world) .register_documented( @@ -527,11 +527,11 @@ pub(crate) fn register_global_transform_functions(world: &mut World) { registry .register_type_data::< ::bevy_transform::components::GlobalTransform, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_transform_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_transform::components::Transform, >::new(world) .register_documented( @@ -1308,11 +1308,11 @@ pub(crate) fn register_transform_functions(world: &mut World) { registry .register_type_data::< ::bevy_transform::components::Transform, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } pub(crate) fn register_transform_tree_changed_functions(world: &mut World) { - bevy_mod_scripting_core::bindings::function::namespace::NamespaceBuilder::< + bevy_mod_scripting_bindings::function::namespace::NamespaceBuilder::< ::bevy_transform::components::TransformTreeChanged, >::new(world) .register_documented( @@ -1359,7 +1359,7 @@ pub(crate) fn register_transform_tree_changed_functions(world: &mut World) { registry .register_type_data::< ::bevy_transform::components::TransformTreeChanged, - bevy_mod_scripting_core::bindings::MarkAsGenerated, + bevy_mod_scripting_bindings::MarkAsGenerated, >(); } impl Plugin for BevyTransformScriptingPlugin { diff --git a/crates/ladfile_builder/Cargo.toml b/crates/ladfile_builder/Cargo.toml index 80bd326c3f..5fe8938840 100644 --- a/crates/ladfile_builder/Cargo.toml +++ b/crates/ladfile_builder/Cargo.toml @@ -18,6 +18,7 @@ bevy_ecs = { workspace = true, default-features = false, features = [] } bevy_platform = { workspace = true, default-features = false, features = [] } bevy_log = { workspace = true, default-features = false, features = [] } bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_reflect = { workspace = true, features = ["documentation"] } ladfile = { workspace = true } regex = { workspace = true } diff --git a/crates/ladfile_builder/src/lib.rs b/crates/ladfile_builder/src/lib.rs index 42cbb6de6a..11efb8a816 100644 --- a/crates/ladfile_builder/src/lib.rs +++ b/crates/ladfile_builder/src/lib.rs @@ -11,21 +11,17 @@ use std::{ use bevy_ecs::world::World; use bevy_log::warn; -use bevy_mod_scripting_core::{ - bindings::{ - MarkAsCore, MarkAsGenerated, MarkAsSignificant, ReflectReference, - function::{ - namespace::Namespace, - script_function::{ - DynamicScriptFunction, DynamicScriptFunctionMut, FunctionCallContext, - }, - }, - }, +use bevy_mod_scripting_bindings::{ + MarkAsCore, MarkAsGenerated, MarkAsSignificant, ReflectReference, docgen::{ TypedThrough, info::FunctionInfo, typed_through::{ThroughTypeInfo, TypedWrapperKind, UntypedWrapperKind}, }, + function::{ + namespace::Namespace, + script_function::{DynamicScriptFunction, DynamicScriptFunctionMut, FunctionCallContext}, + }, match_by_type, }; use bevy_platform::collections::{HashMap, HashSet}; @@ -775,10 +771,8 @@ impl<'t> LadFileBuilder<'t> { fn lad_function_id_from_info(&mut self, function_info: &FunctionInfo) -> LadFunctionId { let namespace_string = match function_info.namespace { - bevy_mod_scripting_core::bindings::function::namespace::Namespace::Global => { - "".to_string() - } - bevy_mod_scripting_core::bindings::function::namespace::Namespace::OnType(type_id) => { + bevy_mod_scripting_bindings::function::namespace::Namespace::Global => "".to_string(), + bevy_mod_scripting_bindings::function::namespace::Namespace::OnType(type_id) => { self.lad_id_from_type_id(type_id).to_string() } }; @@ -854,15 +848,13 @@ impl<'t> LadFileBuilder<'t> { mod test { use std::collections::HashMap; - use bevy_mod_scripting_core::{ - bindings::{ - Union, Val, - function::{ - from::Ref, - namespace::{GlobalNamespace, IntoNamespace}, - }, - }, + use bevy_mod_scripting_bindings::{ + Union, Val, docgen::info::GetFunctionInfo, + function::{ + from::Ref, + namespace::{GlobalNamespace, IntoNamespace}, + }, }; use bevy_reflect::Reflect; diff --git a/crates/ladfile_builder/src/plugin.rs b/crates/ladfile_builder/src/plugin.rs index 97a3db29e5..98f9ee20f1 100644 --- a/crates/ladfile_builder/src/plugin.rs +++ b/crates/ladfile_builder/src/plugin.rs @@ -7,7 +7,7 @@ use ::{ bevy_ecs::{prelude::Resource, reflect::AppTypeRegistry, system::Res, world::World}, }; use bevy_log::{error, info}; -use bevy_mod_scripting_core::bindings::{ +use bevy_mod_scripting_bindings::{ IntoNamespace, function::{namespace::Namespace, script_function::AppScriptFunctionRegistry}, globals::AppScriptGlobalsRegistry, diff --git a/crates/languages/bevy_mod_scripting_lua/Cargo.toml b/crates/languages/bevy_mod_scripting_lua/Cargo.toml index e544426bca..562a8990de 100644 --- a/crates/languages/bevy_mod_scripting_lua/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_lua/Cargo.toml @@ -42,7 +42,9 @@ bevy_ecs = { workspace = true, default-features = false, features = [] } bevy_asset = { workspace = true, default-features = false, features = [] } bevy_log = { workspace = true, default-features = false, features = [] } bevy_platform = { workspace = true, default-features = false, features = [] } -bevy_mod_scripting_core = { workspace = true, features = ["mlua_impls"] } +bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_display = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_asset = { workspace = true } mlua = { workspace = true, features = ["vendored", "send", "macros"] } profiling = { workspace = true } diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs index 7c50ae219d..23f1a85643 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs @@ -1,14 +1,13 @@ use std::any::TypeId; -use bevy_mod_scripting_core::{ - bindings::{ - ReflectReference, ThreadWorldContainer, WorldContainer, pretty_print::DisplayWithWorld, - script_value::ScriptValue, - }, - error::InteropError, - reflection_extensions::TypeIdExtensions, +use bevy_mod_scripting_bindings::{ + ReflectReference, ThreadWorldContainer, WorldContainer, error::InteropError, + script_value::ScriptValue, }; -use mlua::{MetaMethod, UserData, UserDataMethods}; +use bevy_mod_scripting_display::OrFakeId; +use mlua::{ExternalError, MetaMethod, UserData, UserDataMethods}; + +use crate::IntoMluaError; use super::script_value::{LUA_CALLER_CONTEXT, LuaScriptValue}; @@ -41,9 +40,14 @@ impl UserData for LuaReflectReference { MetaMethod::Index, |_, (self_, key): (LuaReflectReference, LuaScriptValue)| { profiling::function_scope!("MetaMethod::Index"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let self_: ReflectReference = self_.into(); - let type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoMluaError::to_lua_error)? + .or_fake_id(); let key: ScriptValue = key.into(); let key = match key.as_string() { @@ -65,7 +69,8 @@ impl UserData for LuaReflectReference { let out = registry .magic_functions - .get(LUA_CALLER_CONTEXT, self_, key)?; + .get(LUA_CALLER_CONTEXT, self_, key) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue(out)) }, ); @@ -74,7 +79,9 @@ impl UserData for LuaReflectReference { MetaMethod::NewIndex, |_, (self_, key, value): (LuaReflectReference, LuaScriptValue, LuaScriptValue)| { profiling::function_scope!("MetaMethod::NewIndex"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let self_: ReflectReference = self_.into(); let key: ScriptValue = key.into(); let value: ScriptValue = value.into(); @@ -84,7 +91,8 @@ impl UserData for LuaReflectReference { registry .magic_functions - .set(LUA_CALLER_CONTEXT, self_, key, value)?; + .set(LUA_CALLER_CONTEXT, self_, key, value) + .map_err(IntoMluaError::to_lua_error)?; Ok(()) }, @@ -94,13 +102,19 @@ impl UserData for LuaReflectReference { MetaMethod::Sub, |_, (self_, other): (LuaReflectReference, LuaScriptValue)| { profiling::function_scope!("MetaMethod::Sub"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let self_: ReflectReference = self_.into(); let other: ScriptValue = other.into(); - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoMluaError::to_lua_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = - world.try_call_overloads(target_type_id, "sub", args, LUA_CALLER_CONTEXT)?; + let out = world + .try_call_overloads(target_type_id, "sub", args, LUA_CALLER_CONTEXT) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue(out)) }, ); @@ -109,13 +123,19 @@ impl UserData for LuaReflectReference { MetaMethod::Add, |_, (self_, other): (LuaReflectReference, LuaScriptValue)| { profiling::function_scope!("MetaMethod::Add"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let self_: ReflectReference = self_.into(); let other: ScriptValue = other.into(); - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoMluaError::to_lua_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = - world.try_call_overloads(target_type_id, "add", args, LUA_CALLER_CONTEXT)?; + let out = world + .try_call_overloads(target_type_id, "add", args, LUA_CALLER_CONTEXT) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue(out)) }, ); @@ -124,13 +144,19 @@ impl UserData for LuaReflectReference { MetaMethod::Mul, |_, (self_, other): (LuaReflectReference, LuaScriptValue)| { profiling::function_scope!("MetaMethod::Mul"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let self_: ReflectReference = self_.into(); let other: ScriptValue = other.into(); - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoMluaError::to_lua_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = - world.try_call_overloads(target_type_id, "mul", args, LUA_CALLER_CONTEXT)?; + let out = world + .try_call_overloads(target_type_id, "mul", args, LUA_CALLER_CONTEXT) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue(out)) }, ); @@ -139,13 +165,19 @@ impl UserData for LuaReflectReference { MetaMethod::Div, |_, (self_, other): (LuaReflectReference, LuaScriptValue)| { profiling::function_scope!("MetaMethod::Div"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let self_: ReflectReference = self_.into(); let other: ScriptValue = other.into(); - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoMluaError::to_lua_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = - world.try_call_overloads(target_type_id, "div", args, LUA_CALLER_CONTEXT)?; + let out = world + .try_call_overloads(target_type_id, "div", args, LUA_CALLER_CONTEXT) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue(out)) }, ); @@ -154,24 +186,37 @@ impl UserData for LuaReflectReference { MetaMethod::Mod, |_, (self_, other): (LuaReflectReference, LuaScriptValue)| { profiling::function_scope!("MetaMethod::Mod"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let self_: ReflectReference = self_.into(); let other: ScriptValue = other.into(); - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoMluaError::to_lua_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = - world.try_call_overloads(target_type_id, "rem", args, LUA_CALLER_CONTEXT)?; + let out = world + .try_call_overloads(target_type_id, "rem", args, LUA_CALLER_CONTEXT) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue(out)) }, ); m.add_meta_function(MetaMethod::Unm, |_, self_: LuaReflectReference| { profiling::function_scope!("MetaMethod::Unm"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let self_: ReflectReference = self_.into(); - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoMluaError::to_lua_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_)]; - let out = world.try_call_overloads(target_type_id, "neg", args, LUA_CALLER_CONTEXT)?; + let out = world + .try_call_overloads(target_type_id, "neg", args, LUA_CALLER_CONTEXT) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue(out)) }); @@ -179,13 +224,19 @@ impl UserData for LuaReflectReference { MetaMethod::Pow, |_, (self_, other): (LuaReflectReference, LuaScriptValue)| { profiling::function_scope!("MetaMethod::Pow"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let self_: ReflectReference = self_.into(); let other: ScriptValue = other.into(); - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoMluaError::to_lua_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = - world.try_call_overloads(target_type_id, "pow", args, LUA_CALLER_CONTEXT)?; + let out = world + .try_call_overloads(target_type_id, "pow", args, LUA_CALLER_CONTEXT) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue(out)) }, ); @@ -194,13 +245,19 @@ impl UserData for LuaReflectReference { MetaMethod::Eq, |_, (self_, other): (LuaReflectReference, LuaScriptValue)| { profiling::function_scope!("MetaMethod::Eq"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let self_: ReflectReference = self_.into(); let other: ScriptValue = other.into(); - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoMluaError::to_lua_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = - world.try_call_overloads(target_type_id, "eq", args, LUA_CALLER_CONTEXT)?; + let out = world + .try_call_overloads(target_type_id, "eq", args, LUA_CALLER_CONTEXT) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue(out)) }, ); @@ -209,23 +266,31 @@ impl UserData for LuaReflectReference { MetaMethod::Lt, |_, (self_, other): (LuaReflectReference, LuaScriptValue)| { profiling::function_scope!("MetaMethod::Lt"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let self_: ReflectReference = self_.into(); let other: ScriptValue = other.into(); - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoMluaError::to_lua_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = - world.try_call_overloads(target_type_id, "lt", args, LUA_CALLER_CONTEXT)?; + let out = world + .try_call_overloads(target_type_id, "lt", args, LUA_CALLER_CONTEXT) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue(out)) }, ); m.add_meta_function(MetaMethod::Len, |_lua, self_: LuaScriptValue| { profiling::function_scope!("MetaMethod::Len"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let script_value: ScriptValue = self_.into(); Ok(match script_value { - ScriptValue::Reference(r) => r.len(world)?, + ScriptValue::Reference(r) => r.len(world).map_err(IntoMluaError::to_lua_error)?, ScriptValue::List(l) => Some(l.len()), _ => None, }) @@ -241,30 +306,43 @@ impl UserData for LuaReflectReference { profiling::function_scope!("MetaMethod::Pairs"); // let mut iter_func = lookup_dynamic_function_typed::(l, "iter") // .expect("No iter function registered"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let iter_func = world .lookup_function([TypeId::of::()], "iter") - .map_err(|f| InteropError::missing_function(TypeId::of::(), f))?; - - Ok(LuaScriptValue::from(iter_func.call( - vec![ScriptValue::Reference(s.into())], - LUA_CALLER_CONTEXT, - )?)) + .map_err(|f| { + InteropError::missing_function(f, TypeId::of::().into()) + }) + .map_err(IntoMluaError::to_lua_error)?; + + Ok(LuaScriptValue::from( + iter_func + .call(vec![ScriptValue::Reference(s.into())], LUA_CALLER_CONTEXT) + .map_err(IntoMluaError::to_lua_error)?, + )) }); m.add_meta_function(MetaMethod::ToString, |_, self_: LuaReflectReference| { profiling::function_scope!("MetaMethod::ToString"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let reflect_reference: ReflectReference = self_.into(); let func = world - .lookup_function([TypeId::of::()], "display_ref") - .map_err(|f| InteropError::missing_function(TypeId::of::(), f))?; - let out = func.call( - vec![ScriptValue::Reference(reflect_reference)], - LUA_CALLER_CONTEXT, - )?; + .lookup_function([TypeId::of::()], "display") + .map_err(|f| { + InteropError::missing_function(f, TypeId::of::().into()) + }) + .map_err(IntoMluaError::to_lua_error)?; + let out = func + .call( + vec![ScriptValue::Reference(reflect_reference)], + LUA_CALLER_CONTEXT, + ) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue(out)) }); } @@ -283,7 +361,9 @@ impl UserData for LuaStaticReflectReference { MetaMethod::Index, |_, (self_, key): (LuaStaticReflectReference, LuaScriptValue)| { profiling::function_scope!("MetaMethod::Index"); - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoMluaError::to_lua_error)?; let type_id = self_.0; let key: ScriptValue = key.into(); @@ -295,11 +375,9 @@ impl UserData for LuaStaticReflectReference { }, Err(key) => key, }; - - let world = ThreadWorldContainer.try_get_world()?; Err( - InteropError::missing_function(type_id, key.display_with_world(world.clone())) - .into(), + InteropError::missing_function(format!("{key:#?}"), type_id.into()) + .into_lua_err(), ) }, ); diff --git a/crates/languages/bevy_mod_scripting_lua/src/bindings/script_value.rs b/crates/languages/bevy_mod_scripting_lua/src/bindings/script_value.rs index abdb02ba22..52a4f9971e 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/bindings/script_value.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/bindings/script_value.rs @@ -4,13 +4,14 @@ use std::{ }; use bevy_mod_scripting_asset::Language; -use bevy_mod_scripting_core::{ - bindings::{function::script_function::FunctionCallContext, script_value::ScriptValue}, - error::InteropError, +use bevy_mod_scripting_bindings::{ + error::InteropError, function::script_function::FunctionCallContext, script_value::ScriptValue, }; use bevy_platform::collections::HashMap; use mlua::{FromLua, IntoLua, Value, Variadic}; +use crate::IntoMluaError; + use super::reference::LuaReflectReference; #[derive(Debug, Clone)] @@ -64,7 +65,7 @@ impl FromLua for LuaScriptValue { .collect::>(), ) { Ok(v) => v.0, - Err(e) => ScriptValue::Error(InteropError::external_error(Box::new(e))), + Err(e) => ScriptValue::Error(InteropError::external(Box::new(e))), } }) .into(), @@ -140,16 +141,18 @@ impl IntoLua for LuaScriptValue { ScriptValue::Error(script_error) => return Err(mlua::Error::external(script_error)), ScriptValue::Function(function) => lua .create_function(move |_lua, args: Variadic| { - let out = - function.call(args.into_iter().map(Into::into), LUA_CALLER_CONTEXT)?; + let out = function + .call(args.into_iter().map(Into::into), LUA_CALLER_CONTEXT) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue::from(out)) })? .into_lua(lua)?, ScriptValue::FunctionMut(function) => lua .create_function(move |_lua, args: Variadic| { - let out = - function.call(args.into_iter().map(Into::into), LUA_CALLER_CONTEXT)?; + let out = function + .call(args.into_iter().map(Into::into), LUA_CALLER_CONTEXT) + .map_err(IntoMluaError::to_lua_error)?; Ok(LuaScriptValue::from(out)) })? diff --git a/crates/languages/bevy_mod_scripting_lua/src/lib.rs b/crates/languages/bevy_mod_scripting_lua/src/lib.rs index 1c35c417b7..393deed3fa 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/lib.rs @@ -10,18 +10,17 @@ use bevy_app::App; use bevy_ecs::world::WorldId; use bevy_log::trace; use bevy_mod_scripting_asset::{Language, ScriptAsset}; +use bevy_mod_scripting_bindings::{ + InteropError, PartialReflectExt, ThreadWorldContainer, WorldContainer, + function::namespace::Namespace, globals::AppScriptGlobalsRegistry, script_value::ScriptValue, +}; use bevy_mod_scripting_core::{ IntoScriptPluginParams, ScriptingPlugin, - bindings::{ - ThreadWorldContainer, WorldContainer, function::namespace::Namespace, - globals::AppScriptGlobalsRegistry, script_value::ScriptValue, - }, config::{GetPluginThreadConfig, ScriptingPluginConfiguration}, error::ScriptError, event::CallbackLabel, extractors::GetPluginFor, make_plugin_config_static, - reflection_extensions::PartialReflectExt, script::{ContextPolicy, ScriptAttachment}, }; use bindings::{ @@ -106,7 +105,7 @@ impl Default for LuaScriptingPlugin { "world", LuaStaticReflectReference(std::any::TypeId::of::()), ) - .map_err(ScriptError::from_mlua_error)?; + .map_err(IntoInteropError::to_bms_error)?; Ok(()) }, @@ -124,11 +123,15 @@ impl Default for LuaScriptingPlugin { let global = (maker)(world.clone())?; context .globals() - .set(key.to_string(), LuaScriptValue::from(global))? + .set(key.to_string(), LuaScriptValue::from(global)) + .map_err(IntoInteropError::to_bms_error)? } None => { let ref_ = LuaStaticReflectReference(global.type_id); - context.globals().set(key.to_string(), ref_)? + context + .globals() + .set(key.to_string(), ref_) + .map_err(IntoInteropError::to_bms_error)? } } } @@ -147,7 +150,7 @@ impl Default for LuaScriptingPlugin { key.name.to_string(), LuaScriptValue::from(ScriptValue::Function(function.clone())), ) - .map_err(ScriptError::from_mlua_error)?; + .map_err(IntoInteropError::to_bms_error)?; } Ok(()) @@ -166,7 +169,7 @@ impl Default for LuaScriptingPlugin { world.clone(), )), ) - .map_err(ScriptError::from_mlua_error)?; + .map_err(IntoInteropError::to_bms_error)?; } context .globals() @@ -177,7 +180,7 @@ impl Default for LuaScriptingPlugin { world, )), ) - .map_err(ScriptError::from_mlua_error)?; + .map_err(IntoInteropError::to_bms_error)?; Ok(()) }], @@ -219,7 +222,7 @@ fn load_lua_content_into_context( context .load(content) .exec() - .map_err(ScriptError::from_mlua_error)?; + .map_err(IntoInteropError::to_bms_error)?; Ok(()) } @@ -285,13 +288,53 @@ pub fn lua_handler( let input = MultiValue::from_vec( args.into_iter() .map(|arg| LuaScriptValue::from(arg).into_lua(context)) - .collect::>()?, + .collect::>() + .map_err(IntoInteropError::to_bms_error)?, ); - let out = handler.call::(input)?; + let out = handler + .call::(input) + .map_err(IntoInteropError::to_bms_error)?; Ok(out.into()) } +/// A trait to convert between mlua::Error and InteropError +pub trait IntoInteropError { + /// Convert into InteropError + fn to_bms_error(self) -> InteropError; +} + +impl IntoInteropError for mlua::Error { + fn to_bms_error(self) -> InteropError { + match self { + mlua::Error::CallbackError { traceback, cause } + if matches!(cause.as_ref(), mlua::Error::ExternalError(_)) => + { + let inner = cause.deref().clone(); + inner.to_bms_error().with_context(traceback) + } + e => { + if let Some(inner) = e.downcast_ref::() { + inner.clone() + } else { + InteropError::external(e) + } + } + } + } +} + +/// A trait to convert between InteropError and mlua::Error +pub trait IntoMluaError { + /// Convert into mlua::Error + fn to_lua_error(self) -> mlua::Error; +} + +impl IntoMluaError for InteropError { + fn to_lua_error(self) -> mlua::Error { + mlua::Error::external(self) + } +} #[cfg(test)] mod test { use ::bevy_asset::{AssetId, AssetIndex, Handle}; diff --git a/crates/languages/bevy_mod_scripting_rhai/Cargo.toml b/crates/languages/bevy_mod_scripting_rhai/Cargo.toml index 0977e2a0df..146ac80327 100644 --- a/crates/languages/bevy_mod_scripting_rhai/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_rhai/Cargo.toml @@ -21,8 +21,10 @@ bevy_asset = { workspace = true, default-features = false, features = [] } bevy_app = { workspace = true, default-features = false, features = [] } bevy_log = { workspace = true, default-features = false, features = [] } bevy_platform = { workspace = true, default-features = false, features = [] } -rhai = { workspace = true, features = ["std"] } -bevy_mod_scripting_core = { workspace = true, features = ["rhai_impls"] } +rhai = { workspace = true, features = ["std", "sync"] } +bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_display = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_asset = { workspace = true } strum = { workspace = true, features = ["derive"] } parking_lot = { workspace = true } diff --git a/crates/languages/bevy_mod_scripting_rhai/src/bindings/reference.rs b/crates/languages/bevy_mod_scripting_rhai/src/bindings/reference.rs index 0f5189eed1..a5799c3427 100644 --- a/crates/languages/bevy_mod_scripting_rhai/src/bindings/reference.rs +++ b/crates/languages/bevy_mod_scripting_rhai/src/bindings/reference.rs @@ -3,15 +3,12 @@ use std::{ ops::{Deref, DerefMut}, }; -use bevy_mod_scripting_core::{ - bindings::{ - ReflectReference, ThreadWorldContainer, WorldContainer, - function::script_function::DynamicScriptFunctionMut, pretty_print::DisplayWithWorld, - script_value::ScriptValue, - }, - error::InteropError, - reflection_extensions::TypeIdExtensions, +use crate::IntoRhaiError; +use bevy_mod_scripting_bindings::{ + ReflectReference, ScriptValue, ThreadWorldContainer, WorldContainer, error::InteropError, + function::script_function::DynamicScriptFunctionMut, }; +use bevy_mod_scripting_display::OrFakeId; use rhai::{CustomType, Dynamic, EvalAltResult}; use strum::VariantNames; @@ -247,7 +244,7 @@ impl Iterator for RhaiReflectRefIter { match self.next_func.call(vec![], RHAI_CALLER_CONTEXT) { Ok(ScriptValue::Unit) => None, Ok(v) => Some(v.into_dynamic()), - Err(error) => Some(Err(error.into())), + Err(error) => Some(Err(error.into_rhai_error())), } } } @@ -263,7 +260,9 @@ impl IntoIterator for RhaiReflectReference { let iter_func = world .lookup_function([TypeId::of::()], "iter") - .map_err(|f| InteropError::missing_function(TypeId::of::(), f))?; + .map_err(|f| { + InteropError::missing_function(f, TypeId::of::().into()) + })?; iter_func.call( vec![ScriptValue::Reference(self.0.clone())], @@ -295,9 +294,14 @@ impl CustomType for RhaiReflectReference { builder .with_name(std::any::type_name::()) .with_indexer_get(|self_: &mut Self, index: Dynamic| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let self_ = &self_.0; - let type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoRhaiError::into_rhai_error)? + .or_fake_id(); let key: ScriptValue = ScriptValue::from_dynamic(index)?; let key = match key.as_string() { @@ -321,12 +325,15 @@ impl CustomType for RhaiReflectReference { let out = registry .magic_functions - .get(RHAI_CALLER_CONTEXT, self_.clone(), key)?; + .get(RHAI_CALLER_CONTEXT, self_.clone(), key) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }) .with_indexer_set(|self_: &mut Self, index: Dynamic, value: Dynamic| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let self_ = self_.0.clone(); let key = ScriptValue::from_dynamic(index)?; let value = ScriptValue::from_dynamic(value)?; @@ -336,183 +343,244 @@ impl CustomType for RhaiReflectReference { registry .magic_functions - .set(RHAI_CALLER_CONTEXT, self_, key, value)?; + .set(RHAI_CALLER_CONTEXT, self_, key, value) + .map_err(IntoRhaiError::into_rhai_error)?; Ok(()) }) .with_fn( RhaiOperator::Sub.function_name(), |self_: Self, other: Dynamic| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let self_: ReflectReference = self_.0.clone(); let other: ScriptValue = ScriptValue::from_dynamic(other)?; - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoRhaiError::into_rhai_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = world.try_call_overloads( - target_type_id, - "sub", - args, - RHAI_CALLER_CONTEXT, - )?; + let out = world + .try_call_overloads(target_type_id, "sub", args, RHAI_CALLER_CONTEXT) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }, ) .with_fn( RhaiOperator::Add.function_name(), |self_: Self, other: Dynamic| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let self_: ReflectReference = self_.0.clone(); let other: ScriptValue = ScriptValue::from_dynamic(other)?; - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoRhaiError::into_rhai_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = world.try_call_overloads( - target_type_id, - "add", - args, - RHAI_CALLER_CONTEXT, - )?; + let out = world + .try_call_overloads(target_type_id, "add", args, RHAI_CALLER_CONTEXT) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }, ) .with_fn( RhaiOperator::Mul.function_name(), |self_: Self, other: Dynamic| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let self_: ReflectReference = self_.0.clone(); let other: ScriptValue = ScriptValue::from_dynamic(other)?; - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoRhaiError::into_rhai_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = world.try_call_overloads( - target_type_id, - "mul", - args, - RHAI_CALLER_CONTEXT, - )?; + let out = world + .try_call_overloads(target_type_id, "mul", args, RHAI_CALLER_CONTEXT) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }, ) .with_fn( RhaiOperator::Div.function_name(), |self_: Self, other: Dynamic| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let self_: ReflectReference = self_.0.clone(); let other: ScriptValue = ScriptValue::from_dynamic(other)?; - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoRhaiError::into_rhai_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = world.try_call_overloads( - target_type_id, - "div", - args, - RHAI_CALLER_CONTEXT, - )?; + let out = world + .try_call_overloads(target_type_id, "div", args, RHAI_CALLER_CONTEXT) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }, ) .with_fn( RhaiOperator::Mod.function_name(), |self_: Self, other: Dynamic| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let self_: ReflectReference = self_.0.clone(); let other: ScriptValue = ScriptValue::from_dynamic(other)?; - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoRhaiError::into_rhai_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = world.try_call_overloads( - target_type_id, - "rem", - args, - RHAI_CALLER_CONTEXT, - )?; + let out = world + .try_call_overloads(target_type_id, "rem", args, RHAI_CALLER_CONTEXT) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }, ) .with_fn(RhaiOperator::Unm.function_name(), |self_: Self| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let self_: ReflectReference = self_.0.clone(); - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoRhaiError::into_rhai_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_)]; - let out = - world.try_call_overloads(target_type_id, "neg", args, RHAI_CALLER_CONTEXT)?; + let out = world + .try_call_overloads(target_type_id, "neg", args, RHAI_CALLER_CONTEXT) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }) .with_fn( RhaiOperator::Pow.function_name(), |self_: Self, other: Dynamic| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let self_: ReflectReference = self_.0.clone(); let other: ScriptValue = ScriptValue::from_dynamic(other)?; - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoRhaiError::into_rhai_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = world.try_call_overloads( - target_type_id, - "pow", - args, - RHAI_CALLER_CONTEXT, - )?; + let out = world + .try_call_overloads(target_type_id, "pow", args, RHAI_CALLER_CONTEXT) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }, ) .with_fn( RhaiOperator::Eq.function_name(), |self_: Self, other: Dynamic| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let self_: ReflectReference = self_.0.clone(); let other: ScriptValue = ScriptValue::from_dynamic(other)?; - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoRhaiError::into_rhai_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = world.try_call_overloads( - target_type_id, - "eq", - args, - RHAI_CALLER_CONTEXT, - )?; + let out = world + .try_call_overloads(target_type_id, "eq", args, RHAI_CALLER_CONTEXT) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }, ) .with_fn( RhaiOperator::Ne.function_name(), |self_: Self, other: Dynamic| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let self_: ReflectReference = self_.0.clone(); let other: ScriptValue = ScriptValue::from_dynamic(other)?; - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoRhaiError::into_rhai_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = world.try_call_overloads( - target_type_id, - "eq", - args, - RHAI_CALLER_CONTEXT, - )?; + let out = world + .try_call_overloads(target_type_id, "eq", args, RHAI_CALLER_CONTEXT) + .map_err(IntoRhaiError::into_rhai_error)?; match out { ScriptValue::Bool(b) => ScriptValue::Bool(!b).into_dynamic(), - _ => Err(InteropError::invariant("eq did not return a bool").into()), + _ => { + Err(InteropError::invariant("eq did not return a bool") + .into_rhai_error()) + } } }, ) .with_fn( RhaiOperator::Lt.function_name(), |self_: Self, other: Dynamic| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let self_: ReflectReference = self_.0.clone(); let other: ScriptValue = ScriptValue::from_dynamic(other)?; - let target_type_id = self_.tail_type_id(world.clone())?.or_fake_id(); + let target_type_id = self_ + .tail_type_id(world.clone()) + .map_err(IntoRhaiError::into_rhai_error)? + .or_fake_id(); let args = vec![ScriptValue::Reference(self_), other]; - let out = world.try_call_overloads( - target_type_id, - "lt", - args, - RHAI_CALLER_CONTEXT, - )?; + let out = world + .try_call_overloads(target_type_id, "lt", args, RHAI_CALLER_CONTEXT) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }, ) + .on_debug(|self_| { + let result: Result<_, InteropError> = (|| { + let world = ThreadWorldContainer.try_get_world()?; + let reflect_reference = self_.0.clone(); + + let func = world + .lookup_function([TypeId::of::()], "debug") + .map_err(|f| { + InteropError::missing_function( + f, + TypeId::of::().into(), + ) + })?; + + let out = func.call( + vec![ScriptValue::Reference(reflect_reference)], + RHAI_CALLER_CONTEXT, + )?; + + match out { + ScriptValue::String(s) => Ok(s), + _ => Err(InteropError::invariant("debug failed to return a string")), + } + })(); + + match result { + Ok(str_) => str_.into(), + Err(error) => error.to_string(), + } + }) .on_print(|self_| { let result: Result<_, InteropError> = (|| { let world = ThreadWorldContainer.try_get_world()?; let reflect_reference = self_.0.clone(); let func = world - .lookup_function([TypeId::of::()], "display_ref") + .lookup_function([TypeId::of::()], "display") .map_err(|f| { - InteropError::missing_function(TypeId::of::(), f) + InteropError::missing_function( + f, + TypeId::of::().into(), + ) })?; let out = func.call( @@ -522,9 +590,7 @@ impl CustomType for RhaiReflectReference { match out { ScriptValue::String(s) => Ok(s), - _ => Err(InteropError::invariant( - "display_ref failed to return a string", - )), + _ => Err(InteropError::invariant("display failed to return a string")), } })(); @@ -545,7 +611,9 @@ impl CustomType for RhaiStaticReflectReference { builder .with_name(std::any::type_name::()) .with_indexer_get(|self_: &mut Self, index: Dynamic| { - let world = ThreadWorldContainer.try_get_world()?; + let world = ThreadWorldContainer + .try_get_world() + .map_err(IntoRhaiError::into_rhai_error)?; let type_id = self_.0; let key: ScriptValue = ScriptValue::from_dynamic(index)?; @@ -558,8 +626,8 @@ impl CustomType for RhaiStaticReflectReference { }; Err::<_, Box>( - InteropError::missing_function(type_id, key.display_with_world(world.clone())) - .into(), + InteropError::missing_function(format!("{key:#?}"), type_id.into()) + .into_rhai_error(), ) }); } diff --git a/crates/languages/bevy_mod_scripting_rhai/src/bindings/script_value.rs b/crates/languages/bevy_mod_scripting_rhai/src/bindings/script_value.rs index 6ce94244d7..29e8ccfeea 100644 --- a/crates/languages/bevy_mod_scripting_rhai/src/bindings/script_value.rs +++ b/crates/languages/bevy_mod_scripting_rhai/src/bindings/script_value.rs @@ -1,15 +1,15 @@ use std::str::FromStr; use bevy_mod_scripting_asset::Language; -use bevy_mod_scripting_core::{ - bindings::{ - function::script_function::{DynamicScriptFunction, FunctionCallContext}, - script_value::ScriptValue, - }, +use bevy_mod_scripting_bindings::{ error::InteropError, + function::script_function::{DynamicScriptFunction, FunctionCallContext}, + script_value::ScriptValue, }; use rhai::{Dynamic, EvalAltResult, FnPtr, Map, NativeCallContext}; +use crate::IntoRhaiError; + use super::reference::RhaiReflectReference; /// The default function call context for rhai @@ -41,10 +41,13 @@ impl IntoDynamic for FunctionWithReceiver { .map(|arg| ScriptValue::from_dynamic(arg.clone())) .collect::, _>>()?; - let out = self.function.call( - std::iter::once(self.receiver.clone()).chain(convert_args), - RHAI_CALLER_CONTEXT, - )?; + let out = self + .function + .call( + std::iter::once(self.receiver.clone()).chain(convert_args), + RHAI_CALLER_CONTEXT, + ) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }, @@ -101,7 +104,9 @@ impl IntoDynamic for ScriptValue { .map(|arg| ScriptValue::from_dynamic(arg.clone())) .collect::, _>>()?; - let out = func.call(convert_args, RHAI_CALLER_CONTEXT)?; + let out = func + .call(convert_args, RHAI_CALLER_CONTEXT) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }, @@ -115,7 +120,9 @@ impl IntoDynamic for ScriptValue { .map(|arg| ScriptValue::from_dynamic(arg.clone())) .collect::, _>>()?; - let out = func.call(convert_args, RHAI_CALLER_CONTEXT)?; + let out = func + .call(convert_args, RHAI_CALLER_CONTEXT) + .map_err(IntoRhaiError::into_rhai_error)?; out.into_dynamic() }, @@ -162,20 +169,21 @@ impl FromDynamic for ScriptValue { )), d if d.is_array() => Ok(ScriptValue::List( d.into_array() - .map_err(|_| InteropError::invariant("d is proved to be an array"))? + .map_err(|_| InteropError::invariant("d is proved to be an array")) + .map_err(IntoRhaiError::into_rhai_error)? .into_iter() .map(ScriptValue::from_dynamic) .collect::, _>>()?, )), d => { + let type_name = d.type_name(); if let Some(v) = d.try_cast::() { Ok(ScriptValue::Reference(v.0)) } else { Err(Box::new(EvalAltResult::ErrorSystem( "FromDynamic".to_string(), - Box::new(InteropError::impossible_conversion(std::any::TypeId::of::< - ScriptValue, - >( + Box::new(InteropError::string(format!( + "unsupported dynamic type for conversion to ScriptValue from dynamic type: {type_name:?}", ))), ))) } diff --git a/crates/languages/bevy_mod_scripting_rhai/src/lib.rs b/crates/languages/bevy_mod_scripting_rhai/src/lib.rs index 612e4e216f..94b2e78be2 100644 --- a/crates/languages/bevy_mod_scripting_rhai/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_rhai/src/lib.rs @@ -2,6 +2,8 @@ use std::ops::Deref; +use crate::bindings::script_value::{FromDynamic, IntoDynamic}; + use ::{ bevy_app::Plugin, bevy_asset::Handle, @@ -11,28 +13,24 @@ use bevy_app::App; use bevy_ecs::world::WorldId; use bevy_log::trace; use bevy_mod_scripting_asset::{Language, ScriptAsset}; +use bevy_mod_scripting_bindings::{ + AppScriptGlobalsRegistry, InteropError, Namespace, PartialReflectExt, ScriptValue, + ThreadWorldContainer, WorldContainer, +}; use bevy_mod_scripting_core::{ IntoScriptPluginParams, ScriptingPlugin, - bindings::{ - ThreadWorldContainer, WorldContainer, function::namespace::Namespace, - globals::AppScriptGlobalsRegistry, script_value::ScriptValue, - }, config::{GetPluginThreadConfig, ScriptingPluginConfiguration}, error::ScriptError, event::CallbackLabel, extractors::GetPluginFor, make_plugin_config_static, - reflection_extensions::PartialReflectExt, script::{ContextPolicy, DisplayProxy, ScriptAttachment}, }; -use bindings::{ - reference::{ReservedKeyword, RhaiReflectReference, RhaiStaticReflectReference}, - script_value::{FromDynamic, IntoDynamic}, -}; +use bindings::reference::{ReservedKeyword, RhaiReflectReference, RhaiStaticReflectReference}; use parking_lot::RwLock; pub use rhai; -use rhai::{AST, CallFnOptions, Dynamic, Engine, EvalAltResult, Scope}; +use rhai::{AST, CallFnOptions, Dynamic, Engine, EvalAltResult, ParseError, Scope}; /// Bindings for rhai. pub mod bindings; @@ -76,6 +74,47 @@ impl IntoScriptPluginParams for RhaiScriptingPlugin { } } +/// A trait for converting types into an [`EvalAltResult`] +pub trait IntoRhaiError { + /// Converts the error into an [`InteropError`] + fn into_rhai_error(self) -> Box; +} + +impl IntoRhaiError for InteropError { + fn into_rhai_error(self) -> Box { + Box::new(rhai::EvalAltResult::ErrorSystem( + "ScriptError".to_owned(), + Box::new(self), + )) + } +} + +/// A trait for converting types into an [`InteropError`] +pub trait IntoInteropError { + /// Converts the error into an [`InteropError`] + fn into_bms_error(self) -> InteropError; +} + +impl IntoInteropError for Box { + fn into_bms_error(self) -> InteropError { + match *self { + rhai::EvalAltResult::ErrorSystem(message, error) => { + if let Some(inner) = error.downcast_ref::() { + inner.clone() + } else { + InteropError::external_boxed(error).with_context(message) + } + } + _ => InteropError::external(self), + } + } +} + +impl IntoInteropError for ParseError { + fn into_bms_error(self) -> InteropError { + InteropError::external(self) + } +} /// The rhai scripting plugin. Used to add rhai scripting to a bevy app within the context of the BMS framework. pub struct RhaiScriptingPlugin { /// The internal scripting plugin @@ -120,9 +159,12 @@ impl Default for RhaiScriptingPlugin { match &global.maker { Some(maker) => { let global = (maker)(world.clone())?; - context - .scope - .set_or_push(key.to_string(), global.into_dynamic()?); + context.scope.set_or_push( + key.to_string(), + global + .into_dynamic() + .map_err(IntoInteropError::into_bms_error)?, + ); } None => { let ref_ = RhaiStaticReflectReference(global.type_id); @@ -159,7 +201,9 @@ impl Default for RhaiScriptingPlugin { { context.scope.set_or_push( key.name.clone(), - ScriptValue::Function(function.clone()).into_dynamic()?, + ScriptValue::Function(function.clone()) + .into_dynamic() + .map_err(IntoInteropError::into_bms_error)?, ); } @@ -219,7 +263,9 @@ fn load_rhai_content_into_context( let pre_handling_initializers = config.pre_handling_callbacks; let runtime = config.runtime.read(); - context.ast = runtime.compile(std::str::from_utf8(content)?)?; + context.ast = runtime + .compile(std::str::from_utf8(content)?) + .map_err(IntoInteropError::into_bms_error)?; context .ast .set_source(context_key.script().display().to_string()); @@ -230,7 +276,9 @@ fn load_rhai_content_into_context( pre_handling_initializers .iter() .try_for_each(|init| init(context_key, context))?; - runtime.eval_ast_with_scope::<()>(&mut context.scope, &context.ast)?; + runtime + .eval_ast_with_scope::<()>(&mut context.scope, &context.ast) + .map_err(IntoInteropError::into_bms_error)?; context.ast.clear_statements(); Ok(()) @@ -282,7 +330,8 @@ pub fn rhai_callback_handler( let args = args .into_iter() .map(|v| v.into_dynamic()) - .collect::, _>>()?; + .collect::, _>>() + .map_err(IntoInteropError::into_bms_error)?; trace!( "Calling callback {} in context {} with args: {:?}", @@ -297,7 +346,7 @@ pub fn rhai_callback_handler( callback.as_ref(), args, ) { - Ok(v) => Ok(ScriptValue::from_dynamic(v)?), + Ok(v) => Ok(ScriptValue::from_dynamic(v).map_err(IntoInteropError::into_bms_error)?), Err(e) => { if let EvalAltResult::ErrorFunctionNotFound(_, _) = e.unwrap_inner() { trace!( @@ -306,7 +355,7 @@ pub fn rhai_callback_handler( ); Ok(ScriptValue::Unit) } else { - Err(ScriptError::from(e)) + Err(ScriptError::from(e.into_bms_error())) } } } diff --git a/crates/testing_crates/script_integration_test_harness/Cargo.toml b/crates/testing_crates/script_integration_test_harness/Cargo.toml index cb9469e159..bfc7692ed9 100644 --- a/crates/testing_crates/script_integration_test_harness/Cargo.toml +++ b/crates/testing_crates/script_integration_test_harness/Cargo.toml @@ -21,6 +21,7 @@ test_utils = { workspace = true } bevy_reflect = { workspace = true } bevy_log = { workspace = true } bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_asset = { workspace = true } bevy_mod_scripting_functions = { workspace = true, features = [ "core_functions", diff --git a/crates/testing_crates/script_integration_test_harness/src/lib.rs b/crates/testing_crates/script_integration_test_harness/src/lib.rs index e1704664d4..2a7a780cd5 100644 --- a/crates/testing_crates/script_integration_test_harness/src/lib.rs +++ b/crates/testing_crates/script_integration_test_harness/src/lib.rs @@ -20,12 +20,12 @@ use ::{ }, bevy_reflect::Reflect, }; +use bevy_mod_scripting_bindings::{ + CoreScriptGlobalsPlugin, ReflectAccessId, ThreadWorldContainer, WorldAccessGuard, + WorldContainer, WorldGuard, +}; use bevy_mod_scripting_core::{ BMSScriptingInfrastructurePlugin, IntoScriptPluginParams, - bindings::{ - CoreScriptGlobalsPlugin, ReflectAccessId, WorldAccessGuard, WorldGuard, - pretty_print::DisplayWithWorld, - }, commands::CreateOrUpdateScript, error::ScriptError, script::{DisplayProxy, ScriptAttachment, ScriptComponent, ScriptContext, ScriptId}, @@ -64,39 +64,47 @@ pub fn install_test_plugin(app: &mut App, include_test_functions: bool) { #[cfg(feature = "lua")] pub fn make_test_lua_plugin() -> bevy_mod_scripting_lua::LuaScriptingPlugin { - use bevy_mod_scripting_core::{ConfigureScriptPlugin, bindings::WorldContainer}; + use bevy_mod_scripting_core::ConfigureScriptPlugin; use bevy_mod_scripting_lua::{LuaScriptingPlugin, mlua}; LuaScriptingPlugin::default().add_context_initializer( |_, ctxt: &mut bevy_mod_scripting_lua::LuaContext| { + use bevy_mod_scripting_lua::IntoInteropError; + let globals = ctxt.globals(); - globals.set( - "assert_throws", - ctxt.create_function(|_lua, (f, reg): (mlua::Function, String)| { - let world = - bevy_mod_scripting_core::bindings::ThreadWorldContainer.try_get_world()?; - let result = f.call::<()>(mlua::MultiValue::new()); - let err = match result { - Ok(_) => { - return Err(mlua::Error::external( - "Expected function to throw error, but it did not.", - )); + globals + .set( + "assert_throws", + ctxt.create_function(|_lua, (f, reg): (mlua::Function, String)| { + let result = f.call::<()>(mlua::MultiValue::new()); + let err = match result { + Ok(_) => { + return Err(mlua::Error::external( + "Expected function to throw error, but it did not.", + )); + } + Err(e) => format!( + "{}", + ScriptError::from( + bevy_mod_scripting_lua::IntoInteropError::to_bms_error(e), + ) + ), + }; + + let regex = regex::Regex::new(®).unwrap(); + if regex.is_match(&err) { + Ok(()) + } else { + Err(mlua::Error::external(format!( + "Expected error message to match the regex: \n{}\n\nBut got:\n{}", + regex.as_str(), + err + ))) } - Err(e) => ScriptError::from_mlua_error(e).display_with_world(world), - }; - - let regex = regex::Regex::new(®).unwrap(); - if regex.is_match(&err) { - Ok(()) - } else { - Err(mlua::Error::external(format!( - "Expected error message to match the regex: \n{}\n\nBut got:\n{}", - regex.as_str(), - err - ))) - } - })?, - )?; + }) + .map_err(IntoInteropError::to_bms_error)?, + ) + .map_err(IntoInteropError::to_bms_error)?; Ok(()) }, ) @@ -104,10 +112,7 @@ pub fn make_test_lua_plugin() -> bevy_mod_scripting_lua::LuaScriptingPlugin { #[cfg(feature = "rhai")] pub fn make_test_rhai_plugin() -> bevy_mod_scripting_rhai::RhaiScriptingPlugin { - use bevy_mod_scripting_core::{ - ConfigureScriptPlugin, - bindings::{ThreadWorldContainer, WorldContainer}, - }; + use bevy_mod_scripting_core::ConfigureScriptPlugin; use bevy_mod_scripting_rhai::{ RhaiScriptingPlugin, rhai::{Dynamic, EvalAltResult, FnPtr, NativeCallContext}, @@ -136,14 +141,15 @@ pub fn make_test_rhai_plugin() -> bevy_mod_scripting_rhai::RhaiScriptingPlugin { runtime.register_fn( "assert_throws", |ctxt: NativeCallContext, fn_: FnPtr, regex: String| { - let world = ThreadWorldContainer.try_get_world()?; let args: [Dynamic; 0] = []; let result = fn_.call_within_context::<()>(&ctxt, args); match result { Ok(_) => panic!("Expected function to throw error, but it did not."), Err(e) => { - let e = ScriptError::from_rhai_error(*e); - let err = e.display_with_world(world); + use bevy_mod_scripting_rhai::IntoInteropError; + + let e = ScriptError::from(e.into_bms_error()); + let err = format!("{e}"); let regex = regex::Regex::new(®ex).unwrap(); if regex.is_match(&err) { Ok::<(), Box>(()) @@ -262,10 +268,6 @@ where P: IntoScriptPluginParams + Plugin, F: Fn(&mut P::C, &P::R, &str, &mut criterion::BenchmarkGroup) -> Result<(), String>, { - use bevy_mod_scripting_core::bindings::{ - ThreadWorldContainer, WorldAccessGuard, WorldContainer, - }; - let mut app = setup_integration_test(|_, _| {}); install_test_plugin(&mut app, true); @@ -324,7 +326,7 @@ where // Ensure the world is available via ThreadWorldContainer ThreadWorldContainer .set_world(guard.clone()) - .map_err(|e| e.display_with_world(guard))?; + .map_err(|e| format!("{e:#?}"))?; // Pass the locked context to the closure for benchmarking its Lua (or generic) part bench_fn(&mut ctxt_locked, runtime, label, criterion) }); diff --git a/crates/testing_crates/script_integration_test_harness/src/parse.rs b/crates/testing_crates/script_integration_test_harness/src/parse.rs index f7ce011202..1dc6035cdc 100644 --- a/crates/testing_crates/script_integration_test_harness/src/parse.rs +++ b/crates/testing_crates/script_integration_test_harness/src/parse.rs @@ -2,8 +2,8 @@ use std::path::PathBuf; use anyhow::Error; use bevy_mod_scripting_asset::Language; +use bevy_mod_scripting_bindings::ScriptValue; use bevy_mod_scripting_core::{ - bindings::ScriptValue, callback_labels, event::{ CallbackLabel, OnScriptLoaded, OnScriptReloaded, OnScriptUnloaded, Recipients, diff --git a/crates/testing_crates/script_integration_test_harness/src/scenario.rs b/crates/testing_crates/script_integration_test_harness/src/scenario.rs index 9ffd26b932..0775560ab5 100644 --- a/crates/testing_crates/script_integration_test_harness/src/scenario.rs +++ b/crates/testing_crates/script_integration_test_harness/src/scenario.rs @@ -22,9 +22,9 @@ use bevy_app::{DynEq, FixedUpdate, Last, PostUpdate, Startup, Update}; use bevy_asset::{AssetServer, Assets}; use bevy_log::info; use bevy_mod_scripting_asset::{Language, LanguageExtensions, ScriptAsset}; +use bevy_mod_scripting_bindings::ScriptValue; use bevy_mod_scripting_core::{ ConfigureScriptPlugin, - bindings::{DisplayWithWorld, ScriptValue, WorldGuard}, commands::{AddStaticScript, RemoveStaticScript}, event::{ CallbackLabel, IntoCallbackLabel, ScriptCallbackEvent, ScriptCallbackResponseEvent, @@ -641,23 +641,21 @@ impl ScenarioStep { if ScriptValue::String(Cow::Owned(expected_string.clone())) != *val { return Err(anyhow!( - "Callback '{}' for attachment: '{}' expected: {}, but got: {}", + "Callback '{}' for attachment: '{}' expected: {}, but got: {:#?}", label, script.to_string(), expected_string, - val.display_with_world(WorldGuard::new_exclusive( - app.world_mut() - )) + val )); } } } Err(e) => { return Err(anyhow!( - "Callback '{}' for attachment: '{}' failed with error: {}", + "Callback '{}' for attachment: '{}' failed with error: {:#?}", label, script.to_string(), - e.display_with_world(WorldGuard::new_exclusive(app.world_mut())) + e )); } } diff --git a/crates/testing_crates/script_integration_test_harness/src/test_functions.rs b/crates/testing_crates/script_integration_test_harness/src/test_functions.rs index 0a3f8fc7a1..5c4ed1c694 100644 --- a/crates/testing_crates/script_integration_test_harness/src/test_functions.rs +++ b/crates/testing_crates/script_integration_test_harness/src/test_functions.rs @@ -9,17 +9,14 @@ use ::{ bevy_reflect::{Reflect, TypeRegistration}, }; use bevy_mod_scripting_asset::Language; -use bevy_mod_scripting_core::{ - bindings::{ - DynamicScriptFunction, ReflectReference, ScriptComponentRegistration, - ScriptResourceRegistration, ScriptTypeRegistration, ScriptValue, - function::{ - namespace::{GlobalNamespace, NamespaceBuilder}, - script_function::{DynamicScriptFunctionMut, FunctionCallContext}, - }, - pretty_print::DisplayWithWorld, - }, +use bevy_mod_scripting_bindings::{ + DynamicScriptFunction, ReflectReference, ScriptComponentRegistration, + ScriptResourceRegistration, ScriptTypeRegistration, ScriptValue, error::InteropError, + function::{ + namespace::{GlobalNamespace, NamespaceBuilder}, + script_function::{DynamicScriptFunctionMut, FunctionCallContext}, + }, }; use rand::{Rng, SeedableRng}; use rand_chacha::ChaCha12Rng; @@ -89,31 +86,26 @@ pub fn register_test_functions(world: &mut App) { ) .register( "_assert_throws", - |s: FunctionCallContext, f: DynamicScriptFunctionMut, reg: String| { - let world = s.world().unwrap(); - + |_s: FunctionCallContext, f: DynamicScriptFunctionMut, reg: String| { let result = f.call(vec![], FunctionCallContext::new(Language::Unknown)); let err = match result { Ok(_) => { - return Err(InteropError::external_error( - "Expected function to throw error, but it did not.".into(), + return Err(InteropError::str( + "Expected function to throw error, but it did not.", )); } - Err(e) => e.display_with_world(world.clone()), + Err(e) => format!("{e:#?}"), }; let regex = regex::Regex::new(®).unwrap(); if regex.is_match(&err) { Ok(()) } else { - Err(InteropError::external_error( - format!( - "Expected error message to match the regex: \n{}\n\nBut got:\n{}", - regex.as_str(), - err - ) - .into(), - )) + Err(InteropError::string(format!( + "Expected error message to match the regex: \n{}\n\nBut got:\n{}", + regex.as_str(), + err + ))) } }, ); diff --git a/crates/testing_crates/test_utils/src/test_plugin.rs b/crates/testing_crates/test_utils/src/test_plugin.rs index e76cfaa02e..d7308a303c 100644 --- a/crates/testing_crates/test_utils/src/test_plugin.rs +++ b/crates/testing_crates/test_utils/src/test_plugin.rs @@ -44,7 +44,7 @@ macro_rules! make_test_plugin { .invocations .lock() .push((context_key.entity(), Some(context_key.script().id()))); - Ok($ident::bindings::script_value::ScriptValue::Unit) + Ok(ScriptValue::Unit) }) as $ident::HandlerFn } @@ -72,7 +72,7 @@ macro_rules! make_test_plugin { #[derive(Default, std::fmt::Debug, Clone)] struct TestContext { - pub invocations: Vec<$ident::bindings::script_value::ScriptValue>, + pub invocations: Vec, } }; } diff --git a/docs/src/Development/AddingLanguages/necessary-features.md b/docs/src/Development/AddingLanguages/necessary-features.md index 9bbfefb37f..d3e873275e 100644 --- a/docs/src/Development/AddingLanguages/necessary-features.md +++ b/docs/src/Development/AddingLanguages/necessary-features.md @@ -35,6 +35,7 @@ In order for a language to be called "implemented" in BMS, it needs to support t - Less than: dispatches to the `lt` binary function on the type - Length: calls the `len` method on `ReflectReference` or on the table if the value is one. - Iteration: dispatches to the `iter` method on `ReflectReference` which returns an iterator function, this can be repeatedly called until it returns `ScriptValue::Unit` to signal the end of the iteration. - - Print: calls the `display_ref` method on `ReflectReference` or on the table if the value is one. + - Print: calls the `display` method on `ReflectReference` or on the table if the value is one. + - Debug print: calls the `debug` method on `ReflectReference` or on the table if the value is one. - Script handlers, loaders etc. must be implemented such that the `ThreadWorldContainer` is set for every interaction with script contexts, or anywhere else it might be needed. diff --git a/docs/src/Summary/controlling-script-bindings.md b/docs/src/Summary/controlling-script-bindings.md index 802979310a..13479491bb 100644 --- a/docs/src/Summary/controlling-script-bindings.md +++ b/docs/src/Summary/controlling-script-bindings.md @@ -153,8 +153,8 @@ There are a few reserved functions that you can override by registering them on | eq | an equality function, used for checking if two values are equal | ✅ | ❌ | | lt | a less than function, used for checking if a value is less than another | ✅ | ❌ | | iter | an iterator function, used for iterating over a value | ❌ | ✅ | -| display_ref | a display function, used for displaying a reference to a value | ❌ | ✅ | -| display_value | a display function, used for displaying a mutable reference to a value | ❌ | ✅ | +| display | a display function, used for displaying a reference to a value | ❌ | ✅ | +| debug | a display function, used for displaying a mutable reference to a value | ❌ | ✅ | In this context `overridable` indicates whether language implementations will look for a specific function on your type before looking at the generic `ReflectReference` namespace. You can still remove the existing registration for these functions on the `ReflectReference` namespace if you want to replace them with your own implementation. diff --git a/examples/docgen.rs b/examples/docgen.rs index 285c51fd5e..1b5960142d 100644 --- a/examples/docgen.rs +++ b/examples/docgen.rs @@ -1,12 +1,10 @@ use bevy::{DefaultPlugins, app::App, ecs::reflect::AppTypeRegistry}; use bevy_mod_scripting::ScriptFunctionsPlugin; -use bevy_mod_scripting_core::{ - BMSScriptingInfrastructurePlugin, - bindings::{ - function::script_function::AppScriptFunctionRegistry, - globals::{AppScriptGlobalsRegistry, core::CoreScriptGlobalsPlugin}, - }, +use bevy_mod_scripting_bindings::{ + function::script_function::AppScriptFunctionRegistry, + globals::{AppScriptGlobalsRegistry, core::CoreScriptGlobalsPlugin}, }; +use bevy_mod_scripting_core::BMSScriptingInfrastructurePlugin; use ladfile_builder::plugin::{LadFileSettings, ScriptingDocgenPlugin, generate_lad_file}; fn main() -> std::io::Result<()> { diff --git a/examples/game_of_life.rs b/examples/game_of_life.rs index 2b796a4a00..f1c09e51ed 100644 --- a/examples/game_of_life.rs +++ b/examples/game_of_life.rs @@ -15,7 +15,8 @@ use bevy::{ window::{PrimaryWindow, WindowResized}, }; use bevy_console::{AddConsoleCommand, ConsoleCommand, ConsoleOpen, ConsolePlugin, make_layer}; -use bevy_mod_scripting::{core::bindings::AllocatorDiagnosticPlugin, prelude::*}; +use bevy_mod_scripting::prelude::*; +use bevy_mod_scripting_bindings::AllocatorDiagnosticPlugin; use bevy_mod_scripting_core::commands::RemoveStaticScript; use clap::Parser; diff --git a/src/lib.rs b/src/lib.rs index 111e42c911..dd724a1282 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,13 @@ #![doc=include_str!("../readme.md")] +pub mod display { + pub use bevy_mod_scripting_display::*; +} + +pub mod bindings { + pub use bevy_mod_scripting_bindings::*; +} + pub mod core { pub use bevy_mod_scripting_core::*; } @@ -21,9 +29,8 @@ pub mod rhai { } use bevy_app::plugin_group; -use bevy_mod_scripting_core::{ - BMSScriptingInfrastructurePlugin, bindings::CoreScriptGlobalsPlugin, -}; +use bevy_mod_scripting_bindings::CoreScriptGlobalsPlugin; +use bevy_mod_scripting_core::BMSScriptingInfrastructurePlugin; pub use bevy_mod_scripting_derive::*; pub use bevy_mod_scripting_functions::*; diff --git a/src/prelude.rs b/src/prelude.rs index e00adcc0be..38de892eb4 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -1,17 +1,17 @@ pub use bevy_mod_scripting_core::{ - ConfigureScriptPlugin, IntoScriptPluginParams, - bindings::{ - CoreScriptGlobalsPlugin, - function::namespace::{GlobalNamespace, NamespaceBuilder}, - script_value::ScriptValue, - }, - callback_labels, + ConfigureScriptPlugin, IntoScriptPluginParams, callback_labels, commands::{AddStaticScript, DeleteScript}, event::ScriptCallbackEvent, handler::event_handler, script::{ScriptComponent, ScriptId}, }; +pub use bevy_mod_scripting_bindings::{ + CoreScriptGlobalsPlugin, + function::namespace::{GlobalNamespace, NamespaceBuilder}, + script_value::ScriptValue, +}; + pub use bevy_mod_scripting_asset::*; #[cfg(feature = "lua")] diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 91d900e102..4d03699903 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -1265,8 +1265,8 @@ impl Xtasks { }; 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") + let bms_bindings_path = Self::workspace_dir(&main_workspace_app_settings)? + .join("crates/bevy_mod_scripting_bindings") .to_path_buf(); Self::run_workspace_command( @@ -1275,8 +1275,8 @@ impl Xtasks { "Failed to run bms-codegen generate", vec![ "generate", - "--bms-core-path", - bms_core_path.to_str().unwrap(), + "--bms-bindings-path", + bms_bindings_path.to_str().unwrap(), "--output", output_dir.to_str().unwrap(), "--template-args", @@ -1296,8 +1296,8 @@ impl Xtasks { "Failed to run bms-codegen generate", vec![ "collect", - "--bms-core-path", - bms_core_path.to_str().unwrap(), + "--bms-bindings-path", + bms_bindings_path.to_str().unwrap(), "--output", output_dir.to_str().unwrap(), "--template-args", diff --git a/xtask/templates/bindings_crate.toml.tera b/xtask/templates/bindings_crate.toml.tera index b5d0dbe86a..c0fddc95b0 100644 --- a/xtask/templates/bindings_crate.toml.tera +++ b/xtask/templates/bindings_crate.toml.tera @@ -20,6 +20,7 @@ bevy_ecs = { workspace = true, features = ["std", "bevy_reflect"] } bevy_app = { workspace = true, features = ["std"] } {%- endif %} bevy_mod_scripting_core = { workspace = true } +bevy_mod_scripting_bindings = { workspace = true } bevy_mod_scripting_derive = { workspace = true } {{ crate_name }} = { version = "{{ generated_from_version }}", features = [ {%- for feature in features -%}