js/jsd/idl/jsdIDebuggerService.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/jsd/idl/jsdIDebuggerService.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1233 @@
     1.4 +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +    
     1.9 +#include "nsISupports.idl"
    1.10 +
    1.11 +%{ C++
    1.12 +#include "jsdebug.h"
    1.13 +#include "nsAString.h"
    1.14 +%}
    1.15 +    
    1.16 +[ptr] native JSDContext(JSDContext);
    1.17 +[ptr] native JSDObject(JSDObject);
    1.18 +[ptr] native JSDProperty(JSDProperty);
    1.19 +[ptr] native JSDScript(JSDScript);
    1.20 +[ptr] native JSDStackFrameInfo(JSDStackFrameInfo);
    1.21 +[ptr] native JSDThreadState(JSDThreadState);
    1.22 +[ptr] native JSDValue(JSDValue);
    1.23 +[ptr] native JSRuntime(JSRuntime);
    1.24 +[ptr] native JSContext(JSContext);
    1.25 +[ptr] native JSCompartment(JSCompartment);
    1.26 +
    1.27 +/* interfaces we declare in this file */
    1.28 +interface jsdIDebuggerService;
    1.29 +interface jsdIFilter;
    1.30 +interface jsdINestCallback;
    1.31 +interface jsdIFilterEnumerator;
    1.32 +interface jsdIContextEnumerator;
    1.33 +interface jsdIScriptEnumerator;
    1.34 +interface jsdIScriptHook;
    1.35 +interface jsdIErrorHook;
    1.36 +interface jsdIExecutionHook;
    1.37 +interface jsdICallHook;
    1.38 +interface jsdIEphemeral;
    1.39 +interface jsdIContext;
    1.40 +interface jsdIStackFrame;
    1.41 +interface jsdIScript;
    1.42 +interface jsdIValue;
    1.43 +interface jsdIObject;
    1.44 +interface jsdIProperty;
    1.45 +interface jsdIActivationCallback;
    1.46 +
    1.47 +/**
    1.48 + * Debugger service. It is not a good idea to have more than one active client
    1.49 + * of the debugger service.
    1.50 + *
    1.51 + * Note that all the APIs in this file are deprecated. All consumers of
    1.52 + * these interfaces should switch to using the new Debugger API, documented
    1.53 + * here: https://wiki.mozilla.org/Debugger
    1.54 + */
    1.55 +[scriptable, uuid(39609752-2d73-4019-a324-a374dee16d3c)]
    1.56 +interface jsdIDebuggerService : nsISupports
    1.57 +{
    1.58 +    /** Internal use only. */
    1.59 +    [noscript] readonly attribute JSDContext        JSDContext;
    1.60 +
    1.61 +    /**
    1.62 +     * Called when an error or warning occurs.
    1.63 +     */
    1.64 +    attribute jsdIErrorHook     errorHook;
    1.65 +    /**
    1.66 +     * Called when a jsdIScript is created or destroyed.
    1.67 +     */
    1.68 +    attribute jsdIScriptHook    scriptHook;
    1.69 +    /**
    1.70 +     * Called when the engine encounters a breakpoint.
    1.71 +     */
    1.72 +    attribute jsdIExecutionHook breakpointHook;
    1.73 +    /**
    1.74 +     * Called when the engine encounters the debugger keyword.
    1.75 +     */
    1.76 +    attribute jsdIExecutionHook debuggerHook;
    1.77 +    /**
    1.78 +     * Called when the errorHook returns false.
    1.79 +     */
    1.80 +    attribute jsdIExecutionHook debugHook;
    1.81 +    /**
    1.82 +     * Called before the next PC is executed.
    1.83 +     */
    1.84 +    attribute jsdIExecutionHook interruptHook;
    1.85 +    /**
    1.86 +     * Called when an exception is thrown (even if it will be caught.)
    1.87 +     */
    1.88 +    attribute jsdIExecutionHook throwHook;
    1.89 +    /**
    1.90 +     * Called before and after a toplevel script is evaluated.
    1.91 +     */
    1.92 +    attribute jsdICallHook      topLevelHook;
    1.93 +    /**
    1.94 +     * Called before and after a function is called.
    1.95 +     */
    1.96 +    attribute jsdICallHook      functionHook;
    1.97 +
    1.98 +    /**
    1.99 +     * Link native frames in call stacks.
   1.100 +     */
   1.101 +    const unsigned long ENABLE_NATIVE_FRAMES     = 0x01;
   1.102 +    /**
   1.103 +     * Normally, if a script has a 0 in JSD_SCRIPT_PROFILE_BIT it is included in
   1.104 +     * profile data, otherwise it is not profiled. Setting the
   1.105 +     * PROFILE_WHEN_SET flag reverses this convention.
   1.106 +     */
   1.107 +    const unsigned long PROFILE_WHEN_SET         = 0x02;
   1.108 +    /**
   1.109 +     * Normally, when the script in the top frame of a thread state has a 1 in
   1.110 +     * JSD_SCRIPT_DEBUG_BIT, the execution hook is ignored. Setting the
   1.111 +     * DEBUG_WHEN_SET flag reverses this convention.
   1.112 +     */
   1.113 +    const unsigned long DEBUG_WHEN_SET           = 0x04;
   1.114 +    /**
   1.115 +     * When this flag is set the internal call hook will collect profile data.
   1.116 +     */
   1.117 +    const unsigned long COLLECT_PROFILE_DATA     = 0x08;
   1.118 +    /**
   1.119 +     * When this flag is set, stack frames that are disabled for debugging
   1.120 +     * will not appear in the call stack chain.
   1.121 +     */
   1.122 +    const unsigned long HIDE_DISABLED_FRAMES     = 0x10;
   1.123 +    /**
   1.124 +     * When this flag is set, the debugger will only check the
   1.125 +     * JSD_SCRIPT_DEBUG_BIT on the top (most recent) stack frame. This
   1.126 +     * makes it possible to stop in an enabled frame which was called from
   1.127 +     * a stack that contains a disabled frame.
   1.128 +     *
   1.129 +     * When this flag is *not* set, any stack that contains a disabled frame
   1.130 +     * will not be debugged (the execution hook will not be invoked.)
   1.131 +     *
   1.132 +     * This only applies when the reason for calling the hook would have
   1.133 +     * been TYPE_INTERRUPTED or TYPE_THROW. TYPE_BREAKPOINT,
   1.134 +     * TYPE_DEBUG_REQUESTED, and TYPE_DEBUGGER_KEYWORD always stop, regardless
   1.135 +     * of this setting, as long as the top frame is not disabled.
   1.136 +     *
   1.137 +     * If HIDE_DISABLED_FRAMES is set, this is effectively set as well.
   1.138 +     */
   1.139 +    const unsigned long MASK_TOP_FRAME_ONLY     = 0x20;
   1.140 +    /**
   1.141 +     * This flag has been retired, do not re-use. It previously provided a hook
   1.142 +     * for object allocation.
   1.143 +     */
   1.144 +    const unsigned long DISABLE_OBJECT_TRACE_RETIRED = 0x40;
   1.145 +
   1.146 +    /**
   1.147 +     * Debugger service flags.
   1.148 +     */
   1.149 +    attribute unsigned long flags;
   1.150 +    
   1.151 +    /**
   1.152 +     * Major version number of implementation.
   1.153 +     */
   1.154 +    readonly attribute unsigned long implementationMajor;
   1.155 +    /**
   1.156 +     * Minor version number of implementation.
   1.157 +     */
   1.158 +    readonly attribute unsigned long implementationMinor;
   1.159 +    /**
   1.160 +     * Free form AUTF8String identifier for implementation.
   1.161 +     */
   1.162 +    readonly attribute AUTF8String implementationString;
   1.163 +    
   1.164 +    /**
   1.165 +     * |true| if the debugger service has been turned on. This does not
   1.166 +     * necessarily mean another app is actively using the service, as the 
   1.167 +     * autostart pref may have turned the service on.
   1.168 +     */
   1.169 +    readonly attribute boolean isOn;
   1.170 +
   1.171 +
   1.172 +    /**
   1.173 +     * Synchronous activation of the debugger is no longer supported,
   1.174 +     * and will throw an exception.
   1.175 +     */
   1.176 +    void on();
   1.177 +
   1.178 +    /**
   1.179 +     * Turn on the debugger. This function should only be called from
   1.180 +     * JavaScript code. The debugger will be enabled on the runtime the call is
   1.181 +     * made on, as determined by nsIXPCNativeCallContext.
   1.182 +     *
   1.183 +     * The debugger will be activated asynchronously, because there can be no
   1.184 +     * JS on the stack when code is to be re-compiled for debug mode.
   1.185 +     */
   1.186 +    void asyncOn(in jsdIActivationCallback callback);
   1.187 +    
   1.188 +    /**
   1.189 +     * Called by nsIXPConnect after it's had a chance to recompile for
   1.190 +     * debug mode.
   1.191 +     */
   1.192 +    [noscript] void activateDebugger(in JSRuntime rt);
   1.193 +
   1.194 +    /**
   1.195 +     * Called by nsIXPConnect to deactivate debugger on setup failure.
   1.196 +     */
   1.197 +    [noscript] void deactivateDebugger();
   1.198 +
   1.199 +    /**
   1.200 +     * Recompile all active scripts in the runtime for debugMode.
   1.201 +     */
   1.202 +    [noscript] void recompileForDebugMode(in JSContext cx, in JSCompartment comp, in boolean mode);
   1.203 +
   1.204 +    /**
   1.205 +     * Turn the debugger off. This will invalidate all of your jsdIEphemeral
   1.206 +     * derived objects, and clear all of your breakpoints.
   1.207 +     */
   1.208 +    void off ();
   1.209 +
   1.210 +    /**
   1.211 +     * Peek at the current pause depth of the debugger.
   1.212 +     *
   1.213 +     * @return depth Number of pause() calls still waiting to be unPause()d.
   1.214 +     */
   1.215 +    readonly attribute unsigned long pauseDepth;
   1.216 +    /**
   1.217 +     * Temporarily disable the debugger. Hooks will not be called while the
   1.218 +     * debugger is paused. Multiple calls to pause will increase the "pause
   1.219 +     * depth", and equal number of unPause calles must be made to resume
   1.220 +     * normal debugging.
   1.221 +     *
   1.222 +     * @return depth Number of times pause has been called since the debugger
   1.223 +     *               has been unpaused.
   1.224 +     */
   1.225 +    unsigned long pause();
   1.226 +    /**
   1.227 +     * Undo a pause.  Once this is called, the debugger won't start
   1.228 +     * getting execution callbacks until the stack is fully unwound so
   1.229 +     * that no JS scripts are live.  There is no way to query whether
   1.230 +     * there are such scripts left to unwind at a given point in time.
   1.231 +     *
   1.232 +     * @return depth The number of remaining pending pause calls.
   1.233 +     */
   1.234 +    unsigned long unPause();
   1.235 +    
   1.236 +    /**
   1.237 +     * Force the engine to perform garbage collection.
   1.238 +     */
   1.239 +    void GC();
   1.240 +    
   1.241 +    /**
   1.242 +     * Clear profile data for all scripts.
   1.243 +     */
   1.244 +    void clearProfileData();
   1.245 +    
   1.246 +    /**
   1.247 +     * Adds an execution hook filter. These filters are consulted each time one
   1.248 +     * of the jsdIExecutionHooks is about to be called. Filters are matched in
   1.249 +     * a first in, first compared fashion. The first filter to match determines
   1.250 +     * whether or not the hook is called. Use swapFilter to reorder existing
   1.251 +     * filters, and removeFilter to remove them.
   1.252 +     *
   1.253 +     * If |filter| is already present this method throws NS_ERROR_INVALID_ARG.
   1.254 +     *
   1.255 +     * @param filter Object representing the filter to add.
   1.256 +     * @param after  Insert |filter| after this one. Pass null to insert at
   1.257 +     *               the beginning.
   1.258 +     */
   1.259 +    void insertFilter(in jsdIFilter filter, in jsdIFilter after);
   1.260 +    /**
   1.261 +     * Same as insertFilter, except always add to the end of the list.
   1.262 +     */
   1.263 +    void appendFilter(in jsdIFilter filter);
   1.264 +    /**
   1.265 +     * Remove a filter.
   1.266 +     *
   1.267 +     * If |filter| is not present this method throws NS_ERROR_INVALID_ARG.
   1.268 +     *
   1.269 +     * @param filter Object representing the filter to remove. Must be the exact
   1.270 +     * object passed to addFilter, not just a new object with the same
   1.271 +     * properties.
   1.272 +     */
   1.273 +    void removeFilter(in jsdIFilter filter);
   1.274 +    /**
   1.275 +     * Swap position of two filters.
   1.276 +     * 
   1.277 +     * If |filter_a| is not present, this method throws NS_ERROR_INVALID_ARG.
   1.278 +     * If |filter_b| is not present, filter_a is replaced by filter_b.
   1.279 +     * If |filter_a| == |filter_b|, then filter is refreshed.
   1.280 +     */
   1.281 +    void swapFilters(in jsdIFilter filter_a, in jsdIFilter filter_b);
   1.282 +    /**
   1.283 +     * Enumerate registered filters. This routine refreshes each filter before
   1.284 +     * passing them on to the enumeration function. Calling this with a null
   1.285 +     * |enumerator| is equivalent to jsdIService::refreshFilters.
   1.286 +     *
   1.287 +     * @param enumerator jsdIFilterEnumerator instance to be called back for the
   1.288 +     *                   enumeration.
   1.289 +     */
   1.290 +    void enumerateFilters(in jsdIFilterEnumerator enumerator);
   1.291 +    /**
   1.292 +     * Force the debugger to resync its internal filter cache with the
   1.293 +     * actual values in the jsdIFilter objects. To refresh a single filter
   1.294 +     * use jsdIService::swapFilters. This method is equivalent to
   1.295 +     * jsdIService::enumerateFilters with a null enumerator.
   1.296 +     */
   1.297 +    void refreshFilters();
   1.298 +    /**
   1.299 +     * Clear the list of filters.
   1.300 +     */
   1.301 +    void clearFilters();
   1.302 +
   1.303 +    /**
   1.304 +     * Enumerate all known contexts.
   1.305 +     */
   1.306 +    void enumerateContexts(in jsdIContextEnumerator enumerator);
   1.307 +    
   1.308 +    /**
   1.309 +     * Enumerate all scripts the debugger knows about. Any scripts created
   1.310 +     * before you turned the debugger on, or after turning the debugger off
   1.311 +     * will not be available unless the autostart perf is set.
   1.312 +     *
   1.313 +     * @param enumerator jsdIScriptEnumerator instance to be called back for
   1.314 +     *                   the enumeration.
   1.315 +     */
   1.316 +    void enumerateScripts(in jsdIScriptEnumerator enumerator);
   1.317 +    /**
   1.318 +     * Clear all breakpoints in all scripts.
   1.319 +     */
   1.320 +    void clearAllBreakpoints();
   1.321 +
   1.322 +    /**
   1.323 +     * When called from JavaScript, this method returns the jsdIValue wrapper
   1.324 +     * for the given value. If a wrapper does not exist one will be created.
   1.325 +     * When called from another language this method returns an xpconnect
   1.326 +     * defined error code.
   1.327 +     */
   1.328 +    jsdIValue wrapValue(in jsval value);
   1.329 +
   1.330 +    /* XXX these two routines are candidates for refactoring. The only problem
   1.331 +     * is that it is not clear where and how they should land.
   1.332 +     */
   1.333 +
   1.334 +    /**
   1.335 +     * Push a new network queue, and enter a new UI event loop.
   1.336 +     * @param callback jsdINestCallback instance to be called back after the
   1.337 +     *                 network queue has been pushed, but before the
   1.338 +     *                 UI loop starts.
   1.339 +     * @return depth returns the current number of times the event loop has been
   1.340 +     *               nested. your code can use it for sanity checks.
   1.341 +     */
   1.342 +    unsigned long enterNestedEventLoop(in jsdINestCallback callback);
   1.343 +    /**
   1.344 +     * Exit the current nested event loop after the current iteration completes,
   1.345 +     * and pop the network event queue.
   1.346 +     *
   1.347 +     * @return depth returns the current number of times the event loop has been
   1.348 +     *               nested. your code can use it for sanity checks.
   1.349 +     */
   1.350 +    unsigned long exitNestedEventLoop();
   1.351 +
   1.352 +    /**
   1.353 +     * Output dump of JS heap.
   1.354 +     *
   1.355 +     * @param fileName Filename to dump the heap into.
   1.356 +     */
   1.357 +    void dumpHeap(in AUTF8String fileName);
   1.358 +
   1.359 +    /**
   1.360 +     * Suppress console warnings about using JSD, which is a deprecated API.
   1.361 +     *
   1.362 +     * This applies only to the next call to asyncOn; any subsequent calls
   1.363 +     * will elicit the warning, unless you call 'acknowledgeDeprecation'
   1.364 +     * before each of them, too. This arrangement ensures that one add-on's
   1.365 +     * acknowledgement doesn't suppress warnings for other add-ons.
   1.366 +     */
   1.367 +    void acknowledgeDeprecation();
   1.368 +};
   1.369 +
   1.370 +/* callback interfaces */
   1.371 +
   1.372 +/**
   1.373 + * Object representing a pattern of global object and/or url the debugger should
   1.374 + * ignore. The debugger service itself will not modify properties of these
   1.375 + * objects.
   1.376 + */
   1.377 +[scriptable, uuid(9ae587cd-b78c-47f0-a612-4b3a211a6a71)]
   1.378 +interface jsdIFilter : nsISupports
   1.379 +{
   1.380 +    /**
   1.381 +     * These two bytes of the flags attribute are reserved for interpretation
   1.382 +     * by the jsdService implementation. You can do what you like with the
   1.383 +     * remaining flags.
   1.384 +     */
   1.385 +    const unsigned long FLAG_RESERVED_MASK = 0xFF;
   1.386 +    /**
   1.387 +     * Filters without this flag set are ignored.
   1.388 +     */
   1.389 +    const unsigned long FLAG_ENABLED       = 0x01;
   1.390 +    /**
   1.391 +     * Filters with this flag set are "pass" filters, they allow matching hooks
   1.392 +     * to continue. Filters without this flag block matching hooks.
   1.393 +     */
   1.394 +    const unsigned long FLAG_PASS          = 0x02;
   1.395 +
   1.396 +    /**
   1.397 +     * FLAG_* values from above, OR'd together.
   1.398 +     */
   1.399 +    attribute unsigned long flags;
   1.400 +
   1.401 +    /**
   1.402 +     * String representing the url pattern to be filtered. Supports limited
   1.403 +     * glob matching, at the beginning and end of the pattern only. For example,
   1.404 +     * "chrome://venkman*" filters all urls that start with chrome/venkman,
   1.405 +     * "*.cgi" filters all cgi's, and "http://myserver/utils.js" filters only
   1.406 +     * the utils.js file on "myserver". A null urlPattern matches all urls.
   1.407 +     *
   1.408 +     * The jsdIService caches this value internally, to if it changes you must
   1.409 +     * swap the filter with itself using jsdIService::swapFilters.
   1.410 +     */
   1.411 +    attribute AUTF8String urlPattern;
   1.412 +
   1.413 +    /**
   1.414 +     * Line number for the start of this filter. Line numbers are one based.
   1.415 +     * Assigning a 0 to this attribute will tell the debugger to ignore the
   1.416 +     * entire file.
   1.417 +     */
   1.418 +    attribute unsigned long startLine;
   1.419 +
   1.420 +    /**
   1.421 +     * Line number for the end of this filter. Line numbers are one based.
   1.422 +     * Assigning a 0 to this attribute will tell the debugger to ignore from
   1.423 +     * |startLine| to the end of the file.
   1.424 +     */
   1.425 +    attribute unsigned long endLine;
   1.426 +};
   1.427 +
   1.428 +/**
   1.429 + * Notify client code that debugMode has been activated.
   1.430 + */
   1.431 +[scriptable, function, uuid(6da7f5fb-3a84-4abe-9e23-8b2045960732)]
   1.432 +interface jsdIActivationCallback : nsISupports
   1.433 +{
   1.434 +    void onDebuggerActivated();
   1.435 +};
   1.436 +
   1.437 +/**
   1.438 + * Pass an instance of one of these to jsdIDebuggerService::enterNestedEventLoop.
   1.439 + */
   1.440 +[scriptable, function, uuid(88bea60f-9b5d-4b39-b08b-1c3a278782c6)]
   1.441 +interface jsdINestCallback : nsISupports
   1.442 +{
   1.443 +    /**
   1.444 +     * This method will be called after pre-nesting work has completed, such
   1.445 +     * as pushing the js context and network event queue, but before the new
   1.446 +     * event loop starts.
   1.447 +     */
   1.448 +    void onNest();
   1.449 +};
   1.450 +
   1.451 +/**
   1.452 + * Pass an instance of one of these to jsdIDebuggerService::enumerateFilters.
   1.453 + */
   1.454 +[scriptable, function, uuid(e391ba85-9379-4762-b387-558e38db730f)]
   1.455 +interface jsdIFilterEnumerator : nsISupports
   1.456 +{
   1.457 +    /**
   1.458 +     * The enumerateFilter method will be called once for every filter the
   1.459 +     * debugger knows about.
   1.460 +     */
   1.461 +    void enumerateFilter(in jsdIFilter filter);
   1.462 +};
   1.463 +
   1.464 +/**
   1.465 + * Pass an instance of one of these to jsdIDebuggerService::enumerateScripts.
   1.466 + */
   1.467 +[scriptable, function, uuid(4eef60c2-9bbc-48fa-b196-646a832c6c81)]
   1.468 +interface jsdIScriptEnumerator : nsISupports
   1.469 +{
   1.470 +    /**
   1.471 +     * The enumerateScript method will be called once for every script the
   1.472 +     * debugger knows about.
   1.473 +     */
   1.474 +    void enumerateScript(in jsdIScript script);
   1.475 +};
   1.476 +
   1.477 +/**
   1.478 + * Pass an instance of one of these to jsdIDebuggerService::enumerateContexts.
   1.479 + */
   1.480 +[scriptable, function, uuid(57d18286-550c-4ca9-ac33-56f12ebba91e)]
   1.481 +interface jsdIContextEnumerator : nsISupports
   1.482 +{
   1.483 +    /**
   1.484 +     * The enumerateContext method will be called once for every context
   1.485 +     * currently in use.
   1.486 +     */
   1.487 +    void enumerateContext(in jsdIContext executionContext);
   1.488 +};
   1.489 +
   1.490 +/**
   1.491 + * Set jsdIDebuggerService::scriptHook to an instance of one of these.
   1.492 + */
   1.493 +[scriptable, uuid(d030d1a2-a58a-4f19-b9e3-96da4e2cdd09)]
   1.494 +interface jsdIScriptHook : nsISupports
   1.495 +{
   1.496 +    /**
   1.497 +     * Called when scripts are created.
   1.498 +     */
   1.499 +    void onScriptCreated(in jsdIScript script);
   1.500 +    /**
   1.501 +     * Called when the JavaScript engine destroys a script. The jsdIScript
   1.502 +     * object passed in will already be invalidated.
   1.503 +     */
   1.504 +    void onScriptDestroyed(in jsdIScript script);
   1.505 +};
   1.506 +
   1.507 +/**
   1.508 + * Hook instances of this interface up to the
   1.509 + * jsdIDebuggerService::functionHook and toplevelHook properties.
   1.510 + */
   1.511 +[scriptable, function, uuid(3eff1314-7ae3-4cf8-833b-c33c24a55633)]
   1.512 +interface jsdICallHook : nsISupports
   1.513 +{
   1.514 +    /**
   1.515 +     * TYPE_* values must be kept in sync with the JSD_HOOK_* #defines
   1.516 +     * in jsdebug.h.
   1.517 +     */
   1.518 +
   1.519 +    /**
   1.520 +     * Toplevel script is starting.
   1.521 +     */
   1.522 +    const unsigned long TYPE_TOPLEVEL_START  = 0;
   1.523 +    /**
   1.524 +     * Toplevel script has completed.
   1.525 +     */
   1.526 +    const unsigned long TYPE_TOPLEVEL_END    = 1;
   1.527 +    /**
   1.528 +     * Function is being called.
   1.529 +     */
   1.530 +    const unsigned long TYPE_FUNCTION_CALL   = 2;
   1.531 +    /**
   1.532 +     * Function is returning.
   1.533 +     */
   1.534 +    const unsigned long TYPE_FUNCTION_RETURN = 3;
   1.535 +    
   1.536 +    /**
   1.537 +     * Called before the JavaScript engine executes a top level script or calls
   1.538 +     * a function.
   1.539 +     */
   1.540 +    void onCall(in jsdIStackFrame frame, in unsigned long type);
   1.541 +};
   1.542 +
   1.543 +[scriptable, function, uuid(e6b45eee-d974-4d85-9d9e-f5a67218deb4)]
   1.544 +interface jsdIErrorHook : nsISupports
   1.545 +{
   1.546 +    /**
   1.547 +     * REPORT_* values must be kept in sync with JSREPORT_* #defines in
   1.548 +     * jsapi.h
   1.549 +     */
   1.550 +    
   1.551 +    /**
   1.552 +     * Report is an error.
   1.553 +     */
   1.554 +    const unsigned long REPORT_ERROR     = 0x00;
   1.555 +    /**
   1.556 +     * Report is only a warning.
   1.557 +     */
   1.558 +    const unsigned long REPORT_WARNING   = 0x01;
   1.559 +    /**
   1.560 +     * Report represents an uncaught exception.
   1.561 +     */
   1.562 +    const unsigned long REPORT_EXCEPTION = 0x02;
   1.563 +    /**
   1.564 +     * Report is due to strict mode.
   1.565 +     */
   1.566 +    const unsigned long REPORT_STRICT    = 0x04;
   1.567 +
   1.568 +    /**
   1.569 +     * Called when the JavaScript engine encounters an error. Return |true|
   1.570 +     * to pass the error along, |false| to invoke the debugHook.
   1.571 +     */
   1.572 +    boolean onError(in AUTF8String message, in AUTF8String fileName,
   1.573 +                    in unsigned long line, in unsigned long pos,
   1.574 +                    in unsigned long flags, in unsigned long errnum,
   1.575 +                    in jsdIValue exc);
   1.576 +};
   1.577 +
   1.578 +/**
   1.579 + * Hook instances of this interface up to the
   1.580 + * jsdIDebuggerService::breakpointHook, debuggerHook, errorHook, interruptHook,
   1.581 + * and throwHook properties.
   1.582 + */
   1.583 +[scriptable, function, uuid(3a722496-9d78-4f0a-a797-293d9e8cb8d2)]
   1.584 +interface jsdIExecutionHook : nsISupports
   1.585 +{
   1.586 +    /**
   1.587 +     * TYPE_* values must be kept in sync with JSD_HOOK_* #defines in jsdebug.h.
   1.588 +     */
   1.589 +
   1.590 +    /**
   1.591 +     * Execution stopped because we're in single step mode.
   1.592 +     */
   1.593 +    const unsigned long TYPE_INTERRUPTED      = 0;
   1.594 +    /**
   1.595 +     * Execution stopped by a trap instruction (i.e. breakoint.)
   1.596 +     */
   1.597 +    const unsigned long TYPE_BREAKPOINT       = 1;
   1.598 +    /**
   1.599 +     * Error handler returned an "invoke debugger" value.
   1.600 +     */
   1.601 +    const unsigned long TYPE_DEBUG_REQUESTED  = 2;
   1.602 +    /**
   1.603 +     * Debugger keyword encountered.
   1.604 +     */
   1.605 +    const unsigned long TYPE_DEBUGGER_KEYWORD = 3;
   1.606 +    /**
   1.607 +     * Exception was thrown.
   1.608 +     */
   1.609 +    const unsigned long TYPE_THROW            = 4;
   1.610 +
   1.611 +    /**
   1.612 +     * RETURN_* values must be kept in sync with JSD_HOOK_RETURN_* #defines in
   1.613 +     * jsdebug.h.
   1.614 +     */
   1.615 +
   1.616 +    /**
   1.617 +     * Indicates unrecoverable error processing the hook. This will cause
   1.618 +     * the script being executed to be aborted without raising a JavaScript
   1.619 +     * exception.
   1.620 +     */
   1.621 +    const unsigned long RETURN_HOOK_ERROR     = 0;
   1.622 +    /**
   1.623 +     * Continue processing normally. This is the "do nothing special" return
   1.624 +     * value for all hook types *except* TYPE_THROW. Returning RETURN_CONTINUE
   1.625 +     * from TYPE_THROW cause the exception to be ignored. Return
   1.626 +     * RETURN_CONTINUE_THROW to continue exception processing from TYPE_THROW
   1.627 +     * hooks.
   1.628 +     */
   1.629 +    const unsigned long RETURN_CONTINUE       = 1;
   1.630 +    /**
   1.631 +     * Same effect as RETURN_HOOK_ERROR.
   1.632 +     */
   1.633 +    const unsigned long RETURN_ABORT          = 2;
   1.634 +    /**
   1.635 +     * Return the value of the |val| parameter.
   1.636 +     */
   1.637 +    const unsigned long RETURN_RET_WITH_VAL   = 3;
   1.638 +    /**
   1.639 +     * Throw the value of the |val| parameter.
   1.640 +     */
   1.641 +    const unsigned long RETURN_THROW_WITH_VAL = 4;
   1.642 +    /**
   1.643 +     * Continue the current throw.
   1.644 +     */
   1.645 +    const unsigned long RETURN_CONTINUE_THROW = 5;
   1.646 +
   1.647 +    /**
   1.648 +     * @param frame A jsdIStackFrame object representing the bottom stack frame.
   1.649 +     * @param type  One of the jsdIExecutionHook::TYPE_ constants.
   1.650 +     * @param val   in  - Current exception (if any) when this method is called.
   1.651 +     *              out - If you return RETURN_THROW_WITH_VAL, value to be
   1.652 +     *                    thrown.
   1.653 +     *                    If you return RETURN_RET_WITH_VAL, value to return.
   1.654 +     *                    All other return values, not significant.
   1.655 +     * @retval      One of the jsdIExecutionHook::RETURN_* constants.
   1.656 +     */
   1.657 +    unsigned long onExecute(in jsdIStackFrame frame, 
   1.658 +                            in unsigned long type, inout jsdIValue val);
   1.659 +};
   1.660 +
   1.661 +/**
   1.662 + * Objects which inherit this interface may go away, with (jsdIScript) or
   1.663 + * without (all others) notification. These objects are generally wrappers
   1.664 + * around JSD structures that go away when you call jsdService::Off().
   1.665 + */
   1.666 +[scriptable, uuid(46f1e23e-1dd2-11b2-9ceb-8285f2e95e69)]
   1.667 +interface jsdIEphemeral : nsISupports
   1.668 +{
   1.669 +    /**
   1.670 +     * |true| if this object is still valid. If not, many or all of the methods
   1.671 +     * and/or properties of the inheritor may no longer be callable.
   1.672 +     */
   1.673 +    readonly attribute boolean isValid;
   1.674 +    /**
   1.675 +     * Mark this instance as invalid.
   1.676 +     */
   1.677 +    [noscript] void invalidate(); 
   1.678 +};    
   1.679 +
   1.680 +/* handle objects */
   1.681 +
   1.682 +/**
   1.683 + * Context object. Only context's which are also nsISupports objects can be
   1.684 + * reflected by this interface.
   1.685 + */
   1.686 +[scriptable, uuid(3e5c934d-6863-4d81-96f5-76a3b962fc2b)]
   1.687 +interface jsdIContext : jsdIEphemeral
   1.688 +{
   1.689 +    /* Internal use only. */
   1.690 +    [noscript] readonly attribute JSContext   JSContext;
   1.691 +
   1.692 +    /**
   1.693 +     * OPT_* values must be kept in sync with JSOPTION_* #defines in jsapi.h.
   1.694 +     */
   1.695 +
   1.696 +    /**
   1.697 +     * Strict mode is on.
   1.698 +     */
   1.699 +    const long OPT_STRICT      = 0x01;
   1.700 +    /**
   1.701 +     * Warnings reported as errors.
   1.702 +     */
   1.703 +    const long OPT_WERR        = 0x02;
   1.704 +    /**
   1.705 +     * Makes eval() use the last object on its 'obj' param's scope chain as the
   1.706 +     * ECMA 'variables object'.
   1.707 +     */
   1.708 +    const long OPT_VAROBJFIX   = 0x04;
   1.709 +    /**
   1.710 +     * Private data for this object is an nsISupports object. Attempting to
   1.711 +     * alter this bit will result in an NS_ERROR_ILLEGAL_VALUE.
   1.712 +     */
   1.713 +    const long OPT_ISUPPORTS   = 0x08;
   1.714 +    /**
   1.715 +     * OPT_* values above, OR'd together.
   1.716 +     */
   1.717 +    attribute unsigned long          options;
   1.718 +
   1.719 +    /**
   1.720 +     * Unique tag among all valid jsdIContext objects, useful as a hash key.
   1.721 +     */
   1.722 +    readonly attribute unsigned long tag;
   1.723 +
   1.724 +    /**
   1.725 +     * Private data for this context, if it is an nsISupports, |null| otherwise.
   1.726 +     */
   1.727 +    readonly attribute nsISupports   privateData;
   1.728 +    
   1.729 +    /**
   1.730 +     * Retrieve the underlying context wrapped by this jsdIContext.
   1.731 +     */
   1.732 +    readonly attribute nsISupports   wrappedContext;
   1.733 +
   1.734 +    /**
   1.735 +     * Top of the scope chain for this context.
   1.736 +     */
   1.737 +    readonly attribute jsdIValue     globalObject;
   1.738 +
   1.739 +    /**
   1.740 +     * |true| if this context should be allowed to run scripts, |false|
   1.741 +     * otherwise. This attribute is only valid for contexts which implement
   1.742 +     * nsIScriptContext. Setting or getting this attribute on any other
   1.743 +     * context will throw a NS_ERROR_NO_INTERFACE exception.
   1.744 +     */
   1.745 +    attribute boolean                scriptsEnabled;
   1.746 +};
   1.747 +
   1.748 +/**
   1.749 + * Stack frame objects. These are only valid inside the jsdIExecutionHook which
   1.750 + * gave it to you. After you return from that handler the bottom frame, and any
   1.751 + * frame you found attached through it, are invalidated via the jsdIEphemeral
   1.752 + * interface. Once a jsdIStackFrame has been invalidated all method and
   1.753 + * property accesses will throw a NS_ERROR_NOT_AVAILABLE exception.
   1.754 + */
   1.755 +[scriptable, uuid(7c95422c-7579-4a6f-8ef7-e5b391552ee5)]
   1.756 +interface jsdIStackFrame : jsdIEphemeral
   1.757 +{
   1.758 +    /** Internal use only. */
   1.759 +    [noscript] readonly attribute JSDContext        JSDContext;
   1.760 +    /** Internal use only. */
   1.761 +    [noscript] readonly attribute JSDThreadState    JSDThreadState;
   1.762 +    /** Internal use only. */
   1.763 +    [noscript] readonly attribute JSDStackFrameInfo JSDStackFrameInfo;
   1.764 +   
   1.765 +    /**
   1.766 +     * True if stack frame represents a frame created as a result of a debugger
   1.767 +     * evaluation.
   1.768 +     */
   1.769 +    readonly attribute boolean isDebugger;
   1.770 +    /**
   1.771 +     * True if stack frame is constructing a new object.
   1.772 +     */
   1.773 +    readonly attribute boolean isConstructing;
   1.774 +
   1.775 +    /**
   1.776 +     * Link to the caller's stack frame.
   1.777 +     */
   1.778 +    readonly attribute jsdIStackFrame callingFrame;
   1.779 +    /**
   1.780 +     * Executon context.
   1.781 +     */
   1.782 +    readonly attribute jsdIContext    executionContext;
   1.783 +    /**
   1.784 +     * Function name executing in this stack frame.
   1.785 +     */
   1.786 +    readonly attribute AUTF8String    functionName;
   1.787 +    /**
   1.788 +     * Script running in this stack frame, null for native frames.
   1.789 +     */
   1.790 +    readonly attribute jsdIScript     script;
   1.791 +    /**
   1.792 +     * Current program counter in this stack frame.
   1.793 +     */
   1.794 +    readonly attribute unsigned long  pc;
   1.795 +    /**
   1.796 +     * Current line number (using the script's pc to line map.)
   1.797 +     */
   1.798 +    readonly attribute unsigned long  line;
   1.799 +    /**
   1.800 +     * Function object running in this stack frame.
   1.801 +     */
   1.802 +    readonly attribute jsdIValue      callee;
   1.803 +    /**
   1.804 +     * Top object in the scope chain.
   1.805 +     */
   1.806 +    readonly attribute jsdIValue      scope;
   1.807 +    /**
   1.808 +     * |this| object for this stack frame.
   1.809 +     */
   1.810 +    readonly attribute jsdIValue      thisValue;
   1.811 +    /**
   1.812 +     * Evaluate arbitrary JavaScript in this stack frame.
   1.813 +     * @param bytes    Script to be evaluated.
   1.814 +     * @param fileName Filename to compile this script under. This is the
   1.815 +     *                 filename you'll see in error messages, etc.
   1.816 +     * @param line     Starting line number for this script. One based.
   1.817 +     * @retval         Result of evaluating the script.
   1.818 +     */
   1.819 +    boolean eval(in AString bytes, in AUTF8String fileName,
   1.820 +                 in unsigned long line, out jsdIValue result);
   1.821 +    
   1.822 +};
   1.823 +
   1.824 +/**
   1.825 + * Script object. In JavaScript engine terms, there's a single script for each
   1.826 + * function, and one for the top level script.
   1.827 + */
   1.828 +[scriptable, uuid(8ce9b2a2-cc33-48a8-9f47-8696186ed9a5)]
   1.829 +interface jsdIScript : jsdIEphemeral
   1.830 +{
   1.831 +    /** Internal use only. */
   1.832 +    [noscript] readonly attribute JSDContext JSDContext;
   1.833 +    /** Internal use only. */
   1.834 +    [noscript] readonly attribute JSDScript  JSDScript;
   1.835 +    
   1.836 +    /**
   1.837 +     * Last version set on this context.
   1.838 +     * Scripts typically select this with the "language" attribute.
   1.839 +     * See the VERSION_* consts on jsdIDebuggerService.
   1.840 +     */
   1.841 +    readonly attribute long          version;
   1.842 +
   1.843 +    /**
   1.844 +     * Tag value guaranteed unique among jsdIScript objects. Useful as a
   1.845 +     * hash key in script.
   1.846 +     */
   1.847 +    readonly attribute unsigned long tag;
   1.848 +
   1.849 +    /**
   1.850 +     * FLAG_* values need to be kept in sync with JSD_SCRIPT_* #defines in
   1.851 +     * jsdebug.h.
   1.852 +     */
   1.853 +
   1.854 +    /**
   1.855 +     * Determines whether or not to collect profile information for this
   1.856 +     * script. The context flag FLAG_PROFILE_WHEN_SET decides the logic.
   1.857 +     */
   1.858 +    const unsigned long FLAG_PROFILE = 0x01;
   1.859 +    /**
   1.860 +     * Determines whether or not to ignore breakpoints, etc. in this script.
   1.861 +     * The context flag JSD_DEBUG_WHEN_SET decides the logic.
   1.862 +     */
   1.863 +    const unsigned long FLAG_DEBUG   = 0x02;
   1.864 +    /**
   1.865 +     * Determines whether to invoke the onScriptDestroy callback for this
   1.866 +     * script. The default is for this to be true if the onScriptCreated
   1.867 +     * callback was invoked for this script.
   1.868 +     */
   1.869 +    const unsigned long FLAG_CALL_DESTROY_HOOK = 0x04;
   1.870 +    
   1.871 +    /**
   1.872 +     * FLAG_* attributes from above, OR'd together.
   1.873 +     */
   1.874 +    attribute unsigned long flags;
   1.875 +
   1.876 +    /**
   1.877 +     * Filename given for this script when it was compiled.
   1.878 +     * This data is copied from the underlying structure when the jsdIScript
   1.879 +     * instance is created and is therefore available even after the script is
   1.880 +     * invalidated.
   1.881 +     */
   1.882 +    readonly attribute AUTF8String   fileName;
   1.883 +    /**
   1.884 +     * Function name for this script. "anonymous" for unnamed functions (or
   1.885 +     * a function actually named anonymous), empty for top level scripts.
   1.886 +     * This data is copied from the underlying structure when the jsdIScript
   1.887 +     * instance is created and is therefore available even after the script is
   1.888 +     * invalidated.
   1.889 +     */
   1.890 +    readonly attribute AUTF8String   functionName;
   1.891 +    /**
   1.892 +     * The names of the arguments for this function; empty if this is
   1.893 +     * not a function.
   1.894 +     */
   1.895 +    void getParameterNames([optional] out unsigned long count,
   1.896 +                           [array, size_is(count), retval] out wstring paramNames);
   1.897 +    /**
   1.898 +     * Fetch the function object as a jsdIValue.
   1.899 +     */
   1.900 +    readonly attribute jsdIValue     functionObject;
   1.901 +    /**
   1.902 +     * Source code for this script, without function declaration.
   1.903 +     */
   1.904 +    readonly attribute AString functionSource;
   1.905 +    /**
   1.906 +     * Line number in source file containing the first line of this script.
   1.907 +     * This data is copied from the underlying structure when the jsdIScript
   1.908 +     * instance is created and is therefore available even after the script is
   1.909 +     * invalidated.
   1.910 +     */
   1.911 +    readonly attribute unsigned long baseLineNumber;
   1.912 +    /**
   1.913 +     * Total number of lines in this script.
   1.914 +     * This data is copied from the underlying structure when the jsdIScript
   1.915 +     * instance is created and is therefore available even after the script is
   1.916 +     * invalidated.
   1.917 +     */
   1.918 +    readonly attribute unsigned long lineExtent;
   1.919 +
   1.920 +    /**
   1.921 +     * Number of times this script has been called.
   1.922 +     */
   1.923 +    readonly attribute unsigned long callCount;
   1.924 +    /**
   1.925 +     * Number of times this script called itself, directly or indirectly.
   1.926 +     */
   1.927 +    readonly attribute unsigned long maxRecurseDepth;
   1.928 +    /**
   1.929 +     * Shortest execution time recorded, in milliseconds.
   1.930 +     */
   1.931 +    readonly attribute double minExecutionTime;
   1.932 +    /**
   1.933 +     * Longest execution time recorded, in milliseconds.
   1.934 +     */
   1.935 +    readonly attribute double maxExecutionTime;
   1.936 +    /**
   1.937 +     * Total time spent in this function, in milliseconds.
   1.938 +     */
   1.939 +    readonly attribute double totalExecutionTime;
   1.940 +    /**
   1.941 +     * Shortest execution time recorded, in milliseconds, excluding time spent
   1.942 +     * in other called code.
   1.943 +     */
   1.944 +    readonly attribute double minOwnExecutionTime;
   1.945 +    /**
   1.946 +     * Longest execution time recorded, in milliseconds, excluding time spent
   1.947 +     * in other called code.
   1.948 +     */
   1.949 +    readonly attribute double maxOwnExecutionTime;
   1.950 +    /**
   1.951 +     * Total time spent in this function, in milliseconds, excluding time spent
   1.952 +     * in other called code.
   1.953 +     */
   1.954 +    readonly attribute double totalOwnExecutionTime;
   1.955 +    
   1.956 +    /**
   1.957 +     * Clear profile data for this script.
   1.958 +     */
   1.959 +    void clearProfileData();
   1.960 +    
   1.961 +    const unsigned long PCMAP_SOURCETEXT  = 1; /* map to actual source text    */
   1.962 +    const unsigned long PCMAP_PRETTYPRINT = 2; /* map to pretty printed source */
   1.963 +
   1.964 +    /**
   1.965 +     * Get the closest line number to a given PC.
   1.966 +     * The |pcmap| argument specifies which pc to source line map to use.
   1.967 +     */
   1.968 +    unsigned long pcToLine(in unsigned long pc, in unsigned long pcmap);
   1.969 +    /**
   1.970 +     * Get the first PC associated with a line.
   1.971 +     * The |pcmap| argument specifies which pc to source line map to use.
   1.972 +     */
   1.973 +    unsigned long lineToPc(in unsigned long line, in unsigned long pcmap);
   1.974 +    /**
   1.975 +     * Determine is a particular line is executable, like checking that
   1.976 +     * lineToPc == pcToLine, except in one call.
   1.977 +     * The |pcmap| argument specifies which pc to source line map to use.
   1.978 +     */
   1.979 +    boolean isLineExecutable(in unsigned long line, in unsigned long pcmap);
   1.980 +
   1.981 +    /**
   1.982 +     * Return a list of all executable lines in a script.
   1.983 +     * |pcmap| specifies which pc to source line map to use.
   1.984 +     * |startLine| and |maxLines| may be used to retrieve a chunk at a time.
   1.985 +     */
   1.986 +    void getExecutableLines(in unsigned long pcmap,
   1.987 +                            in unsigned long startLine, in unsigned long maxLines,
   1.988 +                            [optional] out unsigned long count,
   1.989 +                            [array, size_is(count), retval] out unsigned long executableLines);
   1.990 + 
   1.991 +    /**
   1.992 +     * Set a breakpoint at a PC in this script.
   1.993 +     */
   1.994 +    void setBreakpoint(in unsigned long pc);
   1.995 +    /**
   1.996 +     * Clear a breakpoint at a PC in this script.
   1.997 +     */
   1.998 +    void clearBreakpoint(in unsigned long pc);
   1.999 +    /**
  1.1000 +     * Clear all breakpoints set in this script.
  1.1001 +     */
  1.1002 +    void clearAllBreakpoints();
  1.1003 +    /**
  1.1004 +     * Call interrupt hook at least once per source line
  1.1005 +     */
  1.1006 +    void enableSingleStepInterrupts(in boolean mode);
  1.1007 +};
  1.1008 +
  1.1009 +/**
  1.1010 + * Value objects. Represents typeless JavaScript values (jsval in SpiderMonkey
  1.1011 + * terminology.)  These are valid until the debugger is turned off. Holding a
  1.1012 + * jsdIValue adds a root for the underlying JavaScript value, so don't keep it
  1.1013 + * if you don't need to.
  1.1014 + */
  1.1015 +[scriptable, uuid(1cd3535b-4ddb-4202-9053-e0ec88f5c82b)]
  1.1016 +interface jsdIValue : jsdIEphemeral
  1.1017 +{
  1.1018 +    /** Internal use only. */
  1.1019 +    [noscript] readonly attribute JSDContext JSDContext;
  1.1020 +    /** Internal use only. */
  1.1021 +    [noscript] readonly attribute JSDValue   JSDValue;
  1.1022 +
  1.1023 +    /**
  1.1024 +     * |false| unless the value is a function declared in script.
  1.1025 +     */
  1.1026 +    readonly attribute boolean isNative;
  1.1027 +    /**
  1.1028 +     * |true| if the value represents a number, either double or integer.
  1.1029 +     * |false| for all other values, including numbers assigned as strings
  1.1030 +     * (eg. x = "1";)
  1.1031 +     */
  1.1032 +    readonly attribute boolean isNumber;
  1.1033 +    /**
  1.1034 +     * |true| if the value represents a JavaScript primitive number or AUTF8String
  1.1035 +     */
  1.1036 +    readonly attribute boolean isPrimitive;
  1.1037 +    
  1.1038 +    /** Value is either |true| or |false|. */
  1.1039 +    const unsigned long TYPE_BOOLEAN  = 0;
  1.1040 +    /** Value is a primitive number that is too large to fit in an integer. */
  1.1041 +    const unsigned long TYPE_DOUBLE   = 1;
  1.1042 +    /** Value is a primitive number that fits into an integer. */
  1.1043 +    const unsigned long TYPE_INT      = 2;
  1.1044 +    /** Value is a function. */
  1.1045 +    const unsigned long TYPE_FUNCTION = 3;
  1.1046 +    /** Value is |null|. */
  1.1047 +    const unsigned long TYPE_NULL     = 4;
  1.1048 +    /** Value is an object. */
  1.1049 +    const unsigned long TYPE_OBJECT   = 5;
  1.1050 +    /** Value is a primitive AUTF8String. */
  1.1051 +    const unsigned long TYPE_STRING   = 6;
  1.1052 +    /** Value is void. */
  1.1053 +    const unsigned long TYPE_VOID     = 7;
  1.1054 +    
  1.1055 +    /**
  1.1056 +     * One of the TYPE_* values above.
  1.1057 +     */
  1.1058 +    readonly attribute unsigned long jsType;
  1.1059 +    /**
  1.1060 +     * Prototype value if this value represents an object, null if the value is
  1.1061 +     * not an object or the object has no prototype.
  1.1062 +     */
  1.1063 +    readonly attribute jsdIValue     jsPrototype;
  1.1064 +    /**
  1.1065 +     * Parent value if this value represents an object, null if the value is not
  1.1066 +     * an object or the object has no parent.
  1.1067 +     */    
  1.1068 +    readonly attribute jsdIValue     jsParent;
  1.1069 +    /**
  1.1070 +     * Class name if this value represents an object. Empty AUTF8String if the value
  1.1071 +     * is not an object.
  1.1072 +     */
  1.1073 +    readonly attribute AUTF8String   jsClassName;
  1.1074 +    /**
  1.1075 +     * Constructor name if this value represents an object. Empty AUTF8String if the
  1.1076 +     * value is not an object.
  1.1077 +     */
  1.1078 +    readonly attribute jsdIValue     jsConstructor;
  1.1079 +    /**
  1.1080 +     * Function name if this value represents a function. Empty AUTF8String if the
  1.1081 +     * value is not a function.
  1.1082 +     */
  1.1083 +    readonly attribute AUTF8String   jsFunctionName;
  1.1084 +    
  1.1085 +    /**
  1.1086 +     * Value if interpreted as a boolean. Converts if necessary.
  1.1087 +     */
  1.1088 +    readonly attribute boolean       booleanValue;
  1.1089 +    /**
  1.1090 +     * Value if interpreted as a double. Converts if necessary.
  1.1091 +     */
  1.1092 +    readonly attribute double        doubleValue;
  1.1093 +    /**
  1.1094 +     * Value if interpreted as an integer. Converts if necessary.
  1.1095 +     */
  1.1096 +    readonly attribute long          intValue;
  1.1097 +    /**
  1.1098 +     * Value if interpreted as an object.
  1.1099 +     */
  1.1100 +    readonly attribute jsdIObject    objectValue;
  1.1101 +    /**
  1.1102 +     * Value if interpreted as a AUTF8String. Converts if necessary.
  1.1103 +     */
  1.1104 +    readonly attribute AUTF8String   stringValue;
  1.1105 +
  1.1106 +    /**
  1.1107 +     * Number of properties. 0 if the value is not an object, or the value is
  1.1108 +     * an object but has no properties.
  1.1109 +     */
  1.1110 +    readonly attribute long propertyCount;
  1.1111 +    
  1.1112 +    /**
  1.1113 +     * Retrieves all properties if this value represents an object. If this
  1.1114 +     * value is not an object a 0 element array is returned.
  1.1115 +     * @param propArray Array of jsdIProperty values for this value.
  1.1116 +     * @param length    Size of array.
  1.1117 +     */
  1.1118 +    void getProperties([array, size_is(length)] out jsdIProperty propArray,
  1.1119 +                       out unsigned long length);
  1.1120 +    /**
  1.1121 +     * Retrieves a single property from the value. Only valid if the value
  1.1122 +     * represents an object.
  1.1123 +     * @param name Name of the property to retrieve.
  1.1124 +     * @retval     jsdIProperty for the requested property name or null if no
  1.1125 +     *             property exists for the requested name.
  1.1126 +     */
  1.1127 +    jsdIProperty getProperty(in AUTF8String name);
  1.1128 +
  1.1129 +    /**
  1.1130 +     * jsdIValues are wrappers around JavaScript engine structures. Much of the
  1.1131 +     * data is copied instead of shared. The refresh method is used to resync
  1.1132 +     * the jsdIValue with the underlying structure.
  1.1133 +     */
  1.1134 +    void refresh();
  1.1135 +
  1.1136 +    /**
  1.1137 +     * When called from JavaScript, this method returns the JavaScript value
  1.1138 +     * wrapped by this jsdIValue. The calling script is free to use the result
  1.1139 +     * as it would any other JavaScript value.
  1.1140 +     * When called from another language this method returns an xpconnect
  1.1141 +     * defined error code.
  1.1142 +     */
  1.1143 +    [implicit_jscontext] jsval getWrappedValue();
  1.1144 +
  1.1145 +    /**
  1.1146 +     * If this is a function value, return its associated jsdIScript.
  1.1147 +     * Otherwise, return null.
  1.1148 +     */
  1.1149 +    readonly attribute jsdIScript script;
  1.1150 +};
  1.1151 +
  1.1152 +/**
  1.1153 + * Properties specific to values which are also objects.
  1.1154 + * XXX We don't add roots for these yet, so make sure you hold on to the
  1.1155 + * jsdIValue from whence your jsdIObject instance came for at least as long as
  1.1156 + * you hold the jsdIObject.
  1.1157 + * XXX Maybe the jsClassName, jsConstructorName, and property related attribute/
  1.1158 + * functions from jsdIValue should move to this interface. We could inherit from
  1.1159 + * jsdIValue or use interface flattening or something.
  1.1160 + */
  1.1161 +[scriptable, uuid(87d86308-7a27-4255-b23c-ce2394f02473)]
  1.1162 +interface jsdIObject : nsISupports
  1.1163 +{
  1.1164 +    /** Internal use only. */
  1.1165 +    [noscript] readonly attribute JSDContext JSDContext;
  1.1166 +    /** Internal use only. */
  1.1167 +    [noscript] readonly attribute JSDObject  JSDObject;
  1.1168 +
  1.1169 +    /**
  1.1170 +     * The URL (filename) that contains the script which caused this object
  1.1171 +     * to be created.
  1.1172 +     */
  1.1173 +    readonly attribute AUTF8String   creatorURL;
  1.1174 +    /**
  1.1175 +     * Line number in the creatorURL where this object was created.
  1.1176 +     */
  1.1177 +    readonly attribute unsigned long creatorLine;
  1.1178 +    /**
  1.1179 +     * The URL (filename) that contains the script which defined the constructor
  1.1180 +     * used to create this object.
  1.1181 +     */
  1.1182 +    readonly attribute AUTF8String   constructorURL;
  1.1183 +    /**
  1.1184 +     * Line number in the creatorURL where this object was created.
  1.1185 +     */
  1.1186 +    readonly attribute unsigned long constructorLine;
  1.1187 +    /**
  1.1188 +     * jsdIValue for this object.
  1.1189 +     */
  1.1190 +    readonly attribute jsdIValue     value;
  1.1191 +};
  1.1192 +
  1.1193 +/**
  1.1194 + * Representation of a property of an object. When an instance is invalid, all
  1.1195 + * method and property access will result in a NS_UNAVAILABLE error.
  1.1196 + */
  1.1197 +[scriptable, uuid(acf1329e-aaf6-4d6a-a1eb-f75858566f09)]
  1.1198 +interface jsdIProperty : jsdIEphemeral
  1.1199 +{
  1.1200 +    /** Internal use only. */
  1.1201 +    [noscript] readonly attribute JSDContext  JSDContext;
  1.1202 +    /** Internal use only. */
  1.1203 +    [noscript] readonly attribute JSDProperty JSDProperty;
  1.1204 +
  1.1205 +    /**
  1.1206 +     * FLAG_* values must be kept in sync with JSDPD_* #defines in jsdebug.h.
  1.1207 +     */
  1.1208 +
  1.1209 +    /** visible to for/in loop */
  1.1210 +    const unsigned long FLAG_ENUMERATE = 0x01;
  1.1211 +    /** assignment is error */    
  1.1212 +    const unsigned long FLAG_READONLY  = 0x02;
  1.1213 +    /** property cannot be deleted */
  1.1214 +    const unsigned long FLAG_PERMANENT = 0x04;
  1.1215 +    /** property has an alias id */
  1.1216 +    const unsigned long FLAG_ALIAS     = 0x08;
  1.1217 +    /** argument to function */
  1.1218 +    const unsigned long FLAG_ARGUMENT  = 0x10;
  1.1219 +    /** local variable in function */
  1.1220 +    const unsigned long FLAG_VARIABLE  = 0x20;
  1.1221 +    /** exception occurred looking up property, value is exception */
  1.1222 +    const unsigned long FLAG_EXCEPTION = 0x40;
  1.1223 +    /** native getter returned false without throwing an exception */
  1.1224 +    const unsigned long FLAG_ERROR     = 0x80;
  1.1225 +    /** found via explicit lookup (property defined elsewhere.) */
  1.1226 +    const unsigned long FLAG_HINTED    = 0x800;
  1.1227 +
  1.1228 +    /** FLAG_* values OR'd together, representing the flags for this property. */
  1.1229 +    readonly attribute unsigned long flags;
  1.1230 +    /** jsdIValue representing the alias for this property. */
  1.1231 +    readonly attribute jsdIValue     alias;
  1.1232 +    /** name for this property. */
  1.1233 +    readonly attribute jsdIValue     name;
  1.1234 +    /** value of this property. */
  1.1235 +    readonly attribute jsdIValue     value;
  1.1236 +};

mercurial