Skip to content

Conversation

makspll
Copy link
Owner

@makspll makspll commented Sep 6, 2025

Summary

  • Extracts two larger crates from bms core
  • Removes DisplayWithWorld in favour of DisplayWithTypeInfo and DebugWithTypeInfo
  • Creates a new derive macro for DebugWithTypeInfo which also generates a conventional Debug impl which will use type info if available
  • Type info for the purposes of printing is now retrieved via the thread local world guard
  • In order to print a type which implements one of these traits with type info simply use the WithTypeInfo::new(my_type) wrapper in conventional format strings
  • InteropError is now completely separate from teh core crate and implements both display and debug with type info
  • some error variants have been removed
  • Improved and less opinionated reflect type printing
  • Meta functions display_ref and display_value removed in favour of display and debug
    • display_value effectively became display, and display_ref was turned into debug

Migration Guide

  • Update imports to new crates (bevy_mod_scripting_bindings, bevy_mod_scripting_display, bevy_mod_scripting_asset) where appropriate, if you rely on the workspace these will be re-exported under bindings, display and asset respectively
  • Replace DisplayWithWorld usage with DisplayWithTypeInfo / DebugWithTypeInfo and use WithTypeInfo::new(value) in format strings. Ensure that the WorldGuard is in scope when printing using these utilities, or you might see raw type id's

Copy link

