Skip to content

Commit b533c4f

Browse files
committed
clean up language implementors
1 parent defec17 commit b533c4f

File tree

2 files changed

+8
-26
lines changed
  • crates/languages
    • bevy_mod_scripting_lua/src
    • bevy_mod_scripting_rhai/src

2 files changed

+8
-26
lines changed

crates/languages/bevy_mod_scripting_lua/src/lib.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
//! Lua integration for the bevy_mod_scripting system.
22
use bevy::{
33
app::Plugin,
4-
asset::AssetPath,
54
ecs::{entity::Entity, world::World},
65
};
76
use bevy_mod_scripting_core::{
8-
asset::{AssetPathToLanguageMapper, Language},
7+
asset::Language,
98
bindings::{
109
function::namespace::Namespace, globals::AppScriptGlobalsRegistry,
1110
script_value::ScriptValue, ThreadWorldContainer, WorldContainer,
@@ -60,9 +59,6 @@ impl Default for LuaScriptingPlugin {
6059
load: lua_context_load,
6160
reload: lua_context_reload,
6261
},
63-
language_mapper: AssetPathToLanguageMapper {
64-
map: lua_language_mapper,
65-
},
6662
context_initializers: vec![
6763
|_script_id, context| {
6864
// set the world global
@@ -134,18 +130,13 @@ impl Default for LuaScriptingPlugin {
134130
.map_err(ScriptError::from_mlua_error)?;
135131
Ok(())
136132
}],
137-
additional_supported_extensions: &["lua"],
133+
additional_supported_extensions: &[],
134+
language: Language::Lua,
138135
},
139136
}
140137
}
141138
}
142-
#[profiling::function]
143-
fn lua_language_mapper(path: &AssetPath) -> Language {
144-
match path.path().extension().and_then(|ext| ext.to_str()) {
145-
Some("lua") => Language::Lua,
146-
_ => Language::Unknown,
147-
}
148-
}
139+
149140

150141
impl Plugin for LuaScriptingPlugin {
151142
fn build(&self, app: &mut bevy::prelude::App) {

crates/languages/bevy_mod_scripting_rhai/src/lib.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
33
use bevy::{
44
app::Plugin,
5-
asset::AssetPath,
65
ecs::{entity::Entity, world::World},
76
};
87
use bevy_mod_scripting_core::{
9-
asset::{AssetPathToLanguageMapper, Language},
8+
asset::Language,
109
bindings::{
1110
function::namespace::Namespace, globals::AppScriptGlobalsRegistry,
1211
script_value::ScriptValue, ThreadWorldContainer, WorldContainer,
@@ -84,9 +83,6 @@ impl Default for RhaiScriptingPlugin {
8483
load: rhai_context_load,
8584
reload: rhai_context_reload,
8685
},
87-
language_mapper: AssetPathToLanguageMapper {
88-
map: rhai_language_mapper,
89-
},
9086
context_initializers: vec![
9187
|_, context: &mut RhaiScriptContext| {
9288
context.scope.set_or_push(
@@ -159,19 +155,14 @@ impl Default for RhaiScriptingPlugin {
159155
context.scope.set_or_push("script_id", script.to_owned());
160156
Ok(())
161157
}],
162-
additional_supported_extensions: &["rhai"],
158+
// already supported by BMS core
159+
additional_supported_extensions: &[],
160+
language: Language::Rhai,
163161
},
164162
}
165163
}
166164
}
167165

168-
fn rhai_language_mapper(path: &AssetPath) -> Language {
169-
match path.path().extension().and_then(|ext| ext.to_str()) {
170-
Some("rhai") => Language::Rhai,
171-
_ => Language::Unknown,
172-
}
173-
}
174-
175166
impl Plugin for RhaiScriptingPlugin {
176167
fn build(&self, app: &mut bevy::prelude::App) {
177168
self.scripting_plugin.build(app);

0 commit comments

Comments
 (0)