1#![no_main]
2#![allow(warnings)]
3#[macro_use]
4extern crate mech_core;
5#[cfg(feature = "matrix")]
6extern crate nalgebra as na;
7extern crate paste;
8
9use paste::paste;
10
11#[cfg(feature = "vector3")]
12use nalgebra::Vector3;
13#[cfg(feature = "vectord")]
14use nalgebra::DVector;
15#[cfg(feature = "vector2")]
16use nalgebra::Vector2;
17#[cfg(feature = "vector4")]
18use nalgebra::Vector4;
19#[cfg(feature = "rowdvector")]
20use nalgebra::RowDVector;
21#[cfg(feature = "row_vectord")]
22use nalgebra::RowDVector;
23#[cfg(feature = "matrix1")]
24use nalgebra::Matrix1;
25#[cfg(feature = "matrix3")]
26use nalgebra::Matrix3;
27#[cfg(feature = "matrix4")]
28use nalgebra::Matrix4;
29#[cfg(feature = "row_vector3")]
30use nalgebra::RowVector3;
31#[cfg(feature = "row_vector4")]
32use nalgebra::RowVector4;
33#[cfg(feature = "row_vector2")]
34use nalgebra::RowVector2;
35#[cfg(feature = "matrixd")]
36use nalgebra::DMatrix;
37#[cfg(feature = "matrix2x3")]
38use nalgebra::Matrix2x3;
39#[cfg(feature = "matrix3x2")]
40use nalgebra::Matrix3x2;
41#[cfg(feature = "matrix2")]
42use nalgebra::Matrix2;
43
44use std::marker::PhantomData;
45use std::fmt::{Debug, Display};
46
47use mech_core::*;
48#[cfg(target_arch = "wasm32")]
49use wasm_bindgen::prelude::*;
50#[cfg(target_arch = "wasm32")]
51use web_sys::console;
52
53#[cfg(target_arch = "wasm32")]
54macro_rules! log {
55 ( $( $t:tt )* ) => {
56 web_sys::console::log_1(&format!( $( $t )* ).into());
57 }
58}
59
60#[cfg(feature = "print")]
61pub mod print;
62#[cfg(feature = "println")]
63pub mod println;
64
65#[cfg(feature = "print")]
66pub use self::print::*;
67#[cfg(feature = "println")]
68pub use self::println::*;
69
70#[macro_export]
71macro_rules! register_op {
72 ($op:ident, $type:ty, $size:ty, $size_string:tt) => {
73 paste!{
74 register_descriptor! {
75 FunctionDescriptor {
76 name: concat!(stringify!($op),"<[",stringify!([<$type:lower>]),"]:", $size_string, ">"),
77 ptr: $op::<$type,$size<$type>>::new,
78 }
79 }
80 }
81 };}
82
83#[macro_export]
84macro_rules! register_op_all {
85 ($op:ident, $ty:ty, $ty_feature:literal) => {
86 #[cfg(feature = "row_vector4")]
87 register_op!($op, $ty, RowVector4, "1,4");
88 #[cfg(feature = "row_vector3")]
89 register_op!($op, $ty, RowVector3, "1,3");
90 #[cfg(feature = "row_vector2")]
91 register_op!($op, $ty, RowVector2, "1,2");
92 #[cfg(feature = "vector2")]
93 register_op!($op, $ty, Vector2, "2,1");
94 #[cfg(feature = "vector3")]
95 register_op!($op, $ty, Vector3, "3,1");
96 #[cfg(feature = "vector4")]
97 register_op!($op, $ty, Vector4, "4,1");
98 #[cfg(feature = "matrix1")]
99 register_op!($op, $ty, Matrix1, "1,1");
100 #[cfg(feature = "matrix2")]
101 register_op!($op, $ty, Matrix2, "2,2");
102 #[cfg(feature = "matrix3")]
103 register_op!($op, $ty, Matrix3, "3,3");
104 #[cfg(feature = "matrix4")]
105 register_op!($op, $ty, Matrix4, "4,4");
106 #[cfg(feature = "matrix2x3")]
107 register_op!($op, $ty, Matrix2x3, "2,3");
108 #[cfg(feature = "matrix3x2")]
109 register_op!($op, $ty, Matrix3x2, "3,2");
110 #[cfg(feature = "vectord")]
111 register_op!($op, $ty, DVector, "0,1");
112 #[cfg(feature = "matrixd")]
113 register_op!($op, $ty, DMatrix, "0,0");
114 #[cfg(feature = "row_vectord")]
115 register_op!($op, $ty, RowDVector, "1,0");
116 };
117}
118
119#[macro_export]
120macro_rules! impl_register_all {
121 ($macro_name:ident) => {
122 #[cfg(feature = "u8")]
123 register_op_all!($macro_name, u8, "u8");
124 #[cfg(feature = "u16")]
125 register_op_all!($macro_name, u16, "u16");
126 #[cfg(feature = "u32")]
127 register_op_all!($macro_name, u32, "u32");
128 #[cfg(feature = "u64")]
129 register_op_all!($macro_name, u64, "u64");
130 #[cfg(feature = "u128")]
131 register_op_all!($macro_name, u128, "u128");
132 #[cfg(feature = "i8")]
133 register_op_all!($macro_name, i8, "i8");
134 #[cfg(feature = "i16")]
135 register_op_all!($macro_name, i16, "i16");
136 #[cfg(feature = "i32")]
137 register_op_all!($macro_name, i32, "i32");
138 #[cfg(feature = "i64")]
139 register_op_all!($macro_name, i64, "i64");
140 #[cfg(feature = "i128")]
141 register_op_all!($macro_name, i128, "i128");
142 #[cfg(feature = "f32")]
143 register_op_all!($macro_name, f32, "f32");
144 #[cfg(feature = "f64")]
145 register_op_all!($macro_name, f64, "f64");
146 #[cfg(feature = "r64")]
147 register_op_all!($macro_name, R64, "r64");
148 #[cfg(feature = "c64")]
149 register_op_all!($macro_name, C64, "c64");
150 };
151}