1 | /** @file
|
---|
2 | * VBox frontends: Basic Frontend (BFE):
|
---|
3 | * COM definitions
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef COMDefs_H
|
---|
23 | #define COMDefs_H
|
---|
24 |
|
---|
25 | #ifdef RT_OS_WINDOWS
|
---|
26 | # include <Windows.h>
|
---|
27 | #endif
|
---|
28 | #include <stdarg.h>
|
---|
29 | #include <iprt/assert.h>
|
---|
30 |
|
---|
31 | /* This is a transitional file used to get rid of all COM
|
---|
32 | * definitions from COM/XPCOM. */
|
---|
33 |
|
---|
34 | #define COMGETTER(n) get_##n
|
---|
35 | #define COMSETTER(n) put_##n
|
---|
36 |
|
---|
37 | #define NS_LIKELY(x) RT_LIKELY(x)
|
---|
38 | #define NS_UNLIKELY(x) RT_UNLIKELY(x)
|
---|
39 |
|
---|
40 | #define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) & 0x80000000)))
|
---|
41 | #define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) & 0x80000000))
|
---|
42 |
|
---|
43 | #define ATL_NO_VTABLE
|
---|
44 | #define DECLARE_CLASSFACTORY(a)
|
---|
45 | #define DECLARE_CLASSFACTORY_SINGLETON(a)
|
---|
46 | #define DECLARE_REGISTRY_RESOURCEID(a)
|
---|
47 | #define DECLARE_NOT_AGGREGATABLE(a)
|
---|
48 | #define DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
49 | #define BEGIN_COM_MAP(a)
|
---|
50 | #define COM_INTERFACE_ENTRY(a)
|
---|
51 | #define COM_INTERFACE_ENTRY2(a,b)
|
---|
52 | #define END_COM_MAP()
|
---|
53 |
|
---|
54 | #ifndef RT_OS_WINDOWS
|
---|
55 | typedef unsigned long HRESULT;
|
---|
56 | typedef unsigned long ULONG; /// @todo 64-bit: ULONG is 32-bit.
|
---|
57 | typedef signed long LONG; /// @todo 64-bit: ULONG is 32-bit.
|
---|
58 | typedef unsigned short USHORT;
|
---|
59 | typedef bool BOOL;
|
---|
60 | typedef unsigned char BYTE;
|
---|
61 | # define STDMETHODIMP unsigned long
|
---|
62 | # define STDMETHOD(a) virtual unsigned long a
|
---|
63 | # define S_OK 0
|
---|
64 |
|
---|
65 | # if ! defined(E_NOTIMPL)
|
---|
66 | # define E_NOTIMPL ((unsigned long) 0x80004001L)
|
---|
67 | # endif
|
---|
68 | # define E_POINTER ((unsigned long) 0x80004003L)
|
---|
69 | # define E_FAIL ((unsigned long) 0x80004005L)
|
---|
70 | # define E_UNEXPECTED ((unsigned long) 0x8000ffffL)
|
---|
71 | # define E_INVALIDARG ((unsigned long) 0x80070057L)
|
---|
72 | #define E_ACCESSDENIED ((unsigned long) 0x80070005L)
|
---|
73 |
|
---|
74 | # if ! defined(FALSE)
|
---|
75 | # define FALSE false
|
---|
76 | # endif
|
---|
77 |
|
---|
78 | # if ! defined(TRUE)
|
---|
79 | # define TRUE true
|
---|
80 | # endif
|
---|
81 |
|
---|
82 | # define SUCCEEDED NS_SUCCEEDED
|
---|
83 | # define FAILED NS_FAILED
|
---|
84 |
|
---|
85 | #define ComSafeArrayIn(aType, aArg) unsigned aArg##Size, aType *aArg
|
---|
86 | #define ComSafeArrayInIsNull(aArg) (aArg == NULL)
|
---|
87 | #define ComSafeArrayInArg(aArg) aArg##Size, aArg
|
---|
88 | #define ComSafeArrayAsInParam(aArray) \
|
---|
89 | (aArray).size(), aArray.raw()
|
---|
90 | #else /* !RT_OS_WINDOWS */
|
---|
91 | #define ComSafeArrayIn(aType, aArg) SAFEARRAY **aArg
|
---|
92 | #define ComSafeArrayInIsNull(aArg) (aArg == NULL || *aArg == NULL)
|
---|
93 | #define ComSafeArrayInArg(aArg) aArg
|
---|
94 | #define ComSafeArrayAsInParam(aArray) (SAFEARRAY **)NULL
|
---|
95 |
|
---|
96 | #endif /* !RT_OS_WINDOWS */
|
---|
97 |
|
---|
98 |
|
---|
99 |
|
---|
100 | namespace com
|
---|
101 | {
|
---|
102 | template<class T> class SafeArray {
|
---|
103 | T t;
|
---|
104 | public:
|
---|
105 | SafeArray (size_t aSize) {}
|
---|
106 | SafeArray (ComSafeArrayIn (T, aArg)) {}
|
---|
107 | T &operator[] (size_t aIdx) { return t; }
|
---|
108 | size_t size() const { return 0; }
|
---|
109 | T *raw() { return &t; }
|
---|
110 | };
|
---|
111 | }
|
---|
112 |
|
---|
113 | #define unconst(val) val
|
---|
114 | #endif
|
---|