1998-07-16 01:16:47 +00:00
|
|
|
/* -*- 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 "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#ifndef nsJSEnvironment_h___
|
|
|
|
#define nsJSEnvironment_h___
|
|
|
|
|
|
|
|
#include "nsIScriptContext.h"
|
1998-12-15 06:10:59 +00:00
|
|
|
#include "jsapi.h"
|
|
|
|
|
1998-11-21 00:12:33 +00:00
|
|
|
class nsIScriptSecurityManager;
|
1998-12-22 22:03:20 +00:00
|
|
|
class nsIScriptNameSpaceManager;
|
1998-07-16 01:16:47 +00:00
|
|
|
|
|
|
|
class nsJSContext : public nsIScriptContext {
|
|
|
|
private:
|
|
|
|
JSContext *mContext;
|
1998-12-22 22:03:20 +00:00
|
|
|
nsIScriptNameSpaceManager* mNameSpaceManager;
|
1998-12-30 02:46:36 +00:00
|
|
|
PRBool mIsInitialized;
|
1998-07-16 01:16:47 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
nsJSContext(JSRuntime *aRuntime);
|
|
|
|
~nsJSContext();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
1998-12-21 16:51:10 +00:00
|
|
|
NS_IMETHOD_(PRBool) EvaluateString(const nsString& aScript,
|
|
|
|
const char *aURL,
|
|
|
|
PRUint32 aLineNo,
|
|
|
|
nsString& aRetValue,
|
|
|
|
PRBool* aIsUndefined);
|
|
|
|
NS_IMETHOD_(nsIScriptGlobalObject*) GetGlobalObject();
|
|
|
|
NS_IMETHOD_(void*) GetNativeContext();
|
|
|
|
NS_IMETHOD InitClasses();
|
|
|
|
NS_IMETHOD InitContext(nsIScriptGlobalObject *aGlobalObject);
|
1998-12-30 02:46:36 +00:00
|
|
|
NS_IMETHOD IsContextInitialized();
|
1998-12-21 16:51:10 +00:00
|
|
|
NS_IMETHOD AddNamedReference(void *aSlot, void *aScriptObject,
|
1998-08-20 22:25:21 +00:00
|
|
|
const char *aName);
|
1998-12-21 16:51:10 +00:00
|
|
|
NS_IMETHOD RemoveReference(void *aSlot, void *aScriptObject);
|
|
|
|
NS_IMETHOD GC();
|
|
|
|
NS_IMETHOD GetNameSpaceManager(nsIScriptNameSpaceManager** aInstancePtr);
|
1998-11-21 00:12:33 +00:00
|
|
|
NS_IMETHOD GetSecurityManager(nsIScriptSecurityManager** aInstancePtr);
|
1998-12-30 21:35:35 +00:00
|
|
|
|
|
|
|
nsresult InitializeExternalClasses();
|
1998-07-16 01:16:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsJSEnvironment {
|
|
|
|
private:
|
|
|
|
JSRuntime *mRuntime;
|
|
|
|
|
|
|
|
public:
|
1998-09-01 19:13:36 +00:00
|
|
|
static nsJSEnvironment *sTheEnvironment;
|
|
|
|
|
1998-07-16 01:16:47 +00:00
|
|
|
nsJSEnvironment();
|
|
|
|
~nsJSEnvironment();
|
|
|
|
|
|
|
|
nsIScriptContext* GetNewContext();
|
|
|
|
|
|
|
|
static nsJSEnvironment *GetScriptingEnvironment();
|
1998-08-12 04:56:40 +00:00
|
|
|
|
1998-07-16 01:16:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsJSEnvironment_h___ */
|