|
Go to the documentation of this file.
30 #ifndef ___SYS_DEF_EX_H___
31 #define ___SYS_DEF_EX_H___
57 #include "SysSpec_Windows/SysSpecWin.h"
59 #if defined _WIN32_WCE
65 #ifndef UNREFERENCED_PARAMETER
66 #define UNREFERENCED_PARAMETER(p) (void)0
69 #if (_MSC_VER >= 1600)
73 #define INT32_MAX 0x7FFFFFFF
76 #define UINT32_MAX 0xFFFFFFFF
79 #define UINT64_MAX 0xFFFFFFFFFFFFFFFFui64
84 #define DWORD_MAX 0xFFFFFFFF
88 #define UTF8_BYTE BYTE
92 #define ROTL32UE(__uv,__nv) ((((__uv) << (__nv)) | ((__uv) >> (32 - (__nv)))) & 0xFFFFFFFF)
97 #define SAFE_DELETE(__kp_p) { if((__kp_p) != NULL) { delete (__kp_p); (__kp_p) = NULL; } }
107 #define SAFE_DELETE_ARRAY(__kp_p) { if((__kp_p) != NULL) { delete [](__kp_p); (__kp_p) = NULL; } }
112 #define SAFE_RELEASE(__kp_p) { if((__kp_p) != NULL) { (__kp_p)->Release(); (__kp_p) = NULL; } }
115 #ifndef KP_DEFINE_GUID
116 #define KP_DEFINE_GUID(__kp_name,__kp_l,__kp_w1,__kp_w2,__kp_b1,__kp_b2,__kp_b3,__kp_b4,__kp_b5,__kp_b6,__kp_b7,__kp_b8) \
117 EXTERN_C const GUID DECLSPEC_SELECTANY __kp_name \
118 = { __kp_l, __kp_w1, __kp_w2, { __kp_b1, __kp_b2, __kp_b3, __kp_b4, \
119 __kp_b5, __kp_b6, __kp_b7, __kp_b8 } }
122 #ifndef KP_DECLSPEC_UUID
123 #if ((_MSC_VER >= 1100) && defined(__cplusplus))
124 #define KP_DECLSPEC_UUID(__kp_uuid) __declspec(uuid(__kp_uuid))
126 #define KP_DECLSPEC_UUID(__kp_uuid)
130 #ifndef KP_DECLSPEC_NOVTABLE
131 #if ((_MSC_VER >= 1100) && defined(__cplusplus))
132 #define KP_DECLSPEC_NOVTABLE __declspec(novtable)
134 #define KP_DECLSPEC_NOVTABLE
138 #ifndef KP_DECL_INTERFACE
139 #define KP_DECL_INTERFACE(__kp_if_uuid) KP_DECLSPEC_UUID(__kp_if_uuid) KP_DECLSPEC_NOVTABLE
142 #ifndef KP_DECL_IUNKNOWN
143 #define KP_DECL_IUNKNOWN STDMETHODIMP QueryInterface(REFIID riid, void** ppvObject); \
144 STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) Release()
147 #ifndef KP_DECL_STDREFIMPL
148 #define KP_DECL_STDREFIMPL ULONG __m_uInterfaceRefCount
151 #ifndef KP_IMPL_STDREFIMPL
152 #define KP_IMPL_STDREFIMPL(__kp_class_name) STDMETHODIMP_(ULONG) \
153 __kp_class_name##::AddRef() { return ++__m_uInterfaceRefCount; } \
154 STDMETHODIMP_(ULONG) __kp_class_name##::Release() { \
155 ULONG __kp_ref = __m_uInterfaceRefCount; \
156 if(__m_uInterfaceRefCount != 0) { __kp_ref = --__m_uInterfaceRefCount; \
157 if(__m_uInterfaceRefCount == 0) delete this; } \
158 else { assert(false); } return __kp_ref; }
161 #ifndef KP_IMPL_STDREFIMPL_SUB
162 #define KP_IMPL_STDREFIMPL_SUB(__kp_class_name,__kp_sub_name) STDMETHODIMP_(ULONG) \
163 __kp_class_name##::AddRef() { return ++__m_uInterfaceRefCount; } \
164 STDMETHODIMP_(ULONG) __kp_class_name##::Release() { \
165 ULONG __kp_ref = __m_uInterfaceRefCount; \
166 if(__m_uInterfaceRefCount != 0) { __kp_ref = --__m_uInterfaceRefCount; \
167 if(__m_uInterfaceRefCount == 0) { SAFE_DELETE(__kp_sub_name); delete this; } } \
168 else { assert(false); } return __kp_ref; }
171 #ifndef KP_IMPL_STDREFIMPL_NODELETE
172 #define KP_IMPL_STDREFIMPL_NODELETE(__kp_class_name) STDMETHODIMP_(ULONG) \
173 __kp_class_name##::AddRef() { return ++__m_uInterfaceRefCount; } \
174 STDMETHODIMP_(ULONG) __kp_class_name##::Release() { \
175 if(__m_uInterfaceRefCount != 0) --__m_uInterfaceRefCount; \
176 else { assert(false); } return __m_uInterfaceRefCount; }
179 #ifndef KP_IMPL_CONSTRUCT
180 #define KP_IMPL_CONSTRUCT { __m_uInterfaceRefCount = 1; }
183 #ifndef KP_SUPPORT_INTERFACE
184 #define KP_SUPPORT_INTERFACE(__kp_iid,__kp_int) { assert(__m_uInterfaceRefCount > 0); \
185 if(riid == __kp_iid) { __kp_int##* __kp_p = this; *ppvObject = __kp_p; \
186 this->AddRef(); return S_OK; } }
197 #ifndef KP_ASSERT_REFS
198 #define KP_ASSERT_REFS(__kp_comobj,__kp_refcnt) ASSERT((__kp_comobj).AddRef() \
199 > 0); ASSERT((__kp_comobj).Release() == (__kp_refcnt));
202 #ifndef KP_REQ_OUT_PTR
203 #define KP_REQ_OUT_PTR(__kp_ppv) { if((__kp_ppv) == NULL) { assert(false); \
204 return E_POINTER; } }
207 #ifndef KP_REQ_OUT_PTR_INIT
208 #define KP_REQ_OUT_PTR_INIT(__kp_ppvx) { KP_REQ_OUT_PTR(__kp_ppvx); \
209 *(__kp_ppvx) = NULL; }
213 #ifndef KP_QUERY_INTERFACE_RELEASE_LOCAL_RET
214 #define KP_QUERY_INTERFACE_RELEASE_LOCAL_RET(__kp_comobj,__kp_riid,__kp_ppvout) { \
215 void* __kp_ip = NULL; if((__kp_comobj)->QueryInterface((__kp_riid), &__kp_ip) == \
216 S_OK) { *(__kp_ppvout) = __kp_ip; VERIFY((__kp_comobj)->Release() == 1); \
217 return S_OK; } else { VERIFY((__kp_comobj)->Release() == 0); return E_NOINTERFACE; } }
220 #endif // ___SYS_DEF_EX_H___
Documentation generated with
Doxygen.
|
|