semanticdiff-com bot commented Sep 6, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  assets/tests/get_type_by_name/registered_resource_returns_correct_type.lua  99% smaller
  assets/tests/get_type_by_name/registered_component_returns_correct_type.lua  99% smaller
  assets/tests/functions/contains_reflect_reference_functions.lua  99% smaller
  crates/bindings/bevy_scene_bms_bindings/src/lib.rs  92% smaller
  codegen/src/context.rs  92% smaller
  crates/bevy_mod_scripting_bindings/src/function/arg_meta.rs  89% smaller
  crates/bindings/bevy_math_bms_bindings/src/lib.rs  84% smaller
  crates/bindings/bevy_time_bms_bindings/src/lib.rs  83% smaller
  crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs  83% smaller
  crates/bevy_mod_scripting_bindings/src/function/into.rs  81% smaller
  crates/bevy_mod_scripting_derive/src/derive/into_script.rs  79% smaller
  crates/bindings/bevy_text_bms_bindings/src/lib.rs  77% smaller
  crates/bevy_mod_scripting_derive/src/derive/mod.rs  76% smaller
  crates/testing_crates/script_integration_test_harness/src/test_functions.rs  76% smaller
  assets/tests/construct/construct_tuple_struct.lua  75% smaller
  crates/languages/bevy_mod_scripting_lua/src/bindings/script_value.rs  73% smaller
  crates/bevy_mod_scripting_core/src/context.rs  72% smaller
  crates/testing_crates/script_integration_test_harness/src/lib.rs  71% smaller
  crates/bindings/bevy_pbr_bms_bindings/src/lib.rs  70% smaller
  crates/bindings/bevy_gltf_bms_bindings/src/lib.rs  69% smaller
  crates/bevy_mod_scripting_bindings/src/function/from.rs  68% smaller
  crates/languages/bevy_mod_scripting_rhai/src/bindings/reference.rs  65% smaller
  crates/languages/bevy_mod_scripting_rhai/src/bindings/script_value.rs  65% smaller
  examples/docgen.rs  63% smaller
  crates/bevy_mod_scripting_bindings/src/query.rs  63% smaller
  crates/bevy_mod_scripting_bindings/src/function/from_ref.rs  62% smaller
  crates/bevy_mod_scripting_bindings/src/docgen/typed_through.rs  60% smaller
  crates/bindings/bevy_sprite_bms_bindings/src/lib.rs  58% smaller
  crates/bevy_mod_scripting_bindings/src/globals/core.rs  57% smaller
  crates/bevy_mod_scripting_core/src/commands.rs  55% smaller
  crates/bevy_mod_scripting_bindings/src/function/mod.rs  55% smaller
  crates/bindings/bevy_ecs_bms_bindings/src/lib.rs  54% smaller
  crates/bevy_mod_scripting_core/src/handler.rs  53% smaller
  crates/bindings/bevy_render_bms_bindings/src/lib.rs  50% smaller
  crates/bevy_mod_scripting_bindings/src/function/magic_functions.rs  40% smaller
  crates/bevy_mod_scripting_bindings/src/function/into_ref.rs  32% smaller
  examples/game_of_life.rs  32% smaller
  crates/languages/bevy_mod_scripting_rhai/src/lib.rs  31% smaller
  crates/bevy_mod_scripting_core/src/lib.rs  29% smaller
  crates/bevy_mod_scripting_core/src/extractors.rs  28% smaller
  crates/bevy_mod_scripting_functions/src/core.rs  28% smaller
  codegen/src/bin/main.rs  25% smaller
  crates/ladfile_builder/src/lib.rs  24% smaller
  src/prelude.rs  24% smaller
  crates/bevy_mod_scripting_bindings/src/reflection_extensions.rs  23% smaller
  crates/testing_crates/script_integration_test_harness/src/scenario.rs  23% smaller
  crates/languages/bevy_mod_scripting_lua/src/lib.rs  22% smaller
  assets/tests/remove_resource/no_resource_data_errors.lua  20% smaller
  crates/bevy_mod_scripting_bindings/src/globals/mod.rs  19% smaller
  crates/bevy_mod_scripting_bindings/src/docgen/info.rs  18% smaller
  crates/bevy_mod_scripting_core/src/script_system.rs  17% smaller
  crates/bevy_mod_scripting_bindings/src/function/script_function.rs  16% smaller
  src/lib.rs  15% smaller
  crates/bevy_mod_scripting_bindings/src/allocator.rs  12% smaller
  crates/bevy_mod_scripting_bindings/src/reference.rs  12% smaller
  crates/bevy_mod_scripting_bindings/src/access_map.rs  11% smaller
  crates/bevy_mod_scripting_bindings/src/function/type_dependencies.rs  8% smaller
  crates/bindings/bevy_picking_bms_bindings/src/lib.rs  7% smaller
  crates/bevy_mod_scripting_bindings/src/function/namespace.rs  6% smaller
  crates/bevy_mod_scripting_core/src/error.rs  1% smaller
  crates/bevy_mod_scripting_bindings/src/script_value.rs  1% smaller
  .github/instructions/documentation.instructions.md Unsupported file format
  .github/instructions/general.instructions.md Unsupported file format
  .github/instructions/rhai.instructions.md Unsupported file format
  Cargo.toml Unsupported file format
  assets/tests/add_system/added_systems_run_in_parallel.lua  0% smaller
  assets/tests/add_system/added_systems_run_in_parallel.rhai Unsupported file format
  assets/tests/display/print_value_by_default.lua  0% smaller
  assets/tests/functions/contains_reflect_reference_functions.rhai Unsupported file format
  assets/tests/remove_resource/no_resource_data_errors.rhai Unsupported file format
  benches/benchmarks.rs  0% smaller
  codegen/Cargo.bootstrap.toml Unsupported file format
  codegen/src/args.rs  0% smaller
  codegen/src/modifying_file_loader.rs  0% smaller
  codegen/src/template.rs  0% smaller
  codegen/templates/footer.tera Unsupported file format
  codegen/templates/header.tera Unsupported file format
  codegen/templates/macros.tera Unsupported file format
  crates/bevy_mod_scripting_bindings/Cargo.toml Unsupported file format
  crates/bevy_mod_scripting_bindings/src/docgen/mod.rs  0% smaller
  crates/bevy_mod_scripting_bindings/src/error.rs  0% smaller
  crates/bevy_mod_scripting_bindings/src/lib.rs  0% smaller
  crates/bevy_mod_scripting_bindings/src/schedule.rs  0% smaller
  crates/bevy_mod_scripting_bindings/src/script_component.rs  0% smaller
  crates/bevy_mod_scripting_bindings/src/type_data.rs  0% smaller
  crates/bevy_mod_scripting_bindings/src/world.rs  0% smaller
  crates/bevy_mod_scripting_core/Cargo.toml Unsupported file format
  crates/bevy_mod_scripting_core/src/bindings/mod.rs  0% smaller
  crates/bevy_mod_scripting_core/src/bindings/pretty_print.rs  0% smaller
  crates/bevy_mod_scripting_core/src/docgen/mod.rs  0% smaller
  crates/bevy_mod_scripting_core/src/event.rs  0% smaller
  crates/bevy_mod_scripting_core/src/private/mod.rs  0% smaller
  crates/bevy_mod_scripting_core/src/script/context_key.rs  0% smaller
  crates/bevy_mod_scripting_core/src/script/script_context.rs  0% smaller
  crates/bevy_mod_scripting_derive/src/derive/debug_with_type_info.rs  0% smaller
  crates/bevy_mod_scripting_derive/src/derive/get_type_dependencies.rs  0% smaller
  crates/bevy_mod_scripting_derive/src/derive/script_bindings.rs  0% smaller
  crates/bevy_mod_scripting_derive/src/derive/script_globals.rs  0% smaller
  crates/bevy_mod_scripting_derive/src/derive/typed_through.rs  0% smaller
  crates/bevy_mod_scripting_derive/src/lib.rs  0% smaller
  crates/bevy_mod_scripting_display/Cargo.toml Unsupported file format
  crates/bevy_mod_scripting_display/src/impls/bevy_ecs.rs  0% smaller
  crates/bevy_mod_scripting_display/src/impls/bevy_platform.rs  0% smaller
  crates/bevy_mod_scripting_display/src/impls/bevy_reflect.rs  0% smaller
  crates/bevy_mod_scripting_display/src/impls/mod.rs  0% smaller
  crates/bevy_mod_scripting_display/src/impls/parking_lock.rs  0% smaller
  crates/bevy_mod_scripting_display/src/impls/std.rs  0% smaller
  crates/bevy_mod_scripting_display/src/lib.rs  0% smaller
  crates/bevy_mod_scripting_display/src/printer/mod.rs  0% smaller
  crates/bevy_mod_scripting_functions/Cargo.toml Unsupported file format
  crates/bindings/bevy_a11y_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_a11y_bms_bindings/src/lib.rs  0% smaller
  crates/bindings/bevy_animation_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_animation_bms_bindings/src/lib.rs  0% smaller
  crates/bindings/bevy_asset_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_asset_bms_bindings/src/lib.rs  0% smaller
  crates/bindings/bevy_color_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_color_bms_bindings/src/lib.rs  0% smaller
  crates/bindings/bevy_core_pipeline_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_core_pipeline_bms_bindings/src/lib.rs  0% smaller
  crates/bindings/bevy_ecs_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_gizmos_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_gizmos_bms_bindings/src/lib.rs  0% smaller
  crates/bindings/bevy_gltf_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_image_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_image_bms_bindings/src/lib.rs  0% smaller
  crates/bindings/bevy_input_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_input_bms_bindings/src/lib.rs  0% smaller
  crates/bindings/bevy_input_focus_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_input_focus_bms_bindings/src/lib.rs  0% smaller
  crates/bindings/bevy_math_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_mesh_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_mesh_bms_bindings/src/lib.rs  0% smaller
  crates/bindings/bevy_pbr_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_picking_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_reflect_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_reflect_bms_bindings/src/lib.rs Unsupported file format
  crates/bindings/bevy_render_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_scene_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_sprite_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_text_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_time_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_transform_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_transform_bms_bindings/src/lib.rs  0% smaller
  crates/ladfile_builder/Cargo.toml Unsupported file format
  crates/ladfile_builder/src/plugin.rs  0% smaller
  crates/languages/bevy_mod_scripting_lua/Cargo.toml Unsupported file format
  crates/languages/bevy_mod_scripting_rhai/Cargo.toml Unsupported file format
  crates/testing_crates/script_integration_test_harness/Cargo.toml Unsupported file format
  crates/testing_crates/script_integration_test_harness/src/parse.rs  0% smaller
  crates/testing_crates/test_utils/src/test_plugin.rs  0% smaller
  docs/src/Development/AddingLanguages/necessary-features.md Unsupported file format
  docs/src/Summary/controlling-script-bindings.md Unsupported file format
  xtask/src/main.rs  0% smaller
  xtask/templates/bindings_crate.toml.tera Unsupported file format

