// TOGETHER 4.x C++ MACRO DEFINITIONS SUPPORT FILE

/*
 * This file contains macro definitions for the following:
 *    - Macros specific to Together/Professional (original Together release)
 *    - Microsoft (c) Foundation Classes (MFC) library
 *    - ATL
 *    - Borland C++ version 5.0
 *    - Borland C++ Builder
 */

/*
 * Wrapper macros TS_PREINCLUDE_XXX for managing groups of macro definitions.
 *
 * These macros enable you to control whether the group of macro definitions for
 * a specific product will be processed by Together or not (they are used in #ifdef/#endif directives
 * enclosing a group of macros for the specific product)
 *
 * You must define only those wrapper macros that correspond to the product you are using. For example,
 * if you use Microsoft VC (VS, ATL, MFC), wrapper macros for other products (Borland) should not be defined.
 * Otherwise there could be macros with the same name but different definitions. That might cause
 * Together to display numerous error messages while parsing source code files in your Together project.
 *
 * IMPORTANT Together 2.x - 3.x note:
 * - In version 2.x names staring with OI_PREINCUDE_XXX were used
 * - Beginning with version 3.0, macro definitions can be edited via the
 *   Options dialog: Options | Project | Source code | C++ | Define.
 *   Using the Options dialog to define/undefine macros is recommended over
 *   direct editing of this file.
 *
 * By default only Microsoft VC - related wrapper macros are defined. This is done in the
 * "Options | Project | Source code | C++ | Define" option.
 */

/*
 * Wrapper macros added in version 4.0:
 *   TS_PREINCLUDE_VC_STL
 *   TS_PREINCLUDE_VC_STDLIB
 * These macros allow to control preinclude of headers from Microsoft Visual C++ STL and
 * Standard C++ Library respectively . Note that it is necessary to add corresponding
 * folders to Together project to use these wrapper macros. 
 * Please search for occurence of this macro for more details.
 * 
 * Wrapper macros added in version 4.1:
 *   TS_PREINCLUDE_BCPP_STL
 *   TS_PREINCLUDE_BCPP_STDLIB
 *   TS_PREINCLUDE_BCB_STDLIB
 * These macros allow to control preinclude of headers from Borland C++ STL, Standard 
 * C++ Library and Borland C++ Builder Standard C++ Library. Note that it is necessary 
 * to add corresponding folders to Together project to use these wrapper macros. 
 * Please search for occurence of this macro for more details.
 */
 
// The following macro definitions were always "on" in Together/Professional
// (the original release of Together).
// It is recommended to keep it defined (defined in options by default) as
// it is necessary for proper working of OLE/COM Interface Extractor (from
// Together/Professional).
//#define _TCPP_

// Used to control MS-Windows related macro definitions (defined in options by default).
//#define TS_PREINCLUDE_MICROSOFT_WINDOWS

// Used to control Microsoft COM related macro definitions (defined in options by default).
//#define TS_PREINCLUDE_MICROSOFT_COM

// Used to control Microsoft C++ and MFC related macro definitions (defined in options by default)
// Search for the next occurence of this macro to change "level of details"
// of MFC macros expansion. (macros MFC_MACROS_SHOW_EXPANDED, MFC_MACROS_SHOW)
//#define TS_PREINCLUDE_MICROSOFT_VISUAL_C

// Used to control ATL related macro definitions (defined in options by default)
//#define TS_PREINCLUDE_ATL

// Used to control Borland C++ Builder related macro definitions.
//#define TS_PREINCLUDE_BORLAND_CPP_BUILDER

// Used to control Borland C++ related macro definitions
//#define TS_PREINCLUDE_BORLAND_CPP


/*
 * Here you may also add other macro definitions required for correct parsing
 * of your C++ project files when these are not available from other sources.
 *
 * For example, if you don't want to include in your Together project all the header files from some
 * huge library in order to save resouces or use #include <file.ext> style rather than
 * #include "file.ext" for external headers while the option
 * "Options | Project | Source code | C++ | skip standard includes"
 * is on (by default it is on - to save resources too), then macros originally
 * defined in that files will not be availabe to Together parser. If you use these
 * macros in your source files, you'll probably get problems while parsing
 * (syntax errors reported by Together even though you can compile your files w/o errors).
 * To avoid such problems you may copy required definitions here as they are or even
 * simplify them by leaving only a part providing syntax correctness of the code after expanding.
 *
 * Please also ensure that following options are set to the appropriate values:
 * (note: most of them are avaialble in the "Options" dialog as described above)
 * parser.cpp.preprocessor
 * parser.cpp.define
 * parser.cpp.preinclude_file
 * parser.cpp.skip_standard_directories
 */

// **********************************************************************
//
//  Standard or widely used preprocessor symbols
//
// **********************************************************************

#define __cplusplus 1
#define thiscall

#define FAR
#define FARSTRUCT
#define NEAR
#define CONST               const

#define EXTERN_C
#define EXTERN
#define PASCAL
#define CDECL

#define UNALIGNED

// Keep them as identifiers
//#define FALSE   0
//#define TRUE    1
//#define NULL    0

// here are new keywords of ISO 646 standard
#if defined(TS_KEYWORDS_ISO646) || defined(OI_support_keywords_ISO646)

#define and     &&
#define and_eq  &=
#define bitand  &
#define bitor   |
#define compl   ~
#define not     !
#define not_eq  !=
#define or      ||
#define or_eq   |=
#define xor     ^
#define xor_eq  ^=
#define auto
#define register

#endif //TS_KEYWORDS_ISO646


// **********************************************************************
//
// Microsoft Windows specific symbols
//
// **********************************************************************

//Comment should be presented

#if defined(TS_KEYWORDS_VC) || defined(OI_support_VC)

//bad_typeid - exception - should be recognized by Together as ID
//bad_cast - exception - should be recognized by Together as ID
#define __based( x )
#define _based( x )
//_bstr_t  - should be recognized by Together as ID
//_com_error  - should be recognized by Together as ID
//_com_ptr_t  - should be recognized by Together as ID
//dllimport  - should be recognized by Together as ID as attr. __declspec
//dllexport  - should be recognized by Together as ID as attr. __declspec
#define __single_inheritance
#define __multiple_inheritance
#define __virtual_inheritance
#define __inline inline
#define __int8 char
#define __int16 short
#define __int32 int
#define __int64 long
//naked - should be recognized by Together as ID as attr. __declspec
//nothrow - should be recognized by Together as ID as attr. __declspec
//property - should be recognized by Together as ID as attr. __declspec
//selectany - should be recognized by Together as ID as attr. __declspec
//thread - should be recognized by Together as ID as attr. __declspec
#define __try try
#define __finally
//__except - should be recognized by Together as ID as attr. __declspec
//__leave  - It's 'break' from 'try-finally'
//uuid - should be recognized by Together as ID as attr. __declspec
#define __uuidof
//_variant_t - should be recognized by Together as ID
//xalloc - exception - should be recognized by Together as ID

#endif //TS_KEYWORDS_VC


#if defined(TS_PREINCLUDE_MICROSOFT_WINDOWS) || defined(OI_PREINCLUDE_MICROSOFT_WINDOWS)

#define WINVER 0x0400
#define WIN32 100

#define CALLBACK
#define WINAPI
#define WINAPIV
#define APIENTRY
#define APIPRIVATE
#define EXPORT

#endif // TS_PREINCLUDE_MICROSOFT_WINDOWS



// **********************************************************************
//
// Microsoft COM specific symbols
//
// **********************************************************************

#if defined(TS_PREINCLUDE_MICROSOFT_COM) || defined(OI_PREINCLUDE_MICROSOFT_COM)

// COM code configuration. If this macro defined, interfaces
// don't need to list members of base interfaces.
#define NO_BASEINTERFACE_FUNCS

#define IN
#define OUT
#define OPTIONAL

#define STDMETHODCALLTYPE

#define interface struct
#define STDMETHOD(method)       virtual HRESULT method
#define STDMETHOD_(type,method) virtual type method
#define PURE                    = 0
#define THIS_
#define THIS                    void
#define DECLARE_INTERFACE(iface)    interface iface
#define DECLARE_INTERFACE_(iface, baseiface)    interface iface : public baseiface

#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)

#define STDMETHODIMP            HRESULT
#define STDMETHODIMP_(type)     type

#define STDMETHODIMPV           HRESULT
#define STDMETHODIMPV_(type)    type

// for VISUAL C++ midl generated proxy
#define BEGIN_INTERFACE
#define END_INTERFACE
#define DLLDATA_ROUTINES(pProxyFileList,pClsID )
#define PROXYFILE_LIST_START \
   ProxyFileInfo* aProxyFileList[] = {
#define EXTERN_PROXY_FILE(name) \
   EXTERN_C ProxyFileInfo name##_ProxyFileInfo;
#define REFERENCE_PROXY_FILE(name) \
   &name##_ProxyFileInfo
#define PROXYFILE_LIST_END  0 };

#endif // TS_PREINCLUDE_MICROSOFT_COM



// **********************************************************************
//
//  Microsoft C++ specific symbols
//
// **********************************************************************

#if defined(TS_PREINCLUDE_MICROSOFT_VISUAL_C) || defined(OI_PREINCLUDE_MICROSOFT_VISUAL_C)

/*
 * Macro expansion configuration:
 * !!! 2.x/3.x note: Since 3.1 recommended to [un]define via options GUI
 */
// To show result of MFC macros expansion, uncomment
//#define MFC_MACROS_SHOW_EXPANDED
//
// To show MFC macros as functions, uncomment (defined in options by default)
//#define MFC_MACROS_SHOW
//
// Otherwise macros will be expanded to empty


#define _MSC_VER 1100
#define _declspec __declspec
#define DECLSPEC_IMPORT

#define DECLSPEC_UUID(x)
#define MIDL_INTERFACE(x)   struct
#define RPC_VAR_ENTRY
#define __MIDL_DECLSPEC_DLLIMPORT
#define __MIDL_DECLSPEC_DLLEXPORT
#define CONST_VTBL

#define __RPC_FAR
#define __RPC_API
#define __RPC_USER
#define __RPC_STUB

// **********************************************************************
//
//
// Macro definitions for Microsoft (c) Foundations Classes (MFC) library
//
//
// **********************************************************************



#define _AFX     1      // Microsoft Application Framework Classes
//#define _MFC_VER 0x0421 // Microsoft Foundation Classes version 4.21
#define _MFC_VER 0x0600 // Microsoft Foundation Classes version 6.00

#define _AFX_PACKING 8
#define _AFXDLL
//#define _AFX_NO_OLE_SUPPORT
//#define _MAC

#define afx_msg

#define AFX_INIT_SEG
#define AFX_CORE1_SEG
#define AFX_CORE2_SEG
#define AFX_CORE3_SEG
#define AFX_CORE4_SEG
#define AFX_AUX_SEG
#define AFX_COLL_SEG
#define AFX_COLL2_SEG
#define AFX_OLE_SEG
#define AFX_OLE2_SEG
#define AFX_OLE3_SEG
#define AFX_OLE4_SEG
#define AFX_OLE5_SEG
#define AFX_OLERA_SEG
#define AFX_PRINT_SEG
#define AFX_DBG1_SEG
#define AFX_DBG2_SEG
#define AFX_VDEL_SEG
#define AFX_TERM_SEG
#define AFX_MAPI_SEG
#define AFX_SOCK_SEG

#define AfxDebugBreak()

#define AFXAPI
#define AFXOLEAPI
#define AFX_CDECL
#define AFX_EXPORT
#define AFX_DATA_EXPORT
#define AFX_DATA_IMPORT
#define AFX_CLASS_EXPORT
#define AFX_CLASS_IMPORT
#define AFX_API_EXPORT
#define AFX_API_IMPORT

#define AFX_DATA
#define AFX_DATADEF
#define AFX_CORE_DATA
#define AFX_CORE_DATADEF
#define AFX_OLE_DATA
#define AFX_OLE_DATADEF
#define AFX_DB_DATA
#define AFX_DB_DATADEF
#define AFX_NET_DATA
#define AFX_NET_DATADEF

#define AFX_EXT_CLASS
#define AFX_EXT_API
#define AFX_EXT_DATA
#define AFX_EXT_DATADEF

#define BASED_CODE
#define BASED_DEBUG
#define BASED_STACK

#define IPTR(x) x*
#define DEFINE_IPTR(x) typedef IPTR(x) x##Ptr;

#define AFX_ZERO_INIT_OBJECT(x)

#define RUNTIME_CLASS(class_name) ((CRuntimeClass*)(&class_name::class##class_name))
#define ASSERT_KINDOF(class_name, object) \
        ASSERT((object)->IsKindOf(RUNTIME_CLASS(class_name)))

#define THREAD_LOCAL(class_name, ident_name)\
        class_name * ident_name;
#define EXTERN_THREAD_LOCAL(class_name, ident_name) \
        extern THREAD_LOCAL(class_name, ident_name)

#define PROCESS_LOCAL(class_name, ident_name) \
        class_name * ident_name;
#define EXTERN_PROCESS_LOCAL(class_name, ident_name) \
        extern PROCESS_LOCAL(class_name, ident_name)


#define INIT_INTERFACE_PART(theClass, localClass)
#define INIT_INTERFACE_PART_DERIVE(theClass, localClass)

#define AFXISAPI
#define AFXIS_DATADEF
#define AFXISAPI_CDECL
#define AFX_PARSE_CALL

//Used in method body
//#define AFX_MANAGE_STATE(p)
//#define METHOD_PROLOGUE_(theClass, localClass) \
//      theClass* pThis;

// update for version 6.00
#define AFX_NOVTABLE
#define END_INTERFACE_PART_STATIC END_INTERFACE_PART
#define AFX_STATIC extern


#if defined( MFC_MACROS_SHOW_EXPANDED )

#define DECLARE_DYNAMIC(class_name) \
protected: \
        static CRuntimeClass* _GetBaseClass(); \
public: \
        static const CRuntimeClass class_##class_name; \
        virtual CRuntimeClass* GetRuntimeClass() const;

#define _DECLARE_DYNAMIC(class_name) DECLARE_DYNAMIC(class_name)

#define DECLARE_DYNCREATE(class_name) \
        DECLARE_DYNAMIC(class_name) \
        static CObject* CreateObject();

#define _DECLARE_DYNCREATE(class_name) DECLARE_DYNCREATE(class_name)

#define DECLARE_SERIAL(class_name) \
        _DECLARE_DYNCREATE(class_name) \
        friend CArchive& operator>>(CArchive& ar, class_name* &pOb);

#define DECLARE_MESSAGE_MAP() \
private: \
        static const AFX_MSGMAP_ENTRY _messageEntries[]; \
protected: \
        static AFX_DATA const AFX_MSGMAP messageMap; \
        virtual const AFX_MSGMAP* GetMessageMap() const; \

#define DECLARE_DISPATCH_MAP() \
private: \
        static const AFX_DISPMAP_ENTRY _dispatchEntries[]; \
        static UINT _dispatchEntryCount; \
        static DWORD _dwStockPropMask; \
protected: \
        static const AFX_DISPMAP dispatchMap; \
        virtual const AFX_DISPMAP* GetDispatchMap() const; \

#define DECLARE_OLECMD_MAP() \
private: \
        static const AFX_OLECMDMAP_ENTRY _commandEntries[]; \
protected: \
        static const AFX_OLECMDMAP commandMap; \
        static const AFX_OLECMDMAP* _GetBaseCommandMap(); \
        virtual const AFX_OLECMDMAP* GetCommandMap() const; \

#define BEGIN_OLEFACTORY(class_name) \
protected: \
        class class_name##Factory : public COleObjectFactoryEx \
        { \
        public: \
                class_name##Factory(REFCLSID clsid, CRuntimeClass* pRuntimeClass, \
                        BOOL bMultiInstance, LPCTSTR lpszProgID) : \
                                COleObjectFactoryEx(clsid, pRuntimeClass, bMultiInstance, \
                                lpszProgID) {} \
                virtual BOOL UpdateRegistry(BOOL);

#define END_OLEFACTORY(class_name) \
        }; \
        friend class class_name##Factory; \
        static class_name##Factory factory; \
public: \
        static const GUID guid; \
        virtual HRESULT GetClassID(LPCLSID pclsid);

#define DECLARE_OLECREATE(class_name) \
public: \
        static COleObjectFactory factory; \
        static const GUID guid; \

#define DECLARE_OLECREATE_EX(class_name) \
        BEGIN_OLEFACTORY(class_name) \
        END_OLEFACTORY(class_name)

