Bug 460926 A11y hierachy is broken on Ubuntu 8.10 (GNOME 2.24), r=Evan.Yan sr=roc
[wine-gecko.git] / dom / public / nsIDOMClassInfo.h
blob96772a7293c75e48e772a394737922cc6082579f
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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) 2000
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Johnny Stenback <jst@netscape.com> (original author)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef nsIDOMClassInfo_h___
40 #define nsIDOMClassInfo_h___
42 #include "nsIClassInfoImpl.h"
43 #include "nsVoidArray.h"
44 #include "nsDOMClassInfoID.h"
45 #include "nsIXPCScriptable.h"
47 #define DOM_BASE_SCRIPTABLE_FLAGS \
48 (nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY | \
49 nsIXPCScriptable::USE_JSSTUB_FOR_DELPROPERTY | \
50 nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY | \
51 nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE | \
52 nsIXPCScriptable::ALLOW_PROP_MODS_TO_PROTOTYPE | \
53 nsIXPCScriptable::DONT_ASK_INSTANCE_FOR_SCRIPTABLE | \
54 nsIXPCScriptable::DONT_REFLECT_INTERFACE_NAMES)
56 #define DEFAULT_SCRIPTABLE_FLAGS \
57 (DOM_BASE_SCRIPTABLE_FLAGS | \
58 nsIXPCScriptable::WANT_NEWRESOLVE | \
59 nsIXPCScriptable::WANT_CHECKACCESS | \
60 nsIXPCScriptable::WANT_PRECREATE | \
61 nsIXPCScriptable::WANT_POSTCREATE)
63 #define DOM_DEFAULT_SCRIPTABLE_FLAGS \
64 (DEFAULT_SCRIPTABLE_FLAGS | \
65 nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE | \
66 nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY)
69 typedef nsIClassInfo* (*nsDOMClassInfoExternalConstructorFnc)
70 (const char* aName);
73 /**
74 * nsIClassInfo helper macros
77 #define NS_CLASSINFO_MAP_BEGIN(_class)
79 #define NS_CLASSINFO_MAP_BEGIN_EXPORTED(_class)
81 #define NS_CLASSINFO_MAP_ENTRY(_interface)
83 #define NS_CLASSINFO_MAP_ENTRY_FUNCTION(_function)
85 #define NS_CLASSINFO_MAP_END
88 #include "nsIServiceManager.h"
89 #include "nsIDOMScriptObjectFactory.h"
90 #include "nsDOMCID.h"
92 #define NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(_class) \
93 if (aIID.Equals(NS_GET_IID(nsIClassInfo))) { \
94 static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
96 nsresult rv; \
97 nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID, \
98 &rv)); \
99 if (NS_FAILED(rv)) { \
100 *aInstancePtr = nsnull; \
101 return rv; \
104 foundInterface = \
105 sof->GetClassInfoInstance(eDOMClassInfo_##_class##_id); \
106 } else
108 // Looks up the nsIClassInfo for a class name registered with the
109 // nsScriptNamespaceManager. Remember to release NS_CLASSINFO_NAME(_class)
110 // (eg. when your module unloads).
111 #define NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(_class) \
112 if (aIID.Equals(NS_GET_IID(nsIClassInfo))) { \
113 extern nsISupports *NS_CLASSINFO_NAME(_class); \
114 if (NS_CLASSINFO_NAME(_class)) { \
115 foundInterface = NS_CLASSINFO_NAME(_class); \
116 } else { \
117 static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
119 nsresult rv; \
120 nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID, \
121 &rv)); \
122 if (NS_FAILED(rv)) { \
123 *aInstancePtr = nsnull; \
124 return rv; \
127 foundInterface = \
128 sof->GetExternalClassInfoInstance(NS_LITERAL_STRING(#_class)); \
130 if (foundInterface) { \
131 NS_CLASSINFO_NAME(_class) = foundInterface; \
132 NS_CLASSINFO_NAME(_class)->AddRef(); \
135 } else
138 #define NS_DECL_DOM_CLASSINFO(_class) \
139 nsISupports *NS_CLASSINFO_NAME(_class) = nsnull;
141 // {891a7b01-1b61-11d6-a7f2-f690b638899c}
142 #define NS_IDOMCI_EXTENSION_IID \
143 { 0x891a7b01, 0x1b61, 0x11d6, \
144 { 0xa7, 0xf2, 0xf6, 0x90, 0xb6, 0x38, 0x89, 0x9c } }
146 class nsIDOMScriptObjectFactory;
148 class nsIDOMCIExtension : public nsISupports {
149 public:
150 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMCI_EXTENSION_IID)
152 NS_IMETHOD RegisterDOMCI(const char* aName,
153 nsIDOMScriptObjectFactory* aDOMSOFactory) = 0;
156 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMCIExtension, NS_IDOMCI_EXTENSION_IID)
158 #define NS_DOMCI_EXTENSION_NAME(_module) ns##_module##DOMCIExtension
159 #define NS_DOMCI_EXTENSION_CONSTRUCTOR(_module) \
160 ns##_module##DOMCIExtensionConstructor
161 #define NS_DOMCI_EXTENSION_CONSTRUCTOR_IMP(_extension) \
162 NS_GENERIC_FACTORY_CONSTRUCTOR(_extension)
164 #define NS_DOMCI_EXTENSION(_module) \
165 class NS_DOMCI_EXTENSION_NAME(_module) : public nsIDOMCIExtension \
167 public: \
168 NS_DOMCI_EXTENSION_NAME(_module)(); \
169 virtual ~NS_DOMCI_EXTENSION_NAME(_module)(); \
171 NS_DECL_ISUPPORTS \
173 NS_IMETHOD RegisterDOMCI(const char* aName, \
174 nsIDOMScriptObjectFactory* aDOMSOFactory); \
175 }; \
177 NS_DOMCI_EXTENSION_CONSTRUCTOR_IMP(NS_DOMCI_EXTENSION_NAME(_module)) \
179 NS_DOMCI_EXTENSION_NAME(_module)::NS_DOMCI_EXTENSION_NAME(_module)() \
183 NS_DOMCI_EXTENSION_NAME(_module)::~NS_DOMCI_EXTENSION_NAME(_module)() \
187 NS_IMPL_ISUPPORTS1(NS_DOMCI_EXTENSION_NAME(_module), nsIDOMCIExtension) \
189 NS_IMETHODIMP \
190 NS_DOMCI_EXTENSION_NAME(_module)::RegisterDOMCI(const char* aName, \
191 nsIDOMScriptObjectFactory* aDOMSOFactory) \
194 #define NS_DOMCI_EXTENSION_ENTRY_BEGIN(_class) \
195 if (nsCRT::strcmp(aName, #_class) == 0) { \
196 static const nsIID* interfaces[] = {
198 #define NS_DOMCI_EXTENSION_ENTRY_INTERFACE(_interface) \
199 &NS_GET_IID(_interface),
201 // Don't forget to register the primary interface (_proto) in the
202 // JAVASCRIPT_DOM_INTERFACE category, or prototypes for this class
203 // won't work (except if the interface name starts with nsIDOM).
204 #define NS_DOMCI_EXTENSION_ENTRY_END_HELPER(_class, _proto, _hasclassif, \
205 _constructorcid) \
206 nsnull \
207 }; \
208 aDOMSOFactory->RegisterDOMClassInfo(#_class, nsnull, _proto, \
209 interfaces, \
210 DOM_DEFAULT_SCRIPTABLE_FLAGS, \
211 _hasclassif, _constructorcid); \
212 return NS_OK; \
215 #define NS_DOMCI_EXTENSION_ENTRY_END(_class, _proto, _hasclassif, \
216 _constructorcid) \
217 NS_DOMCI_EXTENSION_ENTRY_END_HELPER(_class, &NS_GET_IID(_proto), \
218 _hasclassif, _constructorcid)
220 #define NS_DOMCI_EXTENSION_ENTRY_END_NO_PRIMARY_IF(_class, _hasclassif, \
221 _constructorcid) \
222 NS_DOMCI_EXTENSION_ENTRY_END_HELPER(_class, nsnull, _hasclassif, \
223 _constructorcid)
225 #define NS_DOMCI_EXTENSION_END \
226 return NS_ERROR_FAILURE; \
230 #endif /* nsIDOMClassInfo_h___ */