Merge pull request #99 from jpernst/ffi
Add [repr(C)] to structs likely to be used in FFI
This commit is contained in:
commit
fa8682df53
|
@ -23,6 +23,7 @@ use quickcheck::{Arbitrary, Gen};
|
|||
///
|
||||
/// This is the composition of a rotation followed by a translation.
|
||||
/// Isometries conserve angles and distances, hence do not allow shearing nor scaling.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Copy)]
|
||||
pub struct Iso2<N> {
|
||||
/// The rotation applicable by this isometry.
|
||||
|
@ -35,6 +36,7 @@ pub struct Iso2<N> {
|
|||
///
|
||||
/// This is the composition of a rotation followed by a translation.
|
||||
/// Isometries conserve angles and distances, hence do not allow shearing nor scaling.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Copy)]
|
||||
pub struct Iso3<N> {
|
||||
/// The rotation applicable by this isometry.
|
||||
|
@ -46,6 +48,7 @@ pub struct Iso3<N> {
|
|||
/// Four dimensional isometry.
|
||||
///
|
||||
/// Isometries conserve angles and distances, hence do not allow shearing nor scaling.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Copy)]
|
||||
pub struct Iso4<N> {
|
||||
/// The rotation applicable by this isometry.
|
||||
|
|
|
@ -21,6 +21,7 @@ use quickcheck::{Arbitrary, Gen};
|
|||
|
||||
|
||||
/// Special identity matrix. All its operation are no-ops.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcDecodable, Clone, Debug, Copy)]
|
||||
pub struct Identity;
|
||||
|
||||
|
@ -33,6 +34,7 @@ impl Identity {
|
|||
}
|
||||
|
||||
/// Square matrix of dimension 1.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Mat1<N> {
|
||||
pub m11: N
|
||||
|
@ -79,6 +81,7 @@ arbitrary_impl!(Mat1, m11);
|
|||
rand_impl!(Mat1, m11);
|
||||
|
||||
/// Square matrix of dimension 2.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Mat2<N> {
|
||||
pub m11: N, pub m21: N,
|
||||
|
@ -129,6 +132,7 @@ arbitrary_impl!(Mat2, m11, m12, m21, m22);
|
|||
rand_impl!(Mat2, m11, m12, m21, m22);
|
||||
|
||||
/// Square matrix of dimension 3.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Mat3<N> {
|
||||
pub m11: N, pub m21: N, pub m31: N,
|
||||
|
@ -221,6 +225,7 @@ rand_impl!(Mat3,
|
|||
);
|
||||
|
||||
/// Square matrix of dimension 4.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Mat4<N> {
|
||||
pub m11: N, pub m21: N, pub m31: N, pub m41: N,
|
||||
|
@ -333,6 +338,7 @@ rand_impl!(Mat4,
|
|||
);
|
||||
|
||||
/// Square matrix of dimension 5.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Mat5<N> {
|
||||
pub m11: N, pub m21: N, pub m31: N, pub m41: N, pub m51: N,
|
||||
|
@ -461,6 +467,7 @@ rand_impl!(Mat5,
|
|||
);
|
||||
|
||||
/// Square matrix of dimension 6.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Mat6<N> {
|
||||
pub m11: N, pub m21: N, pub m31: N, pub m41: N, pub m51: N, pub m61: N,
|
||||
|
|
|
@ -19,6 +19,7 @@ use quickcheck::{Arbitrary, Gen};
|
|||
|
||||
|
||||
/// Point of dimension 0.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, Clone, Debug, Copy)]
|
||||
pub struct Pnt0<N>(pub PhantomData<N>);
|
||||
|
||||
|
@ -37,6 +38,7 @@ impl<N> Pnt0<N> {
|
|||
}
|
||||
|
||||
/// Point of dimension 1.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Pnt1<N> {
|
||||
/// First component of the point.
|
||||
|
@ -77,6 +79,7 @@ arbitrary_pnt_impl!(Pnt1, x);
|
|||
rand_impl!(Pnt1, x);
|
||||
|
||||
/// Point of dimension 2.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Pnt2<N> {
|
||||
/// First component of the point.
|
||||
|
@ -119,6 +122,7 @@ arbitrary_pnt_impl!(Pnt2, x, y);
|
|||
rand_impl!(Pnt2, x, y);
|
||||
|
||||
/// Point of dimension 3.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Pnt3<N> {
|
||||
/// First component of the point.
|
||||
|
@ -163,6 +167,7 @@ arbitrary_pnt_impl!(Pnt3, x, y, z);
|
|||
rand_impl!(Pnt3, x, y, z);
|
||||
|
||||
/// Point of dimension 4.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Pnt4<N> {
|
||||
/// First component of the point.
|
||||
|
@ -209,6 +214,7 @@ arbitrary_pnt_impl!(Pnt4, x, y, z, w);
|
|||
rand_impl!(Pnt4, x, y, z, w);
|
||||
|
||||
/// Point of dimension 5.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Pnt5<N> {
|
||||
/// First component of the point.
|
||||
|
@ -257,6 +263,7 @@ arbitrary_pnt_impl!(Pnt5, x, y, z, w, a);
|
|||
rand_impl!(Pnt5, x, y, z, w, a);
|
||||
|
||||
/// Point of dimension 6.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Pnt6<N> {
|
||||
/// First component of the point.
|
||||
|
|
|
@ -20,6 +20,7 @@ use quickcheck::{Arbitrary, Gen};
|
|||
|
||||
|
||||
/// A quaternion.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Quat<N> {
|
||||
/// The scalar component of the quaternion.
|
||||
|
@ -158,6 +159,7 @@ impl<N: ApproxEq<N> + BaseFloat> Div<Quat<N>> for Quat<N> {
|
|||
|
||||
|
||||
/// A unit quaternion that can represent a 3D rotation.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct UnitQuat<N> {
|
||||
q: Quat<N>
|
||||
|
|
|
@ -16,6 +16,7 @@ use quickcheck::{Arbitrary, Gen};
|
|||
|
||||
|
||||
/// Two dimensional rotation matrix.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Hash, Copy)]
|
||||
pub struct Rot2<N> {
|
||||
submat: Mat2<N>
|
||||
|
@ -101,6 +102,7 @@ impl<N: Arbitrary + Clone + BaseFloat + Neg<Output = N>> Arbitrary for Rot2<N> {
|
|||
* 3d rotation
|
||||
*/
|
||||
/// Three dimensional rotation matrix.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Hash, Copy)]
|
||||
pub struct Rot3<N> {
|
||||
submat: Mat3<N>
|
||||
|
@ -306,6 +308,7 @@ impl<N: Arbitrary + Clone + BaseFloat> Arbitrary for Rot3<N> {
|
|||
|
||||
|
||||
/// Four dimensional rotation matrix.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Hash, Copy)]
|
||||
pub struct Rot4<N> {
|
||||
submat: Mat4<N>
|
||||
|
|
|
@ -21,6 +21,7 @@ use quickcheck::{Arbitrary, Gen};
|
|||
|
||||
|
||||
/// Vector of dimension 0.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, Clone, Debug, Copy)]
|
||||
pub struct Vec0<N>(pub PhantomData<N>);
|
||||
|
||||
|
@ -39,6 +40,7 @@ impl<N> Vec0<N> {
|
|||
}
|
||||
|
||||
/// Vector of dimension 1.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Vec1<N> {
|
||||
/// First component of the vector.
|
||||
|
@ -90,6 +92,7 @@ arbitrary_impl!(Vec1, x);
|
|||
rand_impl!(Vec1, x);
|
||||
|
||||
/// Vector of dimension 2.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Vec2<N> {
|
||||
/// First component of the vector.
|
||||
|
@ -143,6 +146,7 @@ arbitrary_impl!(Vec2, x, y);
|
|||
rand_impl!(Vec2, x, y);
|
||||
|
||||
/// Vector of dimension 3.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Vec3<N> {
|
||||
/// First component of the vector.
|
||||
|
@ -199,6 +203,7 @@ rand_impl!(Vec3, x, y, z);
|
|||
|
||||
|
||||
/// Vector of dimension 4.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Vec4<N> {
|
||||
/// First component of the vector.
|
||||
|
@ -256,6 +261,7 @@ arbitrary_impl!(Vec4, x, y, z, w);
|
|||
rand_impl!(Vec4, x, y, z, w);
|
||||
|
||||
/// Vector of dimension 5.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Vec5<N> {
|
||||
/// First component of the vector.
|
||||
|
@ -315,6 +321,7 @@ arbitrary_impl!(Vec5, x, y, z, w, a);
|
|||
rand_impl!(Vec5, x, y, z, w, a);
|
||||
|
||||
/// Vector of dimension 6.
|
||||
#[repr(C)]
|
||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Debug, Copy)]
|
||||
pub struct Vec6<N> {
|
||||
/// First component of the vector.
|
||||
|
|
Loading…
Reference in New Issue