1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
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
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.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* 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 NPL, 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 NPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
38
/* XPTI_PUBLIC_API and XPTI_GetInterfaceInfoManager declarations. */
44
#include "xpt_struct.h"
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
52
#ifdef EXPORT_XPTI_API
53
#define XPTI_PUBLIC_API(t) PR_IMPLEMENT(t)
54
#define XPTI_PUBLIC_DATA(t) PR_IMPLEMENT_DATA(t)
56
# define XPTI_EXPORT __declspec(dllexport)
62
# define XPTI_PUBLIC_API(t) __declspec(dllimport) t
63
# define XPTI_PUBLIC_DATA(t) __declspec(dllimport) t
64
# define XPTI_EXPORT __declspec(dllimport)
66
# define XPTI_PUBLIC_API(t) PR_IMPLEMENT(t)
67
# define XPTI_PUBLIC_DATA(t) t
71
#define XPTI_FRIEND_API(t) XPTI_PUBLIC_API(t)
72
#define XPTI_FRIEND_DATA(t) XPTI_PUBLIC_DATA(t)
74
class nsIInterfaceInfoManager;
76
// Even if this is a service, it is cool to provide a direct accessor
77
XPTI_PUBLIC_API(nsIInterfaceInfoManager*)
78
XPTI_GetInterfaceInfoManager();
80
// Even if this is a service, it is cool to provide a direct accessor
82
XPTI_FreeInterfaceInfoManager();
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!
91
class nsXPTType : public XPTTypeDescriptorPrefix
93
// NO DATA - this a flyweight wrapper
97
nsXPTType(const XPTTypeDescriptorPrefix& prefix)
98
{*(XPTTypeDescriptorPrefix*)this = prefix;}
100
nsXPTType(const uint8& prefix)
101
{*(uint8*)this = prefix;}
103
nsXPTType& operator=(uint8 val)
104
{flags = val; return *this;}
106
nsXPTType& operator=(const nsXPTType& other)
107
{flags = other.flags; return *this;}
109
operator uint8() const
112
PRBool IsPointer() const
113
{return 0 != (XPT_TDP_IS_POINTER(flags));}
115
PRBool IsUniquePointer() const
116
{return 0 != (XPT_TDP_IS_UNIQUE_POINTER(flags));}
118
PRBool IsReference() const
119
{return 0 != (XPT_TDP_IS_REFERENCE(flags));}
121
PRBool IsArithmetic() const // terminology from Harbison/Steele
122
{return flags <= T_WCHAR;}
124
PRBool IsInterfacePointer() const
125
{ switch (TagPart()) {
134
PRBool IsArray() const
135
{return (PRBool) TagPart() == T_ARRAY;}
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()) {
146
case T_PSTRING_SIZE_IS:
147
case T_PWSTRING_SIZE_IS:
152
uint8 TagPart() const
153
{return (uint8) (flags & XPT_TDP_TAGMASK);}
166
T_DOUBLE = TD_DOUBLE ,
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,
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
184
// NO DATA - this a flyweight wrapper
187
class nsXPTParamInfo : public XPTParamDescriptor
189
// NO DATA - this a flyweight wrapper
191
nsXPTParamInfo(const XPTParamDescriptor& desc)
192
{*(XPTParamDescriptor*)this = desc;}
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;}
202
// NOTE: other activities on types are done via methods on nsIInterfaceInfo
205
nsXPTParamInfo(); // no implementation
206
// NO DATA - this a flyweight wrapper
209
class nsXPTMethodInfo : public XPTMethodDescriptor
211
// NO DATA - this a flyweight wrapper
213
nsXPTMethodInfo(const XPTMethodDescriptor& desc)
214
{*(XPTMethodDescriptor*)this = desc;}
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
226
NS_PRECONDITION(idx < GetParamCount(),"bad arg");
229
const nsXPTParamInfo GetResult() const
232
nsXPTMethodInfo(); // no implementation
233
// NO DATA - this a flyweight wrapper
237
// forward declaration
238
struct nsXPTCMiniVariant;
240
class nsXPTConstant : public XPTConstDescriptor
242
// NO DATA - this a flyweight wrapper
244
nsXPTConstant(const XPTConstDescriptor& desc)
245
{*(XPTConstDescriptor*)this = desc;}
247
const char* GetName() const
250
const nsXPTType GetType() const
251
{return type.prefix;}
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;}
260
nsXPTConstant(); // no implementation
261
// NO DATA - this a flyweight wrapper
264
#endif /* xptiinfo_h___ */