guiddef.h 5.79 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright (C) 2000 Alexandre Julliard
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 18
 */

19 20
#ifndef GUID_DEFINED
#define GUID_DEFINED
21 22 23 24 25 26 27 28 29 30

#ifdef __WIDL__
typedef struct
{
    unsigned long  Data1;
    unsigned short Data2;
    unsigned short Data3;
    byte           Data4[ 8 ];
} GUID;
#else
31 32
typedef struct _GUID
{
33
#ifndef __LP64__
34
    unsigned long  Data1;
35 36 37
#else
    unsigned int   Data1;
#endif
38 39 40 41
    unsigned short Data2;
    unsigned short Data3;
    unsigned char  Data4[ 8 ];
} GUID;
42
#endif
43 44

/* Macros for __uuidof emulation */
45 46
#ifdef __cplusplus
# if defined(__MINGW32__)
47 48 49 50
#  if !defined(__uuidof)  /* Mingw64 can provide support for __uuidof and __CRT_UUID_DECL */
#   define __WINE_UUID_ATTR __attribute__((selectany))
#   undef __CRT_UUID_DECL
#  endif
51 52 53 54 55 56
# elif defined(__GNUC__)
#  define __WINE_UUID_ATTR __attribute__((visibility("hidden"),weak))
# endif
#endif

#ifdef __WINE_UUID_ATTR
57 58

extern "C++" {
59 60 61 62 63 64 65 66 67 68 69
    template<typename T> struct __wine_uuidof;

    template<typename T> struct __wine_uuidof_type {
        typedef __wine_uuidof<T> inst;
    };
    template<typename T> struct __wine_uuidof_type<T *> {
        typedef __wine_uuidof<T> inst;
    };
    template<typename T> struct __wine_uuidof_type<T * const> {
        typedef __wine_uuidof<T> inst;
    };
70 71 72 73
}

#define __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)           \
    extern "C++" {                                                      \
74 75 76 77
        template<> struct __wine_uuidof<type> {                         \
            static const GUID uuid;                                     \
        };                                                              \
        __WINE_UUID_ATTR const GUID __wine_uuidof<type>::uuid = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}; \
78 79
    }

80
#define __uuidof(type) __wine_uuidof_type<__typeof__(type)>::inst::uuid
81

82
#elif !defined(__CRT_UUID_DECL)
83 84 85

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

86
#endif /* __WINE_UUID_ATTR */
87

88 89 90 91
#endif

#undef DEFINE_GUID

92 93 94 95 96 97 98 99
#ifndef DECLSPEC_HIDDEN
# if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__CYGWIN__)
#  define DECLSPEC_HIDDEN __attribute__((visibility ("hidden")))
# else
#  define DECLSPEC_HIDDEN
# endif
#endif

100
#ifdef INITGUID
101 102
#ifdef __cplusplus
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
103
        EXTERN_C const GUID name DECLSPEC_HIDDEN; \
104 105 106
        EXTERN_C const GUID name = \
	{ l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
#else
107
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
108
        const GUID name DECLSPEC_HIDDEN; \
109 110
        const GUID name = \
	{ l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
111
#endif
112 113
#else
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
114
    EXTERN_C const GUID name DECLSPEC_HIDDEN
115 116 117 118 119 120 121 122
#endif

#define DEFINE_OLEGUID(name, l, w1, w2) \
	DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)

#ifndef _GUIDDEF_H_
#define _GUIDDEF_H_

123
#ifndef __LPGUID_DEFINED__
Andrew Talbot's avatar
Andrew Talbot committed
124
#define __LPGUID_DEFINED__
125
typedef GUID *LPGUID;
126 127 128 129 130 131 132
#endif

#ifndef __LPCGUID_DEFINED__
#define __LPCGUID_DEFINED__
typedef const GUID *LPCGUID;
#endif

133 134
#ifndef __IID_DEFINED__
#define __IID_DEFINED__
135

136
typedef GUID IID,*LPIID;
137
typedef GUID CLSID,*LPCLSID;
138
typedef GUID FMTID,*LPFMTID;
139 140 141 142 143 144
#define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
#define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
#define IsEqualFMTID(rfmtid1, rfmtid2) IsEqualGUID(rfmtid1, rfmtid2)
#define IID_NULL   GUID_NULL
#define CLSID_NULL GUID_NULL
#define FMTID_NULL GUID_NULL
145

146 147 148 149 150 151
#ifdef __midl_proxy
#define __MIDL_CONST
#else
#define __MIDL_CONST const
#endif

152 153
#endif /* ndef __IID_DEFINED__ */

154
#ifdef __cplusplus
155 156 157 158
#define REFGUID             const GUID &
#define REFCLSID            const CLSID &
#define REFIID              const IID &
#define REFFMTID            const FMTID &
159
#else
160 161 162 163
#define REFGUID             const GUID* __MIDL_CONST
#define REFCLSID            const CLSID* __MIDL_CONST
#define REFIID              const IID* __MIDL_CONST
#define REFFMTID            const FMTID* __MIDL_CONST
164
#endif
165

166
#ifdef __cplusplus
167
#define IsEqualGUID(rguid1, rguid2) (!memcmp(&(rguid1), &(rguid2), sizeof(GUID)))
168 169
inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
{
170 171 172 173
   return (((unsigned int *)&rguid1)[0] == ((unsigned int *)&rguid2)[0] &&
           ((unsigned int *)&rguid1)[1] == ((unsigned int *)&rguid2)[1] &&
           ((unsigned int *)&rguid1)[2] == ((unsigned int *)&rguid2)[2] &&
           ((unsigned int *)&rguid1)[3] == ((unsigned int *)&rguid2)[3]);
174
}
175
#else
176
#define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
177
#define InlineIsEqualGUID(rguid1, rguid2)  \
178 179 180 181
        (((unsigned int *)rguid1)[0] == ((unsigned int *)rguid2)[0] && \
         ((unsigned int *)rguid1)[1] == ((unsigned int *)rguid2)[1] && \
         ((unsigned int *)rguid1)[2] == ((unsigned int *)rguid2)[2] && \
         ((unsigned int *)rguid1)[3] == ((unsigned int *)rguid2)[3])
182
#endif
183

184
#ifdef __cplusplus
185
#include <string.h>
186
inline bool operator==(const GUID& guidOne, const GUID& guidOther)
187 188 189
{
    return !memcmp(&guidOne,&guidOther,sizeof(GUID));
}
190
inline bool operator!=(const GUID& guidOne, const GUID& guidOther)
191 192 193
{
    return !(guidOne == guidOther);
}
194
#endif
195 196

#endif /* _GUIDDEF_H_ */