]> git.saurik.com Git - apple/cf.git/blob - PlugIn.subproj/CFPlugInCOM.h
CF-368.18.tar.gz
[apple/cf.git] / PlugIn.subproj / CFPlugInCOM.h
1 /*
2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /* CFPlugInCOM.h
24 Copyright (c) 1999-2005, Apple, Inc. All rights reserved.
25 */
26
27 #if !defined(__COREFOUNDATION_CFPLUGINCOM__)
28 #define __COREFOUNDATION_CFPLUGINCOM__ 1
29
30 #include <CoreFoundation/CFPlugIn.h>
31
32 #if defined(__cplusplus)
33 extern "C" {
34 #endif
35
36 /* ================= IUnknown definition (C struct) ================= */
37
38 /* All interface structs must have an IUnknownStruct at the beginning. */
39 /* The _reserved field is part of the Microsoft COM binary standard on Macintosh. */
40 /* You can declare new C struct interfaces by defining a new struct that includes "IUNKNOWN_C_GUTS;" before the first field of the struct. */
41
42 typedef SInt32 HRESULT;
43 typedef UInt32 ULONG;
44 typedef void *LPVOID;
45 typedef CFUUIDBytes REFIID;
46
47 #define SUCCEEDED(Status) ((HRESULT)(Status) >= 0)
48 #define FAILED(Status) ((HRESULT)(Status)<0)
49
50 /* Macros for more detailed HRESULT analysis */
51 #define IS_ERROR(Status) ((unsigned long)(Status) >> 31 == SEVERITY_ERROR)
52 #define HRESULT_CODE(hr) ((hr) & 0xFFFF)
53 #define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff)
54 #define HRESULT_SEVERITY(hr) (((hr) >> 31) & 0x1)
55 #define SEVERITY_SUCCESS 0
56 #define SEVERITY_ERROR 1
57
58 /* Creating an HRESULT from its component pieces */
59 #define MAKE_HRESULT(sev,fac,code) ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
60
61 /* Pre-defined success HRESULTS */
62 #define S_OK ((HRESULT)0x00000000L)
63 #define S_FALSE ((HRESULT)0x00000001L)
64
65 /* Common error HRESULTS */
66 #define E_UNEXPECTED ((HRESULT)0x8000FFFFL)
67 #define E_NOTIMPL ((HRESULT)0x80000001L)
68 #define E_OUTOFMEMORY ((HRESULT)0x80000002L)
69 #define E_INVALIDARG ((HRESULT)0x80000003L)
70 #define E_NOINTERFACE ((HRESULT)0x80000004L)
71 #define E_POINTER ((HRESULT)0x80000005L)
72 #define E_HANDLE ((HRESULT)0x80000006L)
73 #define E_ABORT ((HRESULT)0x80000007L)
74 #define E_FAIL ((HRESULT)0x80000008L)
75 #define E_ACCESSDENIED ((HRESULT)0x80000009L)
76
77 /* This macro should be used when defining all interface functions (as it is for the IUnknown functions below). */
78 #define STDMETHODCALLTYPE
79
80 /* The __RPC_FAR macro is for COM source compatibility only. This macro is used a lot in COM interface definitions. If your CFPlugIn interfaces need to be COM interfaces as well, you can use this macro to get better source compatibility. It is not used in the IUnknown definition below, because when doing COM, you will be using the Microsoft supplied IUnknown interface anyway. */
81 #define __RPC_FAR
82
83 /* The IUnknown interface */
84 #define IUnknownUUID CFUUIDGetConstantUUIDWithBytes(NULL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)
85
86 #define IUNKNOWN_C_GUTS \
87 void *_reserved; \
88 HRESULT (STDMETHODCALLTYPE *QueryInterface)(void *thisPointer, REFIID iid, LPVOID *ppv); \
89 ULONG (STDMETHODCALLTYPE *AddRef)(void *thisPointer); \
90 ULONG (STDMETHODCALLTYPE *Release)(void *thisPointer)
91
92 typedef struct IUnknownVTbl {
93 IUNKNOWN_C_GUTS;
94 } IUnknownVTbl;
95
96 /* End of extern "C" stuff */
97 #if defined(__cplusplus)
98 }
99 #endif
100
101
102 /* C++ specific stuff */
103 #if defined(__cplusplus)
104 /* ================= IUnknown definition (C++ class) ================= */
105
106 /* This is a definition of IUnknown as a pure abstract virtual C++ class. This class will work only with compilers that can produce COM-compatible object layouts for C++ classes. egcs can not do this. MetroWerks can do this (if you subclass from __comobject) */
107
108 class IUnknown
109 #if defined(__MWERKS__) && !defined(__MACH__)
110 : __comobject
111 #endif
112 {
113 public:
114 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) = 0;
115 virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0;
116 virtual ULONG STDMETHODCALLTYPE Release(void) = 0;
117 };
118
119 #endif
120
121 #endif /* ! __COREFOUNDATION_CFPLUGINCOM__ */
122