VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/reflect/xptinfo/public/xptinfo.h@ 3149

Last change on this file since 3149 was 3149, checked in by vboxsync, 18 years ago

XPCOM: Ported necessary bits of IPC/DConnect tp OS/2.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.6 KB
Line 
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/*
47 * The linkage of XPTI API functions differs depending on whether the file is
48 * used within the XPTI library or not. Any source file within the XPTI
49 * library should define EXPORT_XPTI_API whereas any client of the library
50 * should not.
51 */
52#ifdef EXPORT_XPTI_API
53#define XPTI_PUBLIC_API(t) PR_IMPLEMENT(t)
54#define XPTI_PUBLIC_DATA(t) PR_IMPLEMENT_DATA(t)
55#if defined(_WIN32)
56# define XPTI_EXPORT __declspec(dllexport)
57#elif defined(XP_OS2) && defined(__declspec)
58# define XPTI_EXPORT __declspec(dllexport)
59#elif defined(XP_OS2_VACPP)
60# define XPTI_EXPORT extern
61#else
62# define XPTI_EXPORT
63#endif
64#else
65#if defined(_WIN32)
66# define XPTI_PUBLIC_API(t) __declspec(dllimport) t
67# define XPTI_PUBLIC_DATA(t) __declspec(dllimport) t
68# define XPTI_EXPORT __declspec(dllimport)
69#elif defined(XP_OS2) && defined(__declspec)
70# define XPTI_PUBLIC_API(t) __declspec(dllimport) t
71# define XPTI_PUBLIC_DATA(t) __declspec(dllimport) t
72# define XPTI_EXPORT __declspec(dllimport)
73#elif defined(XP_OS2_VACPP)
74# define XPTI_PUBLIC_API(t) extern t
75# define XPTI_PUBLIC_DATA(t) extern t
76# define XPTI_EXPORT extern
77#else
78# define XPTI_PUBLIC_API(t) PR_IMPLEMENT(t)
79# define XPTI_PUBLIC_DATA(t) t
80# define XPTI_EXPORT
81#endif
82#endif
83#define XPTI_FRIEND_API(t) XPTI_PUBLIC_API(t)
84#define XPTI_FRIEND_DATA(t) XPTI_PUBLIC_DATA(t)
85
86class nsIInterfaceInfoManager;
87PR_BEGIN_EXTERN_C
88// Even if this is a service, it is cool to provide a direct accessor
89XPTI_PUBLIC_API(nsIInterfaceInfoManager*)
90XPTI_GetInterfaceInfoManager();
91
92// Even if this is a service, it is cool to provide a direct accessor
93XPTI_PUBLIC_API(void)
94XPTI_FreeInterfaceInfoManager();
95PR_END_EXTERN_C
96
97
98
99// Flyweight wrapper classes for xpt_struct.h structs.
100// Everything here is dependent upon - and sensitive to changes in -
101// xpcom/typelib/xpt/public/xpt_struct.h!
102
103class nsXPTType : public XPTTypeDescriptorPrefix
104{
105// NO DATA - this a flyweight wrapper
106public:
107 nsXPTType()
108 {} // random contents
109 nsXPTType(const XPTTypeDescriptorPrefix& prefix)
110 {*(XPTTypeDescriptorPrefix*)this = prefix;}
111
112 nsXPTType(const uint8& prefix)
113 {*(uint8*)this = prefix;}
114
115 nsXPTType& operator=(uint8 val)
116 {flags = val; return *this;}
117
118 nsXPTType& operator=(const nsXPTType& other)
119 {flags = other.flags; return *this;}
120
121 operator uint8() const
122 {return flags;}
123
124 PRBool IsPointer() const
125 {return 0 != (XPT_TDP_IS_POINTER(flags));}
126
127 PRBool IsUniquePointer() const
128 {return 0 != (XPT_TDP_IS_UNIQUE_POINTER(flags));}
129
130 PRBool IsReference() const
131 {return 0 != (XPT_TDP_IS_REFERENCE(flags));}
132
133 PRBool IsArithmetic() const // terminology from Harbison/Steele
134 {return flags <= T_WCHAR;}
135
136 PRBool IsInterfacePointer() const
137 { switch (TagPart()) {
138 default:
139 return PR_FALSE;
140 case T_INTERFACE:
141 case T_INTERFACE_IS:
142 return PR_TRUE;
143 }
144 }
145
146 PRBool IsArray() const
147 {return (PRBool) TagPart() == T_ARRAY;}
148
149 // 'Dependent' means that params of this type are dependent upon other
150 // params. e.g. an T_INTERFACE_IS is dependent upon some other param at
151 // runtime to say what the interface type of this param really is.
152 PRBool IsDependent() const
153 { switch (TagPart()) {
154 default:
155 return PR_FALSE;
156 case T_INTERFACE_IS:
157 case TD_ARRAY:
158 case T_PSTRING_SIZE_IS:
159 case T_PWSTRING_SIZE_IS:
160 return PR_TRUE;
161 }
162 }
163
164 uint8 TagPart() const
165 {return (uint8) (flags & XPT_TDP_TAGMASK);}
166
167 enum
168 {
169 T_I8 = TD_INT8 ,
170 T_I16 = TD_INT16 ,
171 T_I32 = TD_INT32 ,
172 T_I64 = TD_INT64 ,
173 T_U8 = TD_UINT8 ,
174 T_U16 = TD_UINT16 ,
175 T_U32 = TD_UINT32 ,
176 T_U64 = TD_UINT64 ,
177 T_FLOAT = TD_FLOAT ,
178 T_DOUBLE = TD_DOUBLE ,
179 T_BOOL = TD_BOOL ,
180 T_CHAR = TD_CHAR ,
181 T_WCHAR = TD_WCHAR ,
182 T_VOID = TD_VOID ,
183 T_IID = TD_PNSIID ,
184 T_DOMSTRING = TD_DOMSTRING ,
185 T_CHAR_STR = TD_PSTRING ,
186 T_WCHAR_STR = TD_PWSTRING ,
187 T_INTERFACE = TD_INTERFACE_TYPE ,
188 T_INTERFACE_IS = TD_INTERFACE_IS_TYPE,
189 T_ARRAY = TD_ARRAY ,
190 T_PSTRING_SIZE_IS = TD_PSTRING_SIZE_IS ,
191 T_PWSTRING_SIZE_IS = TD_PWSTRING_SIZE_IS ,
192 T_UTF8STRING = TD_UTF8STRING ,
193 T_CSTRING = TD_CSTRING ,
194 T_ASTRING = TD_ASTRING
195 };
196// NO DATA - this a flyweight wrapper
197};
198
199class nsXPTParamInfo : public XPTParamDescriptor
200{
201// NO DATA - this a flyweight wrapper
202public:
203 nsXPTParamInfo(const XPTParamDescriptor& desc)
204 {*(XPTParamDescriptor*)this = desc;}
205
206
207 PRBool IsIn() const {return 0 != (XPT_PD_IS_IN(flags));}
208 PRBool IsOut() const {return 0 != (XPT_PD_IS_OUT(flags));}
209 PRBool IsRetval() const {return 0 != (XPT_PD_IS_RETVAL(flags));}
210 PRBool IsShared() const {return 0 != (XPT_PD_IS_SHARED(flags));}
211 PRBool IsDipper() const {return 0 != (XPT_PD_IS_DIPPER(flags));}
212 const nsXPTType GetType() const {return type.prefix;}
213
214 // NOTE: other activities on types are done via methods on nsIInterfaceInfo
215
216private:
217 nsXPTParamInfo(); // no implementation
218// NO DATA - this a flyweight wrapper
219};
220
221class nsXPTMethodInfo : public XPTMethodDescriptor
222{
223// NO DATA - this a flyweight wrapper
224public:
225 nsXPTMethodInfo(const XPTMethodDescriptor& desc)
226 {*(XPTMethodDescriptor*)this = desc;}
227
228 PRBool IsGetter() const {return 0 != (XPT_MD_IS_GETTER(flags) );}
229 PRBool IsSetter() const {return 0 != (XPT_MD_IS_SETTER(flags) );}
230 PRBool IsNotXPCOM() const {return 0 != (XPT_MD_IS_NOTXPCOM(flags));}
231 PRBool IsConstructor() const {return 0 != (XPT_MD_IS_CTOR(flags) );}
232 PRBool IsHidden() const {return 0 != (XPT_MD_IS_HIDDEN(flags) );}
233 const char* GetName() const {return name;}
234 uint8 GetParamCount() const {return num_args;}
235 /* idx was index before I got _sick_ of the warnings on Unix, sorry jband */
236 const nsXPTParamInfo GetParam(uint8 idx) const
237 {
238 NS_PRECONDITION(idx < GetParamCount(),"bad arg");
239 return params[idx];
240 }
241 const nsXPTParamInfo GetResult() const
242 {return *result;}
243private:
244 nsXPTMethodInfo(); // no implementation
245// NO DATA - this a flyweight wrapper
246};
247
248
249// forward declaration
250struct nsXPTCMiniVariant;
251
252class nsXPTConstant : public XPTConstDescriptor
253{
254// NO DATA - this a flyweight wrapper
255public:
256 nsXPTConstant(const XPTConstDescriptor& desc)
257 {*(XPTConstDescriptor*)this = desc;}
258
259 const char* GetName() const
260 {return name;}
261
262 const nsXPTType GetType() const
263 {return type.prefix;}
264
265 // XXX this is ugly. But sometimes you gotta do what you gotta do.
266 // A reinterpret_cast won't do the trick here. And this plain C cast
267 // works correctly and is safe enough.
268 // See http://bugzilla.mozilla.org/show_bug.cgi?id=49641
269 const nsXPTCMiniVariant* GetValue() const
270 {return (nsXPTCMiniVariant*) &value;}
271private:
272 nsXPTConstant(); // no implementation
273// NO DATA - this a flyweight wrapper
274};
275
276#endif /* xptiinfo_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette