-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathcomdefs.h
222 lines (181 loc) · 5.55 KB
/
comdefs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#ifndef _COMDEFS_H_
#define _COMDEFS_H_
#include "typedefs.h"
#if defined(WIN32)
#include <ObjBase.h>
#include <InitGuid.h>
#elif defined(CCORE_LINUX) || defined(CCORE_MAC) || defined(CCORE_ANDROID) || defined(CCORE_IOS)
typedef long HRESULT;
typedef void* LPVOID;
#define STDAPI extern "C" HRESULT
#define COM_DECLSPEC_NOTHROW
#define STDMETHODCALLTYPE
#define DECLSPEC_NOVTABLE
#define STDMETHODIMP_(type) type STDMETHODCALLTYPE
#define STDMETHOD(method) virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE method
#define STDMETHOD_(type,method) virtual COM_DECLSPEC_NOTHROW type STDMETHODCALLTYPE method
#define STDMETHODV(method) virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODVCALLTYPE method
#define STDMETHODV_(type,method) virtual COM_DECLSPEC_NOTHROW type STDMETHODVCALLTYPE method
#define PURE = 0
#define THIS_
#define THIS void
#define DECLARE_INTERFACE(iface) struct DECLSPEC_NOVTABLE iface
#define DECLARE_INTERFACE_(iface, baseiface) struct DECLSPEC_NOVTABLE iface : public baseiface
#define DECLARE_INTERFACE_IID(iface, iid) struct DECLSPEC_UUID(iid) DECLSPEC_NOVTABLE iface
#define DECLARE_INTERFACE_IID_(iface, baseiface, iid) struct DECLSPEC_UUID(iid) DECLSPEC_NOVTABLE iface : public baseiface
#if 0
typedef struct _GUID {
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} GUID;
typedef GUID IID;
typedef GUID CLSID;
# define REFIID const IID &
# define REFCLSID const IID &
# define DECLSPEC_SELECTANY
# define FAR
# define INITGUID
# ifdef INITGUID
# define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
extern "C" const GUID DECLSPEC_SELECTANY name \
= { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
# else
# define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
extern "C" const GUID FAR name
# endif // INITGUID
inline int operator==(const GUID& guidOne, const GUID& guidOther)
{
return guidOne.Data1 == guidOther.Data1 &&
guidOne.Data2 == guidOther.Data2 &&
guidOne.Data3 == guidOther.Data3;
}
#else
typedef int GUID;
typedef GUID IID;
typedef GUID CLSID;
# define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
# define REFIID const IID &
# define REFCLSID const IID &
# define DECLSPEC_SELECTANY
# define FAR
enum
{
CLSID_DataCenter = 0x0000,
IID_IDataCenter = 0x0001,
CLSID_DataReport = 0x0010,
IID_IDataReport = 0x0011,
CLSID_EngineModule = 0x0020,
IID_IEngineModule = 0x0021,
CLSID_FileModule = 0x0030,
IID_IFileModule = 0x0031,
CLSID_FileTransfer = 0x0040,
IID_IFileTransfer = 0x0041,
CLSID_ImageKernel = 0x0050,
IID_IImageKernel = 0x0051,
CLSID_MessageSync = 0x0060,
IID_IMessageSync = 0x0061,
CLSID_NetworkService = 0x0070,
IID_INetworkService = 0x0071,
CLSID_UserFace = 0x0080,
IID_IUserFace = 0x0081,
CLSID_MessageKernel = 0x0090,
IID_IMessageKernel = 0x0091,
IID_IMessageBuddy = 0x0092,
IID_IMessageLogin = 0x0095,
IID_IMessageMaskWord = 0x0096,
IID_IMessageMis = 0x0097,
IID_IMessageNetseting = 0x0098,
IID_IMessageNotice = 0x0099,
IID_IMessageUserInfo = 0x009D,
IID_IMessageMiscellaneous = 0x009F,
IID_IMessageTgroup = 0x00A0,
IID_IMessageConsole = 0x00A1,
IID_IMessageOfficialAccount = 0x00A2,
IID_IMessageSearch = 0x00A3,
IID_IMessageWidget = 0x00A4,
IID_IMessagePassAPI = 0x00A5,
CLSID_NetworkRouting = 0x00B0,
IID_INetworkRouting = 0X00B1,
CLSID_CommonHead = 0x00C0,
IID_ICommonHead = 0x00C1,
CLSID_HttpKernel = 0x00D0,
IID_IHttpKernel = 0x00D1,
CLSID_H5OfflinePkg = 0x00E0,
IID_IH5OfflinePkg = 0x00E1,
};
#endif
//-----------------------------------------------------------------------------
#if defined(CCORE_MAC) || defined(CCORE_IOS)
#include <libkern/OSAtomic.h>
#include <stdlib.h>
#elif defined(CCORE_LINUX) || defined(CCORE_ANDROID)
#include <inttypes.h>
#include <malloc.h>
#endif
struct IUnknown
{
virtual long STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) = 0;
virtual unsigned long STDMETHODCALLTYPE AddRef(void) = 0;
virtual unsigned long STDMETHODCALLTYPE Release(void) = 0;
};
#endif
template <typename T> class CUnknownObject : public T
{
public:
CUnknownObject()
{
m_nRefCount = 0;
}
virtual ~CUnknownObject()
{
m_nRefCount = 0;
}
virtual long STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject)
{
*ppvObject = (T *)this;
this->AddRef();
return 0;
}
virtual unsigned long STDMETHODCALLTYPE AddRef(void)
{
#if defined(WIN32)
return static_cast<unsigned long>(InterlockedIncrement(
reinterpret_cast<volatile long*>(&m_nRefCount)));
#elif defined(CCORE_MAC) || defined(CCORE_IOS)
return OSAtomicIncrement32Barrier(&m_nRefCount);
#elif defined(CCORE_LINUX) || defined(CCORE_ANDROID)
return __sync_fetch_and_add(&m_nRefCount, 1) + 1;
#else
int ref = ++m_nRefCount;
return static_cast<unsigned long>(ref);
#endif
}
virtual unsigned long STDMETHODCALLTYPE Release(void)
{
#if defined(WIN32)
long ref = static_cast<long>(InterlockedDecrement(
reinterpret_cast<volatile long*>(&m_nRefCount)));
#elif defined(CCORE_MAC) || defined(CCORE_IOS)
long ref = OSAtomicDecrement32Barrier(&m_nRefCount);
#elif defined(CCORE_LINUX) || defined(CCORE_ANDROID)
long ref = __sync_fetch_and_sub(&m_nRefCount, 1) - 1;
#else
long ref = --m_nRefCount;
#endif
if (ref == 0)
{
delete this;
}
return static_cast<unsigned long>(ref);
}
long GetRef()
{
return m_nRefCount;
}
private:
int m_nRefCount;
};
#endif // _COMDEFS_H_
//#define UI_CCTALK_OEM_WANGXIAO