a;
a.re;
a.im;
+a == b;
+a != b;
a + b;
<<< a - b >>>;
a.mod;
a.phase;
a;
+a == b;
+a != b;
a + b;
a - b;
a * b;
Vec3 v, w;
+<<< v == >>>;
+
<<< v + w >>>;
<<< v - w >>>;
<<< v * w >>>;
<<< -12 => v.z >>>;
<<< @(.1, .2, .4) => v >>>;
<<< v >>>;
-<<< "set ", v.set(1,2,3) >>>;
+<<< "set ", v.set(1,2,3) >>>;
<<< "setAll ", v.setAll(1.2) >>>;
<<< "should be 1.2 1.2 1.2 ", v >>>;
<<< "Update ", v.update(2) >>>;
Vec4 v, w;
<<< v >>>;
+<<< v == w>>>;
+<<< v != w>>>;
+
<<< v + w>>>;
<<< v - w>>>;
<<< v * w>>>;
ANN2(1) m_int gwi_oper_end(const Gwi gwi, const m_str op, const f_instr f);
ANN m_int gwi_oper_cond(const Gwi, const m_str, const f_instr, const f_instr);
+#define _EQUALITY_OPER(sz, sign) \
+ POP_REG(shred, sz*2 - SZ_INT); \
+ *(m_uint*)REG(-SZ_INT) = sign \
+ memcmp(shred->reg + SZ_INT, shred->reg + SZ_INT + sz, sz); \
+
+#define EQUALITY_OPER(name, sz) \
+static INSTR(name##_eq) { _EQUALITY_OPER(sz, !) } \
+static INSTR(name##_ne) { _EQUALITY_OPER(sz, !!) }
+
#endif
printf("%%(%.4f, %.4f*pi)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT) / M_PI);
}
+EQUALITY_OPER(complex, SZ_COMPLEX)
+
GWION_IMPORT(complex) {
// should be special
const Type t_complex = gwi_class_spe(gwi, "complex", SZ_COMPLEX);
GWI_BB(gwi_item_ini(gwi, "float", "phase"))
GWI_BB(gwi_item_end(gwi, ae_flag_member, NULL))
GWI_BB(gwi_class_end(gwi))
+ GWI_BB(gwi_oper_ini(gwi, "complex", "complex", "bool"))
+ GWI_BB(gwi_oper_end(gwi, "==", complex_eq))
+ GWI_BB(gwi_oper_end(gwi, "!=", complex_ne))
GWI_BB(gwi_oper_ini(gwi, "complex", "complex", "complex"))
GWI_BB(gwi_oper_end(gwi, "+", ComplexAdd))
GWI_BB(gwi_oper_end(gwi, "-", ComplexSub))
GWI_BB(gwi_oper_end(gwi, "*=>", ComplexRMul))
GWI_BB(gwi_oper_add(gwi, opck_rassign))
GWI_BB(gwi_oper_end(gwi, "/=>", ComplexRDiv))
+ GWI_BB(gwi_oper_ini(gwi, "polar", "polar", "bool"))
+ GWI_BB(gwi_oper_end(gwi, "==", complex_eq))
+ GWI_BB(gwi_oper_end(gwi, "!=", complex_ne))
GWI_BB(gwi_oper_ini(gwi, "polar", "polar", "polar"))
GWI_BB(gwi_oper_add(gwi, opck_rassign))
GWI_BB(gwi_oper_end(gwi, "=>", ComplexRAssign))
printf("%%(%.4f, %.4f, %.4f)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT), *(m_float*)(VALUE + SZ_FLOAT*2));
}
+EQUALITY_OPER(vec3, SZ_VEC3);
+
GWION_IMPORT(vec3) {
const Type t_vec3 = gwi_class_spe(gwi, "Vec3", SZ_VEC3);
gwi->gwion->type[et_vec3] = t_vec3;
GWI_BB(gwi_func_end(gwi, vec3_update_set_slew, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
+ GWI_BB(gwi_oper_ini(gwi, "Vec3", "Vec3", "bool"))
+ GWI_BB(gwi_oper_end(gwi, "==", vec3_eq))
+ GWI_BB(gwi_oper_end(gwi, "!=", vec3_ne))
GWI_BB(gwi_oper_ini(gwi, "Vec3", "Vec3", "Vec3"))
GWI_BB(gwi_oper_end(gwi, "+", Vec3Add))
GWI_BB(gwi_oper_end(gwi, "-", Vec3Sub))
*(m_float*)(VALUE + SZ_FLOAT*3));
}
+EQUALITY_OPER(vec4, SZ_VEC4);
+
GWION_IMPORT(vec4) {
const Type t_vec4 = gwi_class_spe(gwi, "Vec4", SZ_VEC4);
gwi->gwion->type[et_vec4] = t_vec4;
gwi_func_ini(gwi, "void", "normalize");
CHECK_BB(gwi_func_end(gwi, vec4_normalize, ae_flag_none))
CHECK_BB(gwi_class_end(gwi))
+ GWI_BB(gwi_oper_ini(gwi, "Vec4", "Vec4", "bool"))
+ GWI_BB(gwi_oper_end(gwi, "==", vec4_eq))
+ GWI_BB(gwi_oper_end(gwi, "!=", vec4_ne))
CHECK_BB(gwi_oper_ini(gwi, "Vec4", "Vec4", "Vec4"))
CHECK_BB(gwi_oper_end(gwi, "+", Vec4Add))
CHECK_BB(gwi_oper_end(gwi, "-", Vec4Sub))