/********************************************** ** ** ** Marshalling Compiler by Martijn Thie ** ** ** **********************************************/ //----------------------------------------------- // Remove some unwanted keywords //----------------------------------------------- #define WINAPI #define __stdcall #define __cdecl #define __pascal #define __clrcall #define far #define near //----------------------------------------------- // Define some commons //----------------------------------------------- #define FALSE 0 #define TRUE 1 #define CONST const //----------------------------------------------- // Define some standard Windows types //----------------------------------------------- typedef unsigned long ULONG; typedef ULONG *PULONG; typedef unsigned short USHORT; typedef USHORT *PUSHORT; typedef unsigned char UCHAR; typedef UCHAR *PUCHAR; typedef char *PSZ; typedef unsigned long DWORD; typedef int BOOL; typedef unsigned char BYTE; typedef unsigned short WORD; typedef float FLOAT; typedef FLOAT *PFLOAT; typedef BOOL *PBOOL; typedef BOOL *LPBOOL; typedef BYTE *PBYTE; typedef BYTE *LPBYTE; typedef int *PINT; typedef int *LPINT; typedef WORD *PWORD; typedef WORD *LPWORD; typedef long *LPLONG; typedef DWORD *PDWORD; typedef DWORD *LPDWORD; typedef void *LPVOID; typedef CONST void *LPCVOID; typedef int INT; typedef unsigned int UINT; typedef unsigned int *PUINT; //----------------------------------------------- // These will be removed without beeing evaluated //----------------------------------------------- #pragma once #include //----------------------------------------------- // The #if will not be evaluated and only the // first definition of ExternC is used. //----------------------------------------------- #if defined(__not_evaluated__) #define SOMESIZE 10 #else #define SOMESIZE 99 #endif //----------------------------------------------- // An enumerator definition //----------------------------------------------- enum MyEnum //be sure to provide a type-name, anonymous enums are not supported { fieldA = 0x1, fieldB = 10, fieldC } MyEnumVar; //Variable definition is ignored //----------------------------------------------- // Struct definitions //----------------------------------------------- typedef struct MyTiny { long fieldA; LPBYTE fieldB; }; //the typedef keyword before a struct or enum is optional struct SomeStructType //make sure to use a type-name. Anonymous structs are not supported { bool fieldA; bool* fieldB; bool fieldC[2]; char fieldD[9]; char fieldE[][SOMESIZE]; char fieldF; char* fieldG; wchar_t fieldH; wchar_t* fieldI; UINT fieldJ; MyEnum fieldK; MyEnum* fieldL; MyTiny* fieldM; //handle nesting of structs like this, you can't declare a nested structure } SomeStruct; //SomeStruct variable declaration is ignored //----------------------------------------------- // Function definitions //----------------------------------------------- extern HRESULT WINAPI MyFunction(LPSTR prmA, LPWSTR prmB, SomeStructType* prmC); extern bool __cdecl SomeFunction(MyEnum prmA, MyEnum* prmB, bool prmC); extern "C" void ThisFunction(); //----------------------------------------------- // Typedefs and #defines are evaluated before // function, struct and enum declarations. //----------------------------------------------- typedef unsigned int HRESULT; #define LPSTR char* #define LPWSTR wchar_t* //-----------------------------------------------