[Gridflow-cvs] [svn] commit: r5092 - /trunk/src/gridflow.cxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Tue Mar 2 02:24:53 EST 2010

Author: matju
Date: Tue Mar  2 02:24:52 2010
New Revision: 5092

BitPacking : in other words...


Modified: trunk/src/gridflow.cxx
--- trunk/src/gridflow.cxx (original)
+++ trunk/src/gridflow.cxx Tue Mar  2 02:24:52 2010
@@ -520,18 +520,14 @@
 #define TRACE
+#define FOO(A) case A##_e:   packer->as_##A(this,n,(A *)in,out); break;
 template <class T> void BitPacking::  pack(long n, T *in, uint8 *out) {TRACE
-	switch (NumberTypeE_type_of(in)) {
-	case uint8_e:   packer->as_uint8(this,n,(uint8 *)in,out); break;
-	case int16_e:   packer->as_int16(this,n,(int16 *)in,out); break;
-	case int32_e:   packer->as_int32(this,n,(int32 *)in,out); break;
-	default: RAISE("argh");}}
+	switch (NumberTypeE_type_of( in)) {FOO(uint8) FOO(int16) FOO(int32) default: RAISE("argh");}}
+#undef FOO
+#define FOO(A) case A##_e: unpacker->as_##A(this,n,in,(A *)out); break;
 template <class T> void BitPacking::unpack(long n, uint8 *in, T *out) {TRACE
-	switch (NumberTypeE_type_of(out)) {
-	case uint8_e: unpacker->as_uint8(this,n,in,(uint8 *)out); break;
-	case int16_e: unpacker->as_int16(this,n,in,(int16 *)out); break;
-	case int32_e: unpacker->as_int32(this,n,in,(int32 *)out); break;
-	default: RAISE("argh");}}
+	switch (NumberTypeE_type_of(out)) {FOO(uint8) FOO(int16) FOO(int32) default: RAISE("argh");}}
+#undef FOO
 // i'm sorry... see the end of grid.c for an explanation...

More information about the Gridflow-cvs mailing list