[Gridflow-cvs] [svn] commit: r3849 - /trunk/gridflow.h

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Tue Jun 10 16:21:08 EDT 2008


Author: matju
Date: Tue Jun 10 16:21:07 2008
New Revision: 3849

Log:
add t_atom to uint32 converter

Modified:
    trunk/gridflow.h

Modified: trunk/gridflow.h
==============================================================================
--- trunk/gridflow.h (original)
+++ trunk/gridflow.h Tue Jun 10 16:21:07 2008
@@ -239,31 +239,27 @@
 struct t_atom2 : t_atom {
 	bool operator == (t_symbol *b) {return this->a_type==A_SYMBOL && this->a_symbol==b;}
 	bool operator != (t_symbol *b) {return !(*this==b);}
-	operator bool () const {
+	operator float32 () const {
 		if (a_type!=A_FLOAT) RAISE("expected float");
-		float f = round(a_float);
+		return a_float;}
+	operator bool () const {float f = round(float32(*this));
 		if (f<0 || f>=2) RAISE("value %f is out of range",f);
 		return (bool)f;}
-	operator uint8 () const {
-		if (a_type!=A_FLOAT) RAISE("expected float");
-		float f = round(a_float);
+	operator uint8 () const {float f = round(float32(*this));
 		if (f<0 || f>=0x100) RAISE("value %f is out of range",f);
 		return (uint8)f;}
-	operator int16 () const {
-		if (a_type!=A_FLOAT) RAISE("expected float");
-		float f = round(a_float);
+	operator int16 () const {float f = round(float32(*this));
 		if (f<-0x8000 || f>=0x8000) RAISE("value %f is out of range",f);
 		return (int16)f;}
-	operator uint16 () const {
-		if (a_type!=A_FLOAT) RAISE("expected float");
-		float f = round(a_float);
+	operator uint16 () const {float f = round(float32(*this));
 		if (f<0 || f>=0x10000) RAISE("value %f is out of range",f);
 		return (uint16)f;}
-	operator int32 () const {
-		if (a_type!=A_FLOAT) RAISE("expected float");
-		float f = round(a_float);
+	operator int32 () const {float f = round(float32(*this));
 		if (f<-0x80000000LL || f>=0x80000000LL) RAISE("value %f is out of range",f);
 		return (int32)f;}
+	operator uint32 () const {float f = round(float32(*this));
+		if (f<0 || f>=0x100000000LL) RAISE("value %f is out of range",f);
+		return (uint32)f;}
 	operator long () const {
 		return sizeof(long)==sizeof(int32) ? (int32)*this : (int64)*this;}
 	operator uint64 () const {
@@ -272,9 +268,6 @@
 	operator int64 () const {
 		if (a_type!=A_FLOAT) RAISE("expected float");
 		return (int64)round(a_float);}
-	operator float32 () const {
-		if (a_type!=A_FLOAT) RAISE("expected float");
-		return a_float;}
 	operator float64 () const {
 		if (a_type!=A_FLOAT) RAISE("expected float");
 		return a_float;}



More information about the Gridflow-cvs mailing list