rglua/userdata/
mod.rs

1macro_rules! udata {
2	(
3		$(#[$outer:meta])*
4		$vis:vis struct $name:ident {
5			$(
6				$fieldvis:vis $field:ident: $ty:ty
7			),*
8		}
9		$($rest:tt)*
10	) => {
11		#[repr(C)]
12		#[derive(
13			PartialEq,
14			PartialOrd,
15			Debug,
16			Default,
17			Copy,
18			Clone
19		)]
20		$(#[$outer])*
21		$vis struct $name {
22			$(
23				$fieldvis $field: $ty
24			),*
25		}
26
27		impl $name {
28			pub fn new( $($field: $ty),* ) -> $name {
29				$name {
30					$($field),*
31				}
32			}
33		}
34		udata!( $($rest)* );
35	};
36	() => ();
37}
38
39udata! {
40	// https://github.com/danielga/sourcesdk-minimal/blob/cab3e07edc4a41e7e69ea645ea51c1e5c5d1be71/public/mathlib/vector.h#L66
41	/// Floating point vector type created by the Vector() function in lua and Vector::new() in Rust.
42	pub struct Vector {
43		pub x: f32,
44		pub y: f32,
45		pub z: f32
46	}
47
48	// https://github.com/danielga/sourcesdk-minimal/blob/cab3e07edc4a41e7e69ea645ea51c1e5c5d1be71/public/mathlib/vector.h#L1765
49	/// Euler angle type.
50	/// This is a QAngle in the source engine.
51	pub struct Angle {
52		pub p: f32,
53		pub y: f32,
54		pub r: f32
55	}
56}