Bug 550784 - [OOPP] Flash deadlocks during script evals that trigger focus related...
[mozilla-central.git] / js / jsd / jsdebug.h
blobd7ea5a34c1673f3a06d1c0f0d6f8aab4b216d62c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 * Header for JavaScript Debugging support - All public functions
42 #ifndef jsdebug_h___
43 #define jsdebug_h___
45 /* Get jstypes.h included first. After that we can use PR macros for doing
46 * this extern "C" stuff!
48 #ifdef __cplusplus
49 extern "C"
51 #endif
52 #include "jstypes.h"
53 #ifdef __cplusplus
55 #endif
57 JS_BEGIN_EXTERN_C
58 #include "jsapi.h"
59 #include "jsdbgapi.h"
60 #ifdef LIVEWIRE
61 #include "lwdbgapi.h"
62 #endif
63 JS_END_EXTERN_C
65 JS_BEGIN_EXTERN_C
68 * The linkage of JSD API functions differs depending on whether the file is
69 * used within the JSD library or not. Any source file within the JSD
70 * libraray should define EXPORT_JSD_API whereas any client of the library
71 * should not.
73 #ifdef EXPORT_JSD_API
74 #define JSD_PUBLIC_API(t) JS_EXPORT_API(t)
75 #define JSD_PUBLIC_DATA(t) JS_EXPORT_DATA(t)
76 #else
77 #define JSD_PUBLIC_API(t) JS_IMPORT_API(t)
78 #define JSD_PUBLIC_DATA(t) JS_IMPORT_DATA(t)
79 #endif
81 #define JSD_FRIEND_API(t) JSD_PUBLIC_API(t)
82 #define JSD_FRIEND_DATA(t) JSD_PUBLIC_DATA(t)
84 /***************************************************************************/
85 /* Opaque typedefs for handles */
87 typedef struct JSDContext JSDContext;
88 typedef struct JSDScript JSDScript;
89 typedef struct JSDSourceText JSDSourceText;
90 typedef struct JSDThreadState JSDThreadState;
91 typedef struct JSDStackFrameInfo JSDStackFrameInfo;
92 typedef struct JSDValue JSDValue;
93 typedef struct JSDProperty JSDProperty;
94 typedef struct JSDObject JSDObject;
96 /***************************************************************************/
97 /* High Level calls */
100 * callback stuff for calls in EXE to be accessed by this code
101 * when it lives in an explicitly loaded DLL
105 * This callback allows JSD to inform the embedding when JSD has been
106 * turned on or off. This is especially useful in the Java-based debugging
107 * system used in mozilla because the debugger applet controls starting
108 * up the JSD system.
110 typedef void
111 (* JSD_SetContextProc)(JSDContext* jsdc, void* user);
113 /* This struct could have more fields in future versions */
114 typedef struct
116 uintN size; /* size of this struct (init before use)*/
117 JSD_SetContextProc setContext;
118 } JSD_UserCallbacks;
121 * Used by an embedding to tell JSD what JSRuntime to use and to set
122 * callbacks without starting up JSD. This assumes only one JSRuntime
123 * will be used. This exists to support the mozilla Java-based debugger
124 * system.
126 extern JSD_PUBLIC_API(void)
127 JSD_SetUserCallbacks(JSRuntime* jsrt,
128 JSD_UserCallbacks* callbacks,
129 void* user);
132 * Startup JSD.
133 * This version of the init function requires that JSD_SetUserCallbacks()
134 * has been previously called (with a non-NULL callback struct pointer)
136 extern JSD_PUBLIC_API(JSDContext*)
137 JSD_DebuggerOn(void);
140 * Startup JSD on a particular JSRuntime with (optional) callbacks
142 extern JSD_PUBLIC_API(JSDContext*)
143 JSD_DebuggerOnForUser(JSRuntime* jsrt,
144 JSD_UserCallbacks* callbacks,
145 void* user);
148 * Shutdown JSD for this JSDContext
150 extern JSD_PUBLIC_API(void)
151 JSD_DebuggerOff(JSDContext* jsdc);
154 * Pause JSD for this JSDContext
156 extern JSD_PUBLIC_API(void)
157 JSD_DebuggerPause(JSDContext* jsdc);
160 * Unpause JSD for this JSDContext
162 extern JSD_PUBLIC_API(void)
163 JSD_DebuggerUnpause(JSDContext* jsdc);
166 * Get the Major Version (initial JSD release used major version = 1)
168 extern JSD_PUBLIC_API(uintN)
169 JSD_GetMajorVersion(void);
172 * Get the Minor Version (initial JSD release used minor version = 0)
174 extern JSD_PUBLIC_API(uintN)
175 JSD_GetMinorVersion(void);
178 * Returns a 'dumb' JSContext that can be used for utility purposes as needed
180 extern JSD_PUBLIC_API(JSContext*)
181 JSD_GetDefaultJSContext(JSDContext* jsdc);
184 * Set the private data for this context, returns previous value
186 extern JSD_PUBLIC_API(void *)
187 JSD_SetContextPrivate(JSDContext *jsdc, void *data);
190 * Get the private data for this context
192 extern JSD_PUBLIC_API(void *)
193 JSD_GetContextPrivate(JSDContext *jsdc);
196 * Clear profile data for all scripts
198 extern JSD_PUBLIC_API(void)
199 JSD_ClearAllProfileData(JSDContext* jsdc);
202 * Context flags.
205 /* Include native frames in JSDThreadStates. */
206 #define JSD_INCLUDE_NATIVE_FRAMES 0x01
208 * Normally, if a script has a 0 in JSD_SCRIPT_PROFILE_BIT it is included in
209 * profile data, otherwise it is not profiled. Setting the JSD_PROFILE_WHEN_SET
210 * flag reverses this convention.
212 #define JSD_PROFILE_WHEN_SET 0x02
214 * Normally, when the script in the top frame of a thread state has a 1 in
215 * JSD_SCRIPT_DEBUG_BIT, the execution hook is ignored. Setting the
216 * JSD_DEBUG_WHEN_SET flag reverses this convention.
218 #define JSD_DEBUG_WHEN_SET 0x04
220 * When this flag is set the internal call hook will collect profile data.
222 #define JSD_COLLECT_PROFILE_DATA 0x08
224 * When this flag is set, stack frames that are disabled for debugging
225 * will not appear in the call stack chain.
227 #define JSD_HIDE_DISABLED_FRAMES 0x10
229 * When this flag is set, the debugger will only check the
230 * JSD_SCRIPT_DEBUG_BIT on the top (most recent) stack frame. This
231 * makes it possible to stop in an enabled frame which was called from
232 * a stack that contains a disabled frame.
234 * When this flag is *not* set, any stack that contains a disabled frame
235 * will not be debugged (the execution hook will not be invoked.)
237 * This only applies when the reason for calling the hook would have
238 * been JSD_HOOK_INTERRUPTED or JSD_HOOK_THROW. JSD_HOOK_BREAKPOINT,
239 * JSD_HOOK_DEBUG_REQUESTED, and JSD_HOOK_DEBUGGER_KEYWORD always stop,
240 * regardless of this setting, as long as the top frame is not disabled.
242 * If JSD_HIDE_DISABLED_FRAMES is set, this is effectively set as well.
244 #define JSD_MASK_TOP_FRAME_ONLY 0x20
246 * When this flag is set, object creation will not be tracked. This will
247 * reduce the performance price you pay by enabling the debugger.
249 #define JSD_DISABLE_OBJECT_TRACE 0x40
251 extern JSD_PUBLIC_API(void)
252 JSD_SetContextFlags (JSDContext* jsdc, uint32 flags);
254 extern JSD_PUBLIC_API(uint32)
255 JSD_GetContextFlags (JSDContext* jsdc);
258 * Notify JSD that this JSContext is 'in use'. This allows JSD to hook the
259 * ErrorReporter. For the most part this is done automatically whenever
260 * events like script loading happen. But, it is a good idea to call this
261 * from the embedding when new contexts come into use.
263 extern JSD_PUBLIC_API(void)
264 JSD_JSContextInUse(JSDContext* jsdc, JSContext* context);
267 * Find the JSDContext (if any) associated with the JSRuntime of a
268 * given JSContext.
270 extern JSD_PUBLIC_API(JSDContext*)
271 JSD_JSDContextForJSContext(JSContext* context);
273 /***************************************************************************/
274 /* Script functions */
277 * Lock the entire script subsystem. This grabs a highlevel lock that
278 * protects the JSD internal information about scripts. It is important
279 * to wrap script related calls in this lock in multithreaded situations
280 * -- i.e. where the debugger is running on a different thread than the
281 * interpreter -- or when multiple debugger threads may be accessing this
282 * subsystem. It is safe (and best) to use this locking even if the
283 * environment might not be multi-threaded. Safely nestable.
285 extern JSD_PUBLIC_API(void)
286 JSD_LockScriptSubsystem(JSDContext* jsdc);
289 * Unlock the entire script subsystem -- see JSD_LockScriptSubsystem
291 extern JSD_PUBLIC_API(void)
292 JSD_UnlockScriptSubsystem(JSDContext* jsdc);
295 * Iterate through all the active scripts for this JSDContext.
296 * NOTE: must initialize iterp to NULL to start iteration.
297 * NOTE: must lock and unlock the subsystem
298 * example:
300 * JSDScript jsdscript;
301 * JSDScript iter = NULL;
303 * JSD_LockScriptSubsystem(jsdc);
304 * while((jsdscript = JSD_IterateScripts(jsdc, &iter)) != NULL) {
305 * *** use jsdscript here ***
307 * JSD_UnlockScriptSubsystem(jsdc);
309 extern JSD_PUBLIC_API(JSDScript*)
310 JSD_IterateScripts(JSDContext* jsdc, JSDScript **iterp);
313 * Get the number of times this script has been called.
315 extern JSD_PUBLIC_API(uintN)
316 JSD_GetScriptCallCount(JSDContext* jsdc, JSDScript *script);
319 * Get the max number of times this script called itself, directly or indirectly.
321 extern JSD_PUBLIC_API(uintN)
322 JSD_GetScriptMaxRecurseDepth(JSDContext* jsdc, JSDScript *script);
325 * Get the shortest execution time recorded.
327 extern JSD_PUBLIC_API(jsdouble)
328 JSD_GetScriptMinExecutionTime(JSDContext* jsdc, JSDScript *script);
331 * Get the longest execution time recorded.
333 extern JSD_PUBLIC_API(jsdouble)
334 JSD_GetScriptMaxExecutionTime(JSDContext* jsdc, JSDScript *script);
337 * Get the total amount of time spent in this script.
339 extern JSD_PUBLIC_API(jsdouble)
340 JSD_GetScriptTotalExecutionTime(JSDContext* jsdc, JSDScript *script);
343 * Get the shortest execution time recorded, excluding time spent in called
344 * functions.
346 extern JSD_PUBLIC_API(jsdouble)
347 JSD_GetScriptMinOwnExecutionTime(JSDContext* jsdc, JSDScript *script);
350 * Get the longest execution time recorded, excluding time spent in called
351 * functions.
353 extern JSD_PUBLIC_API(jsdouble)
354 JSD_GetScriptMaxOwnExecutionTime(JSDContext* jsdc, JSDScript *script);
357 * Get the total amount of time spent in this script, excluding time spent
358 * in called functions.
360 extern JSD_PUBLIC_API(jsdouble)
361 JSD_GetScriptTotalOwnExecutionTime(JSDContext* jsdc, JSDScript *script);
364 * Clear profile data for this script.
366 extern JSD_PUBLIC_API(void)
367 JSD_ClearScriptProfileData(JSDContext* jsdc, JSDScript *script);
370 * Get the JSScript for a JSDScript
372 extern JSD_PUBLIC_API(JSScript*)
373 JSD_GetJSScript(JSDContext* jsdc, JSDScript *script);
376 * Get the JSFunction for a JSDScript
378 extern JSD_PUBLIC_API(JSFunction*)
379 JSD_GetJSFunction(JSDContext* jsdc, JSDScript *script);
382 * Determines whether or not to collect profile information for this
383 * script. The context flag JSD_PROFILE_WHEN_SET decides the logic.
385 #define JSD_SCRIPT_PROFILE_BIT 0x01
387 * Determines whether or not to ignore breakpoints, etc. in this script.
388 * The context flag JSD_DEBUG_WHEN_SET decides the logic.
390 #define JSD_SCRIPT_DEBUG_BIT 0x02
392 extern JSD_PUBLIC_API(uint32)
393 JSD_GetScriptFlags(JSDContext *jsdc, JSDScript* jsdscript);
395 extern JSD_PUBLIC_API(void)
396 JSD_SetScriptFlags(JSDContext *jsdc, JSDScript* jsdscript, uint32 flags);
399 * Set the private data for this script, returns previous value
401 extern JSD_PUBLIC_API(void *)
402 JSD_SetScriptPrivate(JSDScript* jsdscript, void *data);
405 * Get the private data for this script
407 extern JSD_PUBLIC_API(void *)
408 JSD_GetScriptPrivate(JSDScript* jsdscript);
411 * Determine if this script is still loaded in the interpreter
413 extern JSD_PUBLIC_API(JSBool)
414 JSD_IsActiveScript(JSDContext* jsdc, JSDScript *jsdscript);
417 * Get the filename associated with this script
419 extern JSD_PUBLIC_API(const char*)
420 JSD_GetScriptFilename(JSDContext* jsdc, JSDScript *jsdscript);
423 * Get the function name associated with this script (NULL if not a function)
425 extern JSD_PUBLIC_API(const char*)
426 JSD_GetScriptFunctionName(JSDContext* jsdc, JSDScript *jsdscript);
429 * Get the base linenumber of the sourcefile from which this script was loaded.
430 * This is one-based -- i.e. the first line of a file is line '1'. This may
431 * return 0 if this infomation is unknown.
433 extern JSD_PUBLIC_API(uintN)
434 JSD_GetScriptBaseLineNumber(JSDContext* jsdc, JSDScript *jsdscript);
437 * Get the count of source lines associated with this script (1 or greater)
439 extern JSD_PUBLIC_API(uintN)
440 JSD_GetScriptLineExtent(JSDContext* jsdc, JSDScript *jsdscript);
443 * Declaration of callback for notification of script creation and destruction.
444 * 'creating' is JS_TRUE if creating new script, JS_FALSE if destroying existing
445 * script (callback called just before actual destruction).
446 * 'callerdata' is what was passed to JSD_SetScriptHook to set the hook.
448 typedef void
449 (* JSD_ScriptHookProc)(JSDContext* jsdc,
450 JSDScript* jsdscript,
451 JSBool creating,
452 void* callerdata);
455 * Set a hook to be called when scripts are created or destroyed (loaded or
456 * unloaded).
457 * 'callerdata' can be whatever you want it to be.
459 extern JSD_PUBLIC_API(JSBool)
460 JSD_SetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc hook, void* callerdata);
463 * Get the current script hook.
465 extern JSD_PUBLIC_API(JSBool)
466 JSD_GetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc* hook, void** callerdata);
469 * Get a 'Program Counter' value for a given line. This represents the location
470 * of the first bit of executable code for this line of source. This 'pc' should
471 * be considered an opaque handle.
472 * 0 is returned for invalid scripts, or lines that lie outside the script.
473 * If no code is on the given line, then the returned pc represents the first
474 * code within the script (if any) after the given line.
475 * This function can be used to set breakpoints -- see JSD_SetExecutionHook
477 extern JSD_PUBLIC_API(jsuword)
478 JSD_GetClosestPC(JSDContext* jsdc, JSDScript* jsdscript, uintN line);
481 * Get the source line number for a given 'Program Counter' location.
482 * Returns 0 if no source line information is appropriate (or available) for
483 * the given pc.
485 extern JSD_PUBLIC_API(uintN)
486 JSD_GetClosestLine(JSDContext* jsdc, JSDScript* jsdscript, jsuword pc);
488 /* these are only used in cases where scripts are created outside of JS*/
491 * Direct call to notify JSD that a script has been created.
492 * Embeddings that use the normal jsapi script functions need not call this.
493 * Any embedding that follows the (discouraged!) practice of contructing script
494 * structures manually should call this function to inform JSD. (older ssjs
495 * systems do this).
497 extern JSD_PUBLIC_API(void)
498 JSD_ScriptCreated(JSDContext* jsdc,
499 JSContext *cx,
500 const char *filename, /* URL this script loads from */
501 uintN lineno, /* line where this script starts */
502 JSScript *script,
503 JSFunction *fun);
506 * see JSD_ScriptCreated
508 extern JSD_PUBLIC_API(void)
509 JSD_ScriptDestroyed(JSDContext* jsdc,
510 JSContext *cx,
511 JSScript *script);
513 /***************************************************************************/
514 /* Source Text functions */
517 * In some embeddings (e.g. mozilla) JavaScript source code from a 'file' may be
518 * execute before the entire 'file' has even been loaded. This system supports
519 * access to such incrmentally loaded source. It also allows for the possibility
520 * that source loading may fail or be aborted (though the source that did load
521 * may still be usable). Remember that this source is the entire 'file'
522 * contents and that the JavaScript code may only be part of that source.
524 * For any given URL there can only be one source text item (the most recently
525 * loaded).
528 /* these coorespond to netscape.jsdebug.SourceTextItem.java values -
529 * change in both places if anywhere
532 typedef enum
534 JSD_SOURCE_INITED = 0, /* initialized, but contains no source yet */
535 JSD_SOURCE_PARTIAL = 1, /* some source loaded, more expected */
536 JSD_SOURCE_COMPLETED = 2, /* all source finished loading */
537 JSD_SOURCE_ABORTED = 3, /* user aborted loading, some may be loaded */
538 JSD_SOURCE_FAILED = 4, /* loading failed, some may be loaded */
539 JSD_SOURCE_CLEARED = 5 /* text has been cleared by debugger */
540 } JSDSourceStatus;
543 * Lock the entire source text subsystem. This grabs a highlevel lock that
544 * protects the JSD internal information about sources. It is important to
545 * wrap source text related calls in this lock in multithreaded situations
546 * -- i.e. where the debugger is running on a different thread than the
547 * interpreter (or the loader of sources) -- or when multiple debugger
548 * threads may be accessing this subsystem. It is safe (and best) to use
549 * this locking even if the environment might not be multi-threaded.
550 * Safely Nestable.
552 extern JSD_PUBLIC_API(void)
553 JSD_LockSourceTextSubsystem(JSDContext* jsdc);
556 * Unlock the entire source text subsystem. see JSD_LockSourceTextSubsystem.
558 extern JSD_PUBLIC_API(void)
559 JSD_UnlockSourceTextSubsystem(JSDContext* jsdc);
562 * Iterate the source test items. Use the same pattern of calls shown in
563 * the example for JSD_IterateScripts - NOTE that the SourceTextSubsystem.
564 * must be locked before and unlocked after iterating.
566 extern JSD_PUBLIC_API(JSDSourceText*)
567 JSD_IterateSources(JSDContext* jsdc, JSDSourceText **iterp);
570 * Find the source text item for the given URL (or filename - or whatever
571 * string the given embedding uses to describe source locations).
572 * Returns NULL is not found.
574 extern JSD_PUBLIC_API(JSDSourceText*)
575 JSD_FindSourceForURL(JSDContext* jsdc, const char* url);
578 * Get the URL string associated with the given source text item
580 extern JSD_PUBLIC_API(const char*)
581 JSD_GetSourceURL(JSDContext* jsdc, JSDSourceText* jsdsrc);
584 * Get the actual source text. This gives access to the actual storage of
585 * the source - it sHould *not* be written to.
586 * The buffer is NOT zero terminated (nor is it guaranteed to have space to
587 * hold a zero terminating char).
588 * XXX this is 8-bit character data. Unicode source is not yet supported.
590 extern JSD_PUBLIC_API(JSBool)
591 JSD_GetSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc,
592 const char** ppBuf, intN* pLen);
595 * Clear the text -- delete the text and set the status to JSD_SOURCE_CLEARED.
596 * This is useful if source is done loading and the debugger wishes to store
597 * the text data itself (e.g. in a Java String). This allows avoidance of
598 * storing the same text in multiple places.
600 extern JSD_PUBLIC_API(void)
601 JSD_ClearSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc);
604 * Return the status of the source text item. see JSDSourceStatus enum.
606 extern JSD_PUBLIC_API(JSDSourceStatus)
607 JSD_GetSourceStatus(JSDContext* jsdc, JSDSourceText* jsdsrc);
610 * Has the source been altered since the last call to JSD_SetSourceDirty?
611 * Use of JSD_IsSourceDirty and JSD_SetSourceDirty is still supported, but
612 * discouraged in favor of the JSD_GetSourceAlterCount system. This dirty
613 * scheme ASSUMES that there is only one consumer of the data.
615 extern JSD_PUBLIC_API(JSBool)
616 JSD_IsSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc);
619 * Clear the dirty flag
621 extern JSD_PUBLIC_API(void)
622 JSD_SetSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc, JSBool dirty);
625 * Each time a source text item is altered this value is incremented. Any
626 * consumer can store this value when they retieve other data about the
627 * source text item and then check later to see if the current value is
628 * different from their stored value. Thus they can know if they have stale
629 * data or not. NOTE: this value is not gauranteed to start at any given number.
631 extern JSD_PUBLIC_API(uintN)
632 JSD_GetSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc);
635 * Force an increment in the alter count for a source text item. This is
636 * normally automatic when the item changes, but a give consumer may want to
637 * force this to amke an item appear to have changed even if it has not.
639 extern JSD_PUBLIC_API(uintN)
640 JSD_IncrementSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc);
643 * Destroy *all* the source text items
644 * (new for server-side USE WITH CARE)
646 extern JSD_PUBLIC_API(void)
647 JSD_DestroyAllSources( JSDContext* jsdc );
649 /* functions for adding source items */
652 * Add a new item for a given URL. If an iten already exists for the given URL
653 * then the old item is removed.
654 * 'url' may not be NULL.
656 extern JSD_PUBLIC_API(JSDSourceText*)
657 JSD_NewSourceText(JSDContext* jsdc, const char* url);
660 * Append text (or change status -- e.g. set completed) for a source text
661 * item. Text need not be zero terminated. Callers should consider the returned
662 * JSDSourceText to be the 'current' item for future use. This may return NULL
663 * if called after this item has been replaced by a call to JSD_NewSourceText.
665 extern JSD_PUBLIC_API(JSDSourceText*)
666 JSD_AppendSourceText(JSDContext* jsdc,
667 JSDSourceText* jsdsrc,
668 const char* text, /* *not* zero terminated */
669 size_t length,
670 JSDSourceStatus status);
673 * Unicode varient of JSD_AppendSourceText.
675 * NOTE: At this point text is stored in 8bit ASCII so this function just
676 * extracts the bottom 8bits from each jschar. At some future point we may
677 * switch to storing and exposing 16bit Unicode.
679 extern JSD_PUBLIC_API(JSDSourceText*)
680 JSD_AppendUCSourceText(JSDContext* jsdc,
681 JSDSourceText* jsdsrc,
682 const jschar* text, /* *not* zero terminated */
683 size_t length,
684 JSDSourceStatus status);
686 * Convienence function for adding complete source of url in one call.
687 * same as:
688 * JSDSourceText* jsdsrc;
689 * JSD_LOCK_SOURCE_TEXT(jsdc);
690 * jsdsrc = jsd_NewSourceText(jsdc, url);
691 * if(jsdsrc)
692 * jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc,
693 * text, length, JSD_SOURCE_PARTIAL);
694 * if(jsdsrc)
695 * jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc,
696 * NULL, 0, JSD_SOURCE_COMPLETED);
697 * JSD_UNLOCK_SOURCE_TEXT(jsdc);
698 * return jsdsrc ? JS_TRUE : JS_FALSE;
700 extern JSD_PUBLIC_API(JSBool)
701 JSD_AddFullSourceText(JSDContext* jsdc,
702 const char* text, /* *not* zero terminated */
703 size_t length,
704 const char* url);
706 /***************************************************************************/
707 /* Execution/Interrupt Hook functions */
709 /* possible 'type' params for JSD_ExecutionHookProc */
710 #define JSD_HOOK_INTERRUPTED 0
711 #define JSD_HOOK_BREAKPOINT 1
712 #define JSD_HOOK_DEBUG_REQUESTED 2
713 #define JSD_HOOK_DEBUGGER_KEYWORD 3
714 #define JSD_HOOK_THROW 4
716 /* legal return values for JSD_ExecutionHookProc */
717 #define JSD_HOOK_RETURN_HOOK_ERROR 0
718 #define JSD_HOOK_RETURN_CONTINUE 1
719 #define JSD_HOOK_RETURN_ABORT 2
720 #define JSD_HOOK_RETURN_RET_WITH_VAL 3
721 #define JSD_HOOK_RETURN_THROW_WITH_VAL 4
722 #define JSD_HOOK_RETURN_CONTINUE_THROW 5
725 * Implement a callback of this form in order to hook execution.
727 typedef uintN
728 (* JSD_ExecutionHookProc)(JSDContext* jsdc,
729 JSDThreadState* jsdthreadstate,
730 uintN type,
731 void* callerdata,
732 jsval* rval);
734 /* possible 'type' params for JSD_CallHookProc */
735 #define JSD_HOOK_TOPLEVEL_START 0 /* about to evaluate top level script */
736 #define JSD_HOOK_TOPLEVEL_END 1 /* done evaluting top level script */
737 #define JSD_HOOK_FUNCTION_CALL 2 /* about to call a function */
738 #define JSD_HOOK_FUNCTION_RETURN 3 /* done calling function */
741 * Implement a callback of this form in order to hook function call/returns.
742 * Return JS_TRUE from a TOPLEVEL_START or FUNCTION_CALL type call hook if you
743 * want to hear about the TOPLEVEL_END or FUNCTION_RETURN too. Return value is
744 * ignored to TOPLEVEL_END and FUNCTION_RETURN type hooks.
746 typedef JSBool
747 (* JSD_CallHookProc)(JSDContext* jsdc,
748 JSDThreadState* jsdthreadstate,
749 uintN type,
750 void* callerdata);
753 * Set Hook to be called whenever the given pc is about to be executed --
754 * i.e. for 'trap' or 'breakpoint'
756 extern JSD_PUBLIC_API(JSBool)
757 JSD_SetExecutionHook(JSDContext* jsdc,
758 JSDScript* jsdscript,
759 jsuword pc,
760 JSD_ExecutionHookProc hook,
761 void* callerdata);
764 * Clear the hook for this pc
766 extern JSD_PUBLIC_API(JSBool)
767 JSD_ClearExecutionHook(JSDContext* jsdc,
768 JSDScript* jsdscript,
769 jsuword pc);
772 * Clear all the pc specific hooks for this script
774 extern JSD_PUBLIC_API(JSBool)
775 JSD_ClearAllExecutionHooksForScript(JSDContext* jsdc, JSDScript* jsdscript);
778 * Clear all the pc specific hooks for the entire JSRuntime associated with
779 * this JSDContext
781 extern JSD_PUBLIC_API(JSBool)
782 JSD_ClearAllExecutionHooks(JSDContext* jsdc);
785 * Set a hook to be called before the next instruction is executed. Depending
786 * on the threading situation and whether or not an JS code is currently
787 * executing the hook might be called before this call returns, or at some
788 * future time. The hook will continue to be called as each instruction
789 * executes until cleared.
791 extern JSD_PUBLIC_API(JSBool)
792 JSD_SetInterruptHook(JSDContext* jsdc,
793 JSD_ExecutionHookProc hook,
794 void* callerdata);
797 * Clear the current interrupt hook.
799 extern JSD_PUBLIC_API(JSBool)
800 JSD_ClearInterruptHook(JSDContext* jsdc);
803 * Set the hook that should be called whenever a JSD_ErrorReporter hook
804 * returns JSD_ERROR_REPORTER_DEBUG.
806 extern JSD_PUBLIC_API(JSBool)
807 JSD_SetDebugBreakHook(JSDContext* jsdc,
808 JSD_ExecutionHookProc hook,
809 void* callerdata);
812 * Clear the debug break hook
814 extern JSD_PUBLIC_API(JSBool)
815 JSD_ClearDebugBreakHook(JSDContext* jsdc);
818 * Set the hook that should be called when the 'debugger' keyword is
819 * encountered by the JavaScript interpreter during execution.
821 extern JSD_PUBLIC_API(JSBool)
822 JSD_SetDebuggerHook(JSDContext* jsdc,
823 JSD_ExecutionHookProc hook,
824 void* callerdata);
827 * Clear the 'debugger' keyword hook
829 extern JSD_PUBLIC_API(JSBool)
830 JSD_ClearDebuggerHook(JSDContext* jsdc);
833 * Set the hook that should be called when a JS exception is thrown.
834 * NOTE: the 'do default' return value is: JSD_HOOK_RETURN_CONTINUE_THROW
836 extern JSD_PUBLIC_API(JSBool)
837 JSD_SetThrowHook(JSDContext* jsdc,
838 JSD_ExecutionHookProc hook,
839 void* callerdata);
841 * Clear the throw hook
843 extern JSD_PUBLIC_API(JSBool)
844 JSD_ClearThrowHook(JSDContext* jsdc);
847 * Set the hook that should be called when a toplevel script begins or completes.
849 extern JSD_PUBLIC_API(JSBool)
850 JSD_SetTopLevelHook(JSDContext* jsdc,
851 JSD_CallHookProc hook,
852 void* callerdata);
854 * Clear the toplevel call hook
856 extern JSD_PUBLIC_API(JSBool)
857 JSD_ClearTopLevelHook(JSDContext* jsdc);
860 * Set the hook that should be called when a function call or return happens.
862 extern JSD_PUBLIC_API(JSBool)
863 JSD_SetFunctionHook(JSDContext* jsdc,
864 JSD_CallHookProc hook,
865 void* callerdata);
867 * Clear the function call hook
869 extern JSD_PUBLIC_API(JSBool)
870 JSD_ClearFunctionHook(JSDContext* jsdc);
872 /***************************************************************************/
873 /* Stack Frame functions */
876 * Get the count of call stack frames for the given JSDThreadState
878 extern JSD_PUBLIC_API(uintN)
879 JSD_GetCountOfStackFrames(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
882 * Get the 'current' call stack frame for the given JSDThreadState
884 extern JSD_PUBLIC_API(JSDStackFrameInfo*)
885 JSD_GetStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
888 * Get the JSContext for the given JSDThreadState
890 extern JSD_PUBLIC_API(JSContext*)
891 JSD_GetJSContext(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
894 * Get the calling call stack frame for the given frame
896 extern JSD_PUBLIC_API(JSDStackFrameInfo*)
897 JSD_GetCallingStackFrame(JSDContext* jsdc,
898 JSDThreadState* jsdthreadstate,
899 JSDStackFrameInfo* jsdframe);
902 * Get the script for the given call stack frame
904 extern JSD_PUBLIC_API(JSDScript*)
905 JSD_GetScriptForStackFrame(JSDContext* jsdc,
906 JSDThreadState* jsdthreadstate,
907 JSDStackFrameInfo* jsdframe);
910 * Get the 'Program Counter' for the given call stack frame
912 extern JSD_PUBLIC_API(jsuword)
913 JSD_GetPCForStackFrame(JSDContext* jsdc,
914 JSDThreadState* jsdthreadstate,
915 JSDStackFrameInfo* jsdframe);
918 * Get the JavaScript Call Object for the given call stack frame.
919 * *** new for version 1.1 ****
921 extern JSD_PUBLIC_API(JSDValue*)
922 JSD_GetCallObjectForStackFrame(JSDContext* jsdc,
923 JSDThreadState* jsdthreadstate,
924 JSDStackFrameInfo* jsdframe);
927 * Get the head of the scope chain for the given call stack frame.
928 * the chain can be traversed using JSD_GetValueParent.
929 * *** new for version 1.1 ****
931 extern JSD_PUBLIC_API(JSDValue*)
932 JSD_GetScopeChainForStackFrame(JSDContext* jsdc,
933 JSDThreadState* jsdthreadstate,
934 JSDStackFrameInfo* jsdframe);
937 * Get the 'this' Object for the given call stack frame.
938 * *** new for version 1.1 ****
940 extern JSD_PUBLIC_API(JSDValue*)
941 JSD_GetThisForStackFrame(JSDContext* jsdc,
942 JSDThreadState* jsdthreadstate,
943 JSDStackFrameInfo* jsdframe);
946 * Get the name of the function executing in this stack frame. Especially useful
947 * for native frames (without script objects.)
949 extern JSD_PUBLIC_API(const char*)
950 JSD_GetNameForStackFrame(JSDContext* jsdc,
951 JSDThreadState* jsdthreadstate,
952 JSDStackFrameInfo* jsdframe);
955 * True if stack frame represents a native frame.
957 extern JSD_PUBLIC_API(JSBool)
958 JSD_IsStackFrameNative(JSDContext* jsdc,
959 JSDThreadState* jsdthreadstate,
960 JSDStackFrameInfo* jsdframe);
963 * True if stack frame represents a frame created as a result of a debugger
964 * evaluation.
966 extern JSD_PUBLIC_API(JSBool)
967 JSD_IsStackFrameDebugger(JSDContext* jsdc,
968 JSDThreadState* jsdthreadstate,
969 JSDStackFrameInfo* jsdframe);
972 * True if stack frame is constructing a new object.
974 extern JSD_PUBLIC_API(JSBool)
975 JSD_IsStackFrameConstructing(JSDContext* jsdc,
976 JSDThreadState* jsdthreadstate,
977 JSDStackFrameInfo* jsdframe);
980 * Evaluate the given unicode source code in the context of the given stack frame.
981 * returns JS_TRUE and puts result in rval on success, JS_FALSE on failure.
982 * NOTE: The ErrorReporter hook might be called if this fails.
984 extern JSD_PUBLIC_API(JSBool)
985 JSD_EvaluateUCScriptInStackFrame(JSDContext* jsdc,
986 JSDThreadState* jsdthreadstate,
987 JSDStackFrameInfo* jsdframe,
988 const jschar *bytes, uintN length,
989 const char *filename, uintN lineno,
990 jsval *rval);
993 * Same as above, but does not eat exceptions.
995 extern JSD_PUBLIC_API(JSBool)
996 JSD_AttemptUCScriptInStackFrame(JSDContext* jsdc,
997 JSDThreadState* jsdthreadstate,
998 JSDStackFrameInfo* jsdframe,
999 const jschar *bytes, uintN length,
1000 const char *filename, uintN lineno,
1001 jsval *rval);
1003 /* single byte character version of JSD_EvaluateUCScriptInStackFrame */
1004 extern JSD_PUBLIC_API(JSBool)
1005 JSD_EvaluateScriptInStackFrame(JSDContext* jsdc,
1006 JSDThreadState* jsdthreadstate,
1007 JSDStackFrameInfo* jsdframe,
1008 const char *bytes, uintN length,
1009 const char *filename, uintN lineno, jsval *rval);
1012 * Same as above, but does not eat exceptions.
1014 extern JSD_PUBLIC_API(JSBool)
1015 JSD_AttemptScriptInStackFrame(JSDContext* jsdc,
1016 JSDThreadState* jsdthreadstate,
1017 JSDStackFrameInfo* jsdframe,
1018 const char *bytes, uintN length,
1019 const char *filename, uintN lineno, jsval *rval);
1022 * Convert the given jsval to a string
1023 * NOTE: The ErrorReporter hook might be called if this fails.
1025 extern JSD_PUBLIC_API(JSString*)
1026 JSD_ValToStringInStackFrame(JSDContext* jsdc,
1027 JSDThreadState* jsdthreadstate,
1028 JSDStackFrameInfo* jsdframe,
1029 jsval val);
1032 * Get the JSDValue currently being thrown as an exception (may be NULL).
1033 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1034 * *** new for version 1.1 ****
1036 extern JSD_PUBLIC_API(JSDValue*)
1037 JSD_GetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
1040 * Set the JSDValue currently being thrown as an exception.
1041 * *** new for version 1.1 ****
1043 extern JSD_PUBLIC_API(JSBool)
1044 JSD_SetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate,
1045 JSDValue* jsdval);
1047 /***************************************************************************/
1048 /* Error Reporter functions */
1051 * XXX The ErrorReporter Hook scheme is going to change soon to more
1052 * Fully support exceptions.
1055 /* legal return values for JSD_ErrorReporter */
1056 #define JSD_ERROR_REPORTER_PASS_ALONG 0 /* pass along to regular reporter */
1057 #define JSD_ERROR_REPORTER_RETURN 1 /* don't pass to error reporter */
1058 #define JSD_ERROR_REPORTER_DEBUG 2 /* force call to DebugBreakHook */
1059 #define JSD_ERROR_REPORTER_CLEAR_RETURN 3 /* clear exception and don't pass */
1062 * Implement a callback of this form in order to hook the ErrorReporter
1064 typedef uintN
1065 (* JSD_ErrorReporter)(JSDContext* jsdc,
1066 JSContext* cx,
1067 const char* message,
1068 JSErrorReport* report,
1069 void* callerdata);
1071 /* Set ErrorReporter hook */
1072 extern JSD_PUBLIC_API(JSBool)
1073 JSD_SetErrorReporter(JSDContext* jsdc,
1074 JSD_ErrorReporter reporter,
1075 void* callerdata);
1077 /* Get Current ErrorReporter hook */
1078 extern JSD_PUBLIC_API(JSBool)
1079 JSD_GetErrorReporter(JSDContext* jsdc,
1080 JSD_ErrorReporter* reporter,
1081 void** callerdata);
1083 /***************************************************************************/
1084 /* Generic locks that callers can use for their own purposes */
1087 * Is Locking and GetThread supported in this build?
1089 extern JSD_PUBLIC_API(JSBool)
1090 JSD_IsLockingAndThreadIdSupported();
1093 * Create a reentrant/nestable lock
1095 extern JSD_PUBLIC_API(void*)
1096 JSD_CreateLock();
1099 * Aquire lock for this thread (or block until available). Increments a
1100 * counter if this thread already owns the lock.
1102 extern JSD_PUBLIC_API(void)
1103 JSD_Lock(void* lock);
1106 * Release lock for this thread (or decrement the counter if JSD_Lock
1107 * was previous called more than once).
1109 extern JSD_PUBLIC_API(void)
1110 JSD_Unlock(void* lock);
1113 * For debugging only if not (JS_THREADSAFE AND DEBUG) then returns JS_TRUE
1114 * So JSD_IsLocked(lock) may not equal !JSD_IsUnlocked(lock)
1116 extern JSD_PUBLIC_API(JSBool)
1117 JSD_IsLocked(void* lock);
1120 * See above...
1122 extern JSD_PUBLIC_API(JSBool)
1123 JSD_IsUnlocked(void* lock);
1126 * return an ID uniquely identifying this thread.
1128 extern JSD_PUBLIC_API(void*)
1129 JSD_CurrentThread();
1131 /***************************************************************************/
1132 /* Value and Property Functions --- All NEW for 1.1 --- */
1135 * NOTE: JSDValue and JSDProperty objects are reference counted. This allows
1136 * for rooting these objects AND any underlying garbage collected jsvals.
1137 * ALL JSDValue and JSDProperty objects returned by the functions below
1138 * MUST eventually be released using the appropriate JSD_Dropxxx function.
1142 * Create a new JSDValue to wrap the given jsval
1143 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1144 * *** new for version 1.1 ****
1146 extern JSD_PUBLIC_API(JSDValue*)
1147 JSD_NewValue(JSDContext* jsdc, jsval val);
1150 * Release the JSDValue. After this call the object MUST not be referenced again!
1151 * *** new for version 1.1 ****
1153 extern JSD_PUBLIC_API(void)
1154 JSD_DropValue(JSDContext* jsdc, JSDValue* jsdval);
1157 * Get the jsval wrapped by this JSDValue
1158 * *** new for version 1.1 ****
1160 extern JSD_PUBLIC_API(jsval)
1161 JSD_GetValueWrappedJSVal(JSDContext* jsdc, JSDValue* jsdval);
1164 * Clear all property and association information about the given JSDValue.
1165 * Such information will be lazily regenerated when later accessed. This
1166 * function must be called to make changes to the properties of an object
1167 * visible to the accessor functions below (if the properties et.al. have
1168 * changed since a previous call to those accessors).
1169 * *** new for version 1.1 ****
1171 extern JSD_PUBLIC_API(void)
1172 JSD_RefreshValue(JSDContext* jsdc, JSDValue* jsdval);
1174 /**************************************************/
1177 * Does the JSDValue wrap a JSObject?
1178 * *** new for version 1.1 ****
1180 extern JSD_PUBLIC_API(JSBool)
1181 JSD_IsValueObject(JSDContext* jsdc, JSDValue* jsdval);
1184 * Does the JSDValue wrap a number (int or double)?
1185 * *** new for version 1.1 ****
1187 extern JSD_PUBLIC_API(JSBool)
1188 JSD_IsValueNumber(JSDContext* jsdc, JSDValue* jsdval);
1191 * Does the JSDValue wrap an int?
1192 * *** new for version 1.1 ****
1194 extern JSD_PUBLIC_API(JSBool)
1195 JSD_IsValueInt(JSDContext* jsdc, JSDValue* jsdval);
1198 * Does the JSDValue wrap a double?
1199 * *** new for version 1.1 ****
1201 extern JSD_PUBLIC_API(JSBool)
1202 JSD_IsValueDouble(JSDContext* jsdc, JSDValue* jsdval);
1205 * Does the JSDValue wrap a JSString?
1206 * *** new for version 1.1 ****
1208 extern JSD_PUBLIC_API(JSBool)
1209 JSD_IsValueString(JSDContext* jsdc, JSDValue* jsdval);
1212 * Does the JSDValue wrap a JSBool?
1213 * *** new for version 1.1 ****
1215 extern JSD_PUBLIC_API(JSBool)
1216 JSD_IsValueBoolean(JSDContext* jsdc, JSDValue* jsdval);
1219 * Does the JSDValue wrap a JSVAL_NULL?
1220 * *** new for version 1.1 ****
1222 extern JSD_PUBLIC_API(JSBool)
1223 JSD_IsValueNull(JSDContext* jsdc, JSDValue* jsdval);
1226 * Does the JSDValue wrap a JSVAL_VOID?
1227 * *** new for version 1.1 ****
1229 extern JSD_PUBLIC_API(JSBool)
1230 JSD_IsValueVoid(JSDContext* jsdc, JSDValue* jsdval);
1233 * Does the JSDValue wrap a primative (not a JSObject)?
1234 * *** new for version 1.1 ****
1236 extern JSD_PUBLIC_API(JSBool)
1237 JSD_IsValuePrimitive(JSDContext* jsdc, JSDValue* jsdval);
1240 * Does the JSDValue wrap a function?
1241 * *** new for version 1.1 ****
1243 extern JSD_PUBLIC_API(JSBool)
1244 JSD_IsValueFunction(JSDContext* jsdc, JSDValue* jsdval);
1247 * Does the JSDValue wrap a native function?
1248 * *** new for version 1.1 ****
1250 extern JSD_PUBLIC_API(JSBool)
1251 JSD_IsValueNative(JSDContext* jsdc, JSDValue* jsdval);
1253 /**************************************************/
1256 * Return JSBool value (does NOT do conversion).
1257 * *** new for version 1.1 ****
1259 extern JSD_PUBLIC_API(JSBool)
1260 JSD_GetValueBoolean(JSDContext* jsdc, JSDValue* jsdval);
1263 * Return int32 value (does NOT do conversion).
1264 * *** new for version 1.1 ****
1266 extern JSD_PUBLIC_API(int32)
1267 JSD_GetValueInt(JSDContext* jsdc, JSDValue* jsdval);
1270 * Return double value (does NOT do conversion).
1271 * *** new for version 1.1 ****
1273 extern JSD_PUBLIC_API(jsdouble*)
1274 JSD_GetValueDouble(JSDContext* jsdc, JSDValue* jsdval);
1277 * Return JSString value (DOES do conversion if necessary).
1278 * NOTE that the JSString returned is not protected from garbage
1279 * collection. It should be immediately read or wrapped using
1280 * JSD_NewValue(jsdc,STRING_TO_JSVAL(str)) if necessary.
1281 * *** new for version 1.1 ****
1283 extern JSD_PUBLIC_API(JSString*)
1284 JSD_GetValueString(JSDContext* jsdc, JSDValue* jsdval);
1287 * Return name of function IFF JSDValue represents a function.
1288 * *** new for version 1.1 ****
1290 extern JSD_PUBLIC_API(const char*)
1291 JSD_GetValueFunctionName(JSDContext* jsdc, JSDValue* jsdval);
1293 /**************************************************/
1296 * Return the number of properties for the JSDValue.
1297 * *** new for version 1.1 ****
1299 extern JSD_PUBLIC_API(uintN)
1300 JSD_GetCountOfProperties(JSDContext* jsdc, JSDValue* jsdval);
1303 * Iterate through the properties of the JSDValue.
1304 * Use form similar to that shown for JSD_IterateScripts (no locking required).
1305 * NOTE: each JSDProperty returned must eventually be released by calling
1306 * JSD_DropProperty.
1307 * *** new for version 1.1 ****
1309 extern JSD_PUBLIC_API(JSDProperty*)
1310 JSD_IterateProperties(JSDContext* jsdc, JSDValue* jsdval, JSDProperty **iterp);
1313 * Get the JSDProperty for the property of this JSDVal with this name.
1314 * NOTE: must eventually release by calling JSD_DropProperty (if not NULL)
1315 * *** new for version 1.1 ****
1317 extern JSD_PUBLIC_API(JSDProperty*)
1318 JSD_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* name);
1321 * Get the prototype object for this JSDValue.
1322 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1323 * *** new for version 1.1 ****
1325 extern JSD_PUBLIC_API(JSDValue*)
1326 JSD_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval);
1329 * Get the parent object for this JSDValue.
1330 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1331 * *** new for version 1.1 ****
1333 extern JSD_PUBLIC_API(JSDValue*)
1334 JSD_GetValueParent(JSDContext* jsdc, JSDValue* jsdval);
1337 * Get the ctor object for this JSDValue (or likely its prototype's ctor).
1338 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1339 * *** new for version 1.1 ****
1341 extern JSD_PUBLIC_API(JSDValue*)
1342 JSD_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval);
1345 * Get the name of the class for this object.
1346 * *** new for version 1.1 ****
1348 extern JSD_PUBLIC_API(const char*)
1349 JSD_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval);
1352 * Get the script for the given value if the given value represents a
1353 * scripted function. Otherwise, return null.
1355 extern JSD_PUBLIC_API(JSDScript*)
1356 JSD_GetScriptForValue(JSDContext* jsdc, JSDValue* jsdval);
1358 /**************************************************/
1360 /* possible or'd together bitflags returned by JSD_GetPropertyFlags
1362 * XXX these must stay the same as the JSPD_ flags in jsdbgapi.h
1364 #define JSDPD_ENUMERATE JSPD_ENUMERATE /* visible to for/in loop */
1365 #define JSDPD_READONLY JSPD_READONLY /* assignment is error */
1366 #define JSDPD_PERMANENT JSPD_PERMANENT /* property cannot be deleted */
1367 #define JSDPD_ALIAS JSPD_ALIAS /* property has an alias id */
1368 #define JSDPD_ARGUMENT JSPD_ARGUMENT /* argument to function */
1369 #define JSDPD_VARIABLE JSPD_VARIABLE /* local variable in function */
1370 #define JSDPD_EXCEPTION JSPD_EXCEPTION /* exception occurred looking up */
1371 /* proprety, value is exception */
1372 #define JSDPD_ERROR JSPD_ERROR /* native getter returned JS_FALSE */
1373 /* without throwing an exception */
1374 /* this is not one of the JSPD_ flags in jsdbgapi.h - careful not to overlap*/
1375 #define JSDPD_HINTED 0x800 /* found via explicit lookup */
1378 * Release this JSDProperty
1379 * *** new for version 1.1 ****
1381 extern JSD_PUBLIC_API(void)
1382 JSD_DropProperty(JSDContext* jsdc, JSDProperty* jsdprop);
1385 * Get the JSDValue represeting the name of this property (int or string)
1386 * NOTE: must eventually release by calling JSD_DropValue
1387 * *** new for version 1.1 ****
1389 extern JSD_PUBLIC_API(JSDValue*)
1390 JSD_GetPropertyName(JSDContext* jsdc, JSDProperty* jsdprop);
1393 * Get the JSDValue represeting the current value of this property
1394 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1395 * *** new for version 1.1 ****
1397 extern JSD_PUBLIC_API(JSDValue*)
1398 JSD_GetPropertyValue(JSDContext* jsdc, JSDProperty* jsdprop);
1401 * Get the JSDValue represeting the alias of this property (if JSDPD_ALIAS set)
1402 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1403 * *** new for version 1.1 ****
1405 extern JSD_PUBLIC_API(JSDValue*)
1406 JSD_GetPropertyAlias(JSDContext* jsdc, JSDProperty* jsdprop);
1409 * Get the flags for this property
1410 * *** new for version 1.1 ****
1412 extern JSD_PUBLIC_API(uintN)
1413 JSD_GetPropertyFlags(JSDContext* jsdc, JSDProperty* jsdprop);
1416 * Get Variable or Argument slot number (if JSDPD_ARGUMENT or JSDPD_VARIABLE set)
1417 * *** new for version 1.1 ****
1419 extern JSD_PUBLIC_API(uintN)
1420 JSD_GetPropertyVarArgSlot(JSDContext* jsdc, JSDProperty* jsdprop);
1422 /***************************************************************************/
1423 /* Object Functions --- All NEW for 1.1 --- */
1426 * JSDObjects exist to allow a means of iterating through all JSObjects in the
1427 * engine. They are created and destroyed as the wrapped JSObjects are created
1428 * and destroyed in the engine. JSDObjects additionally track the location in
1429 * the JavaScript source where their wrapped JSObjects were created and the name
1430 * and location of the (non-native) constructor used.
1432 * NOTE: JSDObjects are NOT reference counted. The have only weak links to
1433 * jsObjects - thus they do not inhibit garbage collection of JSObjects. If
1434 * you need a JSDObject to safely persist then wrap it in a JSDValue (using
1435 * jsd_GetValueForObject).
1439 * Lock the entire Object subsystem -- see JSD_UnlockObjectSubsystem
1440 * *** new for version 1.1 ****
1442 extern JSD_PUBLIC_API(void)
1443 JSD_LockObjectSubsystem(JSDContext* jsdc);
1446 * Unlock the entire Object subsystem -- see JSD_LockObjectSubsystem
1447 * *** new for version 1.1 ****
1449 extern JSD_PUBLIC_API(void)
1450 JSD_UnlockObjectSubsystem(JSDContext* jsdc);
1453 * Iterate through the known objects
1454 * Use form similar to that shown for JSD_IterateScripts.
1455 * NOTE: the ObjectSubsystem must be locked before and unlocked after iterating.
1456 * *** new for version 1.1 ****
1458 extern JSD_PUBLIC_API(JSDObject*)
1459 JSD_IterateObjects(JSDContext* jsdc, JSDObject** iterp);
1462 * Get the JSObject represented by this JSDObject
1463 * *** new for version 1.1 ****
1465 extern JSD_PUBLIC_API(JSObject*)
1466 JSD_GetWrappedObject(JSDContext* jsdc, JSDObject* jsdobj);
1469 * Get the URL of the line of source that caused this object to be created.
1470 * May be NULL.
1471 * *** new for version 1.1 ****
1473 extern JSD_PUBLIC_API(const char*)
1474 JSD_GetObjectNewURL(JSDContext* jsdc, JSDObject* jsdobj);
1477 * Get the line number of the line of source that caused this object to be
1478 * created. May be 0 indicating that the line number is unknown.
1479 * *** new for version 1.1 ****
1481 extern JSD_PUBLIC_API(uintN)
1482 JSD_GetObjectNewLineNumber(JSDContext* jsdc, JSDObject* jsdobj);
1485 * Get the URL of the line of source of the constructor for this object.
1486 * May be NULL.
1487 * *** new for version 1.1 ****
1489 extern JSD_PUBLIC_API(const char*)
1490 JSD_GetObjectConstructorURL(JSDContext* jsdc, JSDObject* jsdobj);
1493 * Get the line number of the line of source of the constructor for this object.
1494 * created. May be 0 indicating that the line number is unknown.
1495 * *** new for version 1.1 ****
1497 extern JSD_PUBLIC_API(uintN)
1498 JSD_GetObjectConstructorLineNumber(JSDContext* jsdc, JSDObject* jsdobj);
1501 * Get the name of the constructor for this object.
1502 * May be NULL.
1503 * *** new for version 1.1 ****
1505 extern JSD_PUBLIC_API(const char*)
1506 JSD_GetObjectConstructorName(JSDContext* jsdc, JSDObject* jsdobj);
1509 * Get JSDObject representing this JSObject.
1510 * May return NULL.
1511 * *** new for version 1.1 ****
1513 extern JSD_PUBLIC_API(JSDObject*)
1514 JSD_GetJSDObjectForJSObject(JSDContext* jsdc, JSObject* jsobj);
1517 * Get JSDObject representing this JSDValue.
1518 * May return NULL.
1519 * *** new for version 1.1 ****
1521 extern JSD_PUBLIC_API(JSDObject*)
1522 JSD_GetObjectForValue(JSDContext* jsdc, JSDValue* jsdval);
1525 * Create a JSDValue to wrap (and root) this JSDObject.
1526 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1527 * *** new for version 1.1 ****
1529 extern JSD_PUBLIC_API(JSDValue*)
1530 JSD_GetValueForObject(JSDContext* jsdc, JSDObject* jsdobj);
1532 /***************************************************************************/
1533 /* Livewire specific API */
1534 #ifdef LIVEWIRE
1536 extern JSD_PUBLIC_API(LWDBGScript*)
1537 JSDLW_GetLWScript(JSDContext* jsdc, JSDScript* jsdscript);
1539 extern JSD_PUBLIC_API(JSDSourceText*)
1540 JSDLW_PreLoadSource(JSDContext* jsdc, LWDBGApp* app,
1541 const char* filename, JSBool clear);
1543 extern JSD_PUBLIC_API(JSDSourceText*)
1544 JSDLW_ForceLoadSource(JSDContext* jsdc, JSDSourceText* jsdsrc);
1546 extern JSD_PUBLIC_API(JSBool)
1547 JSDLW_RawToProcessedLineNumber(JSDContext* jsdc, JSDScript* jsdscript,
1548 uintN lineIn, uintN* lineOut);
1550 extern JSD_PUBLIC_API(JSBool)
1551 JSDLW_ProcessedToRawLineNumber(JSDContext* jsdc, JSDScript* jsdscript,
1552 uintN lineIn, uintN* lineOut);
1554 #endif
1555 /***************************************************************************/
1557 JS_END_EXTERN_C
1559 #endif /* jsdebug_h___ */