#define DECLARE_OLETYPELIB(class_name) \
        protected: \
                virtual UINT GetTypeInfoCount(); \
                virtual HRESULT GetTypeLib(LCID, LPTYPELIB*); \
                virtual CTypeLibCache* GetTypeLibCache(); \

#define DECLARE_CONNECTION_MAP() \
private: \
        static const AFX_CONNECTIONMAP_ENTRY _connectionEntries[]; \
protected: \
        static const AFX_CONNECTIONMAP connectionMap; \
        static const AFX_CONNECTIONMAP* _GetBaseConnectionMap(); \
        virtual const AFX_CONNECTIONMAP* GetConnectionMap() const; \

#define DECLARE_PROPPAGEIDS(class_name) \
        protected: \
                virtual LPCLSID GetPropPageIDs(ULONG& cPropPages);

#define DECLARE_OLECTLTYPE(class_name) \
        virtual UINT GetUserTypeNameID(); \
        virtual DWORD GetMiscStatus();

#define DECLARE_INTERFACE_MAP() \
  private: \
          static const AFX_INTERFACEMAP_ENTRY _interfaceEntries[]; \
  protected: \
          static const AFX_INTERFACEMAP interfaceMap; \
          virtual const AFX_INTERFACEMAP* GetInterfaceMap() const; \

#define BEGIN_INTERFACE_PART(localClass, baseClass) \
        class X##localClass : public baseClass \
        { \
        public: \
                STDMETHOD_(ULONG, AddRef)(); \
                STDMETHOD_(ULONG, Release)(); \
                STDMETHOD(QueryInterface)(REFIID iid, LPVOID* ppvObj); \

#define BEGIN_INTERFACE_PART_DERIVE(localClass, baseClass) \
        BEGIN_INTERFACE_PART(localClass, baseClass)

#define END_INTERFACE_PART(localClass) \
    };\
  X##localClass m_x##localClass; \
        friend class X##localClass;

#define DECLARE_EVENT_MAP() \
  private: \
          static const AFX_EVENTMAP_ENTRY _eventEntries[]; \
          static DWORD _dwStockEventMask; \
  protected: \
          static const AFX_EVENTMAP eventMap; \
          virtual const AFX_EVENTMAP* GetEventMap() const;

#define DECLARE_EVENTSINK_MAP() \
  private: \
          static const AFX_EVENTSINKMAP_ENTRY _eventsinkEntries[]; \
          static UINT _eventsinkEntryCount; \
  protected: \
          static const AFX_EVENTSINKMAP eventsinkMap; \
          static const AFX_EVENTSINKMAP* _GetBaseEventSinkMap(); \
          virtual const AFX_EVENTSINKMAP* GetEventSinkMap() const;

