upgrade rkyv to 0.7

This commit is contained in:
zyansheep 2022-03-21 12:08:46 -04:00 committed by Sébastien Crozet
parent a850592f7b
commit 90f2603de4
9 changed files with 32 additions and 97 deletions

View File

@ -79,7 +79,7 @@ alga = { version = "0.9", default-features = false, optional = true }
rand_distr = { version = "0.4", default-features = false, optional = true } rand_distr = { version = "0.4", default-features = false, optional = true }
matrixmultiply = { version = "0.3", optional = true } matrixmultiply = { version = "0.3", optional = true }
serde = { version = "1.0", default-features = false, features = [ "derive" ], optional = true } serde = { version = "1.0", default-features = false, features = [ "derive" ], optional = true }
rkyv = { version = "~0.6.4", default-features = false, features = ["const_generics"], optional = true } rkyv = { version = "~0.7.1", optional = true }
mint = { version = "0.5", optional = true } mint = { version = "0.5", optional = true }
quickcheck = { version = "1", optional = true } quickcheck = { version = "1", optional = true }
pest = { version = "2", optional = true } pest = { version = "2", optional = true }

View File

@ -277,23 +277,15 @@ unsafe impl<T: Scalar + Copy + bytemuck::Pod, const R: usize, const C: usize> by
#[cfg(feature = "rkyv-serialize-no-std")] #[cfg(feature = "rkyv-serialize-no-std")]
mod rkyv_impl { mod rkyv_impl {
use super::ArrayStorage; use super::ArrayStorage;
use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize};
impl<T: Archive, const R: usize, const C: usize> Archive for ArrayStorage<T, R, C> { impl<T: Archive, const R: usize, const C: usize> Archive for ArrayStorage<T, R, C> {
type Archived = ArrayStorage<T::Archived, R, C>; type Archived = ArrayStorage<T::Archived, R, C>;
type Resolver = <[[T; R]; C] as Archive>::Resolver; type Resolver = <[[T; R]; C] as Archive>::Resolver;
fn resolve( unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) {
&self, let (fp, fo) = out_field!(out.0);
pos: usize, self.0.resolve(pos + fp, resolver, fo);
resolver: Self::Resolver,
out: &mut core::mem::MaybeUninit<Self::Archived>,
) {
self.0.resolve(
pos + offset_of!(Self::Archived, 0),
resolver,
project_struct!(out: Self::Archived => 0),
);
} }
} }

View File

