-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace trait based systems by function based ones
replace borrowing types, from reference to views impl Iterator for all Shiperator make the proc macro opt-in remove prelude and internal modules modify RunWorkload error add Run error add system and try_system macros fix #75 fix #30 fix #17
- Loading branch information
Showing
120 changed files
with
2,234 additions
and
2,078 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
//use super::FakeBorrow; | ||
use crate::error; | ||
use crate::storage::AllStorages; | ||
use crate::view::{EntitiesView, EntitiesViewMut, UniqueView, UniqueViewMut, View, ViewMut}; | ||
#[cfg(feature = "non_send")] | ||
use crate::NonSend; | ||
#[cfg(all(feature = "non_send", feature = "non_sync"))] | ||
use crate::NonSendSync; | ||
#[cfg(feature = "non_sync")] | ||
use crate::NonSync; | ||
use core::convert::TryInto; | ||
|
||
pub trait AllStoragesBorrow<'a> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> | ||
where | ||
Self: Sized; | ||
} | ||
|
||
impl<'a> AllStoragesBorrow<'a> for () { | ||
fn try_borrow(_: &'a AllStorages) -> Result<Self, error::GetStorage> | ||
where | ||
Self: Sized, | ||
{ | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl<'a> AllStoragesBorrow<'a> for EntitiesView<'a> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
all_storages.try_into() | ||
} | ||
} | ||
|
||
impl<'a> AllStoragesBorrow<'a> for EntitiesViewMut<'a> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
all_storages.try_into() | ||
} | ||
} | ||
|
||
impl<'a, T: 'static + Send + Sync> AllStoragesBorrow<'a> for View<'a, T> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
all_storages.try_into() | ||
} | ||
} | ||
|
||
impl<'a, T: 'static + Send + Sync> AllStoragesBorrow<'a> for ViewMut<'a, T> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
all_storages.try_into() | ||
} | ||
} | ||
|
||
impl<'a, T: 'static + Send + Sync> AllStoragesBorrow<'a> for UniqueView<'a, T> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
all_storages.try_into() | ||
} | ||
} | ||
|
||
impl<'a, T: 'static + Send + Sync> AllStoragesBorrow<'a> for UniqueViewMut<'a, T> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
all_storages.try_into() | ||
} | ||
} | ||
|
||
#[cfg(feature = "non_send")] | ||
impl<'a, T: 'static + Sync> AllStoragesBorrow<'a> for NonSend<View<'a, T>> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
View::try_storage_from_non_send(all_storages).map(|view| NonSend(view)) | ||
} | ||
} | ||
|
||
#[cfg(feature = "non_send")] | ||
impl<'a, T: 'static + Sync> AllStoragesBorrow<'a> for NonSend<ViewMut<'a, T>> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
ViewMut::try_storage_from_non_send(all_storages).map(|view| NonSend(view)) | ||
} | ||
} | ||
|
||
#[cfg(feature = "non_sync")] | ||
impl<'a, T: 'static + Send> AllStoragesBorrow<'a> for NonSync<View<'a, T>> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
View::try_storage_from_non_sync(all_storages).map(|view| NonSync(view)) | ||
} | ||
} | ||
|
||
#[cfg(feature = "non_sync")] | ||
impl<'a, T: 'static + Send> AllStoragesBorrow<'a> for NonSync<ViewMut<'a, T>> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
ViewMut::try_storage_from_non_sync(all_storages).map(|view| NonSync(view)) | ||
} | ||
} | ||
|
||
#[cfg(all(feature = "non_send", feature = "non_sync"))] | ||
impl<'a, T: 'static + Sync> AllStoragesBorrow<'a> for NonSendSync<View<'a, T>> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
View::try_storage_from_non_send_sync(all_storages).map(|view| NonSendSync(view)) | ||
} | ||
} | ||
|
||
#[cfg(all(feature = "non_send", feature = "non_sync"))] | ||
impl<'a, T: 'static + Sync> AllStoragesBorrow<'a> for NonSendSync<ViewMut<'a, T>> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
ViewMut::try_storage_from_non_send_sync(all_storages).map(|view| NonSendSync(view)) | ||
} | ||
} | ||
|
||
#[cfg(feature = "non_send")] | ||
impl<'a, T: 'static + Sync> AllStoragesBorrow<'a> for NonSend<UniqueView<'a, T>> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
UniqueView::try_storage_from_non_send(all_storages).map(|view| NonSend(view)) | ||
} | ||
} | ||
|
||
#[cfg(feature = "non_send")] | ||
impl<'a, T: 'static + Sync> AllStoragesBorrow<'a> for NonSend<UniqueViewMut<'a, T>> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
UniqueViewMut::try_storage_from_non_send(all_storages).map(|view| NonSend(view)) | ||
} | ||
} | ||
|
||
#[cfg(feature = "non_sync")] | ||
impl<'a, T: 'static + Send> AllStoragesBorrow<'a> for NonSync<UniqueView<'a, T>> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
UniqueView::try_storage_from_non_sync(all_storages).map(|view| NonSync(view)) | ||
} | ||
} | ||
|
||
#[cfg(feature = "non_sync")] | ||
impl<'a, T: 'static + Send> AllStoragesBorrow<'a> for NonSync<UniqueViewMut<'a, T>> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
UniqueViewMut::try_storage_from_non_sync(all_storages).map(|view| NonSync(view)) | ||
} | ||
} | ||
|
||
#[cfg(all(feature = "non_send", feature = "non_sync"))] | ||
impl<'a, T: 'static + Sync> AllStoragesBorrow<'a> for NonSendSync<UniqueView<'a, T>> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
UniqueView::try_storage_from_non_send_sync(all_storages).map(|view| NonSendSync(view)) | ||
} | ||
} | ||
|
||
#[cfg(all(feature = "non_send", feature = "non_sync"))] | ||
impl<'a, T: 'static + Sync> AllStoragesBorrow<'a> for NonSendSync<UniqueViewMut<'a, T>> { | ||
fn try_borrow(all_storages: &'a AllStorages) -> Result<Self, error::GetStorage> { | ||
UniqueViewMut::try_storage_from_non_send_sync(all_storages).map(|view| NonSendSync(view)) | ||
} | ||
} | ||
|
||
macro_rules! impl_system_data { | ||
($(($type: ident, $index: tt))+) => { | ||
impl<'a, $($type: AllStoragesBorrow<'a>),+> AllStoragesBorrow<'a> for ($($type,)+) { | ||
fn try_borrow( | ||
all_storages: &'a AllStorages, | ||
) -> Result<Self, error::GetStorage> { | ||
Ok(($( | ||
<$type as AllStoragesBorrow>::try_borrow(all_storages)?, | ||
)+)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
macro_rules! system_data { | ||
($(($type: ident, $index: tt))*;($type1: ident, $index1: tt) $(($queue_type: ident, $queue_index: tt))*) => { | ||
impl_system_data![$(($type, $index))*]; | ||
system_data![$(($type, $index))* ($type1, $index1); $(($queue_type, $queue_index))*]; | ||
}; | ||
($(($type: ident, $index: tt))*;) => { | ||
impl_system_data![$(($type, $index))*]; | ||
} | ||
} | ||
|
||
system_data![(A, 0); (B, 1) (C, 2) (D, 3) (E, 4) (F, 5) (G, 6) (H, 7) (I, 8) (J, 9)]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use core::marker::PhantomData; | ||
|
||
pub struct FakeBorrow<T: ?Sized>(PhantomData<T>); | ||
|
||
impl<T: ?Sized> FakeBorrow<T> { | ||
pub(crate) fn new() -> Self { | ||
FakeBorrow(PhantomData) | ||
} | ||
} |
Oops, something went wrong.