Skip to content

Commit

Permalink
app: rename AppPlugin to Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
cart committed Aug 8, 2020
1 parent bc6194a commit f963cd4
Show file tree
Hide file tree
Showing 27 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_app/src/app_builder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
app::{App, AppExit},
event::Events,
plugin::{load_plugin, AppPlugin},
plugin::{load_plugin, Plugin},
stage, startup_stage,
};
use bevy_ecs::{FromResources, IntoQuerySystem, Resources, System, World};
Expand Down Expand Up @@ -228,7 +228,7 @@ impl AppBuilder {

pub fn add_plugin<T>(&mut self, plugin: T) -> &mut Self
where
T: AppPlugin,
T: Plugin,
{
log::debug!("added plugin: {}", plugin.name());
plugin.build(self);
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod startup_stage;

pub use app::*;
pub use app_builder::*;
pub use bevy_derive::DynamicAppPlugin;
pub use bevy_derive::DynamicPlugin;
pub use event::*;
pub use plugin::*;
pub use schedule_runner::*;
Expand All @@ -20,7 +20,7 @@ pub mod prelude {
app::App,
app_builder::AppBuilder,
event::{EventReader, Events},
plugin::AppPlugin,
stage, DynamicAppPlugin,
plugin::Plugin,
stage, DynamicPlugin,
};
}
8 changes: 4 additions & 4 deletions crates/bevy_app/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ use crate::AppBuilder;
use libloading::{Library, Symbol};
use std::any::Any;

pub trait AppPlugin: Any + Send + Sync {
pub trait Plugin: Any + Send + Sync {
fn build(&self, app: &mut AppBuilder);
fn name(&self) -> &str {
std::any::type_name::<Self>()
}
}

pub type CreateAppPlugin = unsafe fn() -> *mut dyn AppPlugin;
pub type CreatePlugin = unsafe fn() -> *mut dyn Plugin;

pub fn load_plugin(path: &str) -> (Library, Box<dyn AppPlugin>) {
pub fn load_plugin(path: &str) -> (Library, Box<dyn Plugin>) {
let lib = Library::new(path).unwrap();

unsafe {
let func: Symbol<CreateAppPlugin> = lib.get(b"_create_plugin").unwrap();
let func: Symbol<CreatePlugin> = lib.get(b"_create_plugin").unwrap();
let plugin = Box::from_raw(func());
(lib, plugin)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_app/src/schedule_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{App, AppBuilder};
use crate::{
app::AppExit,
event::{EventReader, Events},
plugin::AppPlugin,
plugin::Plugin,
};
use std::{thread, time::Duration};

Expand Down Expand Up @@ -39,7 +39,7 @@ impl ScheduleRunnerPlugin {
}
}

impl AppPlugin for ScheduleRunnerPlugin {
impl Plugin for ScheduleRunnerPlugin {
fn build(&self, app: &mut AppBuilder) {
let run_mode = self.run_mode;
app.set_runner(move |mut app: App| {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ pub mod prelude {
pub use crate::{AddAsset, AssetEvent, AssetServer, Assets, Handle};
}

use bevy_app::{prelude::AppPlugin, AppBuilder};
use bevy_app::{prelude::Plugin, AppBuilder};
use bevy_ecs::IntoQuerySystem;
use bevy_type_registry::RegisterType;

#[derive(Default)]
pub struct AssetPlugin;

impl AppPlugin for AssetPlugin {
impl Plugin for AssetPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_stage_before(bevy_app::stage::PRE_UPDATE, stage::LOAD_ASSETS)
.add_stage_after(bevy_app::stage::POST_UPDATE, stage::ASSET_EVENTS)
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_audio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use bevy_ecs::IntoQuerySystem;
#[derive(Default)]
pub struct AudioPlugin;

impl AppPlugin for AudioPlugin {
impl Plugin for AudioPlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_resource::<AudioOutput>()
.add_asset::<AudioSource>()
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use bevy_type_registry::RegisterType;
#[derive(Default)]
pub struct CorePlugin;

impl AppPlugin for CorePlugin {
impl Plugin for CorePlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_resource::<Time>()
.init_resource::<EntityLabels>()
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_derive/src/app_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput};

pub fn derive_dynamic_app_plugin(input: TokenStream) -> TokenStream {
pub fn derive_dynamic_plugin(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
let struct_name = &ast.ident;

TokenStream::from(quote! {
#[no_mangle]
pub extern "C" fn _create_plugin() -> *mut bevy::app::AppPlugin {
pub extern "C" fn _create_plugin() -> *mut bevy::app::Plugin {
// TODO: without this the assembly does nothing. why is that the case?
print!("");
// make sure the constructor is the correct type.
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn derive_as_vertex_buffer_descriptor(input: TokenStream) -> TokenStream {
as_vertex_buffer_descriptor::derive_as_vertex_buffer_descriptor(input)
}

#[proc_macro_derive(DynamicAppPlugin)]
#[proc_macro_derive(DynamicPlugin)]
pub fn derive_app_plugin(input: TokenStream) -> TokenStream {
app_plugin::derive_dynamic_app_plugin(input)
app_plugin::derive_dynamic_plugin(input)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bevy_ecs::{IntoQuerySystem, Res, ResMut};
#[derive(Default)]
pub struct FrameTimeDiagnosticsPlugin;

impl AppPlugin for FrameTimeDiagnosticsPlugin {
impl Plugin for FrameTimeDiagnosticsPlugin {
fn build(&self, app: &mut bevy_app::AppBuilder) {
app.add_startup_system(Self::setup_system.system())
.add_system(Self::diagnostic_system.system());
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_diagnostic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct PrintDiagnostics {}
#[derive(Default)]
pub struct DiagnosticsPlugin;

impl AppPlugin for DiagnosticsPlugin {
impl Plugin for DiagnosticsPlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_resource::<Diagnostics>();
#[cfg(feature = "profiler")]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_diagnostic/src/print_diagnostics_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Default for PrintDiagnosticsPlugin {
}
}

impl AppPlugin for PrintDiagnosticsPlugin {
impl Plugin for PrintDiagnosticsPlugin {
fn build(&self, app: &mut bevy_app::AppBuilder) {
app.add_resource(PrintDiagnosticsState {
timer: Timer::new(self.wait_duration),
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gltf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bevy_render::mesh::Mesh;
#[derive(Default)]
pub struct GltfPlugin;

impl AppPlugin for GltfPlugin {
impl Plugin for GltfPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_asset_loader::<Mesh, GltfLoader>();
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_input/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use bevy_ecs::IntoQuerySystem;
#[derive(Default)]
pub struct InputPlugin;

impl AppPlugin for InputPlugin {
impl Plugin for InputPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_event::<KeyboardInput>()
.add_event::<MouseButtonInput>()
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use render_graph::ForwardPbrRenderGraphBuilder;
#[derive(Default)]
pub struct PbrPlugin;

impl AppPlugin for PbrPlugin {
impl Plugin for PbrPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_asset::<StandardMaterial>()
.register_component::<Light>()
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl Default for RenderPlugin {
}
}

impl AppPlugin for RenderPlugin {
impl Plugin for RenderPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_stage_after(bevy_asset::stage::ASSET_EVENTS, stage::RENDER_RESOURCE)
.add_stage_after(stage::RENDER_RESOURCE, stage::RENDER_GRAPH_SYSTEMS)
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_scene/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct ScenePlugin;

pub const SCENE_STAGE: &str = "scene";

impl AppPlugin for ScenePlugin {
impl Plugin for ScenePlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_asset::<Scene>()
.add_asset_loader::<Scene, SceneLoader>()
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct SpritePlugin;

pub const QUAD_HANDLE: Handle<Mesh> = Handle::from_u128(142404619811301375266013514540294236421);

impl AppPlugin for SpritePlugin {
impl Plugin for SpritePlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_asset::<ColorMaterial>()
.add_asset::<TextureAtlas>()
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_text/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use bevy_asset::AddAsset;
#[derive(Default)]
pub struct TextPlugin;

impl AppPlugin for TextPlugin {
impl Plugin for TextPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_asset::<Font>()
.add_asset::<FontAtlasSet>()
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(crate) fn transform_systems() -> Vec<Box<dyn System>> {
#[derive(Default)]
pub struct TransformPlugin;

impl AppPlugin for TransformPlugin {
impl Plugin for TransformPlugin {
fn build(&self, app: &mut AppBuilder) {
app.register_component::<Children>()
.register_component::<Parent>()
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_type_registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy_property::DynamicProperties;
#[derive(Default)]
pub struct TypeRegistryPlugin;

impl AppPlugin for TypeRegistryPlugin {
impl Plugin for TypeRegistryPlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_resource::<TypeRegistry>()
.register_property::<DynamicProperties>();
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub mod stage {
pub const UI: &'static str = "ui";
}

impl AppPlugin for UiPlugin {
impl Plugin for UiPlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_resource::<FlexSurface>()
.add_stage_before(bevy_app::stage::POST_UPDATE, stage::UI)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bevy_render::renderer::RenderResourceContext;
#[derive(Default)]
pub struct WgpuResourceDiagnosticsPlugin;

impl AppPlugin for WgpuResourceDiagnosticsPlugin {
impl Plugin for WgpuResourceDiagnosticsPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_startup_system(Self::setup_system.system())
.add_system(Self::diagnostic_system.system());
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use renderer::WgpuRenderResourceContext;
#[derive(Default)]
pub struct WgpuPlugin;

impl AppPlugin for WgpuPlugin {
impl Plugin for WgpuPlugin {
fn build(&self, app: &mut AppBuilder) {
let render_system = wgpu_render_system(app.resources_mut());
app.add_system_to_stage(
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_window/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Default for WindowPlugin {
}
}

impl AppPlugin for WindowPlugin {
impl Plugin for WindowPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_event::<WindowResized>()
.add_event::<CreateWindow>()
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use winit::{
#[derive(Default)]
pub struct WinitPlugin;

impl AppPlugin for WinitPlugin {
impl Plugin for WinitPlugin {
fn build(&self, app: &mut AppBuilder) {
app
// TODO: It would be great to provide a raw winit WindowEvent here, but the lifetime on it is
Expand Down
2 changes: 1 addition & 1 deletion examples/app/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct PrintMessagePlugin {
message: String,
}

impl AppPlugin for PrintMessagePlugin {
impl Plugin for PrintMessagePlugin {
// this is where we set up our plugin
fn build(&self, app: &mut AppBuilder) {
let state = PrintMessageState {
Expand Down

0 comments on commit f963cd4

Please sign in to comment.