#define BEGIN_CONNECTION_PART(theClass, localClass) \
        class X##localClass : public CConnectionPoint \
        { \
        public: \
                X##localClass() \
                        { m_nOffset = offsetof(theClass, m_x##localClass); }

#define CONNECTION_IID(iid) \
                REFIID GetIID() { return iid; }

#define CONNECTION_PART(theClass, iid, localClass) \
                { &iid, offsetof(theClass, m_x##localClass) }, \


#define END_CONNECTION_PART(localClass) \
        };\
  X##localClass m_x##localClass; \
        friend class X##localClass;

#define BEGIN_CONNECTION_MAP(theClass, theBase) \
        const AFX_CONNECTIONMAP* theClass::GetConnectionMap() const \
                { return &theClass::connectionMap; } \
        const AFX_DATADEF AFX_CONNECTIONMAP theClass::connectionMap = \
                { &(theBase::connectionMap), &theClass::_connectionEntries[0], }; \
        const AFX_DATADEF AFX_CONNECTIONMAP_ENTRY theClass::_connectionEntries[] = \
        { \

#define END_CONNECTION_MAP() \
                { NULL, (size_t)-1 } \
        }; \

#define DECLARE_PARSE_MAP() \
private: \
        static AFX_PARSEMAP_ENTRY _parseEntries[]; \
public: \
        static const AFX_PARSEMAP parseMap; \
        static UINT GetNumMapEntries(); \
        virtual const AFX_PARSEMAP* GetParseMap() const;

#elif defined(MFC_MACROS_SHOW)

#define DECLARE_DYNAMIC(class_name)\
  public: \
    DECLARE_DYNAMIC();
#define _DECLARE_DYNAMIC(class_name)\
  public: \
    _DECLARE_DYNAMIC();
#define DECLARE_DYNCREATE(class_name)\
  public: \
    DECLARE_DYNCREATE();
#define _DECLARE_DYNCREATE(class_name)\
  public: \
    _DECLARE_DYNCREATE();
#define DECLARE_SERIAL(class_name)\
  public: \
    DECLARE_SERIAL();

#define DECLARE_MESSAGE_MAP() \
  protected: \
    DECLARE_MESSAGE_MAP();

#define DECLARE_DISPATCH_MAP() \
  protected: \
    DECLARE_DISPATCH_MAP();

#define DECLARE_OLECMD_MAP() \
  protected: \
    DECLARE_OLECMD_MAP();

#define BEGIN_OLEFACTORY(class_name) \
  protected: \
    BEGIN_OLEFACTORY();

#define END_OLEFACTORY(class_name) \
  protected: \
    END_OLEFACTORY();

#define DECLARE_OLECREATE_EX(class_name) \
  protected: \
    DECLARE_OLECREATE_EX();

#define DECLARE_OLECREATE(class_name) \
  public: \
    DECLARE_OLECREATE();

#define DECLARE_OLETYPELIB(class_name) \
        protected: \
    DECLARE_OLETYPELIB();

#define DECLARE_PROPPAGEIDS(class_name) \
        protected: \
                DECLARE_PROPPAGEIDS();

#define DECLARE_OLECTLTYPE(class_name) \
    DECLARE_OLECTLTYPE();

#define DECLARE_CONNECTION_MAP() \
  protected: \
          DECLARE_CONNECTION_MAP();

#define DECLARE_INTERFACE_MAP() \
  protected: \
    DECLARE_INTERFACE_MAP();

#define BEGIN_INTERFACE_PART(localClass, baseClass) \
  BEGIN_INTERFACE_PART_##localClass(baseClass);

#define BEGIN_INTERFACE_PART_DERIVE(localClass, baseClass) \
        BEGIN_INTERFACE_PART(localClass, baseClass)

#define END_INTERFACE_PART(localClass)\
  END_INTERFACE_PART_##localClass();

#define DECLARE_EVENT_MAP() \
  protected: \
    DECLARE_EVENT_MAP();

#define DECLARE_EVENTSINK_MAP() \
  protected: \
    DECLARE_EVENTSINK_MAP();

#define BEGIN_CONNECTION_PART(theClass, localClass) \
        BEGIN_CONNECTION_PART_##localClass();

#define CONNECTION_IID(iid)

#define CONNECTION_PART(theClass, iid, localClass)

#define END_CONNECTION_PART(localClass) \
    END_CONNECTION_PART_##localClass();

#define BEGIN_CONNECTION_MAP(theClass, theBase) \
    BEGIN_CONNECTION_MAP_##theClass();

#define END_CONNECTION_MAP() \
    END_CONNECTION_MAP();

#define DECLARE_PARSE_MAP() \
  public: \
    DECLARE_PARSE_MAP();

#else // expand to nothing

#define DECLARE_DYNAMIC(class_name) public:
#define _DECLARE_DYNAMIC(class_name) public:
#define DECLARE_DYNCREATE(class_name) public:
#define _DECLARE_DYNCREATE(class_name) public:
#define DECLARE_SERIAL(class_name) public:

#define DECLARE_MESSAGE_MAP() protected:
#define DECLARE_DISPATCH_MAP() protected:
#define DECLARE_OLECMD_MAP() protected:

#define DECLARE_CONNECTION_MAP() protected:
#define BEGIN_CONNECTION_PART(theClass, localClass)
#define CONNECTION_IID(iid)
#define CONNECTION_PART(theClass, iid, localClass)
#define END_CONNECTION_PART(localClass)

#define BEGIN_OLEFACTORY(class_name) protected:
#define END_OLEFACTORY(class_name) public:
#define DECLARE_OLECREATE_EX(class_name) public:
#define DECLARE_OLECREATE(class_name) public:
#define DECLARE_OLETYPELIB(class_name) protected:
#define DECLARE_PROPPAGEIDS(class_name) protected:
#define DECLARE_OLECTLTYPE(class_name)
#define DECLARE_CONNECTION_MAP() protected:
#define DECLARE_INTERFACE_MAP() protected:
#define BEGIN_INTERFACE_PART(localClass, baseClass)
#define BEGIN_INTERFACE_PART_DERIVE(localClass, baseClass)
#define END_INTERFACE_PART(localClass)
#define DECLARE_EVENT_MAP() protected:
#define DECLARE_EVENTSINK_MAP() protected:
#define BEGIN_CONNECTION_PART(theClass, localClass)
#define CONNECTION_IID(iid)
#define END_CONNECTION_PART(localClass)

#define DECLARE_PARSE_MAP() public:

#endif


// Implementation: expanded to empty

#define IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, pfnNew)
#define _IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, pfnNew)
#define IMPLEMENT_DYNAMIC(class_name, base_class_name)
#define IMPLEMENT_DYNCREATE(class_name, base_class_name)
#define IMPLEMENT_SERIAL(class_name, base_class_name, wSchema)


#define BEGIN_MESSAGE_MAP(theClass, baseClass)
#define END_MESSAGE_MAP() ;


#define BEGIN_INTERFACE_MAP(theClass, theBase)
#define INTERFACE_PART(theClass, iid, localClass)
#define INTERFACE_AGGREGATE(theClass, theAggr)
#define END_INTERFACE_MAP() ;

#define BEGIN_DISPATCH_MAP(theClass, baseClass)
#define END_DISPATCH_MAP() ;

#define DISP_FUNCTION(theClass, szExternalName, pfnMember, vtRetVal, vtsParams)
#define DISP_PROPERTY(theClass, szExternalName, memberName, vtPropType)
#define DISP_PROPERTY_NOTIFY(theClass, szExternalName, memberName, pfnAfterSet, vtPropType)
#define DISP_PROPERTY_EX(theClass, szExternalName, pfnGet, pfnSet, vtPropType)
#define DISP_PROPERTY_PARAM(theClass, szExternalName, pfnGet, pfnSet, vtPropType, vtsParams)
#define DISP_FUNCTION_ID(theClass, szExternalName, dispid, pfnMember, vtRetVal, vtsParams)
#define DISP_PROPERTY_ID(theClass, szExternalName, dispid, memberName, vtPropType)
#define DISP_PROPERTY_NOTIFY_ID(theClass, szExternalName, dispid, memberName, pfnAfterSet, vtPropType)
#define DISP_PROPERTY_EX_ID(theClass, szExternalName, dispid, pfnGet, pfnSet, vtPropType)
#define DISP_PROPERTY_PARAM_ID(theClass, szExternalName, dispid, pfnGet, pfnSet, vtPropType, vtsParams)
#define DISP_DEFVALUE(theClass, szExternalName)
#define DISP_DEFVALUE_ID(theClass, dispid)

#define BEGIN_OLECMD_MAP(theClass, baseClass)
#define END_OLECMD_MAP()

#define BEGIN_EVENT_MAP(theClass, baseClass)
#define EVENT_CUSTOM(pszName, pfnFire, vtsParams)
#define EVENT_CUSTOM_ID(pszName, dispid, pfnFire, vtsParams)
#define EVENT_PARAM(vtsParams) (BYTE*)(vtsParams)
#define END_EVENT_MAP()

#define BEGIN_PROPPAGEIDS(class_name, count)
#define PROPPAGEID(clsid)
#define END_PROPPAGEIDS(class_name)

#define BEGIN_EVENTSINK_MAP(theClass, baseClass)
#define END_EVENTSINK_MAP()

#define ON_EVENT(theClass, id, dispid, pfnHandler, vtsParams)
#define ON_EVENT_RANGE(theClass, idFirst, idLast, dispid, pfnHandler, vtsParams)
#define ON_PROPNOTIFY(theClass, id, dispid, pfnRequest, pfnChanged)
#define ON_PROPNOTIFY_RANGE(theClass, idFirst, idLast, dispid, pfnRequest, pfnChanged)
#define ON_DSCNOTIFY(theClass, id, pfnNotify)
#define ON_DSCNOTIFY_RANGE(theClass, idFirst, idLast, pfnNotify)
#define ON_EVENT_REFLECT(theClass, dispid, pfnHandler, vtsParams)
#define ON_PROPNOTIFY_REFLECT(theClass, dispid, pfnRequest, pfnChanged)
#define IMPLEMENT_OLECTLTYPE(class_name, idsUserTypeName, dwOleMisc)
#define IMPLEMENT_OLECREATE_EX(class_name, external_name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
#define IMPLEMENT_OLECREATE(class_name, external_name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
#define IMPLEMENT_OLETYPELIB(class_name, tlid, wVerMajor, wVerMinor)

#define BEGIN_PARSE_MAP(theClass, baseClass)
#define ON_PARSE_COMMAND(FnName, mapClass, Args)
#define ON_PARSE_COMMAND_PARAMS(Params)
#define DEFAULT_PARSE_COMMAND(FnName, mapClass)
#define END_PARSE_MAP(theClass)




/////////////////////////////////////////////////////////////////////////////
// Command notifications for CCmdTarget notifications
#define CN_COMMAND              0               // void ()
#define CN_UPDATE_COMMAND_UI    ((UINT)(-1))    // void (CCmdUI*)
#define CN_EVENT                ((UINT)(-2))    // OLE event
#define CN_OLECOMMAND           ((UINT)(-3))    // OLE document command
#define CN_OLE_UNREGISTER       ((UINT)(-4))    // OLE unregister
// > 0 are control notifications
// < 0 are for MFC's use

#define ON_COMMAND(id, memberFxn)
#define ON_COMMAND_RANGE(id, idLast, memberFxn)
#define ON_COMMAND_EX(id, memberFxn)
#define ON_COMMAND_EX_RANGE(id, idLast, memberFxn)
#define ON_UPDATE_COMMAND_UI(id, memberFxn)
#define ON_UPDATE_COMMAND_UI_RANGE(id, idLast, memberFxn)
#define ON_NOTIFY(wNotifyCode, id, memberFxn)
#define ON_NOTIFY_RANGE(wNotifyCode, id, idLast, memberFxn)
#define ON_NOTIFY_EX(wNotifyCode, id, memberFxn)
#define ON_NOTIFY_EX_RANGE(wNotifyCode, id, idLast, memberFxn)

// for general controls
#define ON_CONTROL(wNotifyCode, id, memberFxn)
#define ON_CONTROL_RANGE(wNotifyCode, id, idLast, memberFxn)

#define WM_REFLECT_BASE 0xBC00

// for control notification reflection
#define ON_CONTROL_REFLECT(wNotifyCode, memberFxn)
#define ON_CONTROL_REFLECT_EX(wNotifyCode, memberFxn)
#define ON_NOTIFY_REFLECT(wNotifyCode, memberFxn)
#define ON_NOTIFY_REFLECT_EX(wNotifyCode, memberFxn)
#define ON_UPDATE_COMMAND_UI_REFLECT(memberFxn)

/////////////////////////////////////////////////////////////////////////////
// Message map tables for Windows messages

#define ON_WM_CREATE()
#define ON_WM_COPYDATA()
#define ON_WM_DESTROY()
#define ON_WM_MOVE()
#define ON_WM_SIZE()
#define ON_WM_ACTIVATE()
#define ON_WM_SETFOCUS()
#define ON_WM_KILLFOCUS()
#define ON_WM_ENABLE()
#define ON_WM_HELPINFO()
#define ON_WM_PAINT()
#define ON_WM_PAINT_SPECIAL()
#define ON_WM_CLOSE()
#define ON_WM_QUERYENDSESSION()
#define ON_WM_QUERYOPEN()
#define ON_WM_ERASEBKGND()
#define ON_WM_SYSCOLORCHANGE()
#define ON_WM_ENDSESSION()
#define ON_WM_SHOWWINDOW()
#define ON_WM_CTLCOLOR()
#define ON_WM_CTLCOLOR_REFLECT()
#define ON_WM_SETTINGCHANGE()
#define ON_WM_WININICHANGE()
#define ON_WM_DEVMODECHANGE()
#define ON_WM_ACTIVATEAPP()
#define ON_WM_FONTCHANGE()
#define ON_WM_TIMECHANGE()
#define ON_WM_CANCELMODE()
#define ON_WM_SETCURSOR()
#define ON_WM_MOUSEACTIVATE()
#define ON_WM_CHILDACTIVATE()
#define ON_WM_GETMINMAXINFO()
#define ON_WM_ICONERASEBKGND()
#define ON_WM_SPOOLERSTATUS()
#define ON_WM_DRAWITEM()
#define ON_WM_DRAWITEM_REFLECT()
#define ON_WM_MEASUREITEM()
#define ON_WM_MEASUREITEM_REFLECT()
#define ON_WM_DELETEITEM()
#define ON_WM_DELETEITEM_REFLECT()
#define ON_WM_CHARTOITEM()
#define ON_WM_CHARTOITEM_REFLECT()
#define ON_WM_VKEYTOITEM()
#define ON_WM_VKEYTOITEM_REFLECT()
#define ON_WM_QUERYDRAGICON()
#define ON_WM_COMPAREITEM()
#define ON_WM_COMPAREITEM_REFLECT()
#define ON_WM_COMPACTING()
#define ON_WM_NCCREATE()
#define ON_WM_NCDESTROY()
#define ON_WM_NCCALCSIZE()
#define ON_WM_NCHITTEST()
#define ON_WM_NCPAINT()
#define ON_WM_NCACTIVATE()
#define ON_WM_GETDLGCODE()
#define ON_WM_NCMOUSEMOVE()
#define ON_WM_NCLBUTTONDOWN()
#define ON_WM_NCLBUTTONUP()
#define ON_WM_NCLBUTTONDBLCLK()
#define ON_WM_NCRBUTTONDOWN()
#define ON_WM_NCRBUTTONUP()
#define ON_WM_NCRBUTTONDBLCLK()
#define ON_WM_NCMBUTTONDOWN()
#define ON_WM_NCMBUTTONUP()
#define ON_WM_NCMBUTTONDBLCLK()
#define ON_WM_KEYDOWN()
#define ON_WM_KEYUP()
#define ON_WM_CHAR()
#define ON_WM_DEADCHAR()
#define ON_WM_SYSKEYDOWN()
#define ON_WM_SYSKEYUP()
#define ON_WM_SYSCHAR()
#define ON_WM_SYSDEADCHAR()
#define ON_WM_SYSCOMMAND()
#define ON_WM_TCARD()
#define ON_WM_TIMER()
#define ON_WM_HSCROLL()
#define ON_WM_HSCROLL_REFLECT()
#define ON_WM_VSCROLL()
#define ON_WM_VSCROLL_REFLECT()
#define ON_WM_INITMENU()
#define ON_WM_INITMENUPOPUP()
#define ON_WM_MENUSELECT()
#define ON_WM_MENUCHAR()
#define ON_WM_ENTERIDLE()
#define ON_WM_MOUSEMOVE()
#define ON_WM_MOUSEWHEEL()
#define ON_WM_LBUTTONDOWN()
#define ON_WM_LBUTTONUP()
#define ON_WM_LBUTTONDBLCLK()
#define ON_WM_RBUTTONDOWN()
#define ON_WM_RBUTTONUP()
#define ON_WM_RBUTTONDBLCLK()
#define ON_WM_MBUTTONDOWN()
#define ON_WM_MBUTTONUP()
#define ON_WM_MBUTTONDBLCLK()
#define ON_WM_PARENTNOTIFY()
#define ON_WM_PARENTNOTIFY_REFLECT()
#define ON_WM_MDIACTIVATE()
#define ON_WM_RENDERFORMAT()
#define ON_WM_RENDERALLFORMATS()
#define ON_WM_DESTROYCLIPBOARD()
#define ON_WM_DRAWCLIPBOARD()
#define ON_WM_PAINTCLIPBOARD()
#define ON_WM_VSCROLLCLIPBOARD()
#define ON_WM_CONTEXTMENU()
#define ON_WM_SIZECLIPBOARD()
#define ON_WM_ASKCBFORMATNAME()
#define ON_WM_CHANGECBCHAIN()
#define ON_WM_HSCROLLCLIPBOARD()
#define ON_WM_QUERYNEWPALETTE()
#define ON_WM_PALETTECHANGED()
#define ON_WM_PALETTEISCHANGING()
#define ON_WM_DROPFILES()
#define ON_WM_WINDOWPOSCHANGING()
#define ON_WM_WINDOWPOSCHANGED()
#define ON_WM_EXITMENULOOP()
#define ON_WM_ENTERMENULOOP()
#define ON_WM_STYLECHANGED()
#define ON_WM_STYLECHANGING()
#define ON_WM_SIZING()
#define ON_WM_MOVING()
#define ON_WM_CAPTURECHANGED()
#define ON_WM_DEVICECHANGE()
#define ON_MESSAGE_VOID( messageID, handler )

/////////////////////////////////////////////////////////////////////////////
// Message map tables for Control Notification messages

// Static control notification codes
#define ON_STN_CLICKED(id, memberFxn) \
        ON_CONTROL(STN_CLICKED, id, memberFxn)
#define ON_STN_DBLCLK(id, memberFxn) \
        ON_CONTROL(STN_DBLCLK, id, memberFxn)
#define ON_STN_ENABLE(id, memberFxn) \
        ON_CONTROL(STN_ENABLE, id, memberFxn)
#define ON_STN_DISABLE(id, memberFxn) \
        ON_CONTROL(STN_DISABLE, id, memberFxn)


// Edit Control Notification Codes
#define ON_EN_SETFOCUS(id, memberFxn) \
        ON_CONTROL(EN_SETFOCUS, id, memberFxn)
#define ON_EN_KILLFOCUS(id, memberFxn) \
        ON_CONTROL(EN_KILLFOCUS, id, memberFxn)
#define ON_EN_CHANGE(id, memberFxn) \
        ON_CONTROL(EN_CHANGE, id, memberFxn)
#define ON_EN_UPDATE(id, memberFxn) \
        ON_CONTROL(EN_UPDATE, id, memberFxn)
#define ON_EN_ERRSPACE(id, memberFxn) \
        ON_CONTROL(EN_ERRSPACE, id, memberFxn)
#define ON_EN_MAXTEXT(id, memberFxn) \
        ON_CONTROL(EN_MAXTEXT, id, memberFxn)
#define ON_EN_HSCROLL(id, memberFxn) \
        ON_CONTROL(EN_HSCROLL, id, memberFxn)
#define ON_EN_VSCROLL(id, memberFxn) \
        ON_CONTROL(EN_VSCROLL, id, memberFxn)

// User Button Notification Codes
#define ON_BN_CLICKED(id, memberFxn) \
        ON_CONTROL(BN_CLICKED, id, memberFxn)
#define ON_BN_DOUBLECLICKED(id, memberFxn) \
        ON_CONTROL(BN_DOUBLECLICKED, id, memberFxn)
#define ON_BN_SETFOCUS(id, memberFxn) \
        ON_CONTROL(BN_SETFOCUS, id, memberFxn)
#define ON_BN_KILLFOCUS(id, memberFxn) \
        ON_CONTROL(BN_KILLFOCUS, id, memberFxn)

// old BS_USERBUTTON button notifications - obsolete in Win31
#define ON_BN_PAINT(id, memberFxn) \
        ON_CONTROL(BN_PAINT, id, memberFxn)
#define ON_BN_HILITE(id, memberFxn) \
        ON_CONTROL(BN_HILITE, id, memberFxn)
#define ON_BN_UNHILITE(id, memberFxn) \
        ON_CONTROL(BN_UNHILITE, id, memberFxn)
#define ON_BN_DISABLE(id, memberFxn) \
        ON_CONTROL(BN_DISABLE, id, memberFxn)

// Listbox Notification Codes
#define ON_LBN_ERRSPACE(id, memberFxn) \
        ON_CONTROL(LBN_ERRSPACE, id, memberFxn)
#define ON_LBN_SELCHANGE(id, memberFxn) \
        ON_CONTROL(LBN_SELCHANGE, id, memberFxn)
#define ON_LBN_DBLCLK(id, memberFxn) \
        ON_CONTROL(LBN_DBLCLK, id, memberFxn)
#define ON_LBN_SELCANCEL(id, memberFxn) \
        ON_CONTROL(LBN_SELCANCEL, id, memberFxn)
#define ON_LBN_SETFOCUS(id, memberFxn) \
        ON_CONTROL(LBN_SETFOCUS, id, memberFxn)
#define ON_LBN_KILLFOCUS(id, memberFxn) \
        ON_CONTROL(LBN_KILLFOCUS, id, memberFxn)

// Check Listbox Notification codes
#define CLBN_CHKCHANGE (40)
#define ON_CLBN_CHKCHANGE(id, memberFxn) \
        ON_CONTROL(CLBN_CHKCHANGE, id, memberFxn)

// Combo Box Notification Codes
#define ON_CBN_ERRSPACE(id, memberFxn) \
        ON_CONTROL(CBN_ERRSPACE, id, memberFxn)
#define ON_CBN_SELCHANGE(id, memberFxn) \
        ON_CONTROL(CBN_SELCHANGE, id, memberFxn)
#define ON_CBN_DBLCLK(id, memberFxn) \
        ON_CONTROL(CBN_DBLCLK, id, memberFxn)
#define ON_CBN_SETFOCUS(id, memberFxn) \
        ON_CONTROL(CBN_SETFOCUS, id, memberFxn)
#define ON_CBN_KILLFOCUS(id, memberFxn) \
        ON_CONTROL(CBN_KILLFOCUS, id, memberFxn)
#define ON_CBN_EDITCHANGE(id, memberFxn) \
        ON_CONTROL(CBN_EDITCHANGE, id, memberFxn)
#define ON_CBN_EDITUPDATE(id, memberFxn) \
        ON_CONTROL(CBN_EDITUPDATE, id, memberFxn)
#define ON_CBN_DROPDOWN(id, memberFxn) \
        ON_CONTROL(CBN_DROPDOWN, id, memberFxn)
#define ON_CBN_CLOSEUP(id, memberFxn)  \
        ON_CONTROL(CBN_CLOSEUP, id, memberFxn)
#define ON_CBN_SELENDOK(id, memberFxn)  \
        ON_CONTROL(CBN_SELENDOK, id, memberFxn)
#define ON_CBN_SELENDCANCEL(id, memberFxn)  \
        ON_CONTROL(CBN_SELENDCANCEL, id, memberFxn)

/////////////////////////////////////////////////////////////////////////////
// User extensions for message map entries

// for Windows messages
#define ON_MESSAGE(message, memberFxn)
#define ON_REGISTERED_MESSAGE(nMessageVariable, memberFxn)
#define ON_THREAD_MESSAGE(message, memberFxn)
#define ON_REGISTERED_THREAD_MESSAGE(nMessageVariable, memberFxn)


#define ON_OLECMD(pguid, olecmdid, id)
#define ON_OLECMD_OPEN()
#define ON_OLECMD_NEW()
#define ON_OLECMD_SAVE()
#define ON_OLECMD_SAVE_AS()
#define ON_OLECMD_SAVE_COPY_AS()
#define ON_OLECMD_PRINT()
#define ON_OLECMD_PRINTPREVIEW()
#define ON_OLECMD_PAGESETUP()
#define ON_OLECMD_CUT()
#define ON_OLECMD_COPY()
#define ON_OLECMD_PASTE()
#define ON_OLECMD_PASTESPECIAL()
#define ON_OLECMD_UNDO()
#define ON_OLECMD_REDO()
#define ON_OLECMD_SELECTALL()
#define ON_OLECMD_CLEARSELECTION()

#define ON_OLEVERB(idsVerbName, memberFxn)
#define ON_STDOLEVERB(iVerb, memberFxn)

#define OLEIVERB_PRIMARY            (0L)
#define OLEIVERB_SHOW               (-1L)
#define OLEIVERB_OPEN               (-2L)
#define OLEIVERB_HIDE               (-3L)
#define OLEIVERB_UIACTIVATE         (-4L)
#define OLEIVERB_INPLACEACTIVATE    (-5L)
#define OLEIVERB_DISCARDUNDOSTATE   (-6L)

// ActiveX events

#define EVENT_STOCK_CLICK()
#define EVENT_STOCK_DBLCLICK()
#define EVENT_STOCK_KEYDOWN()
#define EVENT_STOCK_KEYPRESS()
#define EVENT_STOCK_KEYUP()
#define EVENT_STOCK_MOUSEDOWN()
#define EVENT_STOCK_MOUSEMOVE()
#define EVENT_STOCK_MOUSEUP()
#define EVENT_STOCK_ERROREVENT()
#define EVENT_STOCK_READYSTATECHANGE()

#define DISP_PROPERTY_STOCK(theClass, szExternalName, dispid, pfnGet, pfnSet, vtPropType)
#define DISP_STOCKPROP_APPEARANCE()
#define DISP_STOCKPROP_BACKCOLOR()
#define DISP_STOCKPROP_BORDERSTYLE()
#define DISP_STOCKPROP_CAPTION()
#define DISP_STOCKPROP_ENABLED()
#define DISP_STOCKPROP_FONT()
#define DISP_STOCKPROP_FORECOLOR()
#define DISP_STOCKPROP_HWND()
#define DISP_STOCKPROP_TEXT()
#define DISP_STOCKPROP_READYSTATE()

#define DISP_FUNCTION_STOCK(theClass, szExternalName, dispid, pfnMember, vtRetVal, vtsParams)
#define DISP_STOCKFUNC_REFRESH()
#define DISP_STOCKFUNC_DOCLICK()


// parameter types: by value VTs
#define VTS_I2              "\x02"      // a 'short'
#define VTS_I4              "\x03"      // a 'long'
#define VTS_R4              "\x04"      // a 'float'
#define VTS_R8              "\x05"      // a 'double'
#define VTS_CY              "\x06"      // a 'CY' or 'CY*'
#define VTS_DATE            "\x07"      // a 'DATE'
#define VTS_WBSTR           "\x08"      // an 'LPCOLESTR'
#define VTS_DISPATCH        "\x09"      // an 'IDispatch*'
#define VTS_SCODE           "\x0A"      // an 'SCODE'
#define VTS_BOOL            "\x0B"      // a 'BOOL'
#define VTS_VARIANT         "\x0C"      // a 'const VARIANT&' or 'VARIANT*'
#define VTS_UNKNOWN         "\x0D"      // an 'IUnknown*'
#if defined(_UNICODE) || defined(OLE2ANSI)
        #define VTS_BSTR            VTS_WBSTR// an 'LPCOLESTR'
        #define VT_BSTRT            VT_BSTR
#else
        #define VTS_BSTR            "\x0E"  // an 'LPCSTR'
        #define VT_BSTRA            14
        #define VT_BSTRT            VT_BSTRA
#endif
#define VTS_UI1             "\x0F"      // a 'BYTE'

// parameter types: by reference VTs
#define VTS_PI2             "\x42"      // a 'short*'
#define VTS_PI4             "\x43"      // a 'long*'
#define VTS_PR4             "\x44"      // a 'float*'
#define VTS_PR8             "\x45"      // a 'double*'
#define VTS_PCY             "\x46"      // a 'CY*'
#define VTS_PDATE           "\x47"      // a 'DATE*'
#define VTS_PBSTR           "\x48"      // a 'BSTR*'
#define VTS_PDISPATCH       "\x49"      // an 'IDispatch**'
#define VTS_PSCODE          "\x4A"      // an 'SCODE*'
#define VTS_PBOOL           "\x4B"      // a 'VARIANT_BOOL*'
#define VTS_PVARIANT        "\x4C"      // a 'VARIANT*'
#define VTS_PUNKNOWN        "\x4D"      // an 'IUnknown**'
#define VTS_PUI1            "\x4F"      // a 'BYTE*'

// special VT_ and VTS_ values
#define VTS_NONE            NULL        // used for members with 0 params
#define VT_MFCVALUE         0xFFF       // special value for DISPID_VALUE
#define VT_MFCBYREF         0x40        // indicates VT_BYREF type
#define VT_MFCMARKER        0xFF        // delimits named parameters (INTERNAL USE)

// variant handling (use V_BSTRT when you have ANSI BSTRs, as in DAO)
#ifndef _UNICODE
        #define V_BSTRT(b)  (LPSTR)V_BSTR(b)
#else
        #define V_BSTRT(b)  V_BSTR(b)
#endif

/////////////////////////////////////////////////////////////////////////////
// OLE control parameter types

#define VTS_COLOR           VTS_I4      // OLE_COLOR
#define VTS_XPOS_PIXELS     VTS_I4      // OLE_XPOS_PIXELS
#define VTS_YPOS_PIXELS     VTS_I4      // OLE_YPOS_PIXELS
#define VTS_XSIZE_PIXELS    VTS_I4      // OLE_XSIZE_PIXELS
#define VTS_YSIZE_PIXELS    VTS_I4      // OLE_YSIZE_PIXELS
#define VTS_XPOS_HIMETRIC   VTS_I4      // OLE_XPOS_HIMETRIC
#define VTS_YPOS_HIMETRIC   VTS_I4      // OLE_YPOS_HIMETRIC
#define VTS_XSIZE_HIMETRIC  VTS_I4      // OLE_XSIZE_HIMETRIC
#define VTS_YSIZE_HIMETRIC  VTS_I4      // OLE_YSIZE_HIMETRIC
#define VTS_TRISTATE        VTS_I2      // OLE_TRISTATE
#define VTS_OPTEXCLUSIVE    VTS_BOOL    // OLE_OPTEXCLUSIVE

#define VTS_PCOLOR          VTS_PI4     // OLE_COLOR*
#define VTS_PXPOS_PIXELS    VTS_PI4     // OLE_XPOS_PIXELS*
#define VTS_PYPOS_PIXELS    VTS_PI4     // OLE_YPOS_PIXELS*
#define VTS_PXSIZE_PIXELS   VTS_PI4     // OLE_XSIZE_PIXELS*
#define VTS_PYSIZE_PIXELS   VTS_PI4     // OLE_YSIZE_PIXELS*
#define VTS_PXPOS_HIMETRIC  VTS_PI4     // OLE_XPOS_HIMETRIC*
#define VTS_PYPOS_HIMETRIC  VTS_PI4     // OLE_YPOS_HIMETRIC*
#define VTS_PXSIZE_HIMETRIC VTS_PI4     // OLE_XSIZE_HIMETRIC*
#define VTS_PYSIZE_HIMETRIC VTS_PI4     // OLE_YSIZE_HIMETRIC*
#define VTS_PTRISTATE       VTS_PI2     // OLE_TRISTATE*
#define VTS_POPTEXCLUSIVE   VTS_PBOOL   // OLE_OPTEXCLUSIVE*

#define VTS_FONT            VTS_DISPATCH    // IFontDispatch*
#define VTS_PICTURE         VTS_DISPATCH    // IPictureDispatch*

#define VTS_HANDLE          VTS_I4      // OLE_HANDLE
#define VTS_PHANDLE         VTS_PI4     // OLE_HANDLE*

#endif // TS_PREINCLUDE_MICROSOFT_VISUAL_C


// **********************************************************************
//
//  Microsoft Visual C++ 6.0 Standard C++ Library preinclude
//
// **********************************************************************

// It is required to add folder containing Microsoft Visual C++ include 
// files (for example: %MSVC%\VC98\Include) into Together project. 
// This could be done at the "Class/search path" tab of "Project properties" 
// dialog (or "Advanced" mode of "New project" dialog)

// Visual C++ 6.0 STL Library (short version)
#if defined(TS_PREINCLUDE_VC_STL) && !defined(TS_PREINCLUDE_VC_STDLIB)
#include "pi_vc_stl.inc"
#endif // TS_PREINCLUDE_VC_STL

// Visual C++ 6.0 Standard C++ Library (STL included)
#if defined(TS_PREINCLUDE_VC_STDLIB)
#include "pi_vc_stdlib.inc"
#endif // TS_PREINCLUDE_VC_STDLIB


// **********************************************************************
//
//  ATL specific symbols
//
// **********************************************************************

#if defined(TS_PREINCLUDE_ATL) || defined(OI_PREINCLUDE_ATL)

// Note: some definition are simplified in comparison with original ones.

#define ATL_NO_VTABLE
#define ATLAPI HRESULT
#define ATLAPI_(x) x

// == from ATLWIN.H ==

#define BEGIN_MSG_MAP(theClass) \
public: \
	BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0) \
	{

#define ALT_MSG_MAP(msgMapID)
#define MESSAGE_HANDLER(msg, func)
#define MESSAGE_RANGE_HANDLER(msgFirst, msgLast, func)
#define COMMAND_HANDLER(id, code, func)
#define COMMAND_ID_HANDLER(id, func)
#define COMMAND_CODE_HANDLER(code, func)
#define COMMAND_RANGE_HANDLER(idFirst, idLast, func)
#define NOTIFY_HANDLER(id, cd, func)
#define NOTIFY_ID_HANDLER(id, func)
#define NOTIFY_CODE_HANDLER(cd, func)
#define NOTIFY_RANGE_HANDLER(idFirst, idLast, func)
#define CHAIN_MSG_MAP(theChainClass)
#define CHAIN_MSG_MAP_MEMBER(theChainMember)
#define CHAIN_MSG_MAP_ALT(theChainClass, msgMapID)
#define CHAIN_MSG_MAP_ALT_MEMBER(theChainMember, msgMapID)
#define CHAIN_MSG_MAP_DYNAMIC(dynaChainID)
#define CHAIN_MSG_MAP_ALT_DYNAMIC(dynaChainID, msgMapID)
#define END_MSG_MAP() \
	}

#define DECLARE_EMPTY_MSG_MAP() \
public:

#define REFLECT_NOTIFICATIONS()
#define DEFAULT_REFLECTION_HANDLER()

#define DECLARE_WND_CLASS(WndClassName) \
static CWndClassInfo& GetWndClassInfo() {}

#define DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd) \
static CWndClassInfo& GetWndClassInfo() {}

#define DECLARE_WND_SUPERCLASS(WndClassName, OrigWndClassName) \
static CWndClassInfo& GetWndClassInfo() {}


// == from ATLCOM.H ==

#define _ATLDUMPIID(iid, name, hr) hr

#define _ATL_DEBUG_ADDREF_RELEASE_IMPL(className)\
	virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0;\
	virtual ULONG STDMETHODCALLTYPE Release(void) = 0;

#define BEGIN_PROPERTY_MAP(theClass) \
	typedef _ATL_PROP_NOTIFY_EVENT_CLASS __ATL_PROP_NOTIFY_EVENT_CLASS; \
	typedef theClass _PropMapClass; \
	static ATL_PROPMAP_ENTRY* GetPropertyMap()\
	{\
		static ATL_PROPMAP_ENTRY pPropMap[] = \
		{ \

#define BEGIN_PROP_MAP(theClass) \
	typedef _ATL_PROP_NOTIFY_EVENT_CLASS __ATL_PROP_NOTIFY_EVENT_CLASS; \
	typedef theClass _PropMapClass; \
	static ATL_PROPMAP_ENTRY* GetPropertyMap()\
	{\
		static ATL_PROPMAP_ENTRY pPropMap[] = \
		{

#define PROP_ENTRY(szDesc, dispid, clsid) {},

#define PROP_ENTRY_EX(szDesc, dispid, clsid, iidDispatch) {},

#define PROP_PAGE(clsid) {},

#define PROP_DATA_ENTRY(szDesc, member, vt) {},

#define END_PROPERTY_MAP() {}\
		}; \
		return pPropMap; \
	}

#define END_PROP_MAP() {}\
		}; \
		return pPropMap; \
	}

#define DECLARE_PROTECT_FINAL_CONSTRUCT()\
	void InternalFinalConstructAddRef() {InternalAddRef();}\
	void InternalFinalConstructRelease() {InternalRelease();}

#define DECLARE_NOT_AGGREGATABLE(x) public:\
	typedef CComCreator2< CComCreator< CComObject< x > >, CComFailCreator<CLASS_E_NOAGGREGATION> > _CreatorClass;
#define DECLARE_AGGREGATABLE(x) public:\
	typedef CComCreator2< CComCreator< CComObject< x > >, CComCreator< CComAggObject< x > > > _CreatorClass;
#define DECLARE_ONLY_AGGREGATABLE(x) public:\
	typedef CComCreator2< CComFailCreator<E_FAIL>, CComCreator< CComAggObject< x > > > _CreatorClass;
#define DECLARE_POLY_AGGREGATABLE(x) public:\
	typedef CComCreator< CComPolyObject< x > > _CreatorClass;

#define DEBUG_QI_ENTRY(x)

#define _ATL_DECLARE_GET_UNKNOWN(x) IUnknown* GetUnknown() {return _GetRawUnknown();}

#define BEGIN_COM_MAP(x) public: \
	typedef x _ComMapClass; \
	static HRESULT WINAPI _Cache(void* pv, REFIID iid, void** ppvObject, DWORD dw) {}\
	IUnknown* _GetRawUnknown() {}\
	_ATL_DECLARE_GET_UNKNOWN(x)\
	HRESULT _InternalQueryInterface(REFIID iid, void** ppvObject) {}\
	const static _ATL_INTMAP_ENTRY* WINAPI _GetEntries() { \
	static const _ATL_INTMAP_ENTRY _entries[] = { DEBUG_QI_ENTRY(x)

#define DECLARE_GET_CONTROLLING_UNKNOWN() public:\
	virtual IUnknown* GetControllingUnknown() {return GetUnknown();}

#define _ATL_IIDOF(x) IID_##x

#define COM_INTERFACE_ENTRY_BREAK(x) {},
#define COM_INTERFACE_ENTRY_NOINTERFACE(x) {},
#define COM_INTERFACE_ENTRY(x) {},
#define COM_INTERFACE_ENTRY_IID(iid, x) {},

// The impl macros are now obsolete
#define COM_INTERFACE_ENTRY_IMPL(x)\
	COM_INTERFACE_ENTRY_IID(_ATL_IIDOF(x), x##Impl<_ComMapClass>)

#define COM_INTERFACE_ENTRY_IMPL_IID(iid, x)\
	COM_INTERFACE_ENTRY_IID(iid, x##Impl<_ComMapClass>)
//

#define COM_INTERFACE_ENTRY2(x, x2) {},
#define COM_INTERFACE_ENTRY2_IID(iid, x, x2) {},
#define COM_INTERFACE_ENTRY_FUNC(iid, dw, func) {},
#define COM_INTERFACE_ENTRY_FUNC_BLIND(dw, func) {},
#define COM_INTERFACE_ENTRY_TEAR_OFF(iid, x) {},
#define COM_INTERFACE_ENTRY_CACHED_TEAR_OFF(iid, x, punk) {},
#define COM_INTERFACE_ENTRY_AGGREGATE(iid, punk) {},
#define COM_INTERFACE_ENTRY_AGGREGATE_BLIND(punk) {},
#define COM_INTERFACE_ENTRY_AUTOAGGREGATE(iid, punk, clsid) {},
#define COM_INTERFACE_ENTRY_AUTOAGGREGATE_BLIND(punk, clsid) {},
#define COM_INTERFACE_ENTRY_CHAIN(classname) {},

#define END_COM_MAP() {NULL, 0, 0}}; return _entries;} \
	virtual ULONG STDMETHODCALLTYPE AddRef( void) = 0; \
	virtual ULONG STDMETHODCALLTYPE Release( void) = 0; \
	STDMETHOD(QueryInterface)(REFIID, void**) = 0;

#define BEGIN_CATEGORY_MAP(x)\
   static const struct _ATL_CATMAP_ENTRY* GetCategoryMap() {\
   static const struct _ATL_CATMAP_ENTRY pMap[] = {
#define IMPLEMENTED_CATEGORY( catid ) { _ATL_CATMAP_ENTRY_IMPLEMENTED, &catid },
#define REQUIRED_CATEGORY( catid ) { _ATL_CATMAP_ENTRY_REQUIRED, &catid },
#define END_CATEGORY_MAP()\
   { _ATL_CATMAP_ENTRY_END, NULL } };\
   return( pMap ); }

#define BEGIN_OBJECT_MAP(x) static _ATL_OBJMAP_ENTRY x[] = {
#define END_OBJECT_MAP()   {}};
#define OBJECT_ENTRY(clsid, class) {},
#define OBJECT_ENTRY_NON_CREATEABLE(class) {},

#define DECLARE_CLASSFACTORY_EX(cf) typedef CComCreator< CComObjectCached< cf > > _ClassFactoryCreatorClass;
#define DECLARE_CLASSFACTORY() DECLARE_CLASSFACTORY_EX(CComClassFactory)
#define DECLARE_CLASSFACTORY2(lic) DECLARE_CLASSFACTORY_EX(CComClassFactory2<lic>)
#define DECLARE_CLASSFACTORY_AUTO_THREAD() DECLARE_CLASSFACTORY_EX(CComClassFactoryAutoThread)
#define DECLARE_CLASSFACTORY_SINGLETON(obj) DECLARE_CLASSFACTORY_EX(CComClassFactorySingleton<obj>)

#define DECLARE_OBJECT_DESCRIPTION(x)\
	static LPCTSTR WINAPI GetObjectDescription() {}

#define DECLARE_NO_REGISTRY()\
	static HRESULT WINAPI UpdateRegistry(BOOL /*bRegister*/) {}

#define DECLARE_REGISTRY(class, pid, vpid, nid, flags)\
	static HRESULT WINAPI UpdateRegistry(BOOL bRegister) {}

#define DECLARE_REGISTRY_RESOURCE(x)\
	static HRESULT WINAPI UpdateRegistry(BOOL bRegister) {}

#define DECLARE_REGISTRY_RESOURCEID(x)\
	static HRESULT WINAPI UpdateRegistry(BOOL bRegister) {}

#define DECLARE_STATIC_REGISTRY_RESOURCE(x) DECLARE_REGISTRY_RESOURCE(x)
#define DECLARE_STATIC_REGISTRY_RESOURCEID(x) DECLARE_REGISTRY_RESOURCEID(x)


#define BEGIN_SERVICE_MAP(x) public: \
	HRESULT _InternalQueryService(REFGUID guidService, REFIID riid, void** ppvObject) \
	{

#define SERVICE_ENTRY(x) ;
#define SERVICE_ENTRY_CHAIN(x) ;
#define END_SERVICE_MAP() ;

#define BEGIN_SINK_MAP(_class)\
	static const _ATL_EVENT_ENTRY<_class>* _GetSinkMap()\
	{\
		typedef _class _atl_event_classtype;\
		static const _ATL_EVENT_ENTRY<_class> map[] = {

#define SINK_ENTRY_INFO(id, iid, dispid, fn, info)
#define SINK_ENTRY_EX(id, iid, dispid, fn) SINK_ENTRY_INFO(id, iid, dispid, fn, NULL)
#define SINK_ENTRY(id, dispid, fn) SINK_ENTRY_EX(id, IID_NULL, dispid, fn)
#define END_SINK_MAP() }; return map;}

#define BEGIN_CONNECTION_POINT_MAP(x)\
	typedef x _atl_conn_classtype;\
	static const _ATL_CONNMAP_ENTRY* GetConnMap(int* pnEntries) {\
	static const _ATL_CONNMAP_ENTRY _entries[] = {
#define CONNECTION_POINT_ENTRY(iid)
#define END_CONNECTION_POINT_MAP() }; \
	;}

// == from ATLCTL.H ==
#define DECLARE_VIEW_STATUS(statusFlags) \
	DWORD _GetViewStatus() {}

// == from ATLDBCLI.H ==

#define BEGIN_ACCESSOR_MAP(x, num) \
	public: \
	typedef x _classtype; \
	typedef x _OutputColumnsClass; \
	static ULONG _GetNumAccessors() { return num; } \
	static bool HasOutputColumns() { return true; } \
	inline static HRESULT _GetBindEntries(ULONG* pColumns, DBBINDING *pBinding, ULONG nAccessor, bool* pAuto, BYTE* pBuffer = NULL) {
#define BEGIN_ACCESSOR(num, bAuto)
#define END_ACCESSOR()
#define END_ACCESSOR_MAP() }

#define BEGIN_COLUMN_MAP(x) \
	BEGIN_ACCESSOR_MAP(x, 1)
#define END_COLUMN_MAP() \
	END_ACCESSOR_MAP()

/* // Used in method body, unmeaningful for Object Model
#define _COLUMN_ENTRY_CODE(nOrdinal, wType, nLength, nPrecision, nScale, dataOffset, lengthOffset, statusOffset)
#define COLUMN_ENTRY_EX(nOrdinal, wType, nLength, nPrecision, nScale, data, length, status)
#define COLUMN_ENTRY_TYPE(nOrdinal, wType, data)
#define COLUMN_ENTRY_TYPE_SIZE(nOrdinal, wType, nLength, data)

#define COLUMN_ENTRY(nOrdinal, data)
#define COLUMN_ENTRY_LENGTH(nOrdinal, data, length)
#define COLUMN_ENTRY_STATUS(nOrdinal, data, status)
#define COLUMN_ENTRY_LENGTH_STATUS(nOrdinal, data, length, status)

#define COLUMN_ENTRY_PS(nOrdinal, nPrecision, nScale, data)
#define COLUMN_ENTRY_PS_LENGTH(nOrdinal, nPrecision, nScale, data, length)
#define COLUMN_ENTRY_PS_STATUS(nOrdinal, nPrecision, nScale, data, status)
#define COLUMN_ENTRY_PS_LENGTH_STATUS(nOrdinal, nPrecision, nScale, data, length, status)
*/

#define BOOKMARK_ENTRY(variable)

#define _BLOB_ENTRY_CODE(nOrdinal, IID, flags, dataOffset, statusOffset)
#define BLOB_ENTRY(nOrdinal, IID, flags, data)
#define BLOB_ENTRY_STATUS(nOrdinal, IID, flags, data, status)

#define BEGIN_PARAM_MAP(x) \
	public: \
	typedef x _classtype; \
	typedef x _ParamClass; \
	static bool HasParameters() { return true; } \
	static HRESULT _GetParamEntries(ULONG* pColumns, DBBINDING *pBinding, BYTE* pBuffer = NULL) {
#define END_PARAM_MAP() }

#define DEFINE_COMMAND(x, szCommand) \
	typedef x _CommandClass; \
	static HRESULT GetDefaultCommand(LPCTSTR* ppszCommand) {}

// == from ATLSNAP.H ==

#define EXTENSION_SNAPIN_DATACLASS(dataClass) dataClass m_##dataClass;
#define BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP(classname) \
	HRESULT GetDataClass(IDataObject* pDataObject, CSnapInItem** ppItem, DATA_OBJECT_TYPES* pType) {
/* // Used in method body, unmeaningful for Object Model
#define EXTENSION_SNAPIN_NODEINFO_ENTRY(dataClass)
#define END_EXTENSION_SNAPIN_NODEINFO_MAP()
*/
#define END_EXTENSION_SNAPIN_NODEINFO_MAP() }

#define SNAPINMENUID(id) \
public: \
	static const UINT GetMenuID() {}
#define EXT_SNAPINMENUID(id) \
public: \
	static const UINT GetMenuID() {}
#define BEGIN_SNAPINCOMMAND_MAP(theClass, bIsExtension) \
	HRESULT ProcessCommand(UINT nID, bool& bHandled, CSnapInObjectRootBase* pObj, DATA_OBJECT_TYPES type) {
/* // Used in method body, unmeaningful for Object Model
#define SNAPINCOMMAND_ENTRY(id, func)
#define SNAPINCOMMAND_RANGE_ENTRY(id1, id2, func)
*/
#define CHAIN_SNAPINCOMMAND_MAP(theChainClass) {}
#define END_SNAPINCOMMAND_MAP() }

#define BEGIN_SNAPINTOOLBARID_MAP(theClass) \
public: \
	static CSnapInToolbarInfo* GetToolbarInfo() {
/* // Used in method body, unmeaningful for Object Model
#define SNAPINTOOLBARID_ENTRY(id)
*/
#define END_SNAPINTOOLBARID_MAP() }

// == from ATLDB.H ==
#define BEGIN_PROPSET_MAP(Class) \
static UPROPSET* _GetPropSet(ULONG* pNumPropSets, ULONG* pcElemPerSupported, UPROPSET* pSet = NULL, GUID* pguidSet = (GUID*)&(GUID_NULL)) {
/* // Used in method body, unmeaningful for Object Model
#define BEGIN_PROPERTY_SET_EX(guid, flags) \
static const UPROPINFO aProperty##guid[] = \
{
#define BEGIN_PROPERTY_SET(guid) BEGIN_PROPERTY_SET_EX(guid, 0)
#define PROPERTY_INFO_ENTRY_EX(dwPropID, vt, dwFlags, value, options) DBPROP_##dwPropID, IDS_DBPROP_##dwPropID, vt, dwFlags, (DWORD)value, (DBPROPOPTIONS)options,
#define PROPERTY_INFO_ENTRY_VALUE(dwPropID, value) PROPERTY_INFO_ENTRY_EX(dwPropID, dwPropID##_Type, ##dwPropID##_Flags, value, 0)
#define PROPERTY_INFO_ENTRY(dwPropID) PROPERTY_INFO_ENTRY_VALUE(dwPropID, dwPropID##_Value)
#define END_PROPERTY_SET(guid) }
#define CHAIN_PROPERTY_SET(ChainClass)
*/
#define END_PROPSET_MAP() }

#define BEGIN_SCHEMA_MAP(SchemaClass) \
	typedef SchemaClass _SchemaClass; \
	HRESULT _SchemaSupport(GUID** ppGuid, \
						   IUnknown *pUnkOuter, \
						   REFIID rguidSchema, \
						   ULONG cRestrictions, \
						   const VARIANT rgRestrictions[], \
						   REFIID riid, \
						   ULONG cPropertySets, \
						   DBPROPSET rgPropertySets[], \
						   IUnknown **ppRowset) {
/* // Used in method body, unmeaningful for Object Model
#define SCHEMA_ENTRY(guid, rowsetClass) \
*/
#define END_SCHEMA_MAP() }

#define BEGIN_PROVIDER_COLUMN_MAP(theClass) \
	typedef theClass _Class; \
	template <class T> \
	static ATLCOLUMNINFO* GetColumnInfo(T* pv, ULONG* pcCols) {
#define EXPANDGUID(guid) {}
/* // Used in method body, unmeaningful for Object Model
#define PROVIDER_COLUMN_ENTRY_GN(name, ordinal, flags, colSize, dbtype, precision, scale, guid)
#define PROVIDER_COLUMN_ENTRY(name, ordinal, member)
#define PROVIDER_COLUMN_ENTRY_LENGTH(name, ordinal, size, member)
#define PROVIDER_COLUMN_ENTRY_TYPE_LENGTH(name, ordinal, type, size, member)
#define PROVIDER_COLUMN_ENTRY_FIXED(name, ordinal, dbtype, member)
#define PROVIDER_COLUMN_ENTRY_STR(name, ordinal, member)
#define PROVIDER_COLUMN_ENTRY_WSTR(name, ordinal, member)
*/
#define END_PROVIDER_COLUMN_MAP() }

#endif // TS_PREINCLUDE_ATL



// **********************************************************************
//
//
// Macro definitions for Borland C++ version 5.0.
//
//
// **********************************************************************

#if defined(TS_PREINCLUDE_BORLAND_CPP) || defined(OI_PREINCLUDE_BORLAND_CPP)

// workarounds.

#define public_data public
#define protected_data protected

// common macroses.

#define _CALLCNVN
#define _SVCSDLL
#define _RTLDLL

#define _SVCSCLASS     _CALLCNVN
#define _SVCSCLASS_RTL _EXPCLASS
#define _SVCSDATA
#define _SVCSFUNC

#define _RTTI

#define _BIDSCLASS
#define _BIDSFARCLASS
#define _BIDSTEMPL
#define _CLASSTYPE
#define _CLASSDEF(name) class name;
#define _EXPCLASS
#define _WINSYSCLASS
#define _DBAWARECLASS

#define WINOLEAPI_(arg) arg
#define HDC
#define WINAPI ulong
#define STDMETHODIMP_(arg) arg

#define STDMETHODCALLTYPE       __stdcall
#define STDMETHODVCALLTYPE      __cdecl

#define STDAPICALLTYPE          __stdcall
#define STDAPIVCALLTYPE         __cdecl

#define STDAPI                  EXTERN_C HRESULT STDAPICALLTYPE
#define STDAPI_(type)           EXTERN_C type STDAPICALLTYPE

#define STDAPIV                 EXTERN_C HRESULT STDAPIVCALLTYPE
#define STDAPIV_(type)          EXTERN_C type STDAPIVCALLTYPE

#define STDMETHODIMPV           HRESULT STDMETHODVCALLTYPE
#define STDMETHODIMPV_(type)    type STDMETHODVCALLTYPE

#define interface               struct
#define STDMETHODCALLTYPE       __stdcall

#define STDMETHOD(method)       HRESULT (STDMETHODCALLTYPE * method)
#define STDMETHOD_(type,method) type (STDMETHODCALLTYPE * method)
#define PURE
#define THIS_                   this
#define THIS                    this

#define DECLARE_INTERFACE(iface)    typedef interface iface { \
                                    const struct iface##Vtbl FAR* lpVtbl; \
                                } iface; \
                                typedef const struct iface##Vtbl iface##Vtbl; \
                                const struct iface##Vtbl

#define EXTERN_C    extern
#define CDECL
#define GUID

#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
        EXTERN_C const GUID CDECL name \
                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }


//

#define _export
#define _import

#define FAR
#define _FAR
#define far
#define __RTFAR
#define __RCC_FAR
#define FARSTRUCT
#define NEAR
#define CONST               const

#define EXTERN_C
#define EXTERN
#define PASCAL
#define CDECL
#define HUGE
#define huge
#define __huge

#define UNALIGNED
#define IN
#define OUT

//
// Macros to declare a response table
//
#define DECLARE_RESPONSE_TABLE(cls)\
  private:\
    static TResponseTableEntry< cls > __RTFAR __entries[];\
    typedef TResponseTableEntry< cls >::PMF   TMyPMF;\
    typedef cls                               TMyClass;\
  public:\
    bool  Find(TEventInfo&, TEqualOperator = 0)


#define DEFINE_RESPONSE_TABLE_ENTRIES(cls)\
  TResponseTableEntry< cls > __RTFAR  cls::__entries[] = {

//
// Macro to define a response table for a class with no base response tables
//
// Use it like this:
//    DEFINE_RESPONSE_TABLE(cls)
//      EV_WM_PAINT,
//      EV_WM_LBUTTONDOWN,
//    END_RESPONSE_TABLE;
//
#define DEFINE_RESPONSE_TABLE(cls)\
  bool  cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
      {eventInfo.Object = (GENERIC*)this;\
       return SearchEntries((TGenericTableEntry __RTFAR*)__entries, eventInfo, equal);}\
  DEFINE_RESPONSE_TABLE_ENTRIES(cls)

//
// Macro to define a response table for a class with one base. Use this macro
// exactly like macro DEFINE_RESPONSE_TABLE
//
#define DEFINE_RESPONSE_TABLE1(cls, base)\
  bool  cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
      {eventInfo.Object = (GENERIC*)this;\
       return SearchEntries((TGenericTableEntry __RTFAR*)__entries, eventInfo, equal) ||\
              base::Find(eventInfo, equal);}\
  DEFINE_RESPONSE_TABLE_ENTRIES(cls)

//
// Macro to define a response table for a class with two bases. Use this macro
// exactly like macro DEFINE_RESPONSE_TABLE
//
#define DEFINE_RESPONSE_TABLE2(cls, base1, base2)\
  bool  cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
      {eventInfo.Object = (GENERIC*)this;\
       return SearchEntries((TGenericTableEntry __RTFAR*)__entries, eventInfo, equal) ||\
              base1::Find(eventInfo, equal) ||\
              base2::Find(eventInfo, equal);}\
  DEFINE_RESPONSE_TABLE_ENTRIES(cls)

//
// Macro to define a response table for a class with three bases. Use this macro
// exactly like macro DEFINE_RESPONSE_TABLE
//
#define DEFINE_RESPONSE_TABLE3(cls, base1, base2, base3)\
  bool  cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
      {eventInfo.Object = (GENERIC*)this;\
       return SearchEntries((TGenericTableEntry __RTFAR*)__entries, eventInfo, equal) ||\
              base1::Find(eventInfo, equal) ||\
              base2::Find(eventInfo, equal) ||\
              base3::Find(eventInfo, equal);}\
  DEFINE_RESPONSE_TABLE_ENTRIES(cls)

#define END_RESPONSE_TABLE {0, 0, 0, 0}}

// Events.
#define EV_MESSAGE(message, method)
#define EV_REGISTERED(str, method)
#define EV_CHILD_NOTIFY(id, notifyCode, method)
#define EV_CHILD_NOTIFY_AND_CODE(id, notifyCode, method)
#define EV_CHILD_NOTIFY_ALL_CODES(id, method)
#define EV_NOTIFY_AT_CHILD(notifyCode, method)
#define EV_COMMAND(id, method)
#define EV_COMMAND_AND_ID(id, method)
#define EV_COMMAND_ENABLE(id, method)
#define EV_OWLDOCUMENT(id, method)
#define EV_OWLVIEW(id, method)
#define EV_OWLNOTIFY(id, method)
#define EV_VIEWNOTIFY(id, method)
#define EV_OWLFRAMESIZE

// Stream macroses.

#define _TYPENAME(obj) (obj)->CastableID()

#define DECLARE_STREAMER( exp, cls, ver )                           \
public:                                                             \
    class exp Streamer : public TNewStreamer                        \
        {                                                           \
        public:                                                     \
                                                                    \
        Streamer(TStreamableBase *obj);                             \
                                                                    \
        virtual uint32 ClassVersion() const                         \
            { return ver; }                                         \
                                                                    \
        virtual void Write( opstream& ) const;                      \
        virtual void *Read( ipstream&, uint32 ) const;              \
                                                                    \
        cls *GetObject() const                                      \
            {                                                       \
            return object;                                          \
            }                                                       \
                                                                    \
        static TStreamer *Build( TStreamableBase *obj )             \
            {                                                       \
            return new Streamer( obj ? obj : new cls(streamableInit) ); \
            }                                                       \
                                                                    \
        private:                                                    \
            cls *object;                                            \
                                                                    \
        };                                                          \
    friend Streamer;                                                \
    friend void ReadBaseObject( cls *, ipstream& );                 \
    friend void WriteBaseObject( cls *, opstream& );                \
    friend void ReadVirtualBase( cls *, ipstream& );                \
    friend void WriteVirtualBase( cls *, opstream& )

#define DECLARE_STREAMER_FROM_BASE( exp, cls, base )                \
public:                                                             \
    class exp Streamer : public base::Streamer                      \
        {                                                           \
        public:                                                     \
        Streamer( TStreamableBase *obj ) : base::Streamer(obj){}    \
        cls *GetObject() const {}                                   \
        static TStreamer *Build( TStreamableBase *obj ) {}          \
        private:                                                    \
            cls *object;                                            \
        };                                                          \
    friend Streamer;                                                \
    friend void ReadBaseObject( cls *, ipstream& );                 \
    friend void WriteBaseObject( cls *, opstream& );                \
    friend void ReadVirtualBase( cls *, ipstream& );                \
    friend void WriteVirtualBase( cls *, opstream& )

#define DECLARE_ABSTRACT_STREAMER( exp, cls, ver )                  \
public:                                                             \
    class exp Streamer : public TNewStreamer                        \
        {                                                           \
        public:                                                     \
        Streamer( TStreamableBase *obj );                           \
        virtual uint32 ClassVersion() const {}                      \
        virtual void Write( opstream& ) const;                      \
        virtual void *Read( ipstream&, uint32 ) const;              \
        cls *GetObject() const {}                                   \
        private:                                                    \
            cls *object;                                            \
        };                                                          \
    friend Streamer;                                                \
    friend void ReadBaseObject( cls *, ipstream& );                 \
    friend void WriteBaseObject( cls *, opstream& );                \
    friend void ReadVirtualBase( cls *, ipstream& );                \
    friend void WriteVirtualBase( cls *, opstream& )


#define DECLARE_STREAMABLE_OPS( cls )                               \
static ipstream& readRef( ipstream& is, cls& cl );                  \
friend inline ipstream& operator >> ( ipstream& is, cls& cl ) {}    \
static ipstream& readPtr( ipstream& is, cls*& cl );                 \
friend inline ipstream& operator >> ( ipstream& is, cls*& cl )  {}  \
static opstream& writeRef( opstream& is, const cls& cl );           \
friend inline opstream& operator << ( opstream& os, const cls& cl ) {} \
static opstream& writePtr( opstream& is, const cls* cl );           \
friend inline opstream& operator << ( opstream& os, const cls* cl ) {} \

#define DECLARE_STREAMABLE_CTOR( cls )                              \
public:                                                             \

    cls ( StreamableInit )

#define DECLARE_CASTABLE friend class typeinfo

#define DECLARE_STREAMABLE( exp, cls, ver )                         \
    DECLARE_CASTABLE ;                                               \
    DECLARE_STREAMER( exp, cls, ver );                              \
    DECLARE_STREAMABLE_OPS( cls );                                  \
    DECLARE_STREAMABLE_CTOR( cls )

#define DECLARE_STREAMABLE_FROM_BASE( exp, cls, base )              \
    DECLARE_CASTABLE;                                               \
    DECLARE_STREAMER_FROM_BASE( exp, cls, base );                   \
    DECLARE_STREAMABLE_OPS( cls );                                  \
    DECLARE_STREAMABLE_CTOR( cls )

#define DECLARE_ABSTRACT_STREAMABLE( exp, cls, ver )                \
    DECLARE_CASTABLE;                                               \
    DECLARE_ABSTRACT_STREAMER( exp, cls, ver );                     \
    DECLARE_STREAMABLE_OPS( cls );                                  \
    DECLARE_STREAMABLE_CTOR( cls )

#define IMPLEMENT_CASTABLE( cls )
#define IMPLEMENT_CASTABLE1( cls, base1 )
#define IMPLEMENT_CASTABLE2( cls, base1, base2 )
#define IMPLEMENT_CASTABLE3( cls, base1, base2, base3 )
#define IMPLEMENT_CASTABLE4( cls, base1, base2, base3, base4 )
#define IMPLEMENT_CASTABLE5( cls, base1, base2, base3, base4, base5 )

#define IMPLEMENT_STREAMABLE_CLASS( cls )
#define IMPLEMENT_STREAMABLE_POINTER( cls )
#define IMPLEMENT_STREAMER( cls )
#define IMPLEMENT_STREAMABLE_CTOR( cls )
#define IMPLEMENT_STREAMABLE_CTOR1( cls, base1 )
#define IMPLEMENT_STREAMABLE_CTOR2( cls, base1, base2 )
#define IMPLEMENT_STREAMABLE_CTOR3( cls, base1, base2, base3 )
#define IMPLEMENT_STREAMABLE_CTOR4( cls, base1, base2, base3, base4 )
#define IMPLEMENT_STREAMABLE_CTOR5( cls, base1,base2,base3,base4,base5)

#define IMPLEMENT_ABSTRACT_STREAMABLE( cls )
#define IMPLEMENT_ABSTRACT_STREAMABLE1( cls, base1 )
#define IMPLEMENT_ABSTRACT_STREAMABLE2( cls, base1, base2 )
#define IMPLEMENT_ABSTRACT_STREAMABLE3( cls, base1, base2, base3 )
#define IMPLEMENT_ABSTRACT_STREAMABLE4( cls, base1, base2, base3, base4 )
#define IMPLEMENT_ABSTRACT_STREAMABLE5( cls, base1, base2, base3, base4, base5 )
#define IMPLEMENT_STREAMABLE( cls )
#define IMPLEMENT_STREAMABLE1( cls, base1 )
#define IMPLEMENT_STREAMABLE2( cls, base1, base2 )
#define IMPLEMENT_STREAMABLE3( cls, base1, base2, base3 )
#define IMPLEMENT_STREAMABLE4( cls, base1, base2, base3, base4 )
#define IMPLEMENT_STREAMABLE5( cls, base1, base2, base3, base4, base5 )
#define IMPLEMENT_STREAMABLE_FROM_BASE( cls, base1 )

//
// Macros to define enumeration list
//

#define _ICLASS
#define DEFINE_AUTOENUM(cls, type) \
  TAutoEnumVal<type##Enum> cls##_Table[] = {
#define AUTOENUM(name, val) {{name}, val},
#define END_AUTOENUM(cls, type) }; \
  struct cls { static TAutoEnumT<type##Enum> ClassInfo; }; \
  TAutoEnumT<type##Enum> cls::ClassInfo(cls##_Table, \
  sizeof(cls##_Table)/sizeof(TAutoEnumVal<type##Enum>),type::ClassInfo.GetType());

//
// Macros for defining symbol tables
//

#define DEFINE_AUTOCLASS(cls) \
  TAutoSymbol cls::SymbolTable[] = {
#define END_AUTOCLASS(cls, flags, name, doc, help) };
//{{name},{doc}, 0, \
//  flags,0,TAutoSymbol::InitAutoDestructor(cls::TCommand_dtr::Build),help} }; \
//  TAutoClass cls::ClassInfo(cls::SymbolTable, cls::SymbolTable + \
//     (sizeof(cls::SymbolTable)/sizeof(TAutoSymbol) - 1), typeid(cls), 0);

#define DEFINE_AUTOAGGREGATE(cls, aggregator) \
  IUnknown& cls::Aggregator(ObjectPtr inst, TUnknown& inner) \
        { return ((cls*)inst)->aggregator(inner); } \
  DEFINE_AUTOCLASS(cls)

#define END_AUTOAGGREGATE(cls, flags, name, doc, help) };
//{{name},{doc}, 0, \
  //flags,0,TAutoSymbol::InitAutoDestructor(cls::TCommand_dtr::Build),help} }; \
  //TAutoClass cls::ClassInfo(cls::SymbolTable, cls::SymbolTable + \
  //(sizeof(cls::SymbolTable)/sizeof(TAutoSymbol)-1),typeid(cls),cls::Aggregator);

#define DEFINE_AUTOEVENTCLASS(cls) \
  class cls {static TAutoClass ClassInfo; static TAutoSymbol SymbolTable[]; \
  typedef TAutoEventDummy ThisClass; };\
  TAutoSymbol cls::SymbolTable[] = {

#define END_AUTOEVENTCLASS(cls, flags, name, doc, help) };
//{{name},{doc}, 0, \
//  flags|tfEventSource, 0, 0,help} }; \
//  TAutoClass cls::ClassInfo(cls::SymbolTable, cls::SymbolTable + \
//     (sizeof(cls::SymbolTable)/sizeof(TAutoSymbol) - 1), typeid(cls), 0);

#define DEFINE_AUTODISPATCH(cls) DEFINE_AUTOCLASS(cls)
#define END_AUTODISPATCH(cls)    END_AUTOCLASS(cls, 0, 0, 0)

#define EXPOSE_METHOD(cmd, cls, name, doc, help)
#define EXPOSE_METHOD_ID(id, cmd, cls, name, doc, help)
#define EXPOSE_PROPRW(cmd, cls, name, doc, help)
#define EXPOSE_PROPRW_ID(id, cmd, cls, name, doc, help)
#define EXPOSE_PROPRO(cmd, cls, name, doc, help)
#define EXPOSE_PROPRO_ID(id, cmd, cls, name, doc, help)
#define EXPOSE_PROPWO(cmd, cls, name, doc, help)
#define EXPOSE_PROPWO_ID(id, cmd, cls, name, doc, help)
#define EXPOSE_APPLICATION(cls, name, doc, help)
#define EXPOSE_QUIT(name, doc, help)
#define REQUIRED_ARG(cls, name)
#define OPTIONAL_ARG(cls, name, dflt)
#define EXPOSE_DELEGATE(cls, name, locator)
#define EXPOSE_INHERIT(cls, name)
#define EXPOSE_FACTORY(cls, name, base)
#define EXPOSE_ITERATOR(cls, doc, help)

//
// Macros for defining command objects
//

#define AUTOUNDO(code)   TAutoCommand* Undo(){code}  // declare an undo method
#define AUTORECORD(code) int Record(TAutoStack& args){code};  // record method
#define AUTOINVOKE(code) TAutoCommand& Invoke(){code return *this;}// override
#define AUTOVALIDATE(condition) bool Validate() { return condition; }
#define AUTONOHOOK TAutoCommand& Invoke() {Execute();}
#define AUTOREPORT(errcode) long Report() {return errcode;}

//----------------------------------------------------------------------------

//
// Autoclass declaration, adding derived TAutoCommand class with this pointer
//

#define DECLARE_AUTOCLASS(cls) \
  public: \
    static TAutoClass ClassInfo; \
  protected: \
    static TAutoSymbol SymbolTable[]; \
    class TThisCommand : public TAutoCommand { \
      protected: \
        TThisCommand(cls* obj, int attr):TAutoCommand(attr),This(obj){} \
        cls* This; \
    }; \
    typedef cls ThisClass; \
    class TCommand_app : public TAutoCommand { \
     public: \
      TCommand_app(int attr, TServedObject* app) \
                     : TAutoCommand(attr), Val(app) {} \
      void Return(TAutoVal& v) {v=(IDispatch*)Val;} \
      TServedObject* Val; \
      static TAutoCommand* Build(ObjectPtr obj,int attr,TAutoStack& args) \
      { return new TCommand_app(attr, args.Owner->GetAppObject()); } \
    }; \
    class TCommand_dtr : public TThisCommand { \
     public: \
      TCommand_dtr(ThisClass* obj, int attr) \
                     : TThisCommand(obj, attr) {} \
      void Execute(){if (Attr == TObjectDescriptor::PostQuit) \
                       ::PostQuitMessage(0);\
                     else delete This;} \
      static TAutoCommand* Build(ObjectPtr obj,int attr) \
      { return new TCommand_dtr((ThisClass*)obj, attr); }\
    }; friend class TCommand_dtr;

#define DECLARE_AUTODISPATCH(cls) \
  public: \
    static TAutoClass ClassInfo; \
  protected: \
    static TAutoSymbol SymbolTable[]; \
    class TThisCommand : public TAutoCommand { \
      protected: \
        TThisCommand(cls* obj, int attr):TAutoCommand(attr),This(obj){} \
        cls* This; \
    }; typedef cls ThisClass;

//
// Autoclass declaration for COM-aggregatable classes
//

#define DECLARE_AUTOAGGREGATE(cls) \
  public: \
    static IUnknown& Aggregator(ObjectPtr inst, TUnknown& inner); \
  DECLARE_AUTOCLASS(cls)

//
// Command object class definition for methods or get-only properties
//
#define RETARG(t) void Return(TAutoVal& v){v=Val;} t Val;

#define AUTOFUNC_(name, invoke, defs, defargs, bldargs, ctrargs, setargs) \
    class TCommand_##name : public TThisCommand { \
     public:  typedef TCommand_##name ThisCmd; \
      defs defargs \
      TCommand_##name(ThisClass* obj, int attr ctrargs) \
                     : TThisCommand(obj, attr) setargs {} \
      void Execute() {invoke} \
      static TAutoCommand* Build(ObjectPtr obj,int attr,TAutoStack& args) \
      { return new TCommand_##name((ThisClass*)obj, attr bldargs); }\
    }; friend class TCommand_##name;

// Command object class definition for properties with both get and set
//
#define AUTOPROP_(name, getcode, setcode, defs, type) \
    class TCommand_##name : public TThisCommand { \
     public:  typedef TCommand_##name ThisCmd; \
      defs RETARG(type) \
      TCommand_##name(ThisClass* obj, int attr) : TThisCommand(obj, attr) {} \
      TCommand_##name(ThisClass* obj, int attr, type arg) \
                                      : TThisCommand(obj, attr), Val(arg) {} \
      void Execute() {if (IsPropSet()) {setcode} else {getcode}} \
      static TAutoCommand* Build(ObjectPtr obj,int attr,TAutoStack& args) \
      { return (attr & asGet) ?  \
        new TCommand_##name((ThisClass*)obj, attr) : \
        new TCommand_##name((ThisClass*)obj, attr,(type)args[TAutoStack::SetValue]);}\
    }; friend class TCommand_##name;

//
// Command object class definition for constructor commands
//

#define AUTOBUILD_(name, invoke, defs, defargs, bldargs, ctrargs, setargs) \
    class TCommand_##name : public TAutoCommand {\
     public: \
      defs defargs RETARG(TAutoMono<ThisClass>) \
      TCommand_##name(int attr ctrargs) : TAutoCommand(attr) setargs {} \
      void Execute() {invoke} \
      static TAutoCommand* Build(ObjectPtr, int attr, TAutoStack& args) \
      { return new TCommand_##name(attr bldargs); } \
    };

//
// Command object class definition for external object property
//

#define AUTOPROXY(name, proxy, defs) \
        AUTOPROP_(name, Val=This->proxy;, This->proxy.Bind(Val);, defs, IDispatch*)

//
// Iterator class definition
//
#define AUTOITERATOR(state, init, test, step, extract) \
    class TIterator : public TAutoIterator { \
     public: \
      ThisClass* This; \
      state; \
      void Init() {init;} \
      bool Test() {return test;} \
      void Step() {step;} \
      void Return(TAutoVal& v) {v=extract;} \
      TIterator* Copy() {return new TIterator(*this);} \
      TIterator(ThisClass* obj, TAutoCreator& creator, IUnknown* owner, TLangId lang) \
                    : This(obj), TAutoIterator(creator, owner, lang) {} \
      static TAutoIterator* Build(ObjectPtr obj, TAutoCreator& creator, \
                                  IUnknown* owner, TLangId lang) \
      { return new TIterator((ThisClass*)obj, creator, owner, lang); }\
    }; friend class TIterator;

#define AUTOITERATOR_DECLARE(state) \
    class TIterator : public TAutoIterator { \
     public: \
      ThisClass* This; \
      state; \
      void Init(); \
      bool Test(); \
      void Step(); \
      void Return(TAutoVal& v); \
      TIterator* Copy() {return new TIterator(*this);} \
      TIterator(ThisClass* obj, TAutoCreator& creator, IUnknown* owner, TLangId lang) \
                    : This(obj), TAutoIterator(creator, owner, lang) {} \
      static TAutoIterator* Build(ObjectPtr obj, TAutoCreator& creator, \
                                  IUnknown* owner, TLangId lang) \
      { return new TIterator((ThisClass*)obj, creator, owner, lang); }\
    }; friend class TIterator;

#define AUTODETACH \
    struct TDetach : public TAutoDetach { \
      ~TDetach(){Notify((int)&((ThisClass*)0)->dtr_notify,typeid(ThisClass));} \
    } dtr_notify; friend struct TDetach;

//
// Macros for defining lists of arguments
//

#define DEFARGS0(t0)                t0 Val;
#define DEFARGS1(t1)                t1 Arg1;
#define DEFARGS2(t1,t2)             t1 Arg1;t2 Arg2;
#define DEFARGS3(t1,t2,t3)          t1 Arg1;t2 Arg2;t3 Arg3;
#define DEFARGS4(t1,t2,t3,t4)       t1 Arg1;t2 Arg2;t3 Arg3;t4 Arg4;
#define DEFARGS5(t1,t2,t3,t4,t5)    t1 Arg1;t2 Arg2;t3 Arg3;t4 Arg4;t5 Arg5;
#define DEFARGS6(t1,t2,t3,t4,t5,t6) t1 Arg1;t2 Arg2;t3 Arg3;t4 Arg4;t5 Arg5;t6 Arg6;
#define DEFARGS7(t1,t2,t3,t4,t5,t6,t7) \
  t1 Arg1;t2 Arg2;t3 Arg3;t4 Arg4;t5 Arg5;t6 Arg6;t7 Arg7;
#define DEFARGS8(t1,t2,t3,t4,t5,t6,t7,t8) \
  t1 Arg1;t2 Arg2;t3 Arg3;t4 Arg4;t5 Arg5;t6 Arg6;t7 Arg7;t8 Arg8;
#define DEFARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9) \
  t1 Arg1;t2 Arg2;t3 Arg3;t4 Arg4;t5 Arg5;t6 Arg6;t7 Arg7;t8 Arg8;t9 Arg9;
#define DEFARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10) \
  t1 Arg1;t2 Arg2;t3 Arg3;t4 Arg4;t5 Arg5;t6 Arg6;t7 Arg7;t8 Arg8;t9 Arg9;t10 Arg10;

#define BLDARGS0(t0)                ,(t0)args[TAutoStack::SetValue]
#define BLDARGS1(t1)                ,(t1)args[0]
#define BLDARGS2(t1,t2)             ,(t1)args[0],(t2)args[1]
#define BLDARGS3(t1,t2,t3)          ,(t1)args[0],(t2)args[1],(t3)args[2]
#define BLDARGS4(t1,t2,t3,t4)                                  \
  ,(t1)args[0],(t2)args[1],(t3)args[2],(t4)args[3]
#define BLDARGS5(t1,t2,t3,t4,t5)                               \
  ,(t1)args[0],(t2)args[1],(t3)args[2],(t4)args[3],(t5)args[4]
#define BLDARGS6(t1,t2,t3,t4,t5,t6)                            \
  ,(t1)args[0],(t2)args[1],(t3)args[2],(t4)args[3],(t5)args[4],(t6)args[5]
#define BLDARGS7(t1,t2,t3,t4,t5,t6,t7)                         \
  ,(t1)args[0],(t2)args[1],(t3)args[2],(t4)args[3],(t5)args[4] \
  ,(t6)args[5],(t7)args[6]
#define BLDARGS8(t1,t2,t3,t4,t5,t6,t7,t8)                      \
  ,(t1)args[0],(t2)args[1],(t3)args[2],(t4)args[3],(t5)args[4] \
  ,(t6)args[5],(t7)args[6],(t8)args[7]
#define BLDARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9)                   \
  ,(t1)args[0],(t2)args[1],(t3)args[2],(t4)args[3],(t5)args[4] \
  ,(t6)args[5],(t7)args[6],(t8)args[7],(t9)args[8]
#define BLDARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10)              \
  ,(t1)args[0],(t2)args[1],(t3)args[2],(t4)args[3],(t5)args[4] \
  ,(t6)args[5],(t7)args[6],(t8)args[7],(t9)args[8],(t10)args[9]

#define CTRARGS0(t0)                    ,t0 val
#define CTRARGS1(t1)                    ,t1 arg1
#define CTRARGS2(t1,t2)                 ,t1 arg1,t2 arg2
#define CTRARGS3(t1,t2,t3)              ,t1 arg1,t2 arg2,t3 arg3
#define CTRARGS4(t1,t2,t3,t4)           ,t1 arg1,t2 arg2,t3 arg3,t4 arg4
#define CTRARGS5(t1,t2,t3,t4,t5)        ,t1 arg1,t2 arg2,t3 arg3,t4 arg4,t5 arg5
#define CTRARGS6(t1,t2,t3,t4,t5,t6)     ,t1 arg1,t2 arg2,t3 arg3,t4 arg4,t5 arg5,t6 arg6
#define CTRARGS7(t1,t2,t3,t4,t5,t6,t7)  ,t1 arg1,t2 arg2,t3 arg3,t4 arg4,t5 arg5,t6 arg6,t7 arg7
#define CTRARGS8(t1,t2,t3,t4,t5,t6,t7,t8) \
  ,t1 arg1,t2 arg2,t3 arg3,t4 arg4,t5 arg5,t6 arg6,t7 arg7,t8 arg8
#define CTRARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9) \
  ,t1 arg1,t2 arg2,t3 arg3,t4 arg4,t5 arg5,t6 arg6,t7 arg7,t8 arg8,t9 arg9
#define CTRARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10) \
  ,t1 arg1,t2 arg2,t3 arg3,t4 arg4,t5 arg5,t6 arg6,t7 arg7,t8 arg8,t9 arg9,t10 arg10

#define SETARGS0  ,Val(val)
#define SETARGS1  ,Arg1(arg1)
#define SETARGS2  ,Arg1(arg1),Arg2(arg2)
#define SETARGS3  ,Arg1(arg1),Arg2(arg2),Arg3(arg3)
#define SETARGS4  ,Arg1(arg1),Arg2(arg2),Arg3(arg3),Arg4(arg4)
#define SETARGS5  ,Arg1(arg1),Arg2(arg2),Arg3(arg3),Arg4(arg4),Arg5(arg5)
#define SETARGS6  ,Arg1(arg1),Arg2(arg2),Arg3(arg3),Arg4(arg4),Arg5(arg5),Arg6(arg6)
#define SETARGS7  ,Arg1(arg1),Arg2(arg2),Arg3(arg3),Arg4(arg4),Arg5(arg5),Arg6(arg6), \
  Arg7(arg7)
#define SETARGS8  ,Arg1(arg1),Arg2(arg2),Arg3(arg3),Arg4(arg4),Arg5(arg5),Arg6(arg6), \
  Arg7(arg7),Arg8(arg8)
#define SETARGS9  ,Arg1(arg1),Arg2(arg2),Arg3(arg3),Arg4(arg4),Arg5(arg5),Arg6(arg6), \
  Arg7(arg7),Arg8(arg8),Arg9(arg9)
#define SETARGS10 ,Arg1(arg1),Arg2(arg2),Arg3(arg3),Arg4(arg4),Arg5(arg5),Arg6(arg6), \
  Arg7(arg7),Arg8(arg8),Arg9(arg9),Arg10(arg10)

#define AUTOFUNC0(name, func, ret, defs) \
  AUTOFUNC_(name, Val=This->func();, defs, RETARG(ret), , , )

#define AUTOFUNC0V(name, func, defs) \
  AUTOFUNC_(name, This->func();, defs, , , , )

#define AUTOFUNC1(name, func, ret,type1, defs) \
  AUTOFUNC_(name, Val=This->func(Arg1);, defs, RETARG(ret) \
  DEFARGS1(type1), BLDARGS1(type1), CTRARGS1(type1), SETARGS1)

#define AUTOFUNC1V(name, func, type1, defs) \
  AUTOFUNC_(name, This->func(Arg1);, defs, \
  DEFARGS1(type1), BLDARGS1(type1), CTRARGS1(type1), SETARGS1)

#define AUTOFUNC2(name, func, ret,t1,t2, defs) \
  AUTOFUNC_(name, Val=This->func(Arg1,Arg2);, defs, RETARG(ret) \
  DEFARGS2(t1,t2), BLDARGS2(t1,t2), CTRARGS2(t1,t2), SETARGS2)

#define AUTOFUNC2V(name, func, t1,t2, defs) \
  AUTOFUNC_(name, This->func(Arg1,Arg2);, defs, \
  DEFARGS2(t1,t2), BLDARGS2(t1,t2), CTRARGS2(t1,t2), SETARGS2)

#define AUTOFUNC3(name, func, ret,t1,t2,t3, defs) \
  AUTOFUNC_(name, Val=This->func(Arg1,Arg2,Arg3);, defs, RETARG(ret) \
  DEFARGS3(t1,t2,t3), BLDARGS3(t1,t2,t3), CTRARGS3(t1,t2,t3), SETARGS3)

#define AUTOFUNC3V(name, func, t1,t2,t3, defs) \
  AUTOFUNC_(name, This->func(Arg1,Arg2,Arg3);, defs, \
  DEFARGS3(t1,t2,t3), BLDARGS3(t1,t2,t3), CTRARGS3(t1,t2,t3), SETARGS3)

#define AUTOFUNC4(name, func, ret,t1,t2,t3,t4, defs) \
  AUTOFUNC_(name, Val=This->func(Arg1,Arg2,Arg3,Arg4);, defs, RETARG(ret) \
  DEFARGS4(t1,t2,t3,t4), BLDARGS4(t1,t2,t3,t4), CTRARGS4(t1,t2,t3,t4), SETARGS4)

#define AUTOFUNC4V(name, func, t1,t2,t3,t4, defs) \
  AUTOFUNC_(name, This->func(Arg1,Arg2,Arg3,Arg4);, defs,\
  DEFARGS4(t1,t2,t3,t4), BLDARGS4(t1,t2,t3,t4), CTRARGS4(t1,t2,t3,t4), SETARGS4)

#define AUTOFUNC5(name,func,ret,t1,t2,t3,t4,t5,defs)                        \
  AUTOFUNC_(name,Val=This->func(Arg1,Arg2,Arg3,Arg4,Arg5);,defs,RETARG(ret) \
  DEFARGS5(t1,t2,t3,t4,t5),BLDARGS5(t1,t2,t3,t4,t5),CTRARGS5(t1,t2,t3,t4,t5),SETARGS5)

#define AUTOFUNC5V(name,func,t1,t2,t3,t4,t5,defs)            \
  AUTOFUNC_(name,This->func(Arg1,Arg2,Arg3,Arg4,Arg5);,defs, \
  DEFARGS5(t1,t2,t3,t4,t5),BLDARGS5(t1,t2,t3,t4,t5),CTRARGS5(t1,t2,t3,t4,t5),SETARGS5)

#define AUTOFUNC6(name,func,ret,t1,t2,t3,t4,t5,t6,defs)                          \
  AUTOFUNC_(name,Val=This->func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6);,defs,RETARG(ret) \
  DEFARGS6(t1,t2,t3,t4,t5,t6),BLDARGS6(t1,t2,t3,t4,t5,t6), CTRARGS6(t1,t2,t3,t4,t5,t6),SETARGS6)

#define AUTOFUNC6V(name,func,t1,t2,t3,t4,t5,t6,defs)              \
  AUTOFUNC_(name,This->func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6);,defs, \
  DEFARGS6(t1,t2,t3,t4,t5,t6),BLDARGS6(t1,t2,t3,t4,t5,t6),        \
  CTRARGS6(t1,t2,t3,t4,t5,t6),SETARGS6)

#define AUTOFUNC7(name,func,ret,t1,t2,t3,t4,t5,t6,t7,defs)                            \
  AUTOFUNC_(name,Val=This->func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7);,defs,RETARG(ret) \
  DEFARGS7(t1,t2,t3,t4,t5,t6,t7),BLDARGS7(t1,t2,t3,t4,t5,t6,t7),                      \
  CTRARGS7(t1,t2,t3,t4,t5,t6,t7),SETARGS7)

#define AUTOFUNC7V(name,func,t1,t2,t3,t4,t5,t6,t7,defs)                \
  AUTOFUNC_(name,This->func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7);,defs, \
  DEFARGS7(t1,t2,t3,t4,t5,t6,t7),BLDARGS7(t1,t2,t3,t4,t5,t6,t7),       \
  CTRARGS7(t1,t2,t3,t4,t5,t6,t7),SETARGS7)

#define AUTOFUNC8(name,func,ret,t1,t2,t3,t4,t5,t6,t7,t8,defs)                              \
  AUTOFUNC_(name,Val=This->func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8);,defs,RETARG(ret) \
  DEFARGS8(t1,t2,t3,t4,t5,t6,t7,t8),BLDARGS8(t1,t2,t3,t4,t5,t6,t7,t8),                     \
  CTRARGS8(t1,t2,t3,t4,t5,t6,t7,t8),SETARGS8)

#define AUTOFUNC8V(name,func,t1,t2,t3,t4,t5,t6,t7,t8,defs)                  \
  AUTOFUNC_(name,This->func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8);,defs, \
  DEFARGS8(t1,t2,t3,t4,t5,t6,t7,t8),BLDARGS8(t1,t2,t3,t4,t5,t6,t7,t8),      \
  CTRARGS8(t1,t2,t3,t4,t5,t6,t7,t8),SETARGS8)

#define AUTOFUNC9(name,func,ret,t1,t2,t3,t4,t5,t6,t7,t8,t9,defs)                                \
  AUTOFUNC_(name,Val=This->func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9);,defs,RETARG(ret) \
  DEFARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),BLDARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),                    \
  CTRARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),SETARGS9)

#define AUTOFUNC9V(name,func,t1,t2,t3,t4,t5,t6,t7,t8,t9,defs)                    \
  AUTOFUNC_(name,This->func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9);,defs, \
  DEFARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),BLDARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),     \
  CTRARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),SETARGS9)

#define AUTOFUNC10(name,func,ret,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,defs)                                 \
  AUTOFUNC_(name,Val=This->func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9,Arg10);,defs,RETARG(ret) \
  DEFARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),BLDARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),                \
  CTRARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),SETARGS10)

#define AUTOFUNC10V(name,func,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,defs)                     \
  AUTOFUNC_(name,This->func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9,Arg10);,defs, \
  DEFARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),BLDARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10), \
  CTRARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),SETARGS10)

