Add #[repr(C)] to structs likely to be used in ffi

This commit is contained in:
Jameson Ernst 2015-02-28 16:23:09 -08:00
parent 713123565a
commit 532702f554
4 changed files with 23 additions and 0 deletions

View File

@ -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,

View File

@ -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.

View File

@ -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>

View File

@ -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.