js/jsd/jsd.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/jsd/jsd.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1054 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +/*
    1.11 + * Header for JavaScript Debugging support - Internal ONLY declarations
    1.12 + */
    1.13 +
    1.14 +#ifndef jsd_h___
    1.15 +#define jsd_h___
    1.16 +
    1.17 +/*
    1.18 +* NOTE: This is a *private* header file and should only be included by
    1.19 +* the sources in js/jsd. Defining EXPORT_JSD_API in an outside module
    1.20 +* using jsd would be bad.
    1.21 +*/
    1.22 +#define EXPORT_JSD_API 1 /* if used, must be set before include of jsdebug.h */
    1.23 +
    1.24 +/*
    1.25 +* These can be controled by the makefile, but this allows a place to set
    1.26 +* the values always used in the mozilla client, but perhaps done differently
    1.27 +* in other embeddings.
    1.28 +*/
    1.29 +#ifdef MOZILLA_CLIENT
    1.30 +#define JSD_THREADSAFE 1
    1.31 +/* define JSD_HAS_DANGEROUS_THREAD 1 */
    1.32 +#define JSD_USE_NSPR_LOCKS 1
    1.33 +#endif /* MOZILLA_CLIENT */
    1.34 +
    1.35 +#include "jsapi.h"
    1.36 +#include "jshash.h"
    1.37 +#include "jsclist.h"
    1.38 +#include "jsdebug.h"
    1.39 +#include "js/OldDebugAPI.h"
    1.40 +#include "jsd_lock.h"
    1.41 +
    1.42 +#include <stdio.h>
    1.43 +#include <stdlib.h>
    1.44 +#include <string.h>
    1.45 +
    1.46 +#define JSD_MAJOR_VERSION 1
    1.47 +#define JSD_MINOR_VERSION 1
    1.48 +
    1.49 +/***************************************************************************/
    1.50 +/* handy macros */
    1.51 +#undef  CHECK_BIT_FLAG
    1.52 +#define CHECK_BIT_FLAG(f,b) ((f)&(b))
    1.53 +#undef  SET_BIT_FLAG
    1.54 +#define SET_BIT_FLAG(f,b)   ((f)|=(b))
    1.55 +#undef  CLEAR_BIT_FLAG
    1.56 +#define CLEAR_BIT_FLAG(f,b) ((f)&=(~(b)))
    1.57 +
    1.58 +#define JSD_IS_DEBUG_ENABLED(jsdc,jsdscript)                                   \
    1.59 +        (!(((jsdc->flags & JSD_DEBUG_WHEN_SET) ? 1 : 0)  ^                     \
    1.60 +           ((jsdscript->flags & JSD_SCRIPT_DEBUG_BIT) ?  1 : 0)))
    1.61 +#define JSD_IS_PROFILE_ENABLED(jsdc,jsdscript)                                 \
    1.62 +        ((jsdc->flags & JSD_COLLECT_PROFILE_DATA) &&                           \
    1.63 +         (!(((jsdc->flags & JSD_PROFILE_WHEN_SET) ? 1 : 0) ^                   \
    1.64 +            ((jsdscript->flags & JSD_SCRIPT_PROFILE_BIT) ? 1 : 0))))
    1.65 +
    1.66 +
    1.67 +/***************************************************************************/
    1.68 +/* These are not exposed in jsdebug.h - typedef here for consistency */
    1.69 +
    1.70 +typedef struct JSDExecHook          JSDExecHook;
    1.71 +typedef struct JSDAtom              JSDAtom;
    1.72 +typedef struct JSDProfileData       JSDProfileData;
    1.73 +/***************************************************************************/
    1.74 +/* Our structures */
    1.75 +
    1.76 +/*
    1.77 +* XXX What I'm calling a JSDContext is really more of a JSDTaskState. 
    1.78 +*/
    1.79 +
    1.80 +struct JSDContext
    1.81 +{
    1.82 +    JSCList                 links;      /* we are part of a JSCList */
    1.83 +    bool                    inited;
    1.84 +    void*                   data;
    1.85 +    uint32_t                flags;
    1.86 +    JSD_ScriptHookProc      scriptHook;
    1.87 +    void*                   scriptHookData;
    1.88 +    JSD_ExecutionHookProc   interruptHook;
    1.89 +    void*                   interruptHookData;
    1.90 +    JSRuntime*              jsrt;
    1.91 +    JSD_ErrorReporter       errorReporter;
    1.92 +    void*                   errorReporterData;
    1.93 +    JSCList                 threadsStates;
    1.94 +    JSD_ExecutionHookProc   debugBreakHook;
    1.95 +    void*                   debugBreakHookData;
    1.96 +    JSD_ExecutionHookProc   debuggerHook;
    1.97 +    void*                   debuggerHookData;
    1.98 +    JSD_ExecutionHookProc   throwHook;
    1.99 +    void*                   throwHookData;
   1.100 +    JSD_CallHookProc        functionHook;
   1.101 +    void*                   functionHookData;
   1.102 +    JSD_CallHookProc        toplevelHook;
   1.103 +    void*                   toplevelHookData;
   1.104 +    JS::Heap<JSObject*>     glob;
   1.105 +    JSD_UserCallbacks       userCallbacks;
   1.106 +    void*                   user;
   1.107 +    JSCList                 scripts;
   1.108 +    JSHashTable*            scriptsTable;
   1.109 +    JSCList                 sources;
   1.110 +    JSCList                 removedSources;
   1.111 +    unsigned                   sourceAlterCount;
   1.112 +    JSHashTable*            atoms;
   1.113 +    JSCList                 objectsList;
   1.114 +    JSHashTable*            objectsTable;
   1.115 +    JSDProfileData*         callingFunctionPData;
   1.116 +    int64_t                 lastReturnTime;
   1.117 +#ifdef JSD_THREADSAFE
   1.118 +    JSDStaticLock*          scriptsLock;
   1.119 +    JSDStaticLock*          sourceTextLock;
   1.120 +    JSDStaticLock*          objectsLock;
   1.121 +    JSDStaticLock*          atomsLock;
   1.122 +    JSDStaticLock*          threadStatesLock;
   1.123 +#endif /* JSD_THREADSAFE */
   1.124 +#ifdef JSD_HAS_DANGEROUS_THREAD
   1.125 +    void*                   dangerousThread;
   1.126 +#endif /* JSD_HAS_DANGEROUS_THREAD */
   1.127 +
   1.128 +};
   1.129 +
   1.130 +struct JSDScript
   1.131 +{
   1.132 +    JSCList     links;      /* we are part of a JSCList */
   1.133 +    JSDContext* jsdc;       /* JSDContext for this jsdscript */
   1.134 +    JSScript*   script;     /* script we are wrapping */
   1.135 +    unsigned       lineBase;   /* we cache this */
   1.136 +    unsigned       lineExtent; /* we cache this */
   1.137 +    JSCList     hooks;      /* JSCList of JSDExecHooks for this script */
   1.138 +    char*       url;
   1.139 +    uint32_t    flags;
   1.140 +    void*       data;
   1.141 +
   1.142 +    JSDProfileData  *profileData;
   1.143 +};
   1.144 +
   1.145 +struct JSDProfileData
   1.146 +{
   1.147 +    JSDProfileData* caller;
   1.148 +    int64_t  lastCallStart;
   1.149 +    int64_t  runningTime;
   1.150 +    unsigned    callCount;
   1.151 +    unsigned    recurseDepth;
   1.152 +    unsigned    maxRecurseDepth;
   1.153 +    double minExecutionTime;
   1.154 +    double maxExecutionTime;
   1.155 +    double totalExecutionTime;
   1.156 +    double minOwnExecutionTime;
   1.157 +    double maxOwnExecutionTime;
   1.158 +    double totalOwnExecutionTime;
   1.159 +};
   1.160 +
   1.161 +struct JSDSourceText
   1.162 +{
   1.163 +    JSCList          links;      /* we are part of a JSCList */
   1.164 +    char*            url;
   1.165 +    char*            text;
   1.166 +    unsigned         textLength;
   1.167 +    unsigned         textSpace;
   1.168 +    bool             dirty;
   1.169 +    JSDSourceStatus  status;
   1.170 +    unsigned         alterCount;
   1.171 +    bool             doingEval;
   1.172 +};
   1.173 +
   1.174 +struct JSDExecHook
   1.175 +{
   1.176 +    JSCList               links;        /* we are part of a JSCList */
   1.177 +    JSDScript*            jsdscript;
   1.178 +    uintptr_t             pc;
   1.179 +    JSD_ExecutionHookProc hook;
   1.180 +    void*                 callerdata;
   1.181 +};
   1.182 +
   1.183 +#define TS_HAS_DISABLED_FRAME 0x01
   1.184 +
   1.185 +struct JSDThreadState
   1.186 +{
   1.187 +    JSCList             links;        /* we are part of a JSCList */
   1.188 +    JSContext*          context;
   1.189 +    void*               thread;
   1.190 +    JSCList             stack;
   1.191 +    unsigned               stackDepth;
   1.192 +    unsigned               flags;
   1.193 +};
   1.194 +
   1.195 +struct JSDStackFrameInfo
   1.196 +{
   1.197 +    JSCList             links;        /* we are part of a JSCList */
   1.198 +    JSDThreadState*     jsdthreadstate;
   1.199 +    JSDScript*          jsdscript;
   1.200 +    uintptr_t           pc;
   1.201 +    bool                isConstructing;
   1.202 +    JSAbstractFramePtr  frame;
   1.203 +};
   1.204 +
   1.205 +#define GOT_PROTO   ((short) (1 << 0))
   1.206 +#define GOT_PROPS   ((short) (1 << 1))
   1.207 +#define GOT_PARENT  ((short) (1 << 2))
   1.208 +#define GOT_CTOR    ((short) (1 << 3))
   1.209 +
   1.210 +struct JSDValue
   1.211 +{
   1.212 +    JS::Heap<JS::Value> val;
   1.213 +    int                 nref;
   1.214 +    JSCList             props;
   1.215 +    JS::Heap<JSString*> string;
   1.216 +    JS::Heap<JSString*> funName;
   1.217 +    const char*         className;
   1.218 +    JSDValue*           proto;
   1.219 +    JSDValue*           parent;
   1.220 +    JSDValue*           ctor;
   1.221 +    unsigned            flags;
   1.222 +};
   1.223 +
   1.224 +struct JSDProperty
   1.225 +{
   1.226 +    JSCList     links;      /* we are part of a JSCList */
   1.227 +    int        nref;
   1.228 +    JSDValue*   val;
   1.229 +    JSDValue*   name;
   1.230 +    JSDValue*   alias;
   1.231 +    unsigned       flags;
   1.232 +};
   1.233 +
   1.234 +struct JSDAtom
   1.235 +{
   1.236 +    char* str;      /* must be first element in struct for compare */
   1.237 +    int  refcount;
   1.238 +};
   1.239 +
   1.240 +struct JSDObject
   1.241 +{
   1.242 +    JSCList     links;      /* we are part of a JSCList */
   1.243 +    JSObject*   obj;
   1.244 +    JSDAtom*    newURL;
   1.245 +    unsigned       newLineno;
   1.246 +    JSDAtom*    ctorURL;
   1.247 +    unsigned       ctorLineno;
   1.248 +    JSDAtom*    ctorName;
   1.249 +};
   1.250 +
   1.251 +/***************************************************************************/
   1.252 +/* Code validation support */
   1.253 +
   1.254 +#ifdef DEBUG
   1.255 +extern void JSD_ASSERT_VALID_CONTEXT(JSDContext* jsdc);
   1.256 +extern void JSD_ASSERT_VALID_SCRIPT(JSDScript* jsdscript);
   1.257 +extern void JSD_ASSERT_VALID_SOURCE_TEXT(JSDSourceText* jsdsrc);
   1.258 +extern void JSD_ASSERT_VALID_THREAD_STATE(JSDThreadState* jsdthreadstate);
   1.259 +extern void JSD_ASSERT_VALID_STACK_FRAME(JSDStackFrameInfo* jsdframe);
   1.260 +extern void JSD_ASSERT_VALID_EXEC_HOOK(JSDExecHook* jsdhook);
   1.261 +extern void JSD_ASSERT_VALID_VALUE(JSDValue* jsdval);
   1.262 +extern void JSD_ASSERT_VALID_PROPERTY(JSDProperty* jsdprop);
   1.263 +extern void JSD_ASSERT_VALID_OBJECT(JSDObject* jsdobj);
   1.264 +#else
   1.265 +#define JSD_ASSERT_VALID_CONTEXT(x)     ((void)0)
   1.266 +#define JSD_ASSERT_VALID_SCRIPT(x)      ((void)0)
   1.267 +#define JSD_ASSERT_VALID_SOURCE_TEXT(x) ((void)0)
   1.268 +#define JSD_ASSERT_VALID_THREAD_STATE(x)((void)0)
   1.269 +#define JSD_ASSERT_VALID_STACK_FRAME(x) ((void)0)
   1.270 +#define JSD_ASSERT_VALID_EXEC_HOOK(x)   ((void)0)
   1.271 +#define JSD_ASSERT_VALID_VALUE(x)       ((void)0)
   1.272 +#define JSD_ASSERT_VALID_PROPERTY(x)    ((void)0)
   1.273 +#define JSD_ASSERT_VALID_OBJECT(x)      ((void)0)
   1.274 +#endif
   1.275 +
   1.276 +/***************************************************************************/
   1.277 +/* higher level functions */
   1.278 +
   1.279 +extern JSDContext*
   1.280 +jsd_DebuggerOnForUser(JSRuntime*         jsrt,
   1.281 +                      JSD_UserCallbacks* callbacks,
   1.282 +                      void*              user,
   1.283 +                      JSObject*          scopeobj);
   1.284 +
   1.285 +extern JSDContext*
   1.286 +jsd_DebuggerOn(void);
   1.287 +
   1.288 +extern void
   1.289 +jsd_DebuggerOff(JSDContext* jsdc);
   1.290 +
   1.291 +extern void
   1.292 +jsd_DebuggerPause(JSDContext* jsdc, bool forceAllHooksOff);
   1.293 +
   1.294 +extern void
   1.295 +jsd_DebuggerUnpause(JSDContext* jsdc);
   1.296 +
   1.297 +extern void
   1.298 +jsd_SetUserCallbacks(JSRuntime* jsrt, JSD_UserCallbacks* callbacks, void* user);
   1.299 +
   1.300 +extern JSDContext*
   1.301 +jsd_JSDContextForJSContext(JSContext* context);
   1.302 +
   1.303 +extern void*
   1.304 +jsd_SetContextPrivate(JSDContext* jsdc, void *data);
   1.305 +
   1.306 +extern void*
   1.307 +jsd_GetContextPrivate(JSDContext* jsdc);
   1.308 +
   1.309 +extern void
   1.310 +jsd_ClearAllProfileData(JSDContext* jsdc);
   1.311 +
   1.312 +extern bool
   1.313 +jsd_SetErrorReporter(JSDContext*       jsdc,
   1.314 +                     JSD_ErrorReporter reporter,
   1.315 +                     void*             callerdata);
   1.316 +
   1.317 +extern bool
   1.318 +jsd_GetErrorReporter(JSDContext*        jsdc,
   1.319 +                     JSD_ErrorReporter* reporter,
   1.320 +                     void**             callerdata);
   1.321 +
   1.322 +/***************************************************************************/
   1.323 +/* Script functions */
   1.324 +
   1.325 +extern bool
   1.326 +jsd_InitScriptManager(JSDContext *jsdc);
   1.327 +
   1.328 +extern void
   1.329 +jsd_DestroyScriptManager(JSDContext* jsdc);
   1.330 +
   1.331 +extern JSDScript*
   1.332 +jsd_FindJSDScript(JSDContext*  jsdc,
   1.333 +                  JSScript     *script);
   1.334 +
   1.335 +extern JSDScript*
   1.336 +jsd_FindOrCreateJSDScript(JSDContext    *jsdc,
   1.337 +                          JSContext     *cx,
   1.338 +                          JSScript      *script,
   1.339 +                          JSAbstractFramePtr frame);
   1.340 +
   1.341 +extern JSDProfileData*
   1.342 +jsd_GetScriptProfileData(JSDContext* jsdc, JSDScript *script);
   1.343 +
   1.344 +extern uint32_t
   1.345 +jsd_GetScriptFlags(JSDContext *jsdc, JSDScript *script);
   1.346 +
   1.347 +extern void
   1.348 +jsd_SetScriptFlags(JSDContext *jsdc, JSDScript *script, uint32_t flags);
   1.349 +
   1.350 +extern unsigned
   1.351 +jsd_GetScriptCallCount(JSDContext* jsdc, JSDScript *script);
   1.352 +
   1.353 +extern  unsigned
   1.354 +jsd_GetScriptMaxRecurseDepth(JSDContext* jsdc, JSDScript *script);
   1.355 +
   1.356 +extern double
   1.357 +jsd_GetScriptMinExecutionTime(JSDContext* jsdc, JSDScript *script);
   1.358 +
   1.359 +extern double
   1.360 +jsd_GetScriptMaxExecutionTime(JSDContext* jsdc, JSDScript *script);
   1.361 +
   1.362 +extern double
   1.363 +jsd_GetScriptTotalExecutionTime(JSDContext* jsdc, JSDScript *script);
   1.364 +
   1.365 +extern double
   1.366 +jsd_GetScriptMinOwnExecutionTime(JSDContext* jsdc, JSDScript *script);
   1.367 +
   1.368 +extern double
   1.369 +jsd_GetScriptMaxOwnExecutionTime(JSDContext* jsdc, JSDScript *script);
   1.370 +
   1.371 +extern double
   1.372 +jsd_GetScriptTotalOwnExecutionTime(JSDContext* jsdc, JSDScript *script);
   1.373 +
   1.374 +extern void
   1.375 +jsd_ClearScriptProfileData(JSDContext* jsdc, JSDScript *script);
   1.376 +
   1.377 +extern JSScript *
   1.378 +jsd_GetJSScript (JSDContext *jsdc, JSDScript *script);
   1.379 +
   1.380 +extern JSFunction *
   1.381 +jsd_GetJSFunction (JSDContext *jsdc, JSDScript *script);
   1.382 +
   1.383 +extern JSDScript*
   1.384 +jsd_IterateScripts(JSDContext* jsdc, JSDScript **iterp);
   1.385 +
   1.386 +extern void *
   1.387 +jsd_SetScriptPrivate (JSDScript *jsdscript, void *data);
   1.388 +
   1.389 +extern void *
   1.390 +jsd_GetScriptPrivate (JSDScript *jsdscript);
   1.391 +
   1.392 +extern bool
   1.393 +jsd_IsActiveScript(JSDContext* jsdc, JSDScript *jsdscript);
   1.394 +
   1.395 +extern const char*
   1.396 +jsd_GetScriptFilename(JSDContext* jsdc, JSDScript *jsdscript);
   1.397 +
   1.398 +extern JSString*
   1.399 +jsd_GetScriptFunctionId(JSDContext* jsdc, JSDScript *jsdscript);
   1.400 +
   1.401 +extern unsigned
   1.402 +jsd_GetScriptBaseLineNumber(JSDContext* jsdc, JSDScript *jsdscript);
   1.403 +
   1.404 +extern unsigned
   1.405 +jsd_GetScriptLineExtent(JSDContext* jsdc, JSDScript *jsdscript);
   1.406 +
   1.407 +extern bool
   1.408 +jsd_SetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc hook, void* callerdata);
   1.409 +
   1.410 +extern bool
   1.411 +jsd_GetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc* hook, void** callerdata);
   1.412 +
   1.413 +extern uintptr_t
   1.414 +jsd_GetClosestPC(JSDContext* jsdc, JSDScript* jsdscript, unsigned line);
   1.415 +
   1.416 +extern unsigned
   1.417 +jsd_GetClosestLine(JSDContext* jsdc, JSDScript* jsdscript, uintptr_t pc);
   1.418 +
   1.419 +extern bool
   1.420 +jsd_GetLinePCs(JSDContext* jsdc, JSDScript* jsdscript,
   1.421 +               unsigned startLine, unsigned maxLines,
   1.422 +               unsigned* count, unsigned** lines, uintptr_t** pcs);
   1.423 +
   1.424 +extern void
   1.425 +jsd_NewScriptHookProc(
   1.426 +                JSContext   *cx,
   1.427 +                const char  *filename,      /* URL this script loads from */
   1.428 +                unsigned       lineno,         /* line where this script starts */
   1.429 +                JSScript    *script,
   1.430 +                JSFunction  *fun,
   1.431 +                void*       callerdata);
   1.432 +
   1.433 +extern void
   1.434 +jsd_DestroyScriptHookProc(
   1.435 +                JSFreeOp    *fop,
   1.436 +                JSScript    *script,
   1.437 +                void*       callerdata);
   1.438 +
   1.439 +/* Script execution hook functions */
   1.440 +
   1.441 +extern bool
   1.442 +jsd_SetExecutionHook(JSDContext*           jsdc,
   1.443 +                     JSDScript*            jsdscript,
   1.444 +                     uintptr_t             pc,
   1.445 +                     JSD_ExecutionHookProc hook,
   1.446 +                     void*                 callerdata);
   1.447 +
   1.448 +extern bool
   1.449 +jsd_ClearExecutionHook(JSDContext*           jsdc,
   1.450 +                       JSDScript*            jsdscript,
   1.451 +                       uintptr_t             pc);
   1.452 +
   1.453 +extern bool
   1.454 +jsd_ClearAllExecutionHooksForScript(JSDContext* jsdc, JSDScript* jsdscript);
   1.455 +
   1.456 +extern bool
   1.457 +jsd_ClearAllExecutionHooks(JSDContext* jsdc);
   1.458 +
   1.459 +extern void
   1.460 +jsd_ScriptCreated(JSDContext* jsdc,
   1.461 +                  JSContext   *cx,
   1.462 +                  const char  *filename,    /* URL this script loads from */
   1.463 +                  unsigned       lineno,       /* line where this script starts */
   1.464 +                  JSScript    *script,
   1.465 +                  JSFunction  *fun);
   1.466 +
   1.467 +extern void
   1.468 +jsd_ScriptDestroyed(JSDContext* jsdc,
   1.469 +                    JSFreeOp    *fop,
   1.470 +                    JSScript    *script);
   1.471 +
   1.472 +/***************************************************************************/
   1.473 +/* Source Text functions */
   1.474 +
   1.475 +extern JSDSourceText*
   1.476 +jsd_IterateSources(JSDContext* jsdc, JSDSourceText **iterp);
   1.477 +
   1.478 +extern JSDSourceText*
   1.479 +jsd_FindSourceForURL(JSDContext* jsdc, const char* url);
   1.480 +
   1.481 +extern const char*
   1.482 +jsd_GetSourceURL(JSDContext* jsdc, JSDSourceText* jsdsrc);
   1.483 +
   1.484 +extern bool
   1.485 +jsd_GetSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc,
   1.486 +                  const char** ppBuf, int* pLen);
   1.487 +
   1.488 +extern void
   1.489 +jsd_ClearSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc);
   1.490 +
   1.491 +extern JSDSourceStatus
   1.492 +jsd_GetSourceStatus(JSDContext* jsdc, JSDSourceText* jsdsrc);
   1.493 +
   1.494 +extern bool
   1.495 +jsd_IsSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc);
   1.496 +
   1.497 +extern void
   1.498 +jsd_SetSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc, bool dirty);
   1.499 +
   1.500 +extern unsigned
   1.501 +jsd_GetSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc);
   1.502 +
   1.503 +extern unsigned
   1.504 +jsd_IncrementSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc);
   1.505 +
   1.506 +extern JSDSourceText*
   1.507 +jsd_NewSourceText(JSDContext* jsdc, const char* url);
   1.508 +
   1.509 +extern JSDSourceText*
   1.510 +jsd_AppendSourceText(JSDContext* jsdc,
   1.511 +                     JSDSourceText* jsdsrc,
   1.512 +                     const char* text,       /* *not* zero terminated */
   1.513 +                     size_t length,
   1.514 +                     JSDSourceStatus status);
   1.515 +
   1.516 +extern JSDSourceText*
   1.517 +jsd_AppendUCSourceText(JSDContext* jsdc,
   1.518 +                       JSDSourceText* jsdsrc,
   1.519 +                       const jschar* text,       /* *not* zero terminated */
   1.520 +                       size_t length,
   1.521 +                       JSDSourceStatus status);
   1.522 +
   1.523 +/* convienence function for adding complete source of url in one call */
   1.524 +extern bool
   1.525 +jsd_AddFullSourceText(JSDContext* jsdc,
   1.526 +                      const char* text,       /* *not* zero terminated */
   1.527 +                      size_t      length,
   1.528 +                      const char* url);
   1.529 +
   1.530 +extern void
   1.531 +jsd_DestroyAllSources(JSDContext* jsdc);
   1.532 +
   1.533 +extern char*
   1.534 +jsd_BuildNormalizedURL(const char* url_string);
   1.535 +
   1.536 +extern void
   1.537 +jsd_StartingEvalUsingFilename(JSDContext* jsdc, const char* url);
   1.538 +
   1.539 +extern void
   1.540 +jsd_FinishedEvalUsingFilename(JSDContext* jsdc, const char* url);
   1.541 +
   1.542 +/***************************************************************************/
   1.543 +/* Interrupt Hook functions */
   1.544 +
   1.545 +extern bool
   1.546 +jsd_SetInterruptHook(JSDContext*           jsdc,
   1.547 +                     JSD_ExecutionHookProc hook,
   1.548 +                     void*                 callerdata);
   1.549 +
   1.550 +extern bool
   1.551 +jsd_ClearInterruptHook(JSDContext* jsdc);
   1.552 +
   1.553 +extern bool
   1.554 +jsd_EnableSingleStepInterrupts(JSDContext* jsdc,
   1.555 +                               JSDScript*  jsdscript,
   1.556 +                               bool        enable);
   1.557 +
   1.558 +extern bool
   1.559 +jsd_SetDebugBreakHook(JSDContext*           jsdc,
   1.560 +                      JSD_ExecutionHookProc hook,
   1.561 +                      void*                 callerdata);
   1.562 +
   1.563 +extern bool
   1.564 +jsd_ClearDebugBreakHook(JSDContext* jsdc);
   1.565 +
   1.566 +extern bool
   1.567 +jsd_SetDebuggerHook(JSDContext*           jsdc,
   1.568 +                    JSD_ExecutionHookProc hook,
   1.569 +                    void*                 callerdata);
   1.570 +
   1.571 +extern bool
   1.572 +jsd_ClearDebuggerHook(JSDContext* jsdc);
   1.573 +
   1.574 +extern JSTrapStatus
   1.575 +jsd_CallExecutionHook(JSDContext*           jsdc,
   1.576 +                      JSContext*            cx,
   1.577 +                      unsigned                 type,
   1.578 +                      JSD_ExecutionHookProc hook,
   1.579 +                      void*                 hookData,
   1.580 +                      jsval*                rval);
   1.581 +
   1.582 +extern bool
   1.583 +jsd_CallCallHook (JSDContext*      jsdc,
   1.584 +                  JSContext*       cx,
   1.585 +                  unsigned            type,
   1.586 +                  JSD_CallHookProc hook,
   1.587 +                  void*            hookData);
   1.588 +
   1.589 +extern bool
   1.590 +jsd_SetThrowHook(JSDContext*           jsdc,
   1.591 +                 JSD_ExecutionHookProc hook,
   1.592 +                 void*                 callerdata);
   1.593 +extern bool
   1.594 +jsd_ClearThrowHook(JSDContext* jsdc);
   1.595 +
   1.596 +extern JSTrapStatus
   1.597 +jsd_DebuggerHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
   1.598 +                    jsval *rval, void *closure);
   1.599 +
   1.600 +extern JSTrapStatus
   1.601 +jsd_ThrowHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
   1.602 +                 jsval *rval, void *closure);
   1.603 +
   1.604 +extern bool
   1.605 +jsd_SetFunctionHook(JSDContext*      jsdc,
   1.606 +                    JSD_CallHookProc hook,
   1.607 +                    void*            callerdata);
   1.608 +
   1.609 +extern bool
   1.610 +jsd_ClearFunctionHook(JSDContext* jsdc);
   1.611 +
   1.612 +extern bool
   1.613 +jsd_SetTopLevelHook(JSDContext*      jsdc,
   1.614 +                    JSD_CallHookProc hook,
   1.615 +                    void*            callerdata);
   1.616 +
   1.617 +extern bool
   1.618 +jsd_ClearTopLevelHook(JSDContext* jsdc);
   1.619 +
   1.620 +/***************************************************************************/
   1.621 +/* Stack Frame functions */
   1.622 +
   1.623 +extern unsigned
   1.624 +jsd_GetCountOfStackFrames(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
   1.625 +
   1.626 +extern JSDStackFrameInfo*
   1.627 +jsd_GetStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
   1.628 +
   1.629 +extern JSContext*
   1.630 +jsd_GetJSContext(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
   1.631 +
   1.632 +extern JSDStackFrameInfo*
   1.633 +jsd_GetCallingStackFrame(JSDContext* jsdc,
   1.634 +                         JSDThreadState* jsdthreadstate,
   1.635 +                         JSDStackFrameInfo* jsdframe);
   1.636 +
   1.637 +extern JSDScript*
   1.638 +jsd_GetScriptForStackFrame(JSDContext* jsdc,
   1.639 +                           JSDThreadState* jsdthreadstate,
   1.640 +                           JSDStackFrameInfo* jsdframe);
   1.641 +
   1.642 +extern uintptr_t
   1.643 +jsd_GetPCForStackFrame(JSDContext* jsdc,
   1.644 +                       JSDThreadState* jsdthreadstate,
   1.645 +                       JSDStackFrameInfo* jsdframe);
   1.646 +
   1.647 +extern JSDValue*
   1.648 +jsd_GetCallObjectForStackFrame(JSDContext* jsdc,
   1.649 +                               JSDThreadState* jsdthreadstate,
   1.650 +                               JSDStackFrameInfo* jsdframe);
   1.651 +
   1.652 +extern JSDValue*
   1.653 +jsd_GetScopeChainForStackFrame(JSDContext* jsdc,
   1.654 +                               JSDThreadState* jsdthreadstate,
   1.655 +                               JSDStackFrameInfo* jsdframe);
   1.656 +
   1.657 +extern bool
   1.658 +jsd_IsStackFrameDebugger(JSDContext* jsdc, 
   1.659 +                         JSDThreadState* jsdthreadstate,
   1.660 +                         JSDStackFrameInfo* jsdframe);
   1.661 +
   1.662 +extern bool
   1.663 +jsd_IsStackFrameConstructing(JSDContext* jsdc, 
   1.664 +                             JSDThreadState* jsdthreadstate,
   1.665 +                             JSDStackFrameInfo* jsdframe);
   1.666 +
   1.667 +extern JSDValue*
   1.668 +jsd_GetThisForStackFrame(JSDContext* jsdc,
   1.669 +                         JSDThreadState* jsdthreadstate,
   1.670 +                         JSDStackFrameInfo* jsdframe);
   1.671 +
   1.672 +extern JSString*
   1.673 +jsd_GetIdForStackFrame(JSDContext* jsdc, 
   1.674 +                       JSDThreadState* jsdthreadstate,
   1.675 +                       JSDStackFrameInfo* jsdframe);
   1.676 +
   1.677 +extern JSDThreadState*
   1.678 +jsd_NewThreadState(JSDContext* jsdc, JSContext *cx);
   1.679 +
   1.680 +extern void
   1.681 +jsd_DestroyThreadState(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
   1.682 +
   1.683 +extern bool
   1.684 +jsd_EvaluateUCScriptInStackFrame(JSDContext* jsdc,
   1.685 +                                 JSDThreadState* jsdthreadstate,
   1.686 +                                 JSDStackFrameInfo* jsdframe,
   1.687 +                                 const jschar *bytes, unsigned length,
   1.688 +                                 const char *filename, unsigned lineno,
   1.689 +                                 bool eatExceptions, JS::MutableHandleValue rval);
   1.690 +
   1.691 +extern bool
   1.692 +jsd_EvaluateScriptInStackFrame(JSDContext* jsdc,
   1.693 +                               JSDThreadState* jsdthreadstate,
   1.694 +                               JSDStackFrameInfo* jsdframe,
   1.695 +                               const char *bytes, unsigned length,
   1.696 +                               const char *filename, unsigned lineno,
   1.697 +                               bool eatExceptions, JS::MutableHandleValue rval);
   1.698 +
   1.699 +extern JSString*
   1.700 +jsd_ValToStringInStackFrame(JSDContext* jsdc,
   1.701 +                            JSDThreadState* jsdthreadstate,
   1.702 +                            JSDStackFrameInfo* jsdframe,
   1.703 +                            jsval val);
   1.704 +
   1.705 +extern bool
   1.706 +jsd_IsValidThreadState(JSDContext*        jsdc,
   1.707 +                       JSDThreadState*    jsdthreadstate);
   1.708 +
   1.709 +extern bool
   1.710 +jsd_IsValidFrameInThreadState(JSDContext*        jsdc,
   1.711 +                              JSDThreadState*    jsdthreadstate,
   1.712 +                              JSDStackFrameInfo* jsdframe);
   1.713 +
   1.714 +extern JSDValue*
   1.715 +jsd_GetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
   1.716 +
   1.717 +extern bool
   1.718 +jsd_SetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate, 
   1.719 +                 JSDValue* jsdval);
   1.720 +
   1.721 +/***************************************************************************/
   1.722 +/* Locking support */
   1.723 +
   1.724 +/* protos are in js_lock.h for:
   1.725 + *      jsd_CreateLock
   1.726 + *      jsd_Lock
   1.727 + *      jsd_Unlock
   1.728 + *      jsd_IsLocked
   1.729 + *      jsd_CurrentThread
   1.730 + */
   1.731 +
   1.732 +#ifdef JSD_THREADSAFE
   1.733 +
   1.734 +/* the system-wide lock */
   1.735 +extern JSDStaticLock* _jsd_global_lock;
   1.736 +#define JSD_LOCK()                               \
   1.737 +    JS_BEGIN_MACRO                               \
   1.738 +        if(!_jsd_global_lock)                    \
   1.739 +            _jsd_global_lock = jsd_CreateLock(); \
   1.740 +        MOZ_ASSERT(_jsd_global_lock);            \
   1.741 +        jsd_Lock(_jsd_global_lock);              \
   1.742 +    JS_END_MACRO
   1.743 +
   1.744 +#define JSD_UNLOCK()                             \
   1.745 +    JS_BEGIN_MACRO                               \
   1.746 +        MOZ_ASSERT(_jsd_global_lock);            \
   1.747 +        jsd_Unlock(_jsd_global_lock);            \
   1.748 +    JS_END_MACRO
   1.749 +
   1.750 +/* locks for the subsystems of a given context */
   1.751 +#define JSD_INIT_LOCKS(jsdc)                                       \
   1.752 +    ( (nullptr != (jsdc->scriptsLock      = jsd_CreateLock())) &&  \
   1.753 +      (nullptr != (jsdc->sourceTextLock   = jsd_CreateLock())) &&  \
   1.754 +      (nullptr != (jsdc->atomsLock        = jsd_CreateLock())) &&  \
   1.755 +      (nullptr != (jsdc->objectsLock      = jsd_CreateLock())) &&  \
   1.756 +      (nullptr != (jsdc->threadStatesLock = jsd_CreateLock())) )
   1.757 +
   1.758 +#define JSD_LOCK_SCRIPTS(jsdc)        jsd_Lock(jsdc->scriptsLock)
   1.759 +#define JSD_UNLOCK_SCRIPTS(jsdc)      jsd_Unlock(jsdc->scriptsLock)
   1.760 +
   1.761 +#define JSD_LOCK_SOURCE_TEXT(jsdc)    jsd_Lock(jsdc->sourceTextLock)
   1.762 +#define JSD_UNLOCK_SOURCE_TEXT(jsdc)  jsd_Unlock(jsdc->sourceTextLock)
   1.763 +
   1.764 +#define JSD_LOCK_ATOMS(jsdc)          jsd_Lock(jsdc->atomsLock)
   1.765 +#define JSD_UNLOCK_ATOMS(jsdc)        jsd_Unlock(jsdc->atomsLock)
   1.766 +
   1.767 +#define JSD_LOCK_OBJECTS(jsdc)        jsd_Lock(jsdc->objectsLock)
   1.768 +#define JSD_UNLOCK_OBJECTS(jsdc)      jsd_Unlock(jsdc->objectsLock)
   1.769 +
   1.770 +#define JSD_LOCK_THREADSTATES(jsdc)   jsd_Lock(jsdc->threadStatesLock)
   1.771 +#define JSD_UNLOCK_THREADSTATES(jsdc) jsd_Unlock(jsdc->threadStatesLock)
   1.772 +
   1.773 +#else  /* !JSD_THREADSAFE */
   1.774 +
   1.775 +#define JSD_LOCK()                    ((void)0)
   1.776 +#define JSD_UNLOCK()                  ((void)0)
   1.777 +
   1.778 +#define JSD_INIT_LOCKS(jsdc)          1
   1.779 +
   1.780 +#define JSD_LOCK_SCRIPTS(jsdc)        ((void)0)
   1.781 +#define JSD_UNLOCK_SCRIPTS(jsdc)      ((void)0)
   1.782 +
   1.783 +#define JSD_LOCK_SOURCE_TEXT(jsdc)    ((void)0)
   1.784 +#define JSD_UNLOCK_SOURCE_TEXT(jsdc)  ((void)0)
   1.785 +
   1.786 +#define JSD_LOCK_ATOMS(jsdc)          ((void)0)
   1.787 +#define JSD_UNLOCK_ATOMS(jsdc)        ((void)0)
   1.788 +
   1.789 +#define JSD_LOCK_OBJECTS(jsdc)        ((void)0)
   1.790 +#define JSD_UNLOCK_OBJECTS(jsdc)      ((void)0)
   1.791 +
   1.792 +#define JSD_LOCK_THREADSTATES(jsdc)   ((void)0)
   1.793 +#define JSD_UNLOCK_THREADSTATES(jsdc) ((void)0)
   1.794 +
   1.795 +#endif /* JSD_THREADSAFE */
   1.796 +
   1.797 +/* NOTE: These are intended for ASSERTs. Thus we supply checks for both
   1.798 + * LOCKED and UNLOCKED (rather that just LOCKED and !LOCKED) so that in
   1.799 + * the DEBUG non-Threadsafe case we can have an ASSERT that always succeeds
   1.800 + * without having to special case things in the code.
   1.801 + */
   1.802 +#if defined(JSD_THREADSAFE) && defined(DEBUG)
   1.803 +#define JSD_SCRIPTS_LOCKED(jsdc)        (jsd_IsLocked(jsdc->scriptsLock))
   1.804 +#define JSD_SOURCE_TEXT_LOCKED(jsdc)    (jsd_IsLocked(jsdc->sourceTextLock))
   1.805 +#define JSD_ATOMS_LOCKED(jsdc)          (jsd_IsLocked(jsdc->atomsLock))
   1.806 +#define JSD_OBJECTS_LOCKED(jsdc)        (jsd_IsLocked(jsdc->objectsLock))
   1.807 +#define JSD_THREADSTATES_LOCKED(jsdc)   (jsd_IsLocked(jsdc->threadStatesLock))
   1.808 +#define JSD_SCRIPTS_UNLOCKED(jsdc)      (!jsd_IsLocked(jsdc->scriptsLock))
   1.809 +#define JSD_SOURCE_TEXT_UNLOCKED(jsdc)  (!jsd_IsLocked(jsdc->sourceTextLock))
   1.810 +#define JSD_ATOMS_UNLOCKED(jsdc)        (!jsd_IsLocked(jsdc->atomsLock))
   1.811 +#define JSD_OBJECTS_UNLOCKED(jsdc)      (!jsd_IsLocked(jsdc->objectsLock))
   1.812 +#define JSD_THREADSTATES_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->threadStatesLock))
   1.813 +#else
   1.814 +#define JSD_SCRIPTS_LOCKED(jsdc)        1
   1.815 +#define JSD_SOURCE_TEXT_LOCKED(jsdc)    1
   1.816 +#define JSD_ATOMS_LOCKED(jsdc)          1
   1.817 +#define JSD_OBJECTS_LOCKED(jsdc)        1
   1.818 +#define JSD_THREADSTATES_LOCKED(jsdc)   1
   1.819 +#define JSD_SCRIPTS_UNLOCKED(jsdc)      1
   1.820 +#define JSD_SOURCE_TEXT_UNLOCKED(jsdc)  1
   1.821 +#define JSD_ATOMS_UNLOCKED(jsdc)        1
   1.822 +#define JSD_OBJECTS_UNLOCKED(jsdc)      1
   1.823 +#define JSD_THREADSTATES_UNLOCKED(jsdc) 1
   1.824 +#endif /* defined(JSD_THREADSAFE) && defined(DEBUG) */
   1.825 +
   1.826 +/***************************************************************************/
   1.827 +/* Threading support */
   1.828 +
   1.829 +#ifdef JSD_THREADSAFE
   1.830 +
   1.831 +#define JSD_CURRENT_THREAD()        jsd_CurrentThread()
   1.832 +
   1.833 +#else  /* !JSD_THREADSAFE */
   1.834 +
   1.835 +#define JSD_CURRENT_THREAD()        ((void*)0)
   1.836 +
   1.837 +#endif /* JSD_THREADSAFE */
   1.838 +
   1.839 +/***************************************************************************/
   1.840 +/* Dangerous thread support */
   1.841 +
   1.842 +#ifdef JSD_HAS_DANGEROUS_THREAD
   1.843 +
   1.844 +#define JSD_IS_DANGEROUS_THREAD(jsdc) \
   1.845 +    (JSD_CURRENT_THREAD() == jsdc->dangerousThread)
   1.846 +
   1.847 +#else  /* !JSD_HAS_DANGEROUS_THREAD */
   1.848 +
   1.849 +#define JSD_IS_DANGEROUS_THREAD(jsdc)   0
   1.850 +
   1.851 +#endif /* JSD_HAS_DANGEROUS_THREAD */
   1.852 +
   1.853 +/***************************************************************************/
   1.854 +/* Value and Property Functions */
   1.855 +
   1.856 +extern JSDValue*
   1.857 +jsd_NewValue(JSDContext* jsdc, jsval val);
   1.858 +
   1.859 +extern void
   1.860 +jsd_DropValue(JSDContext* jsdc, JSDValue* jsdval);
   1.861 +
   1.862 +extern jsval
   1.863 +jsd_GetValueWrappedJSVal(JSDContext* jsdc, JSDValue* jsdval);
   1.864 +
   1.865 +extern void
   1.866 +jsd_RefreshValue(JSDContext* jsdc, JSDValue* jsdval);
   1.867 +
   1.868 +/**************************************************/
   1.869 +
   1.870 +extern bool
   1.871 +jsd_IsValueObject(JSDContext* jsdc, JSDValue* jsdval);
   1.872 +
   1.873 +extern bool
   1.874 +jsd_IsValueNumber(JSDContext* jsdc, JSDValue* jsdval);
   1.875 +
   1.876 +extern bool
   1.877 +jsd_IsValueInt(JSDContext* jsdc, JSDValue* jsdval);
   1.878 +
   1.879 +extern bool
   1.880 +jsd_IsValueDouble(JSDContext* jsdc, JSDValue* jsdval);
   1.881 +
   1.882 +extern bool
   1.883 +jsd_IsValueString(JSDContext* jsdc, JSDValue* jsdval);
   1.884 +
   1.885 +extern bool
   1.886 +jsd_IsValueBoolean(JSDContext* jsdc, JSDValue* jsdval);
   1.887 +
   1.888 +extern bool
   1.889 +jsd_IsValueNull(JSDContext* jsdc, JSDValue* jsdval);
   1.890 +
   1.891 +extern bool
   1.892 +jsd_IsValueVoid(JSDContext* jsdc, JSDValue* jsdval);
   1.893 +
   1.894 +extern bool
   1.895 +jsd_IsValuePrimitive(JSDContext* jsdc, JSDValue* jsdval);
   1.896 +
   1.897 +extern bool
   1.898 +jsd_IsValueFunction(JSDContext* jsdc, JSDValue* jsdval);
   1.899 +
   1.900 +extern bool
   1.901 +jsd_IsValueNative(JSDContext* jsdc, JSDValue* jsdval);
   1.902 +
   1.903 +/**************************************************/
   1.904 +
   1.905 +extern bool
   1.906 +jsd_GetValueBoolean(JSDContext* jsdc, JSDValue* jsdval);
   1.907 +
   1.908 +extern int32_t
   1.909 +jsd_GetValueInt(JSDContext* jsdc, JSDValue* jsdval);
   1.910 +
   1.911 +extern double
   1.912 +jsd_GetValueDouble(JSDContext* jsdc, JSDValue* jsdval);
   1.913 +
   1.914 +extern JSString*
   1.915 +jsd_GetValueString(JSDContext* jsdc, JSDValue* jsdval);
   1.916 +
   1.917 +extern JSString*
   1.918 +jsd_GetValueFunctionId(JSDContext* jsdc, JSDValue* jsdval);
   1.919 +
   1.920 +extern JSFunction*
   1.921 +jsd_GetValueFunction(JSDContext* jsdc, JSDValue* jsdval);
   1.922 +
   1.923 +/**************************************************/
   1.924 +
   1.925 +extern unsigned
   1.926 +jsd_GetCountOfProperties(JSDContext* jsdc, JSDValue* jsdval);
   1.927 +
   1.928 +extern JSDProperty*
   1.929 +jsd_IterateProperties(JSDContext* jsdc, JSDValue* jsdval, JSDProperty **iterp);
   1.930 +
   1.931 +extern JSDProperty*
   1.932 +jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* name);
   1.933 +
   1.934 +extern JSDValue*
   1.935 +jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval);
   1.936 +
   1.937 +extern JSDValue*
   1.938 +jsd_GetValueParent(JSDContext* jsdc, JSDValue* jsdval);
   1.939 +
   1.940 +extern JSDValue*
   1.941 +jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval);
   1.942 +
   1.943 +extern const char*
   1.944 +jsd_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval);
   1.945 +
   1.946 +extern JSDScript*
   1.947 +jsd_GetScriptForValue(JSDContext* jsdc, JSDValue* jsdval);
   1.948 +
   1.949 +/**************************************************/
   1.950 +
   1.951 +extern void
   1.952 +jsd_DropProperty(JSDContext* jsdc, JSDProperty* jsdprop);
   1.953 +
   1.954 +extern JSDValue*
   1.955 +jsd_GetPropertyName(JSDContext* jsdc, JSDProperty* jsdprop);
   1.956 +
   1.957 +extern JSDValue*
   1.958 +jsd_GetPropertyValue(JSDContext* jsdc, JSDProperty* jsdprop);
   1.959 +
   1.960 +extern JSDValue*
   1.961 +jsd_GetPropertyAlias(JSDContext* jsdc, JSDProperty* jsdprop);
   1.962 +
   1.963 +extern unsigned
   1.964 +jsd_GetPropertyFlags(JSDContext* jsdc, JSDProperty* jsdprop);
   1.965 +
   1.966 +/**************************************************/
   1.967 +/* Stepping Functions */
   1.968 +
   1.969 +extern void *
   1.970 +jsd_FunctionCallHook(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing,
   1.971 +                     bool before, bool *ok, void *closure);
   1.972 +
   1.973 +extern void *
   1.974 +jsd_TopLevelCallHook(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing,
   1.975 +                     bool before, bool *ok, void *closure);
   1.976 +
   1.977 +/**************************************************/
   1.978 +/* Object Functions */
   1.979 +
   1.980 +extern bool
   1.981 +jsd_InitObjectManager(JSDContext* jsdc);
   1.982 +
   1.983 +extern void
   1.984 +jsd_DestroyObjectManager(JSDContext* jsdc);
   1.985 +
   1.986 +extern void
   1.987 +jsd_DestroyObjects(JSDContext* jsdc);
   1.988 +
   1.989 +extern void
   1.990 +jsd_Constructing(JSDContext* jsdc, JSContext *cx, JSObject *obj,
   1.991 +                 JSAbstractFramePtr frame);
   1.992 +
   1.993 +extern JSDObject*
   1.994 +jsd_IterateObjects(JSDContext* jsdc, JSDObject** iterp);
   1.995 +
   1.996 +extern JSObject*
   1.997 +jsd_GetWrappedObject(JSDContext* jsdc, JSDObject* jsdobj);
   1.998 +
   1.999 +extern const char*
  1.1000 +jsd_GetObjectNewURL(JSDContext* jsdc, JSDObject* jsdobj);
  1.1001 +
  1.1002 +extern unsigned
  1.1003 +jsd_GetObjectNewLineNumber(JSDContext* jsdc, JSDObject* jsdobj);
  1.1004 +
  1.1005 +extern const char*
  1.1006 +jsd_GetObjectConstructorURL(JSDContext* jsdc, JSDObject* jsdobj);
  1.1007 +
  1.1008 +extern unsigned
  1.1009 +jsd_GetObjectConstructorLineNumber(JSDContext* jsdc, JSDObject* jsdobj);
  1.1010 +
  1.1011 +extern const char*
  1.1012 +jsd_GetObjectConstructorName(JSDContext* jsdc, JSDObject* jsdobj);
  1.1013 +
  1.1014 +extern JSDObject*
  1.1015 +jsd_GetJSDObjectForJSObject(JSDContext* jsdc, JSObject* jsobj);
  1.1016 +
  1.1017 +extern JSDObject*
  1.1018 +jsd_GetObjectForValue(JSDContext* jsdc, JSDValue* jsdval);
  1.1019 +
  1.1020 +/*
  1.1021 +* returns new refcounted JSDValue
  1.1022 +*/
  1.1023 +extern JSDValue*
  1.1024 +jsd_GetValueForObject(JSDContext* jsdc, JSDObject* jsdobj);
  1.1025 +
  1.1026 +/**************************************************/
  1.1027 +/* Atom Functions */
  1.1028 +
  1.1029 +extern bool
  1.1030 +jsd_CreateAtomTable(JSDContext* jsdc);
  1.1031 +
  1.1032 +extern void
  1.1033 +jsd_DestroyAtomTable(JSDContext* jsdc);
  1.1034 +
  1.1035 +extern JSDAtom*
  1.1036 +jsd_AddAtom(JSDContext* jsdc, const char* str);
  1.1037 +
  1.1038 +extern JSDAtom*
  1.1039 +jsd_CloneAtom(JSDContext* jsdc, JSDAtom* atom);
  1.1040 +
  1.1041 +extern void
  1.1042 +jsd_DropAtom(JSDContext* jsdc, JSDAtom* atom);
  1.1043 +
  1.1044 +#define JSD_ATOM_TO_STRING(a) ((const char*)((a)->str))
  1.1045 +
  1.1046 +struct AutoSaveExceptionState {
  1.1047 +    AutoSaveExceptionState(JSContext *cx) : mCx(cx) {
  1.1048 +        mState = JS_SaveExceptionState(cx);
  1.1049 +    }
  1.1050 +    ~AutoSaveExceptionState() {
  1.1051 +        JS_RestoreExceptionState(mCx, mState);
  1.1052 +    }
  1.1053 +    JSContext *mCx;
  1.1054 +    JSExceptionState *mState;
  1.1055 +};
  1.1056 +
  1.1057 +#endif /* jsd_h___ */

mercurial