#define AUTOSTAT0(name, func, ret, defs) \
  AUTOFUNC_(name, Val=func();, defs, RETARG(ret), , , )

#define AUTOSTAT0V(name, func, defs) \
  AUTOFUNC_(name, func();, defs, , , , )

#define AUTOSTAT1(name, func, ret,type1, defs) \
  AUTOFUNC_(name, Val=func(Arg1);, defs, RETARG(ret) \
  DEFARGS1(type1), BLDARGS1(type1), CTRARGS1(type1), SETARGS1)

#define AUTOSTAT1V(name, func, type1, defs) \
  AUTOFUNC_(name, func(Arg1);, defs, \
  DEFARGS1(type1), BLDARGS1(type1), CTRARGS1(type1), SETARGS1)

#define AUTOSTAT2(name, func, ret,t1,t2, defs) \
  AUTOFUNC_(name, Val=func(Arg1,Arg2);, defs, RETARG(ret) \
  DEFARGS2(t1,t2), BLDARGS2(t1,t2), CTRARGS2(t1,t2), SETARGS2)

#define AUTOSTAT2V(name, func, t1,t2, defs) \
  AUTOFUNC_(name, func(Arg1,Arg2);, defs, \
  DEFARGS2(t1,t2), BLDARGS2(t1,t2), CTRARGS2(t1,t2), SETARGS2)

