On x86 compilers without fastcall, simulate it when invoking traces and un-simulate...
[wine-gecko.git] / xpcom / reflect / xptinfo / public / xptinfo.h
blob70606ff5f709af8858389184d8d0c5ed98058ae3
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
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/
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.
15 * The Original Code is mozilla.org code.
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.
22 * Contributor(s):
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.
36 * ***** END LICENSE BLOCK ***** */
38 /* XPTI_PUBLIC_API and XPTI_GetInterfaceInfoManager declarations. */
40 #ifndef xptiinfo_h___
41 #define xptiinfo_h___
43 #include "prtypes.h"
44 #include "nscore.h"
45 #include "xpt_struct.h"
47 class nsIInterfaceInfoManager;
49 // Flyweight wrapper classes for xpt_struct.h structs.
50 // Everything here is dependent upon - and sensitive to changes in -
51 // xpcom/typelib/xpt/public/xpt_struct.h!
53 class nsXPTType : public XPTTypeDescriptorPrefix
55 // NO DATA - this a flyweight wrapper
56 public:
57 nsXPTType()
58 {} // random contents
59 nsXPTType(const XPTTypeDescriptorPrefix& prefix)
60 {*(XPTTypeDescriptorPrefix*)this = prefix;}
62 nsXPTType(const uint8& prefix)
63 {*(uint8*)this = prefix;}
65 nsXPTType& operator=(uint8 val)
66 {flags = val; return *this;}
68 nsXPTType& operator=(const nsXPTType& other)
69 {flags = other.flags; return *this;}
71 operator uint8() const
72 {return flags;}
74 PRBool IsPointer() const
75 {return 0 != (XPT_TDP_IS_POINTER(flags));}
77 PRBool IsUniquePointer() const
78 {return 0 != (XPT_TDP_IS_UNIQUE_POINTER(flags));}
80 PRBool IsReference() const
81 {return 0 != (XPT_TDP_IS_REFERENCE(flags));}
83 PRBool IsArithmetic() const // terminology from Harbison/Steele
84 {return flags <= T_WCHAR;}
86 PRBool IsInterfacePointer() const
87 { switch (TagPart()) {
88 default:
89 return PR_FALSE;
90 case T_INTERFACE:
91 case T_INTERFACE_IS:
92 return PR_TRUE;
96 PRBool IsArray() const
97 {return TagPart() == T_ARRAY;}
99 // 'Dependent' means that params of this type are dependent upon other
100 // params. e.g. an T_INTERFACE_IS is dependent upon some other param at
101 // runtime to say what the interface type of this param really is.
102 PRBool IsDependent() const
103 { switch (TagPart()) {
104 default:
105 return PR_FALSE;
106 case T_INTERFACE_IS:
107 case TD_ARRAY:
108 case T_PSTRING_SIZE_IS:
109 case T_PWSTRING_SIZE_IS:
110 return PR_TRUE;
114 uint8 TagPart() const
115 {return (uint8) (flags & XPT_TDP_TAGMASK);}
117 enum
119 T_I8 = TD_INT8 ,
120 T_I16 = TD_INT16 ,
121 T_I32 = TD_INT32 ,
122 T_I64 = TD_INT64 ,
123 T_U8 = TD_UINT8 ,
124 T_U16 = TD_UINT16 ,
125 T_U32 = TD_UINT32 ,
126 T_U64 = TD_UINT64 ,
127 T_FLOAT = TD_FLOAT ,
128 T_DOUBLE = TD_DOUBLE ,
129 T_BOOL = TD_BOOL ,
130 T_CHAR = TD_CHAR ,
131 T_WCHAR = TD_WCHAR ,
132 T_VOID = TD_VOID ,
133 T_IID = TD_PNSIID ,
134 T_DOMSTRING = TD_DOMSTRING ,
135 T_CHAR_STR = TD_PSTRING ,
136 T_WCHAR_STR = TD_PWSTRING ,
137 T_INTERFACE = TD_INTERFACE_TYPE ,
138 T_INTERFACE_IS = TD_INTERFACE_IS_TYPE,
139 T_ARRAY = TD_ARRAY ,
140 T_PSTRING_SIZE_IS = TD_PSTRING_SIZE_IS ,
141 T_PWSTRING_SIZE_IS = TD_PWSTRING_SIZE_IS ,
142 T_UTF8STRING = TD_UTF8STRING ,
143 T_CSTRING = TD_CSTRING ,
144 T_ASTRING = TD_ASTRING
146 // NO DATA - this a flyweight wrapper
149 class nsXPTParamInfo : public XPTParamDescriptor
151 // NO DATA - this a flyweight wrapper
152 public:
153 nsXPTParamInfo(const XPTParamDescriptor& desc)
154 {*(XPTParamDescriptor*)this = desc;}
157 PRBool IsIn() const {return 0 != (XPT_PD_IS_IN(flags));}
158 PRBool IsOut() const {return 0 != (XPT_PD_IS_OUT(flags));}
159 PRBool IsRetval() const {return 0 != (XPT_PD_IS_RETVAL(flags));}
160 PRBool IsShared() const {return 0 != (XPT_PD_IS_SHARED(flags));}
161 PRBool IsDipper() const {return 0 != (XPT_PD_IS_DIPPER(flags));}
162 PRBool IsOptional() const {return 0 != (XPT_PD_IS_OPTIONAL(flags));}
163 const nsXPTType GetType() const {return type.prefix;}
165 // NOTE: other activities on types are done via methods on nsIInterfaceInfo
167 private:
168 nsXPTParamInfo(); // no implementation
169 // NO DATA - this a flyweight wrapper
172 class nsXPTMethodInfo : public XPTMethodDescriptor
174 // NO DATA - this a flyweight wrapper
175 public:
176 nsXPTMethodInfo(const XPTMethodDescriptor& desc)
177 {*(XPTMethodDescriptor*)this = desc;}
179 PRBool IsGetter() const {return 0 != (XPT_MD_IS_GETTER(flags) );}
180 PRBool IsSetter() const {return 0 != (XPT_MD_IS_SETTER(flags) );}
181 PRBool IsNotXPCOM() const {return 0 != (XPT_MD_IS_NOTXPCOM(flags));}
182 PRBool IsConstructor() const {return 0 != (XPT_MD_IS_CTOR(flags) );}
183 PRBool IsHidden() const {return 0 != (XPT_MD_IS_HIDDEN(flags) );}
184 const char* GetName() const {return name;}
185 uint8 GetParamCount() const {return num_args;}
186 /* idx was index before I got _sick_ of the warnings on Unix, sorry jband */
187 const nsXPTParamInfo GetParam(uint8 idx) const
189 NS_PRECONDITION(idx < GetParamCount(),"bad arg");
190 return params[idx];
192 const nsXPTParamInfo GetResult() const
193 {return *result;}
194 private:
195 nsXPTMethodInfo(); // no implementation
196 // NO DATA - this a flyweight wrapper
200 // forward declaration
201 struct nsXPTCMiniVariant;
203 class nsXPTConstant : public XPTConstDescriptor
205 // NO DATA - this a flyweight wrapper
206 public:
207 nsXPTConstant(const XPTConstDescriptor& desc)
208 {*(XPTConstDescriptor*)this = desc;}
210 const char* GetName() const
211 {return name;}
213 const nsXPTType GetType() const
214 {return type.prefix;}
216 // XXX this is ugly. But sometimes you gotta do what you gotta do.
217 // A reinterpret_cast won't do the trick here. And this plain C cast
218 // works correctly and is safe enough.
219 // See http://bugzilla.mozilla.org/show_bug.cgi?id=49641
220 const nsXPTCMiniVariant* GetValue() const
221 {return (nsXPTCMiniVariant*) &value;}
222 private:
223 nsXPTConstant(); // no implementation
224 // NO DATA - this a flyweight wrapper
227 #endif /* xptiinfo_h___ */