Skip to content
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

Removing derivative from dependencies #232

Merged
merged 1 commit into from
Feb 8, 2021
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
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ legion_codegen = { path = "codegen", version = "0.3", optional = true }
smallvec = "1.4"
itertools = "0.9"
downcast-rs = "1.2"
derivative = "2.1"
paste = "1.0.0"
parking_lot = "0.11"
bit-set = "0.5"
Expand Down Expand Up @@ -58,4 +57,4 @@ harness = false

[[bench]]
name = "insertion"
harness = false
harness = false
10 changes: 7 additions & 3 deletions src/internals/query/view/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ use crate::internals::{
},
subworld::ComponentAccess,
};
use derivative::Derivative;
use std::{any::TypeId, marker::PhantomData, slice::Iter};

/// Reads a single entity data component type from a chunk.
#[derive(Derivative, Debug, Copy, Clone)]
#[derivative(Default(bound = ""))]
#[derive(Debug, Copy, Clone)]
pub struct Read<T>(PhantomData<*const T>);

impl<T> Default for Read<T> {
fn default() -> Self {
Self(PhantomData)
}
}

unsafe impl<T> Send for Read<T> {}
unsafe impl<T: Sync> Sync for Read<T> {}
unsafe impl<T> ReadOnly for Read<T> {}
Expand Down
10 changes: 7 additions & 3 deletions src/internals/query/view/try_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ use crate::internals::{
},
subworld::ComponentAccess,
};
use derivative::Derivative;
use std::{any::TypeId, marker::PhantomData};

/// Reads a single entity data component type from a chunk.
#[derive(Derivative, Debug, Copy, Clone)]
#[derivative(Default(bound = ""))]
#[derive(Debug, Copy, Clone)]
pub struct TryRead<T>(PhantomData<*const T>);

impl<T> Default for TryRead<T> {
fn default() -> Self {
Self(PhantomData)
}
}

unsafe impl<T> Send for TryRead<T> {}
unsafe impl<T: Sync> Sync for TryRead<T> {}
unsafe impl<T> ReadOnly for TryRead<T> {}
Expand Down
10 changes: 7 additions & 3 deletions src/internals/query/view/try_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ use crate::internals::{
},
subworld::ComponentAccess,
};
use derivative::Derivative;
use std::{any::TypeId, marker::PhantomData};

/// Writes a single entity data component type from a chunk.
#[derive(Derivative, Debug, Copy, Clone)]
#[derivative(Default(bound = ""))]
#[derive(Debug, Copy, Clone)]
pub struct TryWrite<T>(PhantomData<*const T>);

impl<T> Default for TryWrite<T> {
fn default() -> Self {
Self(PhantomData)
}
}

unsafe impl<T: Send> Send for TryWrite<T> {}
unsafe impl<T> Sync for TryWrite<T> {}

Expand Down
10 changes: 7 additions & 3 deletions src/internals/query/view/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ use crate::internals::{
},
subworld::ComponentAccess,
};
use derivative::Derivative;
use std::{any::TypeId, marker::PhantomData, slice::Iter};

/// Writes a single mutable entity data component type from a chunk.
#[derive(Derivative, Debug, Copy, Clone)]
#[derivative(Default(bound = ""))]
#[derive(Debug, Copy, Clone)]
pub struct Write<T>(PhantomData<*const T>);

impl<T> Default for Write<T> {
fn default() -> Self {
Self(PhantomData)
}
}

unsafe impl<T: Send> Send for Write<T> {}
unsafe impl<T> Sync for Write<T> {}

Expand Down
14 changes: 11 additions & 3 deletions src/internals/storage/slicevec.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
//! A vector of slices.

use derivative::Derivative;
use std::iter::{FusedIterator, IntoIterator};

/// A vector of slices.
///
/// Each slice is stored inline so as to be efficiently iterated through linearly.
#[derive(Derivative, Debug)]
#[derivative(Default(bound = ""))]
#[derive(Debug)]
pub struct SliceVec<T> {
data: Vec<T>,
counts: Vec<usize>,
indices: Vec<usize>,
}

impl<T> Default for SliceVec<T> {
fn default() -> Self {
Self {
data: Vec::new(),
counts: Vec::new(),
indices: Vec::new(),
}
}
}

impl<T> SliceVec<T> {
/// Pushes a new slice onto the end of the vector.
pub fn push<I: IntoIterator<Item = T>>(&mut self, items: I) {
Expand Down
61 changes: 45 additions & 16 deletions src/internals/systems/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ use crate::{
},
world::Allocate,
};
use derivative::Derivative;
use smallvec::SmallVec;
use std::ops::Range;
use std::{
any::type_name,
collections::VecDeque,
fmt,
iter::{Fuse, FusedIterator},
marker::PhantomData,
ops::Range,
sync::Arc,
};

Expand All @@ -36,14 +37,21 @@ pub trait WorldWritable: Send + Sync {
fn write(self: Arc<Self>, world: &mut World, cmd: &CommandBuffer);
}

#[derive(Derivative)]
#[derivative(Debug(bound = ""))]
struct InsertBufferedCommand<T> {
#[derivative(Debug = "ignore")]
components: T,
entities: Range<usize>,
}

impl<T> fmt::Debug for InsertBufferedCommand<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!(
"InsertBufferedCommand<{}>({:?})",
type_name::<T>(),
self.entities
))
}
}

impl<T> WorldWritable for InsertBufferedCommand<T>
where
T: ComponentSource + Send + Sync,
Expand Down Expand Up @@ -125,13 +133,16 @@ impl<'a, T, A: Iterator<Item = T> + FusedIterator, B: Iterator<Item = T>> Iterat
}
}

#[derive(Derivative)]
#[derivative(Debug(bound = ""))]
struct InsertCommand<T> {
#[derivative(Debug = "ignore")]
components: T,
}

impl<T> fmt::Debug for InsertCommand<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!("InsertCommand<{}>", type_name::<T>()))
}
}

impl<T> WorldWritable for InsertCommand<T>
where
T: IntoComponentSource + Send + Sync,
Expand All @@ -142,25 +153,35 @@ where
}
}

#[derive(Derivative)]
#[derivative(Debug(bound = ""))]
struct DeleteEntityCommand(Entity);

impl fmt::Debug for DeleteEntityCommand {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!("DeleteEntityCommand({:?})", self.0))
}
}

impl WorldWritable for DeleteEntityCommand {
fn write(self: Arc<Self>, world: &mut World, _: &CommandBuffer) {
world.remove(self.0);
}
}

#[derive(Derivative)]
#[derivative(Debug(bound = ""))]
struct AddComponentCommand<C> {
#[derivative(Debug = "ignore")]
entity: Entity,
#[derivative(Debug = "ignore")]
component: C,
}

impl<T> fmt::Debug for AddComponentCommand<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!(
"AddComponentCommand<{}>({:?})",
type_name::<T>(),
self.entity
))
}
}

impl<C> WorldWritable for AddComponentCommand<C>
where
C: Component,
Expand All @@ -174,13 +195,21 @@ where
}
}

#[derive(Derivative)]
#[derivative(Debug(bound = ""))]
struct RemoveComponentCommand<C> {
entity: Entity,
_marker: PhantomData<C>,
}

impl<T> fmt::Debug for RemoveComponentCommand<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!(
"RemoveComponentCommand<{}>({:?})",
type_name::<T>(),
self.entity
))
}
}

impl<C> WorldWritable for RemoveComponentCommand<C>
where
C: Component,
Expand Down