Skip to content

Make generated wrappers publically accessible #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/bevy_api_gen/templates/item.tera
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ functions[
{% set close_item = "}" %}
{% endif %}

pub struct {{ item.ident -}} {{ open_item }}
struct {{ item.ident -}} {{ open_item }}
{% if not item.is_enum %}
{% for field in item.variants[0].fields %}
{% if field.reflection_strategy != "Filtered" %}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_api_gen/templates/mod.tera
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
{% filter prettyplease %}
{%- for crate in crates %}
pub(crate) mod {{ crate.name }};
pub mod {{ crate.name }};
{% endfor -%}

{% if args.self_is_bevy_script_api %}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_script_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ pub mod rhai;
pub mod common;

#[cfg(feature = "lua")]
pub(crate) mod core_providers;
pub mod core_providers;
// for now providers do not support any other lang so just remove this whole module if they are not needed
#[cfg(feature = "lua")]
pub(crate) mod providers;
pub mod providers;

pub mod script_ref;
pub mod sub_reflect;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_script_api/src/providers/bevy_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn index(&self) -> String {
}
"#]
)]
pub struct Name {}
struct Name {}
#[derive(Default)]
pub(crate) struct Globals;
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {
Expand Down
102 changes: 51 additions & 51 deletions crates/bevy_script_api/src/providers/bevy_ecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ use bevy_script_api::{
derive(clone),
remote = "bevy::ecs::entity::Entity",
functions[r#"

#[lua(
as_trait = "std::cmp::PartialEq",
kind = "MetaFunction",
composite = "eq",
metamethod = "Eq",
)]
fn eq(&self, #[proxy] other: &entity::Entity) -> bool;

"#,
r#"

#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::entity::Entity;

"#,
r#"
/// Creates a new entity ID with the specified `index` and a generation of 1.
/// # Note
/// Spawning a specific `entity` value is __rarely the right choice__. Most apps should favor
Expand Down Expand Up @@ -64,23 +81,6 @@ use bevy_script_api::{
#[lua(kind = "Method")]
fn generation(self) -> u32;

"#,
r#"

#[lua(
as_trait = "std::cmp::PartialEq",
kind = "MetaFunction",
composite = "eq",
metamethod = "Eq",
)]
fn eq(&self, #[proxy] other: &entity::Entity) -> bool;

"#,
r#"

#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::entity::Entity;

"#,
r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
Expand All @@ -89,18 +89,12 @@ fn index(&self) -> String {
}
"#]
)]
pub struct Entity {}
struct Entity {}
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
derive(clone),
remote = "bevy::ecs::component::ComponentId",
functions[r#"

#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
fn assert_receiver_is_total_eq(&self) -> ();

"#,
r#"
/// Creates a new [`ComponentId`].
/// The `index` is a unique value associated with each type of component in a given world.
/// Usually, this value is taken from a counter incremented for each type of component registered with the world.
Expand All @@ -118,8 +112,8 @@ pub struct Entity {}
"#,
r#"

#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::component::ComponentId;
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
fn assert_receiver_is_total_eq(&self) -> ();

"#,
r#"
Expand All @@ -132,6 +126,12 @@ pub struct Entity {}
)]
fn eq(&self, #[proxy] other: &component::ComponentId) -> bool;

"#,
r#"

#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::component::ComponentId;

"#,
r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
Expand All @@ -140,20 +140,21 @@ fn index(&self) -> String {
}
"#]
)]
pub struct ComponentId();
struct ComponentId();
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
derive(clone),
remote = "bevy::ecs::component::Tick",
functions[r#"

#[lua(
as_trait = "std::cmp::PartialEq",
kind = "MetaFunction",
composite = "eq",
metamethod = "Eq",
)]
fn eq(&self, #[proxy] other: &component::Tick) -> bool;
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::component::Tick;

"#,
r#"

#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
fn assert_receiver_is_total_eq(&self) -> ();

"#,
r#"
Expand Down Expand Up @@ -193,14 +194,13 @@ pub struct ComponentId();
"#,
r#"

#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::component::Tick;

"#,
r#"

#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
fn assert_receiver_is_total_eq(&self) -> ();
#[lua(
as_trait = "std::cmp::PartialEq",
kind = "MetaFunction",
composite = "eq",
metamethod = "Eq",
)]
fn eq(&self, #[proxy] other: &component::Tick) -> bool;

"#,
r#"
Expand All @@ -210,12 +210,18 @@ fn index(&self) -> String {
}
"#]
)]
pub struct Tick {}
struct Tick {}
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
derive(clone),
remote = "bevy::ecs::component::ComponentTicks",
functions[r#"

#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::component::ComponentTicks;

"#,
r#"
/// Returns `true` if the component or resource was added after the system last ran.

#[lua(kind = "Method")]
Expand Down Expand Up @@ -271,12 +277,6 @@ pub struct Tick {}
#[lua(kind = "MutatingMethod")]
fn set_changed(&mut self, #[proxy] change_tick: bevy::ecs::component::Tick) -> ();

"#,
r#"

#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::ecs::component::ComponentTicks;

"#,
r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
Expand All @@ -285,7 +285,7 @@ fn index(&self) -> String {
}
"#]
)]
pub struct ComponentTicks {}
struct ComponentTicks {}
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
derive(clone),
Expand All @@ -297,7 +297,7 @@ pub struct ComponentTicks {}

"#]
)]
pub struct EntityHash {}
struct EntityHash {}
#[derive(Default)]
pub(crate) struct Globals;
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {
Expand Down
18 changes: 9 additions & 9 deletions crates/bevy_script_api/src/providers/bevy_hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ fn index(&self) -> String {
}
"#]
)]
pub struct Children();
struct Children();
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
derive(),
remote = "bevy::hierarchy::prelude::Parent",
functions[r#"
/// Gets the [`Entity`] ID of the parent.

#[lua(kind = "Method", output(proxy))]
fn get(&self) -> bevy::ecs::entity::Entity;

"#,
r#"

#[lua(
as_trait = "std::cmp::PartialEq",
Expand All @@ -48,13 +55,6 @@ pub struct Children();
#[lua(as_trait = "std::cmp::Eq", kind = "Method")]
fn assert_receiver_is_total_eq(&self) -> ();

"#,
r#"
/// Gets the [`Entity`] ID of the parent.

#[lua(kind = "Method", output(proxy))]
fn get(&self) -> bevy::ecs::entity::Entity;

"#,
r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
Expand All @@ -63,7 +63,7 @@ fn index(&self) -> String {
}
"#]
)]
pub struct Parent();
struct Parent();
#[derive(Default)]
pub(crate) struct Globals;
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {
Expand Down
Loading