*Sigh* Broken again, in another way.
This works with VC++2008
#ifndef __MATRIX1_CALLDLL_H__
#define __MATRIX1_CALLDLL_H__
//#include <DarkGDK.h>
#include <DarkSDKSystem.h>
#define DLL_INLINE __forceinline
// Change the DWORD to char* for SDK 12/03/2007
//#define FN_NAME DWORD
#define FN_NAME char*
// These are incorrectly defined in DarkSDKSystem.h
void dbLoadDLL ( FN_NAME pDLLFile, int dllid );
int dbDLLCallExist ( int dllid, FN_NAME pDLLFunction );
DWORD dbCallDLL ( int dllid, FN_NAME pDLLFunction);
DWORD dbCallDLL ( int dllid, FN_NAME pDLLFunction, DWORD P1);
DWORD dbCallDLL ( int dllid, FN_NAME pDLLFunction, DWORD P1,DWORD P2);
DWORD dbCallDLL ( int dllid, FN_NAME pDLLFunction, DWORD P1,DWORD P2,DWORD P3);
DWORD dbCallDLL ( int dllid, FN_NAME pDLLFunction, DWORD P1,DWORD P2,DWORD P3,DWORD P4);
DWORD dbCallDLL ( int dllid, FN_NAME pDLLFunction, DWORD P1,DWORD P2,DWORD P3,DWORD P4,DWORD P5);
DWORD dbCallDLL ( int dllid, FN_NAME pDLLFunction, DWORD P1,DWORD P2,DWORD P3,DWORD P4,DWORD P5,DWORD P6);
DWORD dbCallDLL ( int dllid, FN_NAME pDLLFunction, DWORD P1,DWORD P2,DWORD P3,DWORD P4,DWORD P5,DWORD P6,DWORD P7);
DWORD dbCallDLL ( int dllid, FN_NAME pDLLFunction, DWORD P1,DWORD P2,DWORD P3,DWORD P4,DWORD P5,DWORD P6,DWORD P7,DWORD P8);
DWORD dbCallDLL ( int dllid, FN_NAME pDLLFunction, DWORD P1,DWORD P2,DWORD P3,DWORD P4,DWORD P5,DWORD P6,DWORD P7,DWORD P8,DWORD P9 );
DWORD dbCallDLL ( int dllid, FN_NAME pDLLFunction, DWORD P1,DWORD P2,DWORD P3,DWORD P4,DWORD P5,DWORD P6,DWORD P7,DWORD P8,DWORD P9,DWORD P10 );
DWORD dbCallDLLX ( int dllid, FN_NAME pDLLFunction, DWORD pDataPtr, DWORD dwNumberOfDWORDS );
namespace Matrix1_CallDLL__
{
// Helper class - Accepts data of all types and stores in a DWORD
// Note - All constructors are explicit, so we can't create an
// object of this class by accident.
// Also, will only work on data of up to 4 bytes in size
// (not long longs, or doubles).
class Conv
{
public:
// Constructors - these accept the incoming value
explicit Conv(const float &x)
{
Value = *(DWORD*)&x;
}
explicit Conv(const int &x)
{
Value = (DWORD)x;
}
explicit Conv(const DWORD &x)
{
Value = x;
}
explicit Conv(const void* x)
{
Value = (DWORD)x;
}
// Function operator - called to get the DWORD equivalent of the
// input value
DWORD operator() () const
{
return Value;
}
// Conversion operators - used when extracting the return value
operator float() const
{
return *(float*)&Value;
}
operator int() const
{
return *(int*)&Value;
}
operator DWORD() const
{
return Value;
}
template <typename T>
operator T*() const
{
return (T*)Value;
}
private:
DWORD Value;
};
// Helper functions
DLL_INLINE void dbLoadDLL(const char* DLLName, int ID)
{
::dbLoadDLL( (FN_NAME)DLLName, ID );
}
DLL_INLINE int
dbDLLCallExist(int ID, const char* Function)
{
return ::dbDLLCallExist( ID, (FN_NAME)Function );
}
DLL_INLINE Conv
dbCallDLL(int ID, const char* Function)
{
return Conv( ::dbCallDLL(ID, (FN_NAME)Function ) );
}
template <typename T>
DLL_INLINE Conv
dbCallDLL(int ID, const char* Function, T t)
{
return Conv( ::dbCallDLL(ID, (FN_NAME)Function, Conv(t)() ) );
}
template <typename T1, typename T2>
DLL_INLINE Conv
dbCallDLL(int ID, const char* Function, T1 t1, T2 t2)
{
return Conv( ::dbCallDLL(ID, (FN_NAME)Function, Conv(t1)(), Conv(t2)() ) );
}
template <typename T1, typename T2, typename T3>
DLL_INLINE Conv
dbCallDLL(int ID, const char* Function, T1 t1, T2 t2, T3 t3)
{
return Conv( ::dbCallDLL(ID, (FN_NAME)Function, Conv(t1)(), Conv(t2)(), Conv(t3)() ) );
}
template <typename T1, typename T2, typename T3, typename T4>
DLL_INLINE Conv
dbCallDLL(int ID, const char* Function, T1 t1, T2 t2, T3 t3, T4 t4)
{
return Conv( ::dbCallDLL(ID, (FN_NAME)Function, Conv(t1)(), Conv(t2)(), Conv(t3)(),
Conv(t4)() ) );
}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
DLL_INLINE Conv
dbCallDLL(int ID, const char* Function, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
{
return Conv( ::dbCallDLL(ID, (FN_NAME)Function, Conv(t1)(), Conv(t2)(), Conv(t3)(),
Conv(t4)(), Conv(t5)() ) );
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6>
DLL_INLINE Conv
dbCallDLL(int ID, const char* Function, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5,
T6 t6)
{
return Conv( ::dbCallDLL(ID, (FN_NAME)Function, Conv(t1)(), Conv(t2)(), Conv(t3)(),
Conv(t4)(), Conv(t5)(), Conv(t6)() ) );
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7>
DLL_INLINE Conv
dbCallDLL(int ID, const char* Function, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5,
T6 t6, T7 t7)
{
return Conv( ::dbCallDLL(ID, (FN_NAME)Function, Conv(t1)(), Conv(t2)(), Conv(t3)(),
Conv(t4)(), Conv(t5)(), Conv(t6)(),
Conv(t7)() ) );
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8>
DLL_INLINE Conv
dbCallDLL(int ID, const char* Function, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5,
T6 t6, T7 t7, T8 t8)
{
return Conv( ::dbCallDLL(ID, (FN_NAME)Function, Conv(t1)(), Conv(t2)(), Conv(t3)(),
Conv(t4)(), Conv(t5)(), Conv(t6)(),
Conv(t7)(), Conv(t8)() ) );
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9>
DLL_INLINE Conv
dbCallDLL(int ID, const char* Function, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5,
T6 t6, T7 t7, T8 t8, T9 t9)
{
return Conv( ::dbCallDLL(ID, (FN_NAME)Function, Conv(t1)(), Conv(t2)(), Conv(t3)(),
Conv(t4)(), Conv(t5)(), Conv(t6)(),
Conv(t7)(), Conv(t8)(), Conv(t9)() ) );
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10>
DLL_INLINE Conv
dbCallDLL(int ID, const char* Function, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5,
T6 t6, T7 t7, T8 t8, T9 t9, T10 t10)
{
return Conv( ::dbCallDLL(ID, (FN_NAME)Function, Conv(t1)(), Conv(t2)(), Conv(t3)(),
Conv(t4)(), Conv(t5)(), Conv(t6)(),
Conv(t7)(), Conv(t8)(), Conv(t9)(),
Conv(t10)() ) );
}
template <typename T>
DLL_INLINE Conv
dbCallDLLX(int ID, const char* Function, T* PtrToStruct, DWORD SizeInDwords = sizeof(T)/4 )
{
return Conv( ::dbCallDLLX(ID, (FN_NAME)Function, Conv(PtrToStruct), SizeInDwords ) );
}
}
using namespace Matrix1_CallDLL__;
#endif