@makspll makspll force-pushed the refactor/extract-bindings-crate branch from 0f29b53 to d4621ee Compare September 6, 2025 16:40
@makspll makspll enabled auto-merge (squash) September 6, 2025 18:47
Copy link
Contributor

github-actions bot commented Sep 6, 2025

🐰 Bencher Report

Branchrefactor/extract-bindings-crate
Testbedlinux-gha
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Upper Boundary
nanoseconds (ns)
(Limit %)
component/access Lua📈 view plot
🚷 view threshold
3,578.00 ns
(-10.38%)Baseline: 3,992.57 ns
4,431.35 ns
(80.74%)
component/access Rhai📈 view plot
🚷 view threshold
5,315.50 ns
(-9.29%)Baseline: 5,859.73 ns
6,481.33 ns
(82.01%)
component/get Lua📈 view plot
🚷 view threshold
2,201.20 ns
(-8.93%)Baseline: 2,417.00 ns
2,714.16 ns
(81.10%)
component/get Rhai📈 view plot
🚷 view threshold
4,085.50 ns
(-7.15%)Baseline: 4,399.91 ns
4,913.42 ns
(83.15%)
conversions/Mut::from📈 view plot
🚷 view threshold
79.04 ns
(-8.21%)Baseline: 86.11 ns
94.29 ns
(83.83%)
conversions/Ref::from📈 view plot
🚷 view threshold
76.85 ns
(-8.37%)Baseline: 83.87 ns
91.30 ns
(84.18%)
conversions/ScriptValue::List📈 view plot
🚷 view threshold
342.45 ns
(+17.50%)Baseline: 291.45 ns
355.48 ns
(96.33%)
conversions/ScriptValue::Map📈 view plot
🚷 view threshold
961.19 ns
(-14.46%)Baseline: 1,123.69 ns
1,535.91 ns
(62.58%)
conversions/ScriptValue::Reference::from_into📈 view plot
🚷 view threshold
25.39 ns
(+1.33%)Baseline: 25.05 ns
29.76 ns
(85.31%)
conversions/Val::from_into📈 view plot
🚷 view threshold
297.03 ns
(-0.90%)Baseline: 299.73 ns
341.95 ns
(86.86%)
function/call 4 args Lua📈 view plot
🚷 view threshold
1,645.90 ns
(-12.05%)Baseline: 1,871.40 ns
2,123.68 ns
(77.50%)
function/call 4 args Rhai📈 view plot
🚷 view threshold
1,307.80 ns
(-14.18%)Baseline: 1,523.89 ns
1,775.40 ns
(73.66%)
function/call Lua📈 view plot
🚷 view threshold
226.59 ns
(-6.29%)Baseline: 241.79 ns
267.44 ns
(84.73%)
function/call Rhai📈 view plot
🚷 view threshold
455.36 ns
(-3.42%)Baseline: 471.46 ns
525.98 ns
(86.57%)
loading/empty Lua📈 view plot
🚷 view threshold
50,951.00 ns
(-19.78%)Baseline: 63,513.40 ns
75,728.56 ns
(67.28%)
loading/empty Rhai📈 view plot
🚷 view threshold
303,510.00 ns
(-19.83%)Baseline: 378,579.00 ns
474,870.88 ns
(63.91%)
math/vec mat ops Lua📈 view plot
🚷 view threshold
6,579.80 ns
(-16.03%)Baseline: 7,835.66 ns
9,548.47 ns
(68.91%)
math/vec mat ops Rhai📈 view plot
🚷 view threshold
5,739.70 ns
(-13.10%)Baseline: 6,604.62 ns
7,533.35 ns
(76.19%)
query/10 entities Lua📈 view plot
🚷 view threshold
17,602.00 ns
(-14.49%)Baseline: 20,585.90 ns
23,667.36 ns
(74.37%)
query/10 entities Rhai📈 view plot
🚷 view threshold
17,579.00 ns
(-14.00%)Baseline: 20,440.70 ns
23,315.37 ns
(75.40%)
query/100 entities Lua📈 view plot
🚷 view threshold
38,241.00 ns
(-9.72%)Baseline: 42,358.70 ns
46,499.09 ns
(82.24%)
query/100 entities Rhai📈 view plot
🚷 view threshold
30,824.00 ns
(-7.32%)Baseline: 33,258.90 ns
36,812.69 ns
(83.73%)
query/1000 entities Lua📈 view plot
🚷 view threshold
242,920.00 ns
(-11.71%)Baseline: 275,152.00 ns
311,520.61 ns
(77.98%)
query/1000 entities Rhai📈 view plot
🚷 view threshold
186,690.00 ns
(+9.29%)Baseline: 170,822.00 ns
189,536.20 ns
(98.50%)
reflection/10 Lua📈 view plot
🚷 view threshold
5,548.20 ns
(-10.67%)Baseline: 6,211.23 ns
6,933.63 ns
(80.02%)
reflection/10 Rhai📈 view plot
🚷 view threshold
14,610.00 ns
(-7.42%)Baseline: 15,781.20 ns
16,955.72 ns
(86.17%)
reflection/100 Lua📈 view plot
🚷 view threshold
47,847.00 ns
(-7.27%)Baseline: 51,596.10 ns
57,114.16 ns
(83.77%)
reflection/100 Rhai📈 view plot
🚷 view threshold
740,370.00 ns
(-3.69%)Baseline: 768,766.00 ns
836,545.99 ns
(88.50%)
resource/access Lua📈 view plot
🚷 view threshold
3,143.10 ns
(-11.88%)Baseline: 3,566.82 ns
4,017.59 ns
(78.23%)
resource/access Rhai📈 view plot
🚷 view threshold
4,915.10 ns
(-7.76%)Baseline: 5,328.79 ns
5,832.22 ns
(84.27%)
resource/get Lua📈 view plot
🚷 view threshold
1,803.80 ns
(-12.13%)Baseline: 2,052.73 ns
2,354.08 ns
(76.62%)
resource/get Rhai📈 view plot
🚷 view threshold
3,664.00 ns
(-6.44%)Baseline: 3,916.37 ns
4,360.67 ns
(84.02%)
🐰 View full continuous benchmarking report in Bencher

@makspll makspll merged commit f60f33b into main Sep 6, 2025
22 checks passed
@makspll makspll deleted the refactor/extract-bindings-crate branch September 6, 2025 20:01
@github-actions github-actions bot mentioned this pull request Sep 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant