Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Tools/Xabsl2/yabsl/vsyabsl/common.h

Go to the documentation of this file.
00001 
00002 /***************************************************************************
00003          Copyright (c) Microsoft Corporation, All rights reserved.             
00004     This code sample is provided "AS IS" without warranty of any kind, 
00005     it is not recommended for use in a production environment.
00006 ***************************************************************************/
00007 
00008 #ifndef common_h
00009 #define common_h
00010 
00011 /*---------------------------------------------------------
00012   Standard includes
00013 -----------------------------------------------------------*/
00014 #include <stdlib.h>
00015 #include <stdio.h>
00016 #include <assert.h>
00017 #include <malloc.h>
00018 #include <windows.h>
00019 
00020 #include "text.h"
00021 #include "babelservice.h"
00022 
00023 /*---------------------------------------------------------
00024   Debugging
00025 -----------------------------------------------------------*/
00026 void  Trace( const char* format, ... );
00027 
00028 void  TraceInit( const char* moduleName );
00029 void  TraceDone();
00030 void  TraceCreate( const char* name, IUnknown* obj );
00031 void  TraceDestroy( IUnknown* obj );
00032 void  TraceDumpObjects();
00033 
00034 #ifdef NDEBUG
00035 # define ASSERT(x)
00036 # define TRACE(s)       
00037 # define TRACE1(s,x)     
00038 # define TRACE2(s,x,y)   
00039 # define TRACE3(s,x,y,z) 
00040 
00041 # define TRACE_INIT(name)
00042 # define TRACE_DONE
00043 # define TRACE_CREATE(name,obj)  
00044 # define TRACE_DESTROY(obj)      
00045 # define TRACE_LIVE_OBJECTS
00046 #else
00047 # define ASSERT(x)       assert(x)
00048 # define TRACE(s)        Trace(s)
00049 # define TRACE1(s,x)     Trace(s,x)
00050 # define TRACE2(s,x,y)   Trace(s,x,y)
00051 # define TRACE3(s,x,y,z) Trace(s,x,y,z)
00052 
00053 # define TRACE_INIT(name)        TraceInit(name)
00054 # define TRACE_DONE              TraceDone()
00055 # define TRACE_CREATE(name,obj)  TraceCreate(name,obj)
00056 # define TRACE_DESTROY(obj)      TraceDestroy(obj)
00057 # define TRACE_LIVE_OBJECTS      TraceDumpObjects()
00058 #endif
00059 
00060 
00061 /*---------------------------------------------------------
00062   IDL
00063 -----------------------------------------------------------*/
00064 #define in
00065 #define out
00066 #define inout
00067 
00068 
00069 /*---------------------------------------------------------
00070   Argument checking
00071 -----------------------------------------------------------*/
00072 #define OUTARG(p)       ASSERT(p); if (!(p)) return E_INVALIDARG; else *(p) = 0;
00073 #define OUTVAR(v)       ASSERT(v); if (!(v)) return E_INVALIDARG; else VariantInit(v);
00074 
00075 #define INOUTARG(p)     ASSERT(p); if (!(p)) return E_INVALIDARG;
00076 #define REFARG(p)       ASSERT(p); if (!(p)) return E_INVALIDARG;
00077 
00078 
00079 /*---------------------------------------------------------
00080   Memory management
00081 -----------------------------------------------------------*/
00082 #ifdef DELETE
00083 #undef DELETE
00084 #endif
00085 
00086 #define ALLOC(tp)       (tp*)malloc(sizeof(tp))
00087 #define NALLOC(tp,n)    (tp*)malloc(sizeof(tp)*(n))
00088 
00089 #define FREE(p)         if (p) { free((void*)(p)); (p) = NULL; }
00090 #define DELETE(p)       if (p) { delete (p); (p) = NULL; }
00091 #define RELEASE(p)      if (p) { (p)->Release(); (p) = NULL; }
00092 #define REMOVE(p)       if (p) { while ((p)->Release() != 0) ; (p) = NULL; }
00093 #define ADDREF(p)       ASSERT(p); if (p) { (p)->AddRef(); }
00094 
00095 
00096 
00097 /*---------------------------------------------------------
00098   Reference counting
00099 -----------------------------------------------------------*/
00100 ULONG IncRefCount( inout ULONG* refCount );
00101 ULONG DecRefCount( inout ULONG* refCount );
00102 
00103 
00104 /*---------------------------------------------------------
00105   COM
00106 -----------------------------------------------------------*/
00107 #define WINERROR  HRESULT_FROM_WIN32
00108 
00109 
00110 #endif

Generated on Mon Mar 20 22:00:10 2006 for GT2005 by doxygen 1.3.6