https://github.com/jakobhellermann/bevy_reflect_fns
Experimentation for reflecting methods using bevy_reflect, to be upstreamed later
https://github.com/jakobhellermann/bevy_reflect_fns
Last synced: about 1 month ago
JSON representation
Experimentation for reflecting methods using bevy_reflect, to be upstreamed later
- Host: GitHub
- URL: https://github.com/jakobhellermann/bevy_reflect_fns
- Owner: jakobhellermann
- License: apache-2.0
- Created: 2022-08-09T08:00:32.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-11-20T12:28:52.000Z (over 3 years ago)
- Last Synced: 2025-10-21T11:53:18.553Z (8 months ago)
- Language: Rust
- Size: 21.5 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# bevy_reflect_fns
Experimentation for trying out ways to support method calls using `bevy_reflect`.
This will be used together with `bevy_mod_js_scripting` to see if the design works out, and then hopefully upstreamed into `bevy_reflect`.
The core data this crates revolves around is this
```rust
pub enum PassMode {
Ref,
RefMut,
Owned,
}
pub enum ReflectArg<'a> {
Ref(&'a dyn Reflect),
RefMut(&'a mut dyn Reflect),
Owned(&'a dyn Reflect),
}
type RawReflectFunction =
fn(&mut [ReflectArg<'_>]) -> Result, ReflectFunctionError>;
#[derive(Clone)]
pub struct ReflectFunction {
pub fn_name: &'static str,
pub signature: Vec<(PassMode, TypeId)>,
pub f: RawReflectFunction,
}
pub struct ReflectMethods {
methods: HashMap<&'static str, ReflectFunction>,
}
```
together with a macro to simplify creating such `ReflectFunction`s: `reflect_function!(Vec3::lerp: (Vec3, Vec3, f32))`.