bug 126365, "add options and private support to jsdIContext", sr=jst, r=jband

add jsdIContext::options and ::privateData attributes
This commit is contained in:
rginda%netscape.com 2002-02-20 05:45:57 +00:00
Родитель 7c98837e15
Коммит 5f0ee796ec
2 изменённых файлов: 134 добавлений и 1 удалений

Просмотреть файл

@ -442,22 +442,64 @@ interface jsdIScriptHook : nsISupports
[scriptable, uuid(f102caf6-1dd1-11b2-bd43-c1dbacb95a98)]
interface jsdICallHook : nsISupports
{
/**
* TYPE_* values must be kept in sync with the JSD_HOOK_* #defines
* in jsdebug.h.
*/
/**
* Toplevel script is starting.
*/
const unsigned long TYPE_TOPLEVEL_START = 0;
/**
* Toplevel script has completed.
*/
const unsigned long TYPE_TOPLEVEL_END = 1;
/**
* Function is being called.
*/
const unsigned long TYPE_FUNCTION_CALL = 2;
/**
* Function is returning.
*/
const unsigned long TYPE_FUNCTION_RETURN = 3;
/**
* Called before the JavaScript engine executes a top level script or calls
* a function.
*/
void onCall (in jsdIStackFrame frame, in unsigned long type);
};
[scriptable, uuid(b7dd3c1c-1dd1-11b2-83eb-8a857d199e0f)]
interface jsdIErrorHook : nsISupports
{
/**
* REPORT_* values must be kept in sync with JSREPORT_* #defines in
* jsapi.h
*/
/**
* Report is an error.
*/
const unsigned long REPORT_ERROR = 0x00;
/**
* Report is only a warning.
*/
const unsigned long REPORT_WARNING = 0x01;
/**
* Report represents an uncaught exception.
*/
const unsigned long REPORT_EXCEPTION = 0x02;
/**
* Report is due to strict mode.
*/
const unsigned long REPORT_STRICT = 0x04;
/**
* Called when the JavaScript engine encounters an error. Return |true|
* to pass the error along, |false| to invoke the debugHook.
*/
boolean onError (in string message, in string fileName,
in unsigned long line, in unsigned long pos,
in unsigned long flags, in unsigned long errnum,
@ -472,6 +514,10 @@ interface jsdIErrorHook : nsISupports
[scriptable, uuid(9a7b6ad0-1dd1-11b2-a789-fcfae96356a2)]
interface jsdIExecutionHook : nsISupports
{
/**
* TYPE_* values must be kept in sync with JSD_HOOK_* #defines in jsdebug.h.
*/
/**
* Execution stopped because we're in single step mode.
*/
@ -493,6 +539,11 @@ interface jsdIExecutionHook : nsISupports
*/
const unsigned long TYPE_THROW = 4;
/**
* RETURN_* values must be kept in sync with JSD_HOOK_RETURN_* #defines in
* jsdebug.h.
*/
/**
* Indicates unrecoverable error processing the hook. This will cause
* the script being executed to be aborted without raising a JavaScript
@ -569,6 +620,11 @@ interface jsdIContext : jsdIEphemeral
/* Internal use only. */
[noscript] readonly attribute JSContext JSContext;
/**
* VERSION_* values must be kept in sync with the JSVersion enumeration in
* jspubtd.h.
*/
/**
* Possible values for |version|.
*/
@ -587,11 +643,43 @@ interface jsdIContext : jsdIEphemeral
*/
attribute long version;
/**
* OPT_* values must be kept in sync with JSOPTION_* #defines in jsapi.h.
*/
/**
* Strict mode is on.
*/
const long OPT_STRICT = 0x01;
/**
* Warnings reported as errors.
*/
const long OPT_WERR = 0x02;
/**
* Makes eval() use the last object on its 'obj' param's scope chain as the
* ECMA 'variables object'.
*/
const long OPT_VAROBJFIX = 0x04;
/**
* Private data for this object is an nsISupports object. Attempting to
* alter this bit will result in an NS_ERROR_ILLEGAL_VALUE.
*/
const long OPT_ISUPPORTS = 0x08;
/**
* OPT_* values above, OR'd together.
*/
attribute unsigned long options;
/**
* Unique tag among all valid jsdIContext objects, useful as a hash key.
*/
readonly attribute unsigned long tag;
readonly attribute unsigned long tag;
/**
* Private data for this context, if it is an nsISupports, |null| otherwise.
*/
readonly attribute nsISupports privateData;
/**
* Retrieve the underlying context wrapped by this jsdIContext.
*/
@ -966,6 +1054,10 @@ interface jsdIProperty : jsdIEphemeral
/** Internal use only. */
[noscript] readonly attribute JSDProperty JSDProperty;
/**
* FLAG_* values must be kept in sync with JSDPD_* #defines in jsdebug.h.
*/
/** visible to for/in loop */
const unsigned long FLAG_ENUMERATE = 0x01;
/** assignment is error */

Просмотреть файл

@ -1384,6 +1384,47 @@ jsdContext::GetJSContext(JSContext **_rval)
return NS_OK;
}
NS_IMETHODIMP
jsdContext::GetOptions(PRUint32 *_rval)
{
ASSERT_VALID_EPHEMERAL;
*_rval = JS_GetOptions(mJSCx);
return NS_OK;
}
NS_IMETHODIMP
jsdContext::SetOptions(PRUint32 options)
{
ASSERT_VALID_EPHEMERAL;
PRUint32 lastOptions = JS_GetOptions(mJSCx);
/* don't let users change this option, they'd just be shooting themselves
* in the foot. */
if ((options ^ lastOptions) & JSOPTION_PRIVATE_IS_NSISUPPORTS)
return NS_ERROR_ILLEGAL_VALUE;
JS_SetOptions(mJSCx, options);
return NS_OK;
}
NS_IMETHODIMP
jsdContext::GetPrivateData(nsISupports **_rval)
{
ASSERT_VALID_EPHEMERAL;
PRUint32 options = JS_GetOptions(mJSCx);
if (options & JSOPTION_PRIVATE_IS_NSISUPPORTS)
{
*_rval = NS_STATIC_CAST(nsISupports*, JS_GetContextPrivate(mJSCx));
NS_IF_ADDREF(*_rval);
}
else
{
*_rval = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP
jsdContext::GetWrappedContext(nsISupports **_rval)
{