1 | /** @file
|
---|
2 | * VBox frontends: Basic Frontend (BFE):
|
---|
3 | * COM definitions
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Oracle Corporation
|
---|
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 |
|
---|
18 | #ifndef COMDefs_H
|
---|
19 | #define COMDefs_H
|
---|
20 |
|
---|
21 | #ifdef RT_OS_WINDOWS
|
---|
22 | # include <Windows.h>
|
---|
23 | #endif
|
---|
24 | #include <stdarg.h>
|
---|
25 | #include <iprt/assert.h>
|
---|
26 |
|
---|
27 | /* This is a transitional file used to get rid of all COM
|
---|
28 | * definitions from COM/XPCOM. */
|
---|
29 |
|
---|
30 | #define COMGETTER(n) get_##n
|
---|
31 | #define COMSETTER(n) put_##n
|
---|
32 |
|
---|
33 | #define NS_LIKELY(x) RT_LIKELY(x)
|
---|
34 | #define NS_UNLIKELY(x) RT_UNLIKELY(x)
|
---|
35 |
|
---|
36 | #define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) & 0x80000000)))
|
---|
37 | #define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) & 0x80000000))
|
---|
38 |
|
---|
39 | #define ATL_NO_VTABLE
|
---|
40 | #define DECLARE_CLASSFACTORY(a)
|
---|
41 | #define DECLARE_CLASSFACTORY_SINGLETON(a)
|
---|
42 | #define DECLARE_REGISTRY_RESOURCEID(a)
|
---|
43 | #define DECLARE_NOT_AGGREGATABLE(a)
|
---|
44 | #define DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
45 | #define BEGIN_COM_MAP(a)
|
---|
46 | #define COM_INTERFACE_ENTRY(a)
|
---|
47 | #define COM_INTERFACE_ENTRY2(a,b)
|
---|
48 | #define END_COM_MAP()
|
---|
49 | #define VBOX_DEFAULT_INTERFACE_ENTRIES(a)
|
---|
50 | #define BaseFinalConstruct() (S_OK)
|
---|
51 | #define BaseFinalRelease()
|
---|
52 |
|
---|
53 | #ifndef RT_OS_WINDOWS
|
---|
54 | typedef unsigned long HRESULT;
|
---|
55 | typedef unsigned long ULONG; /// @todo 64-bit: ULONG is 32-bit.
|
---|
56 | typedef signed long LONG; /// @todo 64-bit: ULONG is 32-bit.
|
---|
57 | typedef unsigned short USHORT;
|
---|
58 | typedef bool BOOL;
|
---|
59 | typedef unsigned char BYTE;
|
---|
60 | # define STDMETHODIMP unsigned long
|
---|
61 | # define STDMETHOD(a) virtual unsigned long a
|
---|
62 | # define S_OK 0
|
---|
63 |
|
---|
64 | # if ! defined(E_NOTIMPL)
|
---|
65 | # define E_NOTIMPL ((unsigned long) 0x80004001L)
|
---|
66 | # endif
|
---|
67 | # define E_POINTER ((unsigned long) 0x80004003L)
|
---|
68 | # define E_FAIL ((unsigned long) 0x80004005L)
|
---|
69 | # define E_UNEXPECTED ((unsigned long) 0x8000ffffL)
|
---|
70 | # define E_INVALIDARG ((unsigned long) 0x80070057L)
|
---|
71 | #define E_ACCESSDENIED ((unsigned long) 0x80070005L)
|
---|
72 |
|
---|
73 | # if ! defined(FALSE)
|
---|
74 | # define FALSE false
|
---|
75 | # endif
|
---|
76 |
|
---|
77 | # if ! defined(TRUE)
|
---|
78 | # define TRUE true
|
---|
79 | # endif
|
---|
80 |
|
---|
81 | # define SUCCEEDED NS_SUCCEEDED
|
---|
82 | # define FAILED NS_FAILED
|
---|
83 |
|
---|
84 | #define ComSafeArrayIn(aType, aArg) unsigned aArg##Size, aType *aArg
|
---|
85 | #define ComSafeArrayInIsNull(aArg) (aArg == NULL)
|
---|
86 | #define ComSafeArrayInArg(aArg) aArg##Size, aArg
|
---|
87 | #define ComSafeArrayAsInParam(aArray) \
|
---|
88 | (aArray).size(), aArray.raw()
|
---|
89 | #else /* !RT_OS_WINDOWS */
|
---|
90 | #define ComSafeArrayIn(aType, aArg) SAFEARRAY **aArg
|
---|
91 | #define ComSafeArrayInIsNull(aArg) (aArg == NULL || *aArg == NULL)
|
---|
92 | #define ComSafeArrayInArg(aArg) aArg
|
---|
93 | #define ComSafeArrayAsInParam(aArray) (SAFEARRAY **)NULL
|
---|
94 |
|
---|
95 | #endif /* !RT_OS_WINDOWS */
|
---|
96 |
|
---|
97 |
|
---|
98 |
|
---|
99 | namespace com
|
---|
100 | {
|
---|
101 | template<class T> class SafeArray {
|
---|
102 | T t;
|
---|
103 | public:
|
---|
104 | SafeArray (size_t aSize) {}
|
---|
105 | SafeArray (ComSafeArrayIn (T, aArg)) {}
|
---|
106 | T &operator[] (size_t aIdx) { return t; }
|
---|
107 | size_t size() const { return 0; }
|
---|
108 | T *raw() { return &t; }
|
---|
109 | };
|
---|
110 | }
|
---|
111 |
|
---|
112 | #define unconst(val) val
|
---|
113 | #endif
|
---|