gecko-dev/dom/src/base/nsJSEnvironment.h

98 lines
3.3 KiB
C
Raw Normal View History

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"
#include "jsapi.h"
class nsIScriptSecurityManager;
class nsIScriptNameSpaceManager;
class nsIPrincipal;
1998-07-16 01:16:47 +00:00
class nsJSContext : public nsIScriptContext {
private:
JSContext *mContext;
nsIScriptNameSpaceManager* mNameSpaceManager;
PRBool mIsInitialized;
1999-03-12 22:24:30 +00:00
PRUint32 mNumEvaluations;
nsIScriptSecurityManager *mSecurityManager;
nsIScriptContextOwner* mOwner;
1998-07-16 01:16:47 +00:00
public:
nsJSContext(JSRuntime *aRuntime);
1999-03-20 01:54:12 +00:00
virtual ~nsJSContext();
1998-07-16 01:16:47 +00:00
NS_DECL_ISUPPORTS
NS_IMETHOD EvaluateString(const nsString& aScript,
const char *aURL,
PRUint32 aLineNo,
nsString& aRetValue,
PRBool* aIsUndefined);
NS_IMETHOD EvaluateString(const nsString& aScript,
void *aObj,
nsIPrincipal *principal,
const char *aURL,
PRUint32 aLineNo,
nsString& aRetValue,
PRBool* aIsUndefined);
NS_IMETHOD CallFunction(void *aObj, void *aFunction,
PRUint32 argc, void *argv,
PRBool *aBoolResult);
NS_IMETHOD_(nsIScriptGlobalObject*) GetGlobalObject();
NS_IMETHOD_(void*) GetNativeContext();
NS_IMETHOD InitClasses();
NS_IMETHOD InitContext(nsIScriptGlobalObject *aGlobalObject);
NS_IMETHOD IsContextInitialized();
NS_IMETHOD AddNamedReference(void *aSlot, void *aScriptObject,
const char *aName);
NS_IMETHOD RemoveReference(void *aSlot, void *aScriptObject);
NS_IMETHOD GC();
NS_IMETHOD GetNameSpaceManager(nsIScriptNameSpaceManager** aInstancePtr);
NS_IMETHOD GetSecurityManager(nsIScriptSecurityManager** aInstancePtr);
1999-03-12 22:24:30 +00:00
NS_IMETHOD ScriptEvaluated(void);
NS_IMETHOD SetOwner(nsIScriptContextOwner* owner);
NS_IMETHOD GetOwner(nsIScriptContextOwner** owner);
1999-03-12 22:24:30 +00:00
nsresult InitializeExternalClasses();
nsresult InitializeLiveConnectClasses();
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-07-16 01:16:47 +00:00
};
/* prototypes */
void PR_CALLBACK NS_ScriptErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);
1998-07-16 01:16:47 +00:00
#endif /* nsJSEnvironment_h___ */