#define AUTOSTAT3(name, func, ret,t1,t2,t3, defs) \
  AUTOFUNC_(name, Val=func(Arg1,Arg2,Arg3);, defs, RETARG(ret) \
  DEFARGS3(t1,t2,t3), BLDARGS3(t1,t2,t3), CTRARGS3(t1,t2,t3), SETARGS3)

#define AUTOSTAT3V(name, func, t1,t2,t3, defs) \
  AUTOFUNC_(name, func(Arg1,Arg2,Arg3);, defs, \
  DEFARGS3(t1,t2,t3), BLDARGS3(t1,t2,t3), CTRARGS3(t1,t2,t3), SETARGS3)

#define AUTOSTAT4(name, func, ret,t1,t2,t3,t4, defs) \
  AUTOFUNC_(name, Val=func(Arg1,Arg2,Arg3,Arg4);, defs, RETARG(ret) \
  DEFARGS4(t1,t2,t3,t4), BLDARGS4(t1,t2,t3,t4), CTRARGS4(t1,t2,t3,t4), SETARGS4)

#define AUTOSTAT4V(name, func, t1,t2,t3,t4, defs) \
  AUTOFUNC_(name, func(Arg1,Arg2,Arg3,Arg4);, defs,\
  DEFARGS4(t1,t2,t3,t4), BLDARGS4(t1,t2,t3,t4), CTRARGS4(t1,t2,t3,t4), SETARGS4)

