Use safer_ffi for repr C trait
This commit is contained in:
parent
d5e765db61
commit
c131cb9bac
7 changed files with 32 additions and 12 deletions
|
@ -30,6 +30,7 @@ serde = { version = "1.0", features = ["serde_derive"], optional = true }
|
|||
# works only in rust toolchain up to 1.32, disabled indefinitely
|
||||
#simd = { version = "0.2", optional = true }
|
||||
bytemuck = { version = "1.0", optional = true }
|
||||
safer-ffi = { version = "0.0.10", features = ["proc_macros"] }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0"
|
||||
|
|
|
@ -28,10 +28,11 @@ use approx;
|
|||
use mint;
|
||||
use num::BaseFloat;
|
||||
use quaternion::Quaternion;
|
||||
use safer_ffi::prelude::*;
|
||||
|
||||
/// A set of [Euler angles] representing a rotation in three-dimensional space.
|
||||
///
|
||||
/// This type is marked as `#[repr(C)]`.
|
||||
/// This type is marked as `#[derive_ReprC] #[repr(C)]`.
|
||||
///
|
||||
/// The axis rotation sequence is XYZ. That is, the rotation is first around
|
||||
/// the X axis, then the Y axis, and lastly the Z axis (using intrinsic
|
||||
|
@ -78,6 +79,7 @@ use quaternion::Quaternion;
|
|||
/// [Euler angles]: https://en.wikipedia.org/wiki/Euler_angles
|
||||
/// [gimbal lock]: https://en.wikipedia.org/wiki/Gimbal_lock#Gimbal_lock_in_applied_mathematics
|
||||
/// [convert]: #defining-rotations-using-euler-angles
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
|
|
@ -72,6 +72,8 @@ extern crate serde;
|
|||
#[cfg(feature = "simd")]
|
||||
extern crate simd;
|
||||
|
||||
extern crate safer_ffi;
|
||||
|
||||
// Re-exports
|
||||
|
||||
pub use approx::*;
|
||||
|
|
|
@ -33,6 +33,7 @@ use euler::Euler;
|
|||
use num::{BaseFloat, BaseNum};
|
||||
use point::{Point2, Point3};
|
||||
use quaternion::Quaternion;
|
||||
use safer_ffi::prelude::*;
|
||||
use transform::{Transform, Transform2, Transform3};
|
||||
use vector::{Vector2, Vector3, Vector4};
|
||||
|
||||
|
@ -41,7 +42,8 @@ use mint;
|
|||
|
||||
/// A 2 x 2, column major matrix
|
||||
///
|
||||
/// This type is marked as `#[repr(C)]`.
|
||||
/// This type is marked as `#[derive_ReprC] #[repr(C)]`.
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
@ -54,7 +56,8 @@ pub struct Matrix2<S> {
|
|||
|
||||
/// A 3 x 3, column major matrix
|
||||
///
|
||||
/// This type is marked as `#[repr(C)]`.
|
||||
/// This type is marked as `#[derive_ReprC] #[repr(C)]`.
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
@ -69,7 +72,8 @@ pub struct Matrix3<S> {
|
|||
|
||||
/// A 4 x 4, column major matrix
|
||||
///
|
||||
/// This type is marked as `#[repr(C)]`.
|
||||
/// This type is marked as `#[derive_ReprC] #[repr(C)]`.
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
|
10
src/point.rs
10
src/point.rs
|
@ -27,13 +27,15 @@ use structure::*;
|
|||
use approx;
|
||||
use num::{BaseFloat, BaseNum};
|
||||
use vector::{Vector1, Vector2, Vector3, Vector4};
|
||||
use safer_ffi::prelude::*;
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
use mint;
|
||||
|
||||
/// A point in 1-dimensional space.
|
||||
///
|
||||
/// This type is marked as `#[repr(C)]`.
|
||||
/// This type is marked as `#[derive_ReprC] #[repr(C)]`.
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
@ -43,7 +45,8 @@ pub struct Point1<S> {
|
|||
|
||||
/// A point in 2-dimensional space.
|
||||
///
|
||||
/// This type is marked as `#[repr(C)]`.
|
||||
/// This type is marked as `#[derive_ReprC] #[repr(C)]`.
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
@ -54,7 +57,8 @@ pub struct Point2<S> {
|
|||
|
||||
/// A point in 3-dimensional space.
|
||||
///
|
||||
/// This type is marked as `#[repr(C)]`.
|
||||
/// This type is marked as `#[derive_ReprC] #[repr(C)]`.
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
|
|
@ -33,6 +33,7 @@ use num::{BaseFloat, BaseNum};
|
|||
use point::Point3;
|
||||
use quaternion;
|
||||
use rotation::{Basis3, Rotation, Rotation3};
|
||||
use safer_ffi::prelude::*;
|
||||
use vector::Vector3;
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
|
@ -41,7 +42,8 @@ use mint;
|
|||
/// A [quaternion](https://en.wikipedia.org/wiki/Quaternion) in scalar/vector
|
||||
/// form.
|
||||
///
|
||||
/// This type is marked as `#[repr(C)]`.
|
||||
/// This type is marked as `#[derive_ReprC] #[repr(C)]`.
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
|
|
@ -29,13 +29,15 @@ use structure::*;
|
|||
use angle::Rad;
|
||||
use approx;
|
||||
use num::{BaseFloat, BaseNum};
|
||||
use safer_ffi::prelude::*;
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
use mint;
|
||||
|
||||
/// A 1-dimensional vector.
|
||||
///
|
||||
/// This type is marked as `#[repr(C)]`.
|
||||
/// This type is marked as `#[derive_ReprC] #[repr(C)]`.
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
@ -46,7 +48,8 @@ pub struct Vector1<S> {
|
|||
|
||||
/// A 2-dimensional vector.
|
||||
///
|
||||
/// This type is marked as `#[repr(C)]`.
|
||||
/// This type is marked as `#[derive_ReprC] #[repr(C)]`.
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
@ -59,7 +62,8 @@ pub struct Vector2<S> {
|
|||
|
||||
/// A 3-dimensional vector.
|
||||
///
|
||||
/// This type is marked as `#[repr(C)]`.
|
||||
/// This type is marked as `#[derive_ReprC] #[repr(C)]`.
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
@ -74,7 +78,8 @@ pub struct Vector3<S> {
|
|||
|
||||
/// A 4-dimensional vector.
|
||||
///
|
||||
/// This type is marked as `#[repr(C)]`.
|
||||
/// This type is marked as `#[derive_ReprC] #[repr(C)]`.
|
||||
#[derive_ReprC]
|
||||
#[repr(C)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
|
Loading…
Reference in a new issue