aboutsummaryrefslogtreecommitdiff
path: root/packages/noncvs/windows/extra/Gem/dev/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/noncvs/windows/extra/Gem/dev/Utils')
-rw-r--r--packages/noncvs/windows/extra/Gem/dev/Utils/Functions.h360
-rw-r--r--packages/noncvs/windows/extra/Gem/dev/Utils/GLUtil.h35
-rw-r--r--packages/noncvs/windows/extra/Gem/dev/Utils/GemMath.h85
-rw-r--r--packages/noncvs/windows/extra/Gem/dev/Utils/Matrix.h78
-rw-r--r--packages/noncvs/windows/extra/Gem/dev/Utils/PixPete.h221
-rw-r--r--packages/noncvs/windows/extra/Gem/dev/Utils/SIMD.h117
-rw-r--r--packages/noncvs/windows/extra/Gem/dev/Utils/Vector.h77
-rw-r--r--packages/noncvs/windows/extra/Gem/dev/Utils/any.h308
8 files changed, 1281 insertions, 0 deletions
diff --git a/packages/noncvs/windows/extra/Gem/dev/Utils/Functions.h b/packages/noncvs/windows/extra/Gem/dev/Utils/Functions.h
new file mode 100644
index 00000000..00edb6a0
--- /dev/null
+++ b/packages/noncvs/windows/extra/Gem/dev/Utils/Functions.h
@@ -0,0 +1,360 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ GemFuncUtil.h
+ - contains functions for graphics
+ - part of GEM
+
+ Copyright (c) 1997-2000 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef _INCLUDE__GEM_UTILS_FUNCTIONS_H_
+#define _INCLUDE__GEM_UTILS_FUNCTIONS_H_
+
+#ifdef __APPLE__
+#include <Carbon/Carbon.h>
+#endif
+
+#include "Gem/ExportDef.h"
+
+/* this should be included for ALL platforms:
+ * should we define __MMX__ for windows in there ?
+ */
+#include "Utils/SIMD.h"
+#include "Utils/GemMath.h"
+
+// for rand()
+#include <stdlib.h>
+
+///////////////////////////////////////////////////////////////////////////////
+// powerOfTwo
+// get the next higher 2^n-number (if value is'nt 2^n by itself)
+///////////////////////////////////////////////////////////////////////////////
+inline int powerOfTwo(int value)
+{
+/*
+ int x = 1;
+ // while(x <= value) x <<= 1;
+ while(x < value) x <<= 1;
+ return(x);
+*/
+// optimization from "Hacker's Delight"
+// - above loop executes in 4n+3 instructions, where n is the power of 2 of returned int
+// - below code is branch-free and only 12 instructions!
+ value = value - 1;
+ value = value | (value >> 1);
+ value = value | (value >> 2);
+ value = value | (value >> 4);
+ value = value | (value >> 8);
+ value = value | (value >> 16);
+ return (value + 1);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// min/max functions
+//
+///////////////////////////////////////////////////////////////////////////////
+#ifndef MIN
+inline int MIN(int x, int y) { return (x<y)?x:y; }
+inline float MIN(float x, float y) { return (x<y)?x:y; }
+#endif
+#ifndef MAX
+inline int MAX(int x, int y) { return (x>y)?x:y; }
+inline float MAX(float x, float y) { return (x>y)?x:y; }
+#endif
+
+inline unsigned char TRI_MAX(unsigned char v1, unsigned char v2, unsigned char v3){
+ if (v1 > v2 && v1 > v3) return(v1);
+ if (v2 > v3) return(v2);
+ return(v3);
+}
+inline unsigned char TRI_MIN(unsigned char v1, unsigned char v2, unsigned char v3){
+ if (v1 < v2 && v1 < v3) return(v1);
+ if (v2 < v3) return(v2);
+ return(v3);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Clamp functions
+//
+///////////////////////////////////////////////////////////////////////////////
+//////////
+// Clamp a value high
+inline unsigned char CLAMP_HIGH(int x)
+ { return((unsigned char )((x > 255) ? 255 : x)); }
+
+//////////
+// Clamp a value low
+inline unsigned char CLAMP_LOW(int x)
+ { return((unsigned char )((x < 0) ? 0 : x)); }
+
+//////////
+// Clamp an int to the range of an unsigned char
+inline unsigned char CLAMP(int x)
+ { return((unsigned char)((x > 255) ? 255 : ( (x < 0) ? 0 : x))); }
+
+//////////
+// Clamp a float to the range of an unsigned char
+inline unsigned char CLAMP(float x)
+ { return((unsigned char)((x > 255.f) ? 255.f : ( (x < 0.f) ? 0.f : x))); }
+
+//////////
+// Clamp a float to 0. <= x <= 1.0
+inline float FLOAT_CLAMP(float x)
+ { return((x > 1.f) ? 1.f : ( (x < 0.f) ? 0.f : x)); }
+
+/////////
+// Clamp the Y channel of YUV (16%235)
+inline unsigned char CLAMP_Y(int x)
+ { return((unsigned char)((x > 235) ? 235 : ( (x < 16) ? 16 : x))); }
+
+///////////////////////////////////////////////////////////////////////////////
+// Multiply and interpolation
+//
+///////////////////////////////////////////////////////////////////////////////
+//////////
+// Exactly multiply two unsigned chars
+// This avoids a float value (important on Intel...)
+// From Alvy Ray Smith paper
+inline unsigned char INT_MULT(unsigned int a, unsigned int b)
+ { int t = (unsigned int)a * (unsigned int)b + 0x80;
+ return((unsigned char)(((t >> 8) + t) >> 8)); }
+
+//////////
+// Exactly LERPs two values
+// This avoids a float value (important on Intel...)
+// From Alvy Ray Smith paper
+inline unsigned char INT_LERP(unsigned int p, unsigned int q, unsigned int a)
+ { return((unsigned char)(p + INT_MULT(a, q - p))); }
+
+//////////
+// Floating point LERP
+inline float FLOAT_LERP(float p, float q, float a)
+ { return( a * (q - p) + p); }
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Step function
+//
+///////////////////////////////////////////////////////////////////////////////
+inline int stepFunc(float x, float a)
+ { return(x >= a); }
+inline int stepFunc(int x, int a)
+ { return(x >= a); }
+inline int stepFunc(unsigned char x, unsigned char a)
+ { return(x >= a); }
+
+///////////////////////////////////////////////////////////////////////////////
+// Pulse function
+//
+///////////////////////////////////////////////////////////////////////////////
+inline int pulseFunc(float x, float a, float b)
+ { return(stepFunc(a, x) - stepFunc(b, x)); }
+inline int pulseFunc(int x, int a, int b)
+ { return(stepFunc(a, x) - stepFunc(b, x)); }
+inline int pulseFunc(unsigned char x, unsigned char a, unsigned char b)
+ { return(stepFunc(a, x) - stepFunc(b, x)); }
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Clamp function
+//
+///////////////////////////////////////////////////////////////////////////////
+inline float clampFunc(float x, float a, float b)
+ { return(x < a ? a : (x > b ? b : x)); }
+inline int clampFunc(int x, int a, int b)
+ { return(x < a ? a : (x > b ? b : x)); }
+inline unsigned char clampFunc(unsigned char x, unsigned char a, unsigned char b)
+ { return(x < a ? a : (x > b ? b : x)); }
+inline void* clampFunc(void* x, void* a, void* b)
+ { return(x < a ? a : (x > b ? b : x)); }
+/*
+ inline int GateInt(int nValue,int nMin,int nMax)
+ inline float GateFlt(float nValue,float nMin,float nMax)
+ inline void* GatePtr(void* pValue,void* pMin,void* pMax)
+*/
+
+
+///////////////////////////////////////////////////////////////////////////////
+// absolute integer
+//
+///////////////////////////////////////////////////////////////////////////////
+inline int AbsInt(int inValue) { return (inValue>0)?inValue:-inValue; }
+static inline int GetSign(int inValue) { return (inValue<0)?-1:1; }
+
+///////////////////////////////////////////////////////////////////////////////
+// wrapping functions for integers
+//
+///////////////////////////////////////////////////////////////////////////////
+
+inline int GetTiled(int inValue,const int nMax) {
+ int nOutValue=(inValue%nMax);
+ if (nOutValue<0)nOutValue=((nMax-1)+nOutValue);
+ return nOutValue;
+}
+
+inline int GetMirrored(int inValue,const int nMax) {
+ const int nTwoMax=(nMax*2);
+ int nOutValue=GetTiled(inValue,nTwoMax);
+ if (nOutValue>=nMax)nOutValue=((nTwoMax-1)-nOutValue);
+ return nOutValue;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// 2D-algebra
+//
+///////////////////////////////////////////////////////////////////////////////
+static inline void Get2dTangent(float inX,float inY,float* poutX,float* poutY) {
+ *poutX=inY;
+ *poutY=-inX;
+}
+///////////////////////////////////////////////////////////////////////////////
+// 2D-dot product
+///////////////////////////////////////////////////////////////////////////////
+static inline float Dot2d(float Ax,float Ay,float Bx,float By) {
+ return ((Ax*Bx)+(Ay*By));
+}
+///////////////////////////////////////////////////////////////////////////////
+// 2D-vector normalization
+///////////////////////////////////////////////////////////////////////////////
+static inline void Normalise2d(float* pX,float* pY) {
+ const float MagSqr=Dot2d(*pX,*pY,*pX,*pY);
+ float Magnitude=(float)sqrt(MagSqr);
+ if (Magnitude<=0.0f) {
+ Magnitude=0.001f;
+ }
+ const float RecipMag=1.0f/Magnitude;
+
+ *pX*=RecipMag;
+ *pY*=RecipMag;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// higher algebra
+//
+///////////////////////////////////////////////////////////////////////////////
+inline float GetRandomFloat(void) {
+ return rand()/static_cast<float>(RAND_MAX);
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Smooth step function (3x^2 - 2x^3)
+//
+///////////////////////////////////////////////////////////////////////////////
+GEM_EXTERN extern float smoothStep(float x, float a, float b);
+GEM_EXTERN extern int smoothStep(int x, int a, int b);
+GEM_EXTERN extern unsigned char smoothStep(unsigned char x, unsigned char a, unsigned char b);
+
+///////////////////////////////////////////////////////////////////////////////
+// Bias function
+//
+// Remap unit interval (curve)
+// If a == 0.5, then is linear mapping.
+///////////////////////////////////////////////////////////////////////////////
+GEM_EXTERN extern float biasFunc(float x, float a);
+
+///////////////////////////////////////////////////////////////////////////////
+// Gain function
+//
+// Remap unit interval (S-curve)
+// Will always return 0.5 when x is 0.5
+// If a == 0.5, then is linear mapping.
+///////////////////////////////////////////////////////////////////////////////
+GEM_EXTERN extern float gainFunc(float x, float a);
+
+///////////////////////////////////////////////////////////////////////////////
+// Linear function
+//
+// val should be 0 <= val <= 1.
+// ret should point at a float of enough dimensions to hold the returned value
+// For instance, numDimen == 2, should have a ret[2]
+// numDimen is the number of dimensions to compute
+// npnts is the number of points per dimension.
+//
+///////////////////////////////////////////////////////////////////////////////
+GEM_EXTERN extern void linearFunc(float val, float *ret, int numDimen, int npnts, float *pnts);
+
+///////////////////////////////////////////////////////////////////////////////
+// Spline function
+//
+// val should be 0 <= val <= 1.
+// ret should point at a float of enough dimensions to hold the returned value
+// For instance, numDimen == 2, should have a ret[2]
+// numDimen is the number of dimensions to compute
+// nknots is the number of knots per dimension.
+// There must be at least four knots!
+//
+// Thanks to
+// _Texturing and Modeling: A Procedural Approach_
+// David S. Ebert, Ed.
+///////////////////////////////////////////////////////////////////////////////
+GEM_EXTERN extern void splineFunc(float val, float *ret, int numDimen, int nknots, float *knot);
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Pixel access functions
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// Accelerated Pixel Manipulations
+// This is sort on a vector operation on 8 chars at the same time .... could be
+// implemented in MMX
+// Alpha channel is not added !! (would be nr 3 and 7)
+
+#define ADD8_NOALPHA(a,b) \
+ ((unsigned char*)(a))[0] = CLAMP_HIGH((int)((unsigned char*)(a))[0] + ((unsigned char*)(b))[0]);\
+ ((unsigned char*)(a))[1] = CLAMP_HIGH((int)((unsigned char*)(a))[1] + ((unsigned char*)(b))[1]);\
+ ((unsigned char*)(a))[2] = CLAMP_HIGH((int)((unsigned char*)(a))[2] + ((unsigned char*)(b))[2]);\
+ ((unsigned char*)(a))[4] = CLAMP_HIGH((int)((unsigned char*)(a))[4] + ((unsigned char*)(b))[4]);\
+ ((unsigned char*)(a))[5] = CLAMP_HIGH((int)((unsigned char*)(a))[5] + ((unsigned char*)(b))[5]);\
+ ((unsigned char*)(a))[6] = CLAMP_HIGH((int)((unsigned char*)(a))[6] + ((unsigned char*)(b))[6]);\
+
+#define SUB8_NOALPHA(a,b) \
+ ((unsigned char*)(a))[0] = CLAMP_LOW((int)((unsigned char*)(a))[0] - ((unsigned char*)(b))[0]);\
+ ((unsigned char*)(a))[1] = CLAMP_LOW((int)((unsigned char*)(a))[1] - ((unsigned char*)(b))[1]);\
+ ((unsigned char*)(a))[2] = CLAMP_LOW((int)((unsigned char*)(a))[2] - ((unsigned char*)(b))[2]);\
+ ((unsigned char*)(a))[4] = CLAMP_LOW((int)((unsigned char*)(a))[4] - ((unsigned char*)(b))[4]);\
+ ((unsigned char*)(a))[5] = CLAMP_LOW((int)((unsigned char*)(a))[5] - ((unsigned char*)(b))[5]);\
+ ((unsigned char*)(a))[6] = CLAMP_LOW((int)((unsigned char*)(a))[6] - ((unsigned char*)(b))[6]);\
+
+#define ADD8(a,b) \
+ ((unsigned char*)(a))[0] = CLAMP_HIGH((int)((unsigned char*)(a))[0] + ((unsigned char*)(b))[0]);\
+ ((unsigned char*)(a))[1] = CLAMP_HIGH((int)((unsigned char*)(a))[1] + ((unsigned char*)(b))[1]);\
+ ((unsigned char*)(a))[2] = CLAMP_HIGH((int)((unsigned char*)(a))[2] + ((unsigned char*)(b))[2]);\
+ ((unsigned char*)(a))[3] = CLAMP_HIGH((int)((unsigned char*)(a))[3] + ((unsigned char*)(b))[3]);\
+ ((unsigned char*)(a))[4] = CLAMP_HIGH((int)((unsigned char*)(a))[4] + ((unsigned char*)(b))[4]);\
+ ((unsigned char*)(a))[5] = CLAMP_HIGH((int)((unsigned char*)(a))[5] + ((unsigned char*)(b))[5]);\
+ ((unsigned char*)(a))[6] = CLAMP_HIGH((int)((unsigned char*)(a))[6] + ((unsigned char*)(b))[6]);\
+ ((unsigned char*)(a))[7] = CLAMP_HIGH((int)((unsigned char*)(a))[7] + ((unsigned char*)(b))[7]);\
+
+#define SUB8(a,b) \
+ ((unsigned char*)(a))[0] = CLAMP_LOW((int)((unsigned char*)(a))[0] - ((unsigned char*)(b))[0]);\
+ ((unsigned char*)(a))[1] = CLAMP_LOW((int)((unsigned char*)(a))[1] - ((unsigned char*)(b))[1]);\
+ ((unsigned char*)(a))[2] = CLAMP_LOW((int)((unsigned char*)(a))[2] - ((unsigned char*)(b))[2]);\
+ ((unsigned char*)(a))[3] = CLAMP_LOW((int)((unsigned char*)(a))[3] - ((unsigned char*)(b))[3]);\
+ ((unsigned char*)(a))[4] = CLAMP_LOW((int)((unsigned char*)(a))[4] - ((unsigned char*)(b))[4]);\
+ ((unsigned char*)(a))[5] = CLAMP_LOW((int)((unsigned char*)(a))[5] - ((unsigned char*)(b))[5]);\
+ ((unsigned char*)(a))[6] = CLAMP_LOW((int)((unsigned char*)(a))[6] - ((unsigned char*)(b))[6]);\
+ ((unsigned char*)(a))[7] = CLAMP_LOW((int)((unsigned char*)(a))[7] - ((unsigned char*)(b))[7]);\
+
+
+
+#ifdef __APPLE__
+//Ian Ollman's function to determine the cache prefetch for altivec vec_dst()
+inline UInt32 GetPrefetchConstant( int blockSizeInVectors, int blockCount, int blockStride )
+{
+ return ((blockSizeInVectors << 24) & 0x1F000000) | ((blockCount << 16) & 0x00FF0000) | (blockStride & 0xFFFF);
+}
+#endif
+
+
+#endif // for header file
+
diff --git a/packages/noncvs/windows/extra/Gem/dev/Utils/GLUtil.h b/packages/noncvs/windows/extra/Gem/dev/Utils/GLUtil.h
new file mode 100644
index 00000000..05922a04
--- /dev/null
+++ b/packages/noncvs/windows/extra/Gem/dev/Utils/GLUtil.h
@@ -0,0 +1,35 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ GemGLUtil.h
+ - contains functions for graphics
+ - part of GEM
+
+ Copyright (c) 1997-2000 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef _INCLUDE__GEM_UTILS_GLUTIL_H_
+#define _INCLUDE__GEM_UTILS_GLUTIL_H_
+
+#include "Gem/ExportDef.h"
+
+/* for t_symbol/t_atom */
+/* LATER get rid of that (std::string) */
+#include "Gem/RTE.h"
+
+/* for GLenum */
+#include "Gem/GemGL.h"
+
+GEM_EXTERN extern GLenum glReportError (void);
+GEM_EXTERN extern int getGLdefine(const char *name);
+GEM_EXTERN extern int getGLdefine(const t_symbol *name);
+GEM_EXTERN extern int getGLdefine(const t_atom *name);
+GEM_EXTERN extern int getGLbitfield(int argc, t_atom *argv);
+#endif // for header file
+
diff --git a/packages/noncvs/windows/extra/Gem/dev/Utils/GemMath.h b/packages/noncvs/windows/extra/Gem/dev/Utils/GemMath.h
new file mode 100644
index 00000000..c10f6a94
--- /dev/null
+++ b/packages/noncvs/windows/extra/Gem/dev/Utils/GemMath.h
@@ -0,0 +1,85 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ Matrix class
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef _INCLUDE__GEM_UTILS_GEMMATH_H_
+#define _INCLUDE__GEM_UTILS_GEMMATH_H_
+#include <math.h>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#ifdef __APPLE__
+# include <AvailabilityMacros.h>
+# if defined (MAC_OS_X_VERSION_10_3) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
+# else
+
+#define sqrtf(v) (float)sqrt((double)(v))
+#define cosf(v) (float)cos((double)(v))
+#define sinf(v) (float)sin((double)(v))
+#define tanf(v) (float)tan((double)(v))
+#define logf(v) (float)log((double)(v))
+#define expf(v) (float)exp((double)(v))
+
+#define atan2f(v,p) (float)atan2((double)(v), (double)(p))
+#define powf(v,p) (float)pow((double)(v), (double)(p))
+
+# endif /* OSX_10_3 */
+#endif /* __APPLE__ */
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Speedup found via Shark: ppc only
+//
+// If you do not require full precision, you can use the PowerPC floating-point
+// reciprocal square-root estimate instruction (frsqrte) instead of calling sqrt().
+//
+// If needed, you can increase the precision of the estimate returned by
+// frsqrte (5-bits of precision) by using the Newton-Raphson method for improving
+// the estimate (x0) for 1/sqrt(a) (x1 = 0.5 * x0 * [3.0 - a * x0 * x0]).
+///////////////////////////////////////////////////////////////////////////////
+#ifdef __ppc__
+# include <ppc_intrinsics.h>
+# ifdef sqrt
+# undef sqrt
+# endif
+# ifdef sqrtf
+# undef sqrtf
+# endif
+
+# define sqrt fast_sqrtf
+# define sqrtf fast_sqrtf
+
+inline double fast_sqrt(double x)
+{
+ register double est = __frsqrte(x);
+ return x * 0.5 * est * __fnmsub(est * est, x, 3.0);
+}
+
+inline float fast_sqrtf(float x)
+{
+ register float est = (float)__frsqrte(x);
+ return x * 0.5f * est * __fnmsubs(est * est, x, 3.0f);
+}
+#endif /* __ppc__ */
+
+#ifdef _WIN32
+/* seems like there is no drand48() on w32 */
+/* JMZ: this should really return "double" instead of "float",
+ * but we need only float... */
+# define drand48() ((float)rand())/((float)RAND_MAX)
+#endif /* _WIN32 */
+
+
+#endif // for header file
diff --git a/packages/noncvs/windows/extra/Gem/dev/Utils/Matrix.h b/packages/noncvs/windows/extra/Gem/dev/Utils/Matrix.h
new file mode 100644
index 00000000..9b373bee
--- /dev/null
+++ b/packages/noncvs/windows/extra/Gem/dev/Utils/Matrix.h
@@ -0,0 +1,78 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ Matrix class
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef _INCLUDE__GEM_UTILS_MATRIX_H_
+#define _INCLUDE__GEM_UTILS_MATRIX_H_
+
+#include "Gem/ExportDef.h"
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ Matrix
+
+ 4x4 Matrix class
+
+DESCRIPTION
+
+ Post-concatenation
+ Column-major
+
+-----------------------------------------------------------------*/
+class GEM_EXTERN Matrix
+{
+ public:
+
+ //////////
+ // Constructor
+ // Sets the matrix to identity
+ Matrix(void);
+
+ //////////
+ // Set the matrix to the identity
+ void identity(void);
+
+ //////////
+ // Post mulitply the matrix
+ void multiply(Matrix *pMatrix);
+
+ //////////
+ void scale(float x, float y, float z);
+
+ //////////
+ void translate(float x, float y, float z);
+
+ //////////
+ void rotateX(float degrees);
+
+ //////////
+ void rotateY(float degrees);
+
+ //////////
+ void rotateZ(float degrees);
+
+ //////////
+ void transform(float srcX, float srcY, float srcZ, float *dstX, float *dstY, float *dstZ) const;
+
+ //////////
+ // The actual matrix values
+ float mat[4][4];
+
+ //////////
+ // Utility functions
+ static void generateNormal(const float *v1, const float *v2, const float *v3, float *dst);
+};
+
+
+#endif // for header file
diff --git a/packages/noncvs/windows/extra/Gem/dev/Utils/PixPete.h b/packages/noncvs/windows/extra/Gem/dev/Utils/PixPete.h
new file mode 100644
index 00000000..fb724c93
--- /dev/null
+++ b/packages/noncvs/windows/extra/Gem/dev/Utils/PixPete.h
@@ -0,0 +1,221 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ helper stuff for ports of Pete's Plugins
+
+ http://www.petewarden.com
+
+ Copyright (c) 2004-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+#ifndef _INCLUDE__GEM_UTILS_PIXPETE_H_
+#define _INCLUDE__GEM_UTILS_PIXPETE_H_
+
+#include <stdlib.h>
+
+
+// utility functions from PeteHelpers.h
+typedef unsigned long U32;
+typedef unsigned short U16;
+typedef unsigned char U8;
+
+
+/* is this only on my system ?
+ i thought Gem's YUV is UYVY and not YVYU
+ seems weird... (jmz)
+*/
+#ifdef __APPLE__
+
+# define SHIFT_ALPHA (24)
+# define SHIFT_RED (16)
+# define SHIFT_GREEN (8)
+# define SHIFT_BLUE (0)
+
+# define SHIFT_U (24)
+# define SHIFT_Y1 (16)
+# define SHIFT_V (8)
+# define SHIFT_Y2 (0)
+
+#else
+
+# define SHIFT_ALPHA (24)
+# define SHIFT_RED (16)
+# define SHIFT_GREEN (8)
+# define SHIFT_BLUE (0)
+
+# define SHIFT_U (0)
+# define SHIFT_Y1 (8)
+# define SHIFT_V (16)
+# define SHIFT_Y2 (24)
+#endif
+
+const float Pete_Pi=3.141582f;
+const float Pete_TwoPi=(2.0f*Pete_Pi);
+const float Pete_HalfPi=(0.5f*Pete_Pi);
+
+static inline void Pete_ZeroMemory(void* pMemory,int nCount) {
+ char* pCurrent=(char*)pMemory;
+ char* pEnd=(pCurrent+nCount);
+ // while (pCurrent<pEnd) *pCurrent=0;
+ // pCurrent+=1;
+ // }
+ while(pCurrent<pEnd)*pCurrent++=0;
+// memset(pMemory,0,nCount);
+}
+
+typedef U32 PETE_PIXELDATA32;
+#define SIZEOF_PETE_PIXELDATA32 (4)
+
+typedef U32 PETE_PIXELDATA24;
+#define SIZEOF_PETE_PIXELDATA24 (3)
+
+typedef U16 PETE_PIXELDATA16;
+#define SIZEOF_PETE_PIXELDATA16 (2)
+
+static inline void Pete_CopyAndConvert24BitTo32Bit(PETE_PIXELDATA24* pSource,PETE_PIXELDATA32* pOutput,int nPixelCount) {
+
+ char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA24);
+ char* pCurrentSource=((char*)pSource);
+ char* pCurrentOutput=((char*)pOutput);
+
+ while (pCurrentSource<pSourceEnd) {
+ *((PETE_PIXELDATA32*)pCurrentOutput)=
+ *((PETE_PIXELDATA24*)pCurrentSource);
+
+ pCurrentSource+=SIZEOF_PETE_PIXELDATA24;
+ pCurrentOutput+=SIZEOF_PETE_PIXELDATA32;
+ }
+}
+
+static inline void Pete_CopyAndConvert32BitTo24Bit(PETE_PIXELDATA32* pSource,PETE_PIXELDATA24* pOutput,int nPixelCount) {
+
+ char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA32);
+ char* pCurrentSource=((char*)pSource);
+ char* pCurrentOutput=((char*)pOutput);
+
+ while (pCurrentSource<pSourceEnd) {
+ *((PETE_PIXELDATA24*)pCurrentOutput)=
+ *((PETE_PIXELDATA32*)pCurrentSource);
+
+ pCurrentSource+=SIZEOF_PETE_PIXELDATA32;
+ pCurrentOutput+=SIZEOF_PETE_PIXELDATA24;
+ }
+}
+
+static inline void Pete_InPlaceConvert24BitTo32Bit(PETE_PIXELDATA24* pBuffer,int nPixelCount) {
+ char* pBufferStart=(char*)pBuffer;
+
+ char* pBuffer32Current=(pBufferStart+((nPixelCount-1)*SIZEOF_PETE_PIXELDATA32));
+ char* pBuffer24Current=(pBufferStart+((nPixelCount-1)*SIZEOF_PETE_PIXELDATA24));
+
+ while (pBuffer32Current>=pBufferStart) {
+
+ *((PETE_PIXELDATA32*)pBuffer32Current)=
+ *((PETE_PIXELDATA24*)pBuffer24Current);
+
+ pBuffer32Current-=SIZEOF_PETE_PIXELDATA32;
+ pBuffer24Current-=SIZEOF_PETE_PIXELDATA24;
+ }
+}
+
+static inline void Pete_CopyAndConvert16Bit565To32Bit(PETE_PIXELDATA16* pSource,PETE_PIXELDATA32* pOutput,int nPixelCount) {
+
+ char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA16);
+ char* pCurrentSource=((char*)pSource);
+ char* pCurrentOutput=((char*)pOutput);
+
+ while (pCurrentSource<pSourceEnd) {
+
+ PETE_PIXELDATA16 SourceColour=
+ *((PETE_PIXELDATA16*)pCurrentSource);
+
+ const int nMaskedRed=(SourceColour>>11)&31;
+ const int nMaskedGreen=(SourceColour>>5)&63;
+ const int nMaskedBlue=(SourceColour>>0)&31;
+
+ const int nNormalizedRed=(nMaskedRed<<3)|(nMaskedRed>>2);
+ const int nNormalizedGreen=(nMaskedGreen<<2)|(nMaskedGreen>>4);
+ const int nNormalizedBlue=(nMaskedBlue<<3)|(nMaskedBlue>>2);
+
+ const PETE_PIXELDATA32 OutputColour=
+ (nNormalizedRed<<16)|
+ (nNormalizedGreen<<8)|
+ (nNormalizedBlue<<0);
+
+ *((PETE_PIXELDATA32*)pCurrentOutput)=OutputColour;
+
+ pCurrentSource+=SIZEOF_PETE_PIXELDATA16;
+ pCurrentOutput+=SIZEOF_PETE_PIXELDATA32;
+
+ }
+
+}
+
+static inline void Pete_CopyAndConvert32BitTo16Bit565(PETE_PIXELDATA32* pSource,PETE_PIXELDATA16* pOutput,int nPixelCount) {
+
+ char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA32);
+ char* pCurrentSource=((char*)pSource);
+ char* pCurrentOutput=((char*)pOutput);
+
+ while (pCurrentSource<pSourceEnd) {
+
+ PETE_PIXELDATA32 SourceColour=
+ *((PETE_PIXELDATA32*)pCurrentSource);
+
+ const int nSourceRed=(SourceColour>>16)&0xff;
+ const int nSourceGreen=(SourceColour>>8)&0xff;
+ const int nSourceBlue=(SourceColour>>0)&0xff;
+
+ const int nMaskedRed=(nSourceRed>>3);
+ const int nMaskedGreen=(nSourceGreen>>2);
+ const int nMaskedBlue=(nSourceBlue>>3);
+
+ PETE_PIXELDATA16 OutputColour=
+ (nMaskedRed<<11)|
+ (nMaskedGreen<<5)|
+ (nMaskedBlue<<0);
+
+ *((PETE_PIXELDATA16*)pCurrentOutput)=OutputColour;
+
+ pCurrentSource+=SIZEOF_PETE_PIXELDATA32;
+ pCurrentOutput+=SIZEOF_PETE_PIXELDATA16;
+ }
+}
+typedef void* SPete_MemHandle;
+
+inline SPete_MemHandle Pete_NewHandle(int nBytesToAlloc) {
+ return malloc(nBytesToAlloc);
+}
+
+inline void Pete_FreeHandle(SPete_MemHandle InHandle) {
+ free(InHandle);
+}
+
+inline void* Pete_LockHandle(SPete_MemHandle InHandle) {
+ return InHandle;
+}
+
+inline void Pete_UnLockHandle(SPete_MemHandle InHandle) {
+ // do nothing
+}
+
+const int cnBiggestSignedInt=0x7fffffff;
+
+inline int GetLuminance(const U32 inColour) {
+ const int nRed=(inColour&(0xff<<SHIFT_RED))>>16;
+ const int nGreen=(inColour&(0xff<<SHIFT_GREEN))>>8;
+ const int nBlue=(inColour&(0xff<<SHIFT_BLUE))>>0;
+
+ const int nLuminance =
+ ((77 * nRed)+
+ (150* nGreen)+ // used to be 50 which is plain wron
+ (29 * nBlue));
+
+ return nLuminance;
+}
+
+#endif /* _INCLUDE__GEM_UTILS_PIXPETE_H_ */
+// end of PeteHelpers.h stuff
diff --git a/packages/noncvs/windows/extra/Gem/dev/Utils/SIMD.h b/packages/noncvs/windows/extra/Gem/dev/Utils/SIMD.h
new file mode 100644
index 00000000..b6ed0024
--- /dev/null
+++ b/packages/noncvs/windows/extra/Gem/dev/Utils/SIMD.h
@@ -0,0 +1,117 @@
+
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ include file for SIMD
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+/*
+ * compiler-issues:
+ *
+ * gcc: when gcc is invoked with "-mmmx" (or "-msse2" or "-maltivec")
+ * the defines __MMX__ (or corresponding) will be defined automatically
+ *
+ * vc6: you will have to install the microsoft processor-pack to use MMX/SSE2
+ * you have to have the sp5 for vc6 installed (note: do not install sp6!!)
+ * vc6/vc7: (i think) you need to define __MMX__ (and friends) by hand
+ */
+
+#ifndef _INCLUDE__GEM_UTILS_SIMD_H_
+#define _INCLUDE__GEM_UTILS_SIMD_H_
+
+#define GEM_VECTORALIGNMENT 128
+
+const int GEM_SIMD_NONE=0;
+const int GEM_SIMD_MMX=1;
+const int GEM_SIMD_SSE2=2;
+const int GEM_SIMD_ALTIVEC=3;
+
+
+#if defined __APPLE__ && defined __VEC__
+# ifndef __APPLE_ALTIVEC__
+# undef __VEC__
+# endif
+#endif
+
+/* include for SIMD on PC's */
+#ifdef __SSE2__
+#include <emmintrin.h>
+// for icc this should be <dvec.h>
+typedef union{
+ unsigned char c[16];
+ __m128i v;
+} vector_128;
+#elif defined __VEC__
+/* for AltiVec (PowerPC) */
+typedef union{
+ unsigned char c[16];
+ vector unsigned char v;
+} vector_128;
+#endif
+
+#if defined __MMX__
+# include <mmintrin.h>
+// for icc this should be <ivec.h>
+typedef union{
+ __m64 v; unsigned char c[8];
+} vector64i;
+
+#endif
+
+
+#ifdef __SSE__
+#include <xmmintrin.h>
+
+typedef union{
+ __m128 m; float f[4];
+} vector128f;
+#endif
+
+#include "Gem/ExportDef.h"
+
+
+/* this is a help-class to query the capabilities of the cpu
+ * whenever you want to use SIMD-optimized code, you should
+ * make sure you chose the code-block based on the "cpuid" value
+ * of this class and NOT simply on preprocessor defines.
+ *
+ * this class needs only be instantiated once (and it is done in GemMan)
+ * this sets the cpuid
+ */
+class GEM_EXTERN GemSIMD
+{
+ public:
+ GemSIMD(void);
+ virtual ~GemSIMD(void);
+
+ /* this gets the "cpuid" (something like GEM_SIMD_NONE) */
+ static int getCPU(void);
+
+ /* change the cpuid returned by getCPU()
+ * you can only set the cpuid to something that is actually supported
+ * by your processor
+ */
+ static int requestCPU(int cpuid);
+
+ /* performs a runtime-check (if possible) to determine the capabilities
+ * of the CPU
+ * sets realcpuid appropriately and returns this value
+ */
+ static int simd_runtime_check(void);
+
+ private:
+ /* this is the maximum capability of the CPU */
+ static int realcpuid;
+ /* this is the current choosen capability (normally this equals realcpuid) */
+ static int cpuid;
+};
+
+#endif /* _INCLUDE__GEM_UTILS_SIMD_H_ */
diff --git a/packages/noncvs/windows/extra/Gem/dev/Utils/Vector.h b/packages/noncvs/windows/extra/Gem/dev/Utils/Vector.h
new file mode 100644
index 00000000..b0b657c5
--- /dev/null
+++ b/packages/noncvs/windows/extra/Gem/dev/Utils/Vector.h
@@ -0,0 +1,77 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ vector-classes
+
+ zmoelnig@iem.at, tigital@mac.com
+
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef _INCLUDE__GEM_UTILS_VECTOR_H_
+#define _INCLUDE__GEM_UTILS_VECTOR_H_
+
+#include "Gem/ExportDef.h"
+
+
+
+// This is our 2D point class. This will be used to store the UV coordinates.
+class GEM_EXTERN CVector2 {
+public:
+ float x, y;
+};
+
+
+// This is our basic 3D point/vector class
+class GEM_EXTERN CVector3 {
+public:
+ // the elements of a vector:
+ float x, y, z;
+
+ // A default constructor
+ CVector3(void);
+
+ // This is our constructor that allows us to initialize our data upon creating an instance
+ CVector3(float X, float Y, float Z);
+
+ // Here we overload the + operator so we can add vectors together
+ CVector3 operator+(CVector3 vVector) const;
+
+ // Here we overload the - operator so we can subtract vectors
+ CVector3 operator-(CVector3 vVector) const;
+
+ // Here we overload the - operator so we can negate the vector
+ CVector3 operator-(void) const;
+
+ // Here we overload the * operator so we can multiply by scalars
+ CVector3 operator*(float num) const;
+
+ // Here we overload the * operator so we can dot-multiply
+ float operator*(CVector3 vVector) const;
+
+ // cross-multiplication
+ CVector3 cross(CVector3 vVector) const;
+
+ // Here we overload the / operator so we can divide by a scalar
+ CVector3 operator/(float num) const;
+
+
+ // here we calculate the absolute-value of the vector
+ float abs(void) const;
+
+ // here we calculate the square of the absolute-value of the vector
+ float abs2(void) const;
+
+ // here we normalize the vector
+ CVector3 normalize(void) const;
+
+ // here we compare 2 vectors on approx. equality
+ bool equals(CVector3 vVector, float epsilon) const;
+
+
+};
+
+#endif /* _INCLUDE__GEM_UTILS_VECTOR_H_ */
diff --git a/packages/noncvs/windows/extra/Gem/dev/Utils/any.h b/packages/noncvs/windows/extra/Gem/dev/Utils/any.h
new file mode 100644
index 00000000..1294c8c4
--- /dev/null
+++ b/packages/noncvs/windows/extra/Gem/dev/Utils/any.h
@@ -0,0 +1,308 @@
+/*
+ * (C) Copyright Christopher Diggins 2005
+ * (C) Copyright Pablo Aguilar 2005
+ * (C) Copyright Kevlin Henney 2001
+ *
+ * Copyright (C) 2010-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
+ * downloaded this code from http://www.codeproject.com/KB/cpp/dynamic_typing.aspx
+ * changed namespace/defines "cdiggins" to something "gem"
+ *
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef GEM_ANY_HPP
+#define GEM_ANY_HPP
+
+#include "Gem/ExportDef.h"
+
+#ifdef _MSC_VER
+# pragma warning( push )
+# pragma warning( disable: 4275 )
+#endif
+
+#include <stdexcept>
+#include <typeinfo>
+#include <algorithm>
+
+
+namespace gem
+{
+ struct GEM_EXTERN bad_any_cast : std::bad_cast {
+ bad_any_cast(const std::type_info& src, const std::type_info& dest)
+ : from(src.name()), to(dest.name())
+ { }
+ virtual ~bad_any_cast(void) throw()
+ { }
+ virtual const std::string what(void) {
+ std::string result = std::string("bad cast(");
+ result+= from;
+ result+= std::string("->");
+ result+= to;
+ result+= std::string(")");
+ return result;
+ }
+ const std::string from;
+ const std::string to;
+ };
+
+ namespace any_detail {
+ // function pointer table
+
+ struct fxn_ptr_table {
+ const std::type_info& (*get_type)(void);
+ void (*static_delete)(void**);
+ void (*clone)(void* const*, void**);
+ void (*move)(void* const*,void**);
+ };
+
+ // static functions for small value-types
+
+ template<bool is_small>
+ struct fxns
+ {
+ template<typename T>
+ struct type {
+ static const std::type_info& get_type(void) {
+ return typeid(T);
+ }
+ static void static_delete(void** x) {
+ reinterpret_cast<T*>(x)->~T();
+ }
+ static void clone(void* const* src, void** dest) {
+ new(dest) T(*reinterpret_cast<T const*>(src));
+ }
+ static void move(void* const* src, void** dest) {
+ reinterpret_cast<T*>(dest)->~T();
+ *reinterpret_cast<T*>(dest) = *reinterpret_cast<T const*>(src);
+ }
+ };
+ };
+
+ // static functions for big value-types (bigger than a void*)
+
+ template<>
+ struct fxns<false>
+ {
+ template<typename T>
+ struct type {
+ static const std::type_info& get_type(void) {
+ return typeid(T);
+ }
+ static void static_delete(void** x) {
+ delete(*reinterpret_cast<T**>(x));
+ }
+ static void clone(void* const* src, void** dest) {
+ *dest = new T(**reinterpret_cast<T* const*>(src));
+ }
+ static void move(void* const* src, void** dest) {
+ (*reinterpret_cast<T**>(dest))->~T();
+ **reinterpret_cast<T**>(dest) = **reinterpret_cast<T* const*>(src);
+ }
+ };
+ };
+
+ template<typename T>
+ struct get_table
+ {
+ static const bool is_small = sizeof(T) <= sizeof(void*);
+
+ static fxn_ptr_table* get(void)
+ {
+ static fxn_ptr_table static_table = {
+ fxns<is_small>::template type<T>::get_type
+ , fxns<is_small>::template type<T>::static_delete
+ , fxns<is_small>::template type<T>::clone
+ , fxns<is_small>::template type<T>::move
+ };
+ return &static_table;
+ }
+ };
+
+ struct empty {
+ };
+ } // namespace any_detail
+
+
+ struct GEM_EXTERN any
+ {
+ // structors
+
+ template <typename T>
+ any(const T& x) : table(NULL), object(NULL) {
+ table = any_detail::get_table<T>::get();
+ if (sizeof(T) <= sizeof(void*)) {
+ new(&object) T(x);
+ }
+ else {
+ object = new T(x);
+ }
+ }
+
+ any(void) : table(NULL), object(NULL) {
+ table = any_detail::get_table<any_detail::empty>::get();
+ object = NULL;
+ }
+
+ any(const any& x) : table(NULL), object(NULL) {
+ table = any_detail::get_table<any_detail::empty>::get();
+ assign(x);
+ }
+
+ virtual ~any(void) {
+ table->static_delete(&object);
+ }
+
+ // assignment
+
+ any& assign(const any& x) {
+ // are we copying between the same type?
+
+ if (table == x.table) {
+ // if so, we can avoid reallocation
+
+ table->move(&x.object, &object);
+ }
+ else {
+ reset();
+ x.table->clone(&x.object, &object);
+ table = x.table;
+ }
+ return *this;
+ }
+
+ template <typename T>
+ any& assign(const T& x)
+ {
+ // are we copying between the same type?
+
+ any_detail::fxn_ptr_table* x_table = any_detail::get_table<T>::get();
+ if (table == x_table) {
+ // if so, we can avoid deallocating and resuse memory
+
+ if (sizeof(T) <= sizeof(void*)) {
+ // create copy on-top of object pointer itself
+
+ new(&object) T(x);
+ }
+ else {
+ // create copy on-top of old version
+
+ new(object) T(x);
+ }
+ }
+ else {
+ reset();
+ if (sizeof(T) <= sizeof(void*)) {
+ // create copy on-top of object pointer itself
+
+ new(&object) T(x);
+ // update table pointer
+
+ table = x_table;
+ }
+ else {
+ object = new T(x);
+ table = x_table;
+ }
+ }
+ return *this;
+ }
+
+ // assignment operator
+
+ template<typename T>
+ any& operator=(T const& x) {
+ return assign(x);
+ }
+ any& operator=(const any& x) {
+ return assign(x);
+ }
+
+ // utility functions
+
+ any& swap(any& x) {
+ std::swap(table, x.table);
+ std::swap(object, x.object);
+ return *this;
+ }
+
+ const std::type_info& get_type(void) const {
+ return table->get_type();
+ }
+
+ template<typename T>
+ const T& cast(void) const {
+ if (get_type() != typeid(T)) {
+ throw bad_any_cast(get_type(), typeid(T));
+ }
+ if (sizeof(T) <= sizeof(void*)) {
+ return *reinterpret_cast<T const*>(&object);
+ }
+ else {
+ return *reinterpret_cast<T const*>(object);
+ }
+ }
+
+ // implicit casting is disabled by default
+
+ #ifdef ANY_IMPLICIT_CASTING
+ // automatic casting operator
+
+ template<typename T>
+ operator T(void) const {
+ return cast<T>();
+ }
+ #endif // implicit casting
+
+
+ bool empty(void) const {
+ return table == any_detail::get_table<any_detail::empty>::get();
+ }
+
+ void reset(void)
+ {
+ if (empty()) return;
+ table->static_delete(&object);
+ table = any_detail::get_table<any_detail::empty>::get();
+ object = NULL;
+ }
+
+ // fields
+
+ any_detail::fxn_ptr_table* table;
+ void* object;
+ };
+
+ // boost::any-like casting
+
+ template<typename T>
+ T* any_cast(any* this_) {
+ if (this_->get_type() != typeid(T)) {
+ throw bad_any_cast(this_->get_type(), typeid(T));
+ }
+ if (sizeof(T) <= sizeof(void*)) {
+ return reinterpret_cast<T*>(&this_->object);
+ }
+ else {
+ return reinterpret_cast<T*>(this_->object);
+ }
+ }
+
+ template<typename T>
+ T const* any_cast(any const* this_) {
+ return any_cast<T>(const_cast<any*>(this_));
+ }
+
+ template<typename T>
+ T const& any_cast(any const& this_){
+ return *any_cast<T>(const_cast<any*>(&this_));
+ }
+}
+
+#ifdef _MSC_VER
+# pragma warning( pop )
+#endif
+
+#endif // GEM_ANY_HPP