VirtualBox

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

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

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