@ -242,13 +242,7 @@ mod rkyv_impl {
type Archived = Self; type Archived = Self;
type Resolver = (); type Resolver = ();
fn resolve( unsafe fn resolve(&self, _: usize, _: Self::Resolver, _: *mut Self::Archived) {}
&self,
_: usize,
_: Self::Resolver,
_: &mut core::mem::MaybeUninit<Self::Archived>,
) {
}
} }
impl<S: Fallible + ?Sized, const R: usize> Serialize<S> for Const<R> { impl<S: Fallible + ?Sized, const R: usize> Serialize<S> for Const<R> {

View File

@ -292,23 +292,15 @@ where
mod rkyv_impl { mod rkyv_impl {
use super::Matrix; use super::Matrix;
use core::marker::PhantomData; use core::marker::PhantomData;
use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize};
impl<T: Archive, R: Archive, C: Archive, S: Archive> Archive for Matrix<T, R, C, S> { impl<T: Archive, R: Archive, C: Archive, S: Archive> Archive for Matrix<T, R, C, S> {
type Archived = Matrix<T::Archived, R::Archived, C::Archived, S::Archived>; type Archived = Matrix<T::Archived, R::Archived, C::Archived, S::Archived>;
type Resolver = S::Resolver; type Resolver = S::Resolver;
fn resolve( unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) {
&self, let (fp, fo) = out_field!(out.data);
pos: usize, self.data.resolve(pos + fp, resolver, fo);
resolver: Self::Resolver,
out: &mut core::mem::MaybeUninit<Self::Archived>,
) {
self.data.resolve(
pos + offset_of!(Self::Archived, data),
resolver,
project_struct!(out: Self::Archived => data),
);
} }
} }

View File

@ -61,23 +61,15 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for Unit<T> {
#[cfg(feature = "rkyv-serialize-no-std")] #[cfg(feature = "rkyv-serialize-no-std")]
mod rkyv_impl { mod rkyv_impl {
use super::Unit; use super::Unit;
use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize};
impl<T: Archive> Archive for Unit<T> { impl<T: Archive> Archive for Unit<T> {
type Archived = Unit<T::Archived>; type Archived = Unit<T::Archived>;
type Resolver = T::Resolver; type Resolver = T::Resolver;
fn resolve( unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) {
&self, let (fp, fo) = out_field!(out.value);
pos: usize, self.value.resolve(pos + fp, resolver, fo);
resolver: Self::Resolver,
out: &mut ::core::mem::MaybeUninit<Self::Archived>,
) {
self.value.resolve(
pos + offset_of!(Self::Archived, value),
resolver,
project_struct!(out: Self::Archived => value),
);
} }
} }

View File

@ -77,7 +77,7 @@ pub struct Isometry<T, R, const D: usize> {
mod rkyv_impl { mod rkyv_impl {
use super::Isometry; use super::Isometry;
use crate::{base::Scalar, geometry::Translation}; use crate::{base::Scalar, geometry::Translation};
use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize};
impl<T: Scalar + Archive, R: Archive, const D: usize> Archive for Isometry<T, R, D> impl<T: Scalar + Archive, R: Archive, const D: usize> Archive for Isometry<T, R, D>
where where
@ -86,22 +86,11 @@ mod rkyv_impl {
type Archived = Isometry<T::Archived, R::Archived, D>; type Archived = Isometry<T::Archived, R::Archived, D>;
type Resolver = (R::Resolver, <Translation<T, D> as Archive>::Resolver); type Resolver = (R::Resolver, <Translation<T, D> as Archive>::Resolver);
fn resolve( unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) {
&self, let (fp, fo) = out_field!(out.rotation);
pos: usize, self.rotation.resolve(pos + fp, resolver.0, fo);
resolver: Self::Resolver, let (fp, fo) = out_field!(out.translation);
out: &mut core::mem::MaybeUninit<Self::Archived>, self.translation.resolve(pos + fp, resolver.1, fo);
) {
self.rotation.resolve(
pos + offset_of!(Self::Archived, rotation),
resolver.0,
project_struct!(out: Self::Archived => rotation),
);
self.translation.resolve(
pos + offset_of!(Self::Archived, translation),
resolver.1,
project_struct!(out: Self::Archived => translation),
);
} }
} }

View File

@ -101,23 +101,15 @@ where
mod rkyv_impl { mod rkyv_impl {
use super::Quaternion; use super::Quaternion;
use crate::base::Vector4; use crate::base::Vector4;
use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize};
impl<T: Archive> Archive for Quaternion<T> { impl<T: Archive> Archive for Quaternion<T> {
type Archived = Quaternion<T::Archived>; type Archived = Quaternion<T::Archived>;
type Resolver = <Vector4<T> as Archive>::Resolver; type Resolver = <Vector4<T> as Archive>::Resolver;
fn resolve( unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) {
&self, let (fp, fo) = out_field!(out.coords);
pos: usize, self.coords.resolve(pos + fp, resolver, fo);
resolver: Self::Resolver,
out: &mut core::mem::MaybeUninit<Self::Archived>,
) {
self.coords.resolve(
pos + offset_of!(Self::Archived, coords),
resolver,
project_struct!(out: Self::Archived => coords),
);
} }
} }

View File

@ -88,23 +88,15 @@ where
mod rkyv_impl { mod rkyv_impl {
use super::Scale; use super::Scale;
use crate::base::SVector; use crate::base::SVector;
use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize};
impl<T: Archive, const D: usize> Archive for Scale<T, D> { impl<T: Archive, const D: usize> Archive for Scale<T, D> {
type Archived = Scale<T::Archived, D>; type Archived = Scale<T::Archived, D>;
type Resolver = <SVector<T, D> as Archive>::Resolver; type Resolver = <SVector<T, D> as Archive>::Resolver;
fn resolve( unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) {
&self, let (fp, fo) = out_field!(out.vector);
pos: usize, self.vector.resolve(pos + fp, resolver, fo);
resolver: Self::Resolver,
out: &mut core::mem::MaybeUninit<Self::Archived>,
) {
self.vector.resolve(
pos + offset_of!(Self::Archived, vector),
resolver,
project_struct!(out: Self::Archived => vector),
);
} }
} }

View File

@ -88,23 +88,15 @@ where
mod rkyv_impl { mod rkyv_impl {
use super::Translation; use super::Translation;
use crate::base::SVector; use crate::base::SVector;
use rkyv::{offset_of, project_struct, Archive, Deserialize, Fallible, Serialize}; use rkyv::{out_field, Archive, Deserialize, Fallible, Serialize};
impl<T: Archive, const D: usize> Archive for Translation<T, D> { impl<T: Archive, const D: usize> Archive for Translation<T, D> {
type Archived = Translation<T::Archived, D>; type Archived = Translation<T::Archived, D>;
type Resolver = <SVector<T, D> as Archive>::Resolver; type Resolver = <SVector<T, D> as Archive>::Resolver;
fn resolve( unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) {
&self, let (fp, fo) = out_field!(out.vector);
pos: usize, self.vector.resolve(pos + fp, resolver, fo);
resolver: Self::Resolver,
out: &mut core::mem::MaybeUninit<Self::Archived>,
) {
self.vector.resolve(
pos + offset_of!(Self::Archived, vector),
resolver,
project_struct!(out: Self::Archived => vector),
);
} }
} }