mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 15:51:37 +00:00
adding XPCOM interface support (non-functional) -- not part of Gromit
This commit is contained in:
parent
920acd0a4f
commit
ae05f5bb1b
202
js/src/xpcom/jsIContext.h
Normal file
202
js/src/xpcom/jsIContext.h
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* jsIContext.h --- the XPCOM interface to the core JS engine functionality.
|
||||
*/
|
||||
|
||||
#ifndef JS_ICONTEXT_H
|
||||
#define JS_ICONTEXT_H
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include <jsapi.h>
|
||||
#include "jsIScriptable.h"
|
||||
#include "jsIFunction.h"
|
||||
#include "jsIErrorReporter.h"
|
||||
|
||||
#define JS_ICONTEXT_IID \
|
||||
{ 0, 0, 0, \
|
||||
{0, 0, 0, 0, 0, 0, 0, 0}}
|
||||
|
||||
#define JS_IRUNTIME_IID \
|
||||
{ 0, 0, 0, \
|
||||
{0, 0, 0, 0, 0, 0, 0, 0}}
|
||||
|
||||
#define JS_ISCRIPT_IID \
|
||||
{ 0, 0, 0, \
|
||||
{0, 0, 0, 0, 0, 0, 0, 0}}
|
||||
|
||||
/**
|
||||
* jsIScript interface declaration
|
||||
*/
|
||||
|
||||
class jsIScript: public nsISupports {
|
||||
public:
|
||||
virtual jsIScript() = 0;
|
||||
virtual ~jsIScript() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* jsIRuntime interface declaration.
|
||||
*/
|
||||
|
||||
class jsIRuntime: public nsISupports {
|
||||
public:
|
||||
virtual jsIRuntime() = 0;
|
||||
virtual ~jsIRuntime() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* jsIContext interface declaration
|
||||
*/
|
||||
|
||||
class jsIContext: public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Compile a JavaScript function.
|
||||
* @return NULL on error, compiled jsIFunction *otherwise.
|
||||
*/
|
||||
virtual jsIFunction *compileFunction(jsIScriptable *scope,
|
||||
JSString *source,
|
||||
JSString *sourceName,
|
||||
int lineno) = 0;
|
||||
/**
|
||||
* Decompile a JavaScript script to equivalent source.
|
||||
*/
|
||||
virtual JSString *decompileScript(jsIScript *script,
|
||||
jsIScriptable *scope,
|
||||
int indent) = 0;
|
||||
/**
|
||||
* Decompile a JavaScript function to equivalent source, including
|
||||
* the function declaration and parameter list.
|
||||
*
|
||||
* Provides function body of '[native code]' if the provided
|
||||
* jsIFunction * isn't of JS-source heritage.
|
||||
*/
|
||||
virtual JSString *decompileFunction(jsIFunction *fun,
|
||||
int indent) = 0;
|
||||
|
||||
/**
|
||||
* Decompile the body of a JavaScript function.
|
||||
*
|
||||
* Provides function body of '[native code]' if the provided
|
||||
* jsIFunction * isn't of JS-source heritage.
|
||||
*/
|
||||
virtual JSString *decompileFunctionBody(jsIFunction *fun,
|
||||
int indent) = 0;
|
||||
|
||||
/**
|
||||
* Create a new JavaScript object. This is equivalent to evaluating
|
||||
* "new Object()", which requires that the value "Object" in the
|
||||
* provided scope is a function.
|
||||
*/
|
||||
virtual jsIScriptable *newObject(jsIScriptable *scope) = 0;
|
||||
|
||||
/**
|
||||
* Create a new JavaScript object by executing the named constructor.
|
||||
* This requires that the value named by the constructorName argument.
|
||||
*/
|
||||
virtual jsIScriptable *newObject(jsIScriptable *scope,
|
||||
JSString *constructorName) = 0;
|
||||
|
||||
/**
|
||||
* Create a new JavaScript object by executing the named constructor
|
||||
* with the provided arguments.
|
||||
*/
|
||||
virtual jsIScriptable *newObject(jsIScriptable *scope,
|
||||
JSString *constructorName,
|
||||
jsval *argv,
|
||||
uintN argc) = 0;
|
||||
|
||||
/**
|
||||
* Create a new JavaScript Array with the specified inital length.
|
||||
*/
|
||||
virtual jsIScriptable *newArray(jsIScriptable *scope,
|
||||
uintN length) = 0;
|
||||
|
||||
/**
|
||||
* Create a new JavaScript array with the provided initial contents.
|
||||
*/
|
||||
virtual jsIScriptable *newArray(jsIScriptable *scope,
|
||||
jsval *elements,
|
||||
uintN length) = 0;
|
||||
|
||||
/**
|
||||
* Convert a jsval to a JavaScript boolean value.
|
||||
* Note: the return value indicates the success of the operation,
|
||||
* not the resulting boolean value. *bp stores the new boolean value.
|
||||
*/
|
||||
NS_IMETHOD toBoolean(jsval v, JSBool *bp) = 0;
|
||||
|
||||
/**
|
||||
* Convert a jsval to a JavaScript number value.
|
||||
*/
|
||||
virtual jsdouble *toNumber(jsval v) = 0;
|
||||
|
||||
/**
|
||||
* Convert a jsval to a JavaScript string value.
|
||||
*/
|
||||
virtual JSString *toString(jsval v) = 0;
|
||||
|
||||
/**
|
||||
* Convert a jsval to a JavaScript object. The provided scope is
|
||||
* used to look up constructors Number, String and Boolean as required.
|
||||
*/
|
||||
virtual jsIScriptable *toObject(jsval v, jsIScriptable *scope) = 0;
|
||||
|
||||
/**
|
||||
* Evaluate a JavaScript source string.
|
||||
*/
|
||||
NS_IMETHOD evaluateString(jsIScriptable *scope,
|
||||
JSString *source,
|
||||
JSString *sourceName,
|
||||
uintN lineno) = 0;
|
||||
|
||||
/**
|
||||
* Initialize the standard (ECMA-plus) objects in the given scope.
|
||||
* Makes scope an ECMA `global object'.
|
||||
*/
|
||||
NS_IMETHOD initStandardObjects(jsIScriptable *scope) = 0;
|
||||
|
||||
/**
|
||||
* Report a (usually fatal) runtime error.
|
||||
*/
|
||||
NS_IMETHOD reportError(JSString *message) = 0;
|
||||
|
||||
/**
|
||||
* Report a warning.
|
||||
*/
|
||||
NS_IMETHOD reportWarning(JSString *message) = 0;
|
||||
|
||||
/**
|
||||
* Change the error reporter for this context.
|
||||
*/
|
||||
virtual jsIErrorReporter *setErrorReporter(jsIErrorReporter *reporter) = 0;
|
||||
|
||||
/**
|
||||
* Set the current language version.
|
||||
*/
|
||||
NS_IMETHOD setLanguageVersion(uintN version) = 0;
|
||||
|
||||
/**
|
||||
* Get the current language version.
|
||||
*/
|
||||
virtual uintN getLanguageVersion(void) = 0;
|
||||
|
||||
/**
|
||||
* Associate the Context with the current thread.
|
||||
* This should be called whenever a Context is operated upon by a
|
||||
* new thread.
|
||||
*/
|
||||
NS_IMETHOD enter(void);
|
||||
|
||||
/**
|
||||
* Break the Context-thread association.
|
||||
*/
|
||||
NS_IMETHOD exit(void);
|
||||
|
||||
/**
|
||||
* Create a new Context.
|
||||
*/
|
||||
virtual Context(jsIRuntime *runtime, uintN stacksize) = 0;
|
||||
virtual ~Context() = 0;
|
||||
};
|
||||
|
||||
#endif /* JS_ICONTEXT_H */
|
31
js/src/xpcom/jsIErrorReporter.h
Normal file
31
js/src/xpcom/jsIErrorReporter.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* jsIErrorReporter.h -- the XPCOM interface to JS error and warning reporters.
|
||||
*/
|
||||
|
||||
#ifndef JS_IERRORREPORTER_H
|
||||
#define JS_IERRORREPORTER_H
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include <jsapi.h>
|
||||
|
||||
class jsIErrorReporter: public nsISupports {
|
||||
public:
|
||||
virtual jsIErrorReporter() = 0;
|
||||
virtual ~jsIErrorReporter() = 0;
|
||||
/**
|
||||
* Report a warning.
|
||||
*/
|
||||
NS_IMETHOD reportWarning(JSString *message,
|
||||
JSString *sourceName,
|
||||
uintN lineno) = 0;
|
||||
|
||||
/**
|
||||
* Report an error.
|
||||
*/
|
||||
NS_IMETHOD reportError(JSString *message,
|
||||
JSString *sourceName,
|
||||
uintN lineno) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* JS_IERRORREPORTER_H */
|
17
js/src/xpcom/jsIFunction.h
Normal file
17
js/src/xpcom/jsIFunction.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* jsIFunction.h -- the XPCOM interface to JavaScript function objects.
|
||||
*/
|
||||
|
||||
#ifndef JS_IFUNCTION_H
|
||||
#define JS_IFUNCTION_H
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include <jsapi.h>
|
||||
|
||||
class jsIFunction: public nsISupports {
|
||||
public:
|
||||
virtual jsIFunction() = 0;
|
||||
virtual ~jsIFunction() = 0;
|
||||
};
|
||||
|
||||
#endif /* JS_IFUNCTION_H */
|
17
js/src/xpcom/jsIScriptable.h
Normal file
17
js/src/xpcom/jsIScriptable.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* jsIScriptable.h -- the XPCOM interface to native JavaScript objects.
|
||||
*/
|
||||
|
||||
#ifndef JS_ISCRIPTABLE_H
|
||||
#define JS_ISCRIPTABLE_H
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include <jsapi.h>
|
||||
|
||||
class jsIScriptable: public nsISupports {
|
||||
public:
|
||||
virtual jsIScriptable() = 0;
|
||||
virtual ~jsIScriptable() = 0;
|
||||
};
|
||||
|
||||
#endif /* JS_ISCRIPTABLE_H */
|
Loading…
x
Reference in New Issue
Block a user