#define AUTOSTAT5(name,func,ret,t1,t2,t3,t4,t5,defs)                  \
  AUTOFUNC_(name,Val=func(Arg1,Arg2,Arg3,Arg4,Arg5);,defs,RETARG(ret) \
  DEFARGS5(t1,t2,t3,t4,t5),BLDARGS5(t1,t2,t3,t4,t5),CTRARGS5(t1,t2,t3,t4,t5),SETARGS5)

#define AUTOSTAT5V(name,func,t1,t2,t3,t4,t5,defs)      \
  AUTOFUNC_(name,func(Arg1,Arg2,Arg3,Arg4,Arg5);,defs, \
  DEFARGS5(t1,t2,t3,t4,t5),BLDARGS5(t1,t2,t3,t4,t5),CTRARGS5(t1,t2,t3,t4,t5),SETARGS5)

#define AUTOSTAT6(name,func,ret,t1,t2,t3,t4,t5,t6,defs)                    \
  AUTOFUNC_(name,Val=func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6);,defs,RETARG(ret) \
  DEFARGS6(t1,t2,t3,t4,t5,t6),BLDARGS6(t1,t2,t3,t4,t5,t6), CTRARGS6(t1,t2,t3,t4,t5,t6),SETARGS6)

#define AUTOSTAT6V(name,func,t1,t2,t3,t4,t5,t6,defs)        \
  AUTOFUNC_(name,func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6);,defs, \
  DEFARGS6(t1,t2,t3,t4,t5,t6),BLDARGS6(t1,t2,t3,t4,t5,t6), CTRARGS6(t1,t2,t3,t4,t5,t6),SETARGS6)

