зеркало из https://github.com/mozilla/pjs.git
Script global namespace management.
This commit is contained in:
Родитель
f59757445a
Коммит
1254cc9687
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIScriptExternalNameSet_h__
|
||||
#define nsIScriptExternalNameSet_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
#define NS_ISCRIPTEXTERNALNAMESET_IID \
|
||||
{0xa6cf90da, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
class nsIScriptContext;
|
||||
|
||||
/**
|
||||
* This interface represents a set of names or symbols
|
||||
* that should be added to the "global" namespace of a
|
||||
* script context. A name set is registered with the
|
||||
* name set registry (see <code>nsIScriptNameSetRegistry</code>)
|
||||
* at application initialization time. The
|
||||
* <code>AddNameSet</code> method is invoked for each
|
||||
* new script context so that a name set can add its
|
||||
* global symbols to the name space manager
|
||||
* (see <code>nsIScriptNameSpaceManager</code>) of the
|
||||
* script context.
|
||||
*/
|
||||
class nsIScriptExternalNameSet : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Called for each new
|
||||
*/
|
||||
NS_IMETHOD AddNameSet(nsIScriptContext* aScriptContext) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIScriptExternalNameSet_h__ */
|
|
@ -0,0 +1,59 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIScriptNameSetRegistry_h__
|
||||
#define nsIScriptNameSetRegistry_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
#define NS_ISCRIPTNAMESETREGISTRY_IID \
|
||||
{0xa6cf90d9, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
class nsIScriptExternalNameSet;
|
||||
|
||||
/**
|
||||
* Interface used to add and remove name sets. These name sets
|
||||
* are asked to register themselves with a namespace registry
|
||||
* for every new script context.
|
||||
*/
|
||||
class nsIScriptNameSetRegistry : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Add a new name set to the list. Each name set will be asked
|
||||
* to register itself with a namespace registry for each new
|
||||
* script context.
|
||||
*
|
||||
* @param aNameSet the name set to register
|
||||
* @result NS_OK if successful
|
||||
*/
|
||||
NS_IMETHOD AddExternalNameSet(nsIScriptExternalNameSet* aNameSet) = 0;
|
||||
|
||||
/*
|
||||
* Remove a name set from the manager's list.
|
||||
*
|
||||
* @param aNameSet the name set to unregister.
|
||||
* @result NS_OK if successful
|
||||
*/
|
||||
NS_IMETHOD RemoveExternalNameSet(nsIScriptExternalNameSet* aNameSet) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIScriptNameSetRegistry_h__ */
|
|
@ -0,0 +1,76 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIScriptNameSpaceManager_h__
|
||||
#define nsIScriptNameSpaceManager_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
#define NS_ISCRIPTNAMESPACEMANAGER_IID \
|
||||
{0xa6cf90db, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
/**
|
||||
* A per script context construct. The namespace manager maintains
|
||||
* a mapping between a global symbol or name and a class ID to
|
||||
* obtain a factory to use to instantiate a native object.
|
||||
*/
|
||||
class nsIScriptNameSpaceManager : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Used to register a single global symbol or name. The class ID
|
||||
* is used to obtain a factory which is used to instantiate
|
||||
* the the corresponding native object. The name can represent
|
||||
* either an object or a constructor.
|
||||
* XXX How do we indicate clashes in registered names?
|
||||
*
|
||||
* @param aName the name to reflect in the global namespace
|
||||
* @param aCID the class ID used to obtain a factory
|
||||
* @param aIsConstructor set to PR_TRUE if the name represents
|
||||
* a constructor. PR_FALSE if it is a global object.
|
||||
* @result NS_OK if successful
|
||||
*/
|
||||
NS_IMETHOD RegisterGlobalName(const nsString& aName,
|
||||
const nsIID& aCID,
|
||||
PRBool aIsConstructor) = 0;
|
||||
|
||||
/**
|
||||
* Used to remove a global symbol or name from the manager.
|
||||
*
|
||||
* @param aName the name to remove
|
||||
* @result NS_OK if successful
|
||||
*/
|
||||
NS_IMETHOD UnregisterGlobalName(const nsString& aName) = 0;
|
||||
|
||||
/**
|
||||
* Used to look up the manager using a name as a key. The
|
||||
* return value is a class ID that can be used to obtain
|
||||
* a factory.
|
||||
*
|
||||
* @param aName the name to use as a key for the lookup
|
||||
* @param aCID out parameter that returns the class ID
|
||||
* that corresponds to the name
|
||||
* @result NS_OK if successful
|
||||
*/
|
||||
NS_IMETHOD GetClassID(const nsString& aName, nsIID& aCID) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIScriptNameSpaceManager_h__ */
|
Загрузка…
Ссылка в новой задаче