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 |
|
---|
50 | #ifndef RT_OS_WINDOWS
|
---|
51 | typedef unsigned long HRESULT;
|
---|
52 | typedef unsigned long ULONG; /// @todo 64-bit: ULONG is 32-bit.
|
---|
53 | typedef signed long LONG; /// @todo 64-bit: ULONG is 32-bit.
|
---|
54 | typedef unsigned short USHORT;
|
---|
55 | typedef bool BOOL;
|
---|
56 | typedef unsigned char BYTE;
|
---|
57 | # define STDMETHODIMP unsigned long
|
---|
58 | # define STDMETHOD(a) virtual unsigned long a
|
---|
59 | # define S_OK 0
|
---|
60 |
|
---|
61 | # if ! defined(E_NOTIMPL)
|
---|
62 | # define E_NOTIMPL ((unsigned long) 0x80004001L)
|
---|
63 | # endif
|
---|
64 | # define E_POINTER ((unsigned long) 0x80004003L)
|
---|
65 | # define E_FAIL ((unsigned long) 0x80004005L)
|
---|
66 | # define E_UNEXPECTED ((unsigned long) 0x8000ffffL)
|
---|
67 | # define E_INVALIDARG ((unsigned long) 0x80070057L)
|
---|
68 | #define E_ACCESSDENIED ((unsigned long) 0x80070005L)
|
---|
69 |
|
---|
70 | # if ! defined(FALSE)
|
---|
71 | # define FALSE false
|
---|
72 | # endif
|
---|
73 |
|
---|
74 | # if ! defined(TRUE)
|
---|
75 | # define TRUE true
|
---|
76 | # endif
|
---|
77 |
|
---|
78 | # define SUCCEEDED NS_SUCCEEDED
|
---|
79 | # define FAILED NS_FAILED
|
---|
80 |
|
---|
81 | #define ComSafeArrayIn(aType, aArg) unsigned aArg##Size, aType *aArg
|
---|
82 | #define ComSafeArrayInIsNull(aArg) (aArg == NULL)
|
---|
83 | #define ComSafeArrayInArg(aArg) aArg##Size, aArg
|
---|
84 | #define ComSafeArrayAsInParam(aArray) \
|
---|
85 | (aArray).size(), aArray.raw()
|
---|
86 | #else /* !RT_OS_WINDOWS */
|
---|
87 | #define ComSafeArrayIn(aType, aArg) SAFEARRAY **aArg
|
---|
88 | #define ComSafeArrayInIsNull(aArg) (aArg == NULL || *aArg == NULL)
|
---|
89 | #define ComSafeArrayInArg(aArg) aArg
|
---|
90 | #define ComSafeArrayAsInParam(aArray) (SAFEARRAY **)NULL
|
---|
91 |
|
---|
92 | #endif /* !RT_OS_WINDOWS */
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 | namespace com
|
---|
97 | {
|
---|
98 | template<class T> class SafeArray {
|
---|
99 | T t;
|
---|
100 | public:
|
---|
101 | SafeArray (size_t aSize) {}
|
---|
102 | SafeArray (ComSafeArrayIn (T, aArg)) {}
|
---|
103 | T &operator[] (size_t aIdx) { return t; }
|
---|
104 | size_t size() const { return 0; }
|
---|
105 | T *raw() { return &t; }
|
---|
106 | };
|
---|
107 | }
|
---|
108 |
|
---|
109 | #define unconst(val) val
|
---|
110 | #endif
|
---|