#define AUTOSTAT7(name,func,ret,t1,t2,t3,t4,t5,t6,t7,defs)                      \
  AUTOFUNC_(name,Val=func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7);,defs,RETARG(ret) \
  DEFARGS7(t1,t2,t3,t4,t5,t6,t7),BLDARGS7(t1,t2,t3,t4,t5,t6,t7),                \
  CTRARGS7(t1,t2,t3,t4,t5,t6,t7),SETARGS7)

#define AUTOSTAT7V(name,func,t1,t2,t3,t4,t5,t6,t7,defs)          \
  AUTOFUNC_(name,func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7);,defs, \
  DEFARGS7(t1,t2,t3,t4,t5,t6,t7),BLDARGS7(t1,t2,t3,t4,t5,t6,t7), \
  CTRARGS7(t1,t2,t3,t4,t5,t6,t7),SETARGS7)

#define AUTOSTAT8(name,func,ret,t1,t2,t3,t4,t5,t6,t7,t8,defs)                        \
  AUTOFUNC_(name,Val=func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8);,defs,RETARG(ret) \
  DEFARGS8(t1,t2,t3,t4,t5,t6,t7,t8),BLDARGS8(t1,t2,t3,t4,t5,t6,t7,t8),               \
  CTRARGS8(t1,t2,t3,t4,t5,t6,t7,t8),SETARGS8)

