1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
---|
2 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
4 | *
|
---|
5 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
6 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | * http://www.mozilla.org/MPL/
|
---|
9 | *
|
---|
10 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
12 | * for the specific language governing rights and limitations under the
|
---|
13 | * License.
|
---|
14 | *
|
---|
15 | * The Original Code is mozilla.org code.
|
---|
16 | *
|
---|
17 | * The Initial Developer of the Original Code is
|
---|
18 | * Netscape Communications Corporation.
|
---|
19 | * Portions created by the Initial Developer are Copyright (C) 1999
|
---|
20 | * the Initial Developer. All Rights Reserved.
|
---|
21 | *
|
---|
22 | * Contributor(s):
|
---|
23 | *
|
---|
24 | * Alternatively, the contents of this file may be used under the terms of
|
---|
25 | * either of the GNU General Public License Version 2 or later (the "GPL"),
|
---|
26 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
28 | * of those above. If you wish to allow use of your version of this file only
|
---|
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
30 | * use your version of this file under the terms of the MPL, indicate your
|
---|
31 | * decision by deleting the provisions above and replace them with the notice
|
---|
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
33 | * the provisions above, a recipient may use your version of this file under
|
---|
34 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
35 | *
|
---|
36 | * ***** END LICENSE BLOCK ***** */
|
---|
37 |
|
---|
38 | /* XPTI_PUBLIC_API and XPTI_GetInterfaceInfoManager declarations. */
|
---|
39 |
|
---|
40 | #ifndef xptiinfo_h___
|
---|
41 | #define xptiinfo_h___
|
---|
42 |
|
---|
43 | #include "prtypes.h"
|
---|
44 | #include "xpt_struct.h"
|
---|
45 |
|
---|
46 | #ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
|
---|
47 | #define XPTI_GetInterfaceInfoManager VBoxNsxpXPTI_GetInterfaceInfoManager
|
---|
48 | #define XPTI_FreeInterfaceInfoManager VBoxNsxpXPTI_FreeInterfaceInfoManager
|
---|
49 | #endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
|
---|
50 |
|
---|
51 | /*
|
---|
52 | * The linkage of XPTI API functions differs depending on whether the file is
|
---|
53 | * used within the XPTI library or not. Any source file within the XPTI
|
---|
54 | * library should define EXPORT_XPTI_API whereas any client of the library
|
---|
55 | * should not.
|
---|
56 | */
|
---|
57 | #ifdef EXPORT_XPTI_API
|
---|
58 | #define XPTI_PUBLIC_API(t) PR_IMPLEMENT(t)
|
---|
59 | #define XPTI_PUBLIC_DATA(t) PR_IMPLEMENT_DATA(t)
|
---|
60 | #if defined(_WIN32)
|
---|
61 | # define XPTI_EXPORT __declspec(dllexport)
|
---|
62 | #elif defined(XP_OS2) && defined(__declspec)
|
---|
63 | # define XPTI_EXPORT __declspec(dllexport)
|
---|
64 | #elif defined(XP_OS2_VACPP)
|
---|
65 | # define XPTI_EXPORT extern
|
---|
66 | #else
|
---|
67 | # define XPTI_EXPORT
|
---|
68 | #endif
|
---|
69 | #else
|
---|
70 | #if defined(_WIN32)
|
---|
71 | # define XPTI_PUBLIC_API(t) __declspec(dllimport) t
|
---|
72 | # define XPTI_PUBLIC_DATA(t) __declspec(dllimport) t
|
---|
73 | # define XPTI_EXPORT __declspec(dllimport)
|
---|
74 | #elif defined(XP_OS2) && defined(__declspec)
|
---|
75 | # define XPTI_PUBLIC_API(t) __declspec(dllimport) t
|
---|
76 | # define XPTI_PUBLIC_DATA(t) __declspec(dllimport) t
|
---|
77 | # define XPTI_EXPORT __declspec(dllimport)
|
---|
78 | #elif defined(XP_OS2_VACPP)
|
---|
79 | # define XPTI_PUBLIC_API(t) extern t
|
---|
80 | # define XPTI_PUBLIC_DATA(t) extern t
|
---|
81 | # define XPTI_EXPORT extern
|
---|
82 | #else
|
---|
83 | # define XPTI_PUBLIC_API(t) PR_IMPLEMENT(t)
|
---|
84 | # define XPTI_PUBLIC_DATA(t) t
|
---|
85 | # define XPTI_EXPORT
|
---|
86 | #endif
|
---|
87 | #endif
|
---|
88 | #define XPTI_FRIEND_API(t) XPTI_PUBLIC_API(t)
|
---|
89 | #define XPTI_FRIEND_DATA(t) XPTI_PUBLIC_DATA(t)
|
---|
90 |
|
---|
91 | class nsIInterfaceInfoManager;
|
---|
92 | PR_BEGIN_EXTERN_C
|
---|
93 | // Even if this is a service, it is cool to provide a direct accessor
|
---|
94 | XPTI_PUBLIC_API(nsIInterfaceInfoManager*)
|
---|
95 | XPTI_GetInterfaceInfoManager();
|
---|
96 |
|
---|
97 | // Even if this is a service, it is cool to provide a direct accessor
|
---|
98 | XPTI_PUBLIC_API(void)
|
---|
99 | XPTI_FreeInterfaceInfoManager();
|
---|
100 | PR_END_EXTERN_C
|
---|
101 |
|
---|
102 |
|
---|
103 |
|
---|
104 | // Flyweight wrapper classes for xpt_struct.h structs.
|
---|
105 | // Everything here is dependent upon - and sensitive to changes in -
|
---|
106 | // xpcom/typelib/xpt/public/xpt_struct.h!
|
---|
107 |
|
---|
108 | class nsXPTType : public XPTTypeDescriptorPrefix
|
---|
109 | {
|
---|
110 | // NO DATA - this a flyweight wrapper
|
---|
111 | public:
|
---|
112 | nsXPTType()
|
---|
113 | {} // random contents
|
---|
114 | nsXPTType(const XPTTypeDescriptorPrefix& prefix)
|
---|
115 | {*(XPTTypeDescriptorPrefix*)this = prefix;}
|
---|
116 |
|
---|
117 | nsXPTType(const uint8& prefix)
|
---|
118 | {*(uint8*)this = prefix;}
|
---|
119 |
|
---|
120 | nsXPTType& operator=(uint8 val)
|
---|
121 | {flags = val; return *this;}
|
---|
122 |
|
---|
123 | nsXPTType& operator=(const nsXPTType& other)
|
---|
124 | {flags = other.flags; return *this;}
|
---|
125 |
|
---|
126 | operator uint8() const
|
---|
127 | {return flags;}
|
---|
128 |
|
---|
129 | PRBool IsPointer() const
|
---|
130 | {return 0 != (XPT_TDP_IS_POINTER(flags));}
|
---|
131 |
|
---|
132 | PRBool IsUniquePointer() const
|
---|
133 | {return 0 != (XPT_TDP_IS_UNIQUE_POINTER(flags));}
|
---|
134 |
|
---|
135 | PRBool IsReference() const
|
---|
136 | {return 0 != (XPT_TDP_IS_REFERENCE(flags));}
|
---|
137 |
|
---|
138 | PRBool IsArithmetic() const // terminology from Harbison/Steele
|
---|
139 | {return flags <= T_WCHAR;}
|
---|
140 |
|
---|
141 | PRBool IsInterfacePointer() const
|
---|
142 | { switch (TagPart()) {
|
---|
143 | default:
|
---|
144 | return PR_FALSE;
|
---|
145 | case T_INTERFACE:
|
---|
146 | case T_INTERFACE_IS:
|
---|
147 | return PR_TRUE;
|
---|
148 | }
|
---|
149 | }
|
---|
150 |
|
---|
151 | PRBool IsArray() const
|
---|
152 | {return (PRBool) TagPart() == T_ARRAY;}
|
---|
153 |
|
---|
154 | // 'Dependent' means that params of this type are dependent upon other
|
---|
155 | // params. e.g. an T_INTERFACE_IS is dependent upon some other param at
|
---|
156 | // runtime to say what the interface type of this param really is.
|
---|
157 | PRBool IsDependent() const
|
---|
158 | { switch (TagPart()) {
|
---|
159 | default:
|
---|
160 | return PR_FALSE;
|
---|
161 | case T_INTERFACE_IS:
|
---|
162 | case TD_ARRAY:
|
---|
163 | case T_PSTRING_SIZE_IS:
|
---|
164 | case T_PWSTRING_SIZE_IS:
|
---|
165 | return PR_TRUE;
|
---|
166 | }
|
---|
167 | }
|
---|
168 |
|
---|
169 | uint8 TagPart() const
|
---|
170 | {return (uint8) (flags & XPT_TDP_TAGMASK);}
|
---|
171 |
|
---|
172 | enum
|
---|
173 | {
|
---|
174 | T_I8 = TD_INT8 ,
|
---|
175 | T_I16 = TD_INT16 ,
|
---|
176 | T_I32 = TD_INT32 ,
|
---|
177 | T_I64 = TD_INT64 ,
|
---|
178 | T_U8 = TD_UINT8 ,
|
---|
179 | T_U16 = TD_UINT16 ,
|
---|
180 | T_U32 = TD_UINT32 ,
|
---|
181 | T_U64 = TD_UINT64 ,
|
---|
182 | T_FLOAT = TD_FLOAT ,
|
---|
183 | T_DOUBLE = TD_DOUBLE ,
|
---|
184 | T_BOOL = TD_BOOL ,
|
---|
185 | T_CHAR = TD_CHAR ,
|
---|
186 | T_WCHAR = TD_WCHAR ,
|
---|
187 | T_VOID = TD_VOID ,
|
---|
188 | T_IID = TD_PNSIID ,
|
---|
189 | T_DOMSTRING = TD_DOMSTRING ,
|
---|
190 | T_CHAR_STR = TD_PSTRING ,
|
---|
191 | T_WCHAR_STR = TD_PWSTRING ,
|
---|
192 | T_INTERFACE = TD_INTERFACE_TYPE ,
|
---|
193 | T_INTERFACE_IS = TD_INTERFACE_IS_TYPE,
|
---|
194 | T_ARRAY = TD_ARRAY ,
|
---|
195 | T_PSTRING_SIZE_IS = TD_PSTRING_SIZE_IS ,
|
---|
196 | T_PWSTRING_SIZE_IS = TD_PWSTRING_SIZE_IS ,
|
---|
197 | T_UTF8STRING = TD_UTF8STRING ,
|
---|
198 | T_CSTRING = TD_CSTRING ,
|
---|
199 | T_ASTRING = TD_ASTRING
|
---|
200 | };
|
---|
201 | // NO DATA - this a flyweight wrapper
|
---|
202 | };
|
---|
203 |
|
---|
204 | class nsXPTParamInfo : public XPTParamDescriptor
|
---|
205 | {
|
---|
206 | // NO DATA - this a flyweight wrapper
|
---|
207 | public:
|
---|
208 | nsXPTParamInfo(const XPTParamDescriptor& desc)
|
---|
209 | {*(XPTParamDescriptor*)this = desc;}
|
---|
210 |
|
---|
211 |
|
---|
212 | PRBool IsIn() const {return 0 != (XPT_PD_IS_IN(flags));}
|
---|
213 | PRBool IsOut() const {return 0 != (XPT_PD_IS_OUT(flags));}
|
---|
214 | PRBool IsRetval() const {return 0 != (XPT_PD_IS_RETVAL(flags));}
|
---|
215 | PRBool IsShared() const {return 0 != (XPT_PD_IS_SHARED(flags));}
|
---|
216 | PRBool IsDipper() const {return 0 != (XPT_PD_IS_DIPPER(flags));}
|
---|
217 | const nsXPTType GetType() const {return type.prefix;}
|
---|
218 |
|
---|
219 | // NOTE: other activities on types are done via methods on nsIInterfaceInfo
|
---|
220 |
|
---|
221 | private:
|
---|
222 | nsXPTParamInfo(); // no implementation
|
---|
223 | // NO DATA - this a flyweight wrapper
|
---|
224 | };
|
---|
225 |
|
---|
226 | class nsXPTMethodInfo : public XPTMethodDescriptor
|
---|
227 | {
|
---|
228 | // NO DATA - this a flyweight wrapper
|
---|
229 | public:
|
---|
230 | nsXPTMethodInfo(const XPTMethodDescriptor& desc)
|
---|
231 | {*(XPTMethodDescriptor*)this = desc;}
|
---|
232 |
|
---|
233 | PRBool IsGetter() const {return 0 != (XPT_MD_IS_GETTER(flags) );}
|
---|
234 | PRBool IsSetter() const {return 0 != (XPT_MD_IS_SETTER(flags) );}
|
---|
235 | PRBool IsNotXPCOM() const {return 0 != (XPT_MD_IS_NOTXPCOM(flags));}
|
---|
236 | PRBool IsConstructor() const {return 0 != (XPT_MD_IS_CTOR(flags) );}
|
---|
237 | PRBool IsHidden() const {return 0 != (XPT_MD_IS_HIDDEN(flags) );}
|
---|
238 | const char* GetName() const {return name;}
|
---|
239 | uint8 GetParamCount() const {return num_args;}
|
---|
240 | /* idx was index before I got _sick_ of the warnings on Unix, sorry jband */
|
---|
241 | const nsXPTParamInfo GetParam(uint8 idx) const
|
---|
242 | {
|
---|
243 | NS_PRECONDITION(idx < GetParamCount(),"bad arg");
|
---|
244 | return params[idx];
|
---|
245 | }
|
---|
246 | const nsXPTParamInfo GetResult() const
|
---|
247 | {return *result;}
|
---|
248 | private:
|
---|
249 | nsXPTMethodInfo(); // no implementation
|
---|
250 | // NO DATA - this a flyweight wrapper
|
---|
251 | };
|
---|
252 |
|
---|
253 |
|
---|
254 | // forward declaration
|
---|
255 | struct nsXPTCMiniVariant;
|
---|
256 |
|
---|
257 | class nsXPTConstant : public XPTConstDescriptor
|
---|
258 | {
|
---|
259 | // NO DATA - this a flyweight wrapper
|
---|
260 | public:
|
---|
261 | nsXPTConstant(const XPTConstDescriptor& desc)
|
---|
262 | {*(XPTConstDescriptor*)this = desc;}
|
---|
263 |
|
---|
264 | const char* GetName() const
|
---|
265 | {return name;}
|
---|
266 |
|
---|
267 | const nsXPTType GetType() const
|
---|
268 | {return type.prefix;}
|
---|
269 |
|
---|
270 | // XXX this is ugly. But sometimes you gotta do what you gotta do.
|
---|
271 | // A reinterpret_cast won't do the trick here. And this plain C cast
|
---|
272 | // works correctly and is safe enough.
|
---|
273 | // See http://bugzilla.mozilla.org/show_bug.cgi?id=49641
|
---|
274 | const nsXPTCMiniVariant* GetValue() const
|
---|
275 | {return (nsXPTCMiniVariant*) &value;}
|
---|
276 | private:
|
---|
277 | nsXPTConstant(); // no implementation
|
---|
278 | // NO DATA - this a flyweight wrapper
|
---|
279 | };
|
---|
280 |
|
---|
281 | #endif /* xptiinfo_h___ */
|
---|