1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is Mozilla Communicator client code.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
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 *****
40 * This Original Code has been modified by IBM Corporation.
41 * Modifications made by IBM described herein are
42 * Copyright (c) International Business Machines
45 * Modifications to Mozilla code or documentation
46 * identified per MPL Section 3.3
48 * Date Modified by Description of modification
49 * 03/27/2000 IBM Corp. Added PR_CALLBACK for Optlink
53 #ifndef nsScriptNameSpaceManager_h__
54 #define nsScriptNameSpaceManager_h__
56 #include "nsIScriptNameSpaceManager.h"
60 #include "nsDOMClassInfo.h"
61 #include "nsIObserver.h"
62 #include "nsWeakReference.h"
65 struct nsGlobalNameStruct
67 struct ConstructorAlias
71 nsGlobalNameStruct
* mProto
;
78 eTypeExternalConstructor
,
81 eTypeClassConstructor
,
83 eTypeExternalClassInfoCreator
,
84 eTypeExternalClassInfo
,
85 eTypeExternalConstructorAlias
91 PRInt32 mDOMClassInfoID
; // eTypeClassConstructor
92 nsIID mIID
; // eTypeInterface, eTypeClassProto
93 nsExternalDOMClassInfoData
* mData
; // eTypeExternalClassInfo
94 ConstructorAlias
* mAlias
; // eTypeExternalConstructorAlias
95 nsCID mCID
; // All other types...
104 class nsIScriptContext
;
105 class nsICategoryManager
;
106 class GlobalNameMapEntry
;
109 class nsScriptNameSpaceManager
: public nsIObserver
,
110 public nsSupportsWeakReference
116 nsScriptNameSpaceManager();
117 virtual ~nsScriptNameSpaceManager();
120 nsresult
InitForContext(nsIScriptContext
*aContext
);
122 // Returns a nsGlobalNameStruct for aName, or null if one is not
123 // found. The returned nsGlobalNameStruct is only guaranteed to be
124 // valid until the next call to any of the methods in this class.
125 // It also returns a pointer to the string buffer of the classname
126 // in the nsGlobalNameStruct.
127 nsresult
LookupName(const nsAString
& aName
,
128 const nsGlobalNameStruct
**aNameStruct
,
129 const PRUnichar
**aClassName
= nsnull
);
131 nsresult
RegisterClassName(const char *aClassName
,
132 PRInt32 aDOMClassInfoID
,
134 const PRUnichar
**aResult
);
136 nsresult
RegisterClassProto(const char *aClassName
,
137 const nsIID
*aConstructorProtoIID
,
140 nsresult
RegisterExternalInterfaces(PRBool aAsProto
);
142 nsresult
RegisterExternalClassName(const char *aClassName
,
145 // Register the info for an external class. aName must be static
146 // data, it will not be deleted by the DOM code.
147 nsresult
RegisterDOMCIData(const char *aName
,
148 nsDOMClassInfoExternalConstructorFnc aConstructorFptr
,
149 const nsIID
*aProtoChainInterface
,
150 const nsIID
**aInterfaces
,
151 PRUint32 aScriptableFlags
,
152 PRBool aHasClassInterface
,
153 const nsCID
*aConstructorCID
);
155 nsGlobalNameStruct
* GetConstructorProto(const nsGlobalNameStruct
* aStruct
);
158 // Adds a new entry to the hash and returns the nsGlobalNameStruct
159 // that aKey will be mapped to. If mType in the returned
160 // nsGlobalNameStruct is != eTypeNotInitialized, an entry for aKey
162 nsGlobalNameStruct
*AddToHash(const char *aKey
,
163 const PRUnichar
**aClassName
= nsnull
);
165 nsresult
FillHash(nsICategoryManager
*aCategoryManager
,
166 const char *aCategory
);
167 nsresult
FillHashWithDOMInterfaces();
168 nsresult
RegisterInterface(const char* aIfName
,
173 * Add a new category entry into the hash table.
175 * @aCategoryManager Instance of the category manager service.
176 * @aCategory Category where the entry comes from.
177 * @aEntry The entry that should be added.
179 nsresult
AddCategoryEntryToHash(nsICategoryManager
* aCategoryManager
,
180 const char* aCategory
,
181 nsISupports
* aEntry
);
183 // Inline PLDHashTable, init with PL_DHashTableInit() and delete
184 // with PL_DHashTableFinish().
185 PLDHashTable mGlobalNames
;
187 PRPackedBool mIsInitialized
;
190 #endif /* nsScriptNameSpaceManager_h__ */