#define AUTOSTAT8V(name,func,t1,t2,t3,t4,t5,t6,t7,t8,defs)             \
  AUTOFUNC_(name,func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8);,defs,  \
  DEFARGS8(t1,t2,t3,t4,t5,t6,t7,t8),BLDARGS8(t1,t2,t3,t4,t5,t6,t7,t8), \
  CTRARGS8(t1,t2,t3,t4,t5,t6,t7,t8),SETARGS8)

#define AUTOSTAT9(name,func,ret,t1,t2,t3,t4,t5,t6,t7,t8,t9,defs)                          \
  AUTOFUNC_(name,Val=func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9);,defs,RETARG(ret) \
  DEFARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),BLDARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),              \
  CTRARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),SETARGS9)

#define AUTOSTAT9V(name,func,t1,t2,t3,t4,t5,t6,t7,t8,t9,defs)                \
  AUTOFUNC_(name,func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9);,defs,   \
  DEFARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),BLDARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9), \
  CTRARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),SETARGS9)

#define AUTOSTAT10(name,func,ret,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,defs)                           \
  AUTOFUNC_(name,Val=func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9,Arg10);,defs,RETARG(ret) \
  DEFARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),BLDARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),          \
  CTRARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),SETARGS10)

#define AUTOSTAT10V(name,func,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,defs)                     \
  AUTOFUNC_(name,func(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9,Arg10);,defs,       \
  DEFARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),BLDARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10), \
  CTRARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),SETARGS10)


#define AUTOPROP( name, get, set, type, defs) \
  AUTOPROP_(name, Val=This->get();, This->set(Val);, defs, type)

#define AUTOPROPRO(name, get, type, defs) \
  AUTOFUNC0( name, get, type, defs)

#define AUTOPROPWO( name, set, type, defs) \
  AUTOFUNC_(name, This->set(Val);, defs, \
  DEFARGS0(type), BLDARGS0(type), CTRARGS0(type), SETARGS0)

#define AUTODATA( name, data, type, defs) \
  AUTOPROP_(name, Val=This->data;, This->data=Val;, defs, type)

#define AUTODATARO(name, data, type, defs) \
  AUTOFUNC_(name, Val=This->data;, defs, RETARG(type), , , )

#define AUTOTHIS(name, type, defs) \
  AUTOFUNC_(name, Val=*This;, defs, RETARG(type), , , )

#define AUTOFLAG( name, data, mask, defs) \
  AUTOPROP_(name, Val=(TBool)((This->data & (mask)) != 0);, \
  if (Val) This->data|=(mask); else This->data&=~(mask);, defs, TBool)

#define AUTOBUILD0(name, defs) \
  AUTOBUILD_(name, Val = new ThisClass();, defs, , , , )

#define AUTOBUILD1(name, type1, defs) \
  AUTOBUILD_(name, Val = new ThisClass(Arg1);, defs, \
  DEFARGS1(type1), BLDARGS1(type1), CTRARGS1(type1), SETARGS1)

#define AUTOBUILD2(name, t1,t2, defs) \
  AUTOBUILD_(name, Val = new ThisClass(Arg1,Arg2);, defs, \
  DEFARGS2(t1,t2), BLDARGS2(t1,t2), CTRARGS2(t1,t2), SETARGS2)

#define AUTOBUILD3(name, t1,t2,t3, defs) \
  AUTOBUILD_(name, Val = new ThisClass(Arg1,Arg2,Arg3);, defs, \
  DEFARGS3(t1,t2,t3), BLDARGS3(t1,t2,t3), CTRARGS3(t1,t2,t3), SETARGS3)

#define AUTOBUILD4(name, t1,t2,t3,t4, defs) \
  AUTOBUILD_(name, Val = new ThisClass(Arg1,Arg2,Arg3,Arg4);, defs, \
  DEFARGS4(t1,t2,t3,t4), BLDARGS4(t1,t2,t3,t4), CTRARGS4(t1,t2,t3,t4), SETARGS4)

#define AUTOBUILD5(name,func,t1,t2,t3,t4,t5,defs)                    \
  AUTOBUILD_(name,Val=new ThisClass(Arg1,Arg2,Arg3,Arg4,Arg5);,defs, \
  DEFARGS5(t1,t2,t3,t4,t5),BLDARGS5(t1,t2,t3,t4,t5),CTRARGS5(t1,t2,t3,t4,t5),\
  SETARGS5)

#define AUTOBUILD6(name,func,t1,t2,t3,t4,t5,t6,defs)                      \
  AUTOBUILD_(name,Val=new ThisClass(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6);,defs, \
  DEFARGS6(t1,t2,t3,t4,t5,t6),BLDARGS6(t1,t2,t3,t4,t5,t6),                \
  CTRARGS6(t1,t2,t3,t4,t5,t6),SETARGS6)

#define AUTOBUILD7(name,func,t1,t2,t3,t4,t5,t6,t7,defs)                       \
  AUTOBUILD_(name,Val=new ThisClass(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7);,defs,\
  DEFARGS7(t1,t2,t3,t4,t5,t6,t7),BLDARGS7(t1,t2,t3,t4,t5,t6,t7),              \
  CTRARGS7(t1,t2,t3,t4,t5,t6,t7),SETARGS7)

#define AUTOBUILD8(name,func,t1,t2,t3,t4,t5,t6,t7,t8,defs)                    \
  AUTOBUILD_(name,Val=new ThisClass(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8);,defs, \
  DEFARGS8(t1,t2,t3,t4,t5,t6,t7,t8),BLDARGS8(t1,t2,t3,t4,t5,t6,t7,t8),              \
  CTRARGS8(t1,t2,t3,t4,t5,t6,t7,t8),SETARGS8)

#define AUTOBUILD9(name,func,t1,t2,t3,t4,t5,t6,t7,t8,t9,defs)                            \
  AUTOBUILD_(name,Val=new ThisClass(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9);,defs, \
  DEFARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),BLDARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),             \
  CTRARGS9(t1,t2,t3,t4,t5,t6,t7,t8,t9),SETARGS9)

#define AUTOBUILD10(name,func,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,defs)                             \
  AUTOBUILD_(name,Val=new ThisClass(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9,Arg10);,defs, \
  DEFARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),BLDARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),         \
  CTRARGS10(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10),SETARGS10)


//
// Registration parameter table macro definitions
//

#define BEGIN_REGISTRATION(regname) extern TRegItem regname##_list[]; \
                                    extern TRegFormatHeap __regHeap; \
                                    TRegList regname(regname##_list); \
                                    static TRegItem regname##_list[] = {
#define END_REGISTRATION {0,{0}} };

#define REGDATA(var,val) {#var, {val}},
#define REGXLAT(var,val) {#var, {AUTOLANG_XLAT val}},
#define REGITEM(key,val) {" " key, {val}},
#define REGFORMAT(i,f,a,t,d) {"format" #i,{TRegItem::RegFormat(f,a,t,d,__regHeap)}},
#define REGSTATUS(a,f) {"aspect" #a, {TRegItem::RegFlags(f,__regHeap)}},
#define REGVERBOPT(v,mf,sf) {#v "opt",{TRegItem::RegVerbOpt(mf,sf,__regHeap)}},
#define REGICON(i) {"iconindex",{TRegItem::RegFlags(i,__regHeap)}},
#define REGDOCFLAGS(i) {"docflags",{TRegItem::RegFlags(i,__regHeap)}},

//
// Buffer size is no longer needed, use the macro below
//
#define REGISTRATION_FORMAT_BUFFER(n) \
  TRegFormatHeap __regHeap;

#define REGISTRATION_FORMAT_HEAP \
  TRegFormatHeap __regHeap;

//
// OWL.
//

#define _OWLCLASS
#define _OWLCLASS_RTL
#define _OWLFUNC
#define _OWLDATA
#define _OWLLINK(s)

#define _USERCLASS

#endif // TS_PREINCLUDE_BORLAND_CPP


// **********************************************************************
//
//  Borland C++ Standard C++ Library preinclude
//
// **********************************************************************

// It is required to add folder containing Borland C++ (4.x, 5.x) include 
// files (for example: %BCPP_HOME%\Include) into Together project. 
// This could be done at the "Class/search path" tab of "Project properties" 
// dialog (or "Advanced" mode of "New project" dialog)

// Borland C++ STL Library (short version)
#if defined(TS_PREINCLUDE_BCPP_STL) && !defined(TS_PREINCLUDE_BCPP_STDLIB)
#include "pi_bcpp_stl.inc"
#endif // TS_PREINCLUDE_BCPP_STL

// Borland C++ Standard C++ Library (STL included)
#if defined(TS_PREINCLUDE_BCPP_STDLIB)
#include "pi_bcpp_stdlib.inc"
#endif // TS_PREINCLUDE_BCPP_STDLIB


// **********************************************************************
//
//
// Macro definitions for Borland C++ Builder.
//
//
// **********************************************************************

#if defined(TS_PREINCLUDE_BORLAND_CPP_BUILDER) || defined(OI_PREINCLUDE_BORLAND_CPP_BUILDER)

//  keywords extensions.

#define interface       class
#define __published     public
#define __automated     public
#define __interface     class
#define __dispinterface class
#define __property

//
// macroses.
//

// throws ...

#define _RWSTD_THROW_SPEC(ExceptionList) throw ExceptionList
#define _RWSTD_THROW_SPEC_NULL           throw()
#define _RWSTD_INLINE_NO_THROW

// ATL

#define ATL_NO_VTABLE                    __declspec(novtable)

// IMPLs

#define AUTOOBJECT_IMPL(cppClass, CoClass, intf)\
   public CComObjectRootEx,\
   public CComCoClass,\
   public IDispatchImpl

#define REMOTEDATAMODULE_IMPL(cppClass, CoClass, VclClass, intf)\
   public CComObjectRootEx,\
   public CComCoClass,\
   public IDataBrokerImpl

#define DUALINTERFACE_IMPL(coclass, intf) \
   public IDispatchImpl

#define VCLCONTROL_IMPL(cppClass, CoClass, VclClass, intf, EventID)\
   public TVclControlImpl,\
   public IDispatchImpl,\
   public TEvents_##CoClass

// STDMETHOD

#define STDMETHODCALLTYPE                    __export __stdcall
#define STDMETHODVCALLTYPE                   __export __cdecl

#define STDMETHODIMP                         HRESULT STDMETHODCALLTYPE
#define STDMETHOD(method)                    virtual HRESULT STDMETHODCALLTYPE method
#define STDMETHOD_(type,method)              virtual type STDMETHODCALLTYPE method

#define PURE                                 = 0
#define THIS_
#define THIS                                 void
#define DECLARE_INTERFACE(iface)             interface iface
#define DECLARE_INTERFACE_(iface, baseiface) interface iface : public baseiface
#define BEGIN_INTERFACE


// OBJ. maps.

#define BEGIN_OBJECT_MAP(x) static _ATL_OBJMAP_ENTRY x[] = {
#define END_OBJECT_MAP()   {NULL, NULL, NULL, NULL}};
#define OBJECT_ENTRY(clsid, class) {&clsid, &class::UpdateRegistry, &class::_ClassFactoryCreatorClass::CreateInstance, &class::_CreatorClass::CreateInstance, NULL, 0, &class::GetObjectDescription },

#define BEGIN_COM_MAP(x) public:\
        typedef x _ComMapClass;\
        static HRESULT WINAPI _Cache(void* pv, REFIID iid, void** ppvObject, DWORD dw) {}\
        IUnknown* GetUnknown() {}\
        HRESULT _InternalQueryInterface(REFIID iid, void** ppvObject) {}\
        const static _ATL_INTMAP_ENTRY* WINAPI _GetEntries() { \
        static const _ATL_INTMAP_ENTRY _entries[] = { DEBUG_QI_ENTRY(x)

#define END_COM_MAP()   {NULL, 0, 0}}; return _entries;}

#define COM_INTERFACE_ENTRY_BREAK(x)
#define COM_INTERFACE_ENTRY_NOINTERFACE(x)
#define COM_INTERFACE_ENTRY(x)
#define COM_INTERFACE_ENTRY_IID(iid, x)
#define COM_INTERFACE_ENTRY_IMPL(x)
#define COM_INTERFACE_ENTRY_IMPL_IID(iid, x)
#define COM_INTERFACE_ENTRY2(x, x2)
#define COM_INTERFACE_ENTRY2_IID(iid, x, x2)
#define COM_INTERFACE_ENTRY_FUNC(iid, dw, func)
#define COM_INTERFACE_ENTRY_FUNC_BLIND(dw, func)
#define COM_INTERFACE_ENTRY_TEAR_OFF(iid, x)
#define COM_INTERFACE_ENTRY_CACHED_TEAR_OFF(iid, x, punk)
#define COM_INTERFACE_ENTRY_AGGREGATE(iid, punk)
#define COM_INTERFACE_ENTRY_AGGREGATE_BLIND(punk)
#define COM_INTERFACE_ENTRY_AUTOAGGREGATE(iid, punk, clsid)
#define COM_INTERFACE_ENTRY_AUTOAGGREGATE_BLIND(punk, clsid)
#define COM_INTERFACE_ENTRY_CHAIN(classname)

#define VCL_CONTROL_COM_INTERFACE_ENTRIES(intf)
#define AUTOOBJECT_COM_INTERFACE_ENTRIES(intf)
#define PROPERTYPAGE_COM_INTERFACE_ENTRIES

#define BEGIN_AUTOOBJECT_COM_MAP(coclass, intf) \
    BEGIN_COM_MAP(T##coclass)                   \
      AUTOOBJECT_COM_INTERFACE_ENTRIES(intf)
#define END_AUTOOBJECT_COM_MAP END_COM_MAP

#define BEGIN_PROPERTYPAGE_COM_MAP(coclass) \
    BEGIN_COM_MAP(T##coclass) \
         PROPERTYPAGE_COM_INTERFACE_ENTRIES
#define END_PROPERTYPAGE_COM_MAP END_COM_MAP

// registry.

#define UPDATE_REGISTRY_METHOD(code) \
static HRESULT WINAPI UpdateRegistry(BOOL bRegister) {code}

#define DECLARE_COMSERVER_REGISTRY(progid, desc)       UPDATE_REGISTRY_METHOD()
#define DECLARE_TYPED_COMSERVER_REGISTRY(progid)       UPDATE_REGISTRY_METHOD()
#define DECLARE_REMOTEDATAMODULE_REGISTRY(progid)      UPDATE_REGISTRY_METHOD()
#define DECLARE_ACTIVEXCONTROL_REGISTRY(progid, idbmp) UPDATE_REGISTRY_METHOD()

// messages.

#define VCL_MESSAGE_HANDLER
#define VCL_MESSAGE_HANDLER(msg,type,meth)
#define MESSAGE_HANDLER  VCL_MESSAGE_HANDLER

#define BEGIN_MESSAGE_MAP virtual void __fastcall Dispatch(void *Message) {
#define END_MESSAGE_MAP(base) }

// __declspec

#define PACKAGE                 __declspec(package)
#define THREAD                  __declspec(thread)
#define PASCALIMPLEMENTATION    __declspec(pascalimplementation, package)
#define DELPHIRETURN            __declspec(delphireturn, package)
#define DELPHICLASS             __declspec(delphiclass, package)

// properties.

#define BEGIN_PROPERTY_MAP(theClass) \
        static ATL_PROPMAP_ENTRY * GetPropertyMap()\
        {static ATL_PROPMAP_ENTRY pPropMap[] = \
                {
#define PROP_ENTRY(szDesc, dispid, clsid) {OLESTR(szDesc), dispid, &clsid, &IID_IDispatch},
#define PROP_ENTRY_EX(szDesc, dispid, clsid, iidDispatch) {OLESTR(szDesc), dispid, &clsid, &iidDispatch},
#define PROP_PAGE(clsid) {NULL, NULL, &clsid, &IID_NULL},
#define END_PROPERTY_MAP() {NULL, 0, NULL, &IID_NULL}}; return pPropMap;}

#endif // TS_PREINCLUDE_BORLAND_CPP_BUILDER

// **********************************************************************
//
//  Borland C++ Builder Standard C++ Library preinclude
//
// **********************************************************************

// It is required to add folder containing Borland C++ Builder include 
// files (for example: %CBUILDER_HOME%\Include) into Together project. 
// This could be done at the "Class/search path" tab of "Project properties" 
// dialog (or "Advanced" mode of "New project" dialog)

// Borland C++ Builder Standard C++ Library
#if defined(TS_PREINCLUDE_BCB_STDLIB) && !defined(TS_PREINCLUDE_BCPP_STDLIB) && !defined(TS_PREINCLUDE_BCPP_STL)
#include "pi_bcb_stdlib.inc"
#endif // TS_PREINCLUDE_BCB_STDLIB



