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
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.
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
45 /* Get jstypes.h included first. After that we can use PR macros for doing
46 * this extern "C" stuff!
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
74 #define JSD_PUBLIC_API(t) JS_EXPORT_API(t)
75 #define JSD_PUBLIC_DATA(t) JS_EXPORT_DATA(t)
77 #define JSD_PUBLIC_API(t) JS_IMPORT_API(t)
78 #define JSD_PUBLIC_DATA(t) JS_IMPORT_DATA(t)
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
111 (* JS_DLL_CALLBACK JSD_SetContextProc
)(JSDContext
* jsdc
, void* user
);
113 /* This struct could have more fields in future versions */
116 uintN size
; /* size of this struct (init before use)*/
117 JSD_SetContextProc setContext
;
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
126 extern JSD_PUBLIC_API(void)
127 JSD_SetUserCallbacks(JSRuntime
* jsrt
,
128 JSD_UserCallbacks
* callbacks
,
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
,
148 * Shutdown JSD for this JSDContext
150 extern JSD_PUBLIC_API(void)
151 JSD_DebuggerOff(JSDContext
* jsdc
);
154 * Get the Major Version (initial JSD release used major version = 1)
156 extern JSD_PUBLIC_API(uintN
)
157 JSD_GetMajorVersion(void);
160 * Get the Minor Version (initial JSD release used minor version = 0)
162 extern JSD_PUBLIC_API(uintN
)
163 JSD_GetMinorVersion(void);
166 * Returns a 'dumb' JSContext that can be used for utility purposes as needed
168 extern JSD_PUBLIC_API(JSContext
*)
169 JSD_GetDefaultJSContext(JSDContext
* jsdc
);
172 * Set the private data for this context, returns previous value
174 extern JSD_PUBLIC_API(void *)
175 JSD_SetContextPrivate(JSDContext
*jsdc
, void *data
);
178 * Get the private data for this context
180 extern JSD_PUBLIC_API(void *)
181 JSD_GetContextPrivate(JSDContext
*jsdc
);
184 * Clear profile data for all scripts
186 extern JSD_PUBLIC_API(void)
187 JSD_ClearAllProfileData(JSDContext
* jsdc
);
193 /* Include native frames in JSDThreadStates. */
194 #define JSD_INCLUDE_NATIVE_FRAMES 0x01
196 * Normally, if a script has a 0 in JSD_SCRIPT_PROFILE_BIT it is included in
197 * profile data, otherwise it is not profiled. Setting the JSD_PROFILE_WHEN_SET
198 * flag reverses this convention.
200 #define JSD_PROFILE_WHEN_SET 0x02
202 * Normally, when the script in the top frame of a thread state has a 1 in
203 * JSD_SCRIPT_DEBUG_BIT, the execution hook is ignored. Setting the
204 * JSD_DEBUG_WHEN_SET flag reverses this convention.
206 #define JSD_DEBUG_WHEN_SET 0x04
208 * When this flag is set the internal call hook will collect profile data.
210 #define JSD_COLLECT_PROFILE_DATA 0x08
212 * When this flag is set, stack frames that are disabled for debugging
213 * will not appear in the call stack chain.
215 #define JSD_HIDE_DISABLED_FRAMES 0x10
217 * When this flag is set, the debugger will only check the
218 * JSD_SCRIPT_DEBUG_BIT on the top (most recent) stack frame. This
219 * makes it possible to stop in an enabled frame which was called from
220 * a stack that contains a disabled frame.
222 * When this flag is *not* set, any stack that contains a disabled frame
223 * will not be debugged (the execution hook will not be invoked.)
225 * This only applies when the reason for calling the hook would have
226 * been JSD_HOOK_INTERRUPTED or JSD_HOOK_THROW. JSD_HOOK_BREAKPOINT,
227 * JSD_HOOK_DEBUG_REQUESTED, and JSD_HOOK_DEBUGGER_KEYWORD always stop,
228 * regardless of this setting, as long as the top frame is not disabled.
230 * If JSD_HIDE_DISABLED_FRAMES is set, this is effectively set as well.
232 #define JSD_MASK_TOP_FRAME_ONLY 0x20
234 * When this flag is set, object creation will not be tracked. This will
235 * reduce the performance price you pay by enabling the debugger.
237 #define JSD_DISABLE_OBJECT_TRACE 0x40
239 extern JSD_PUBLIC_API(void)
240 JSD_SetContextFlags (JSDContext
* jsdc
, uint32 flags
);
242 extern JSD_PUBLIC_API(uint32
)
243 JSD_GetContextFlags (JSDContext
* jsdc
);
246 * Notify JSD that this JSContext is 'in use'. This allows JSD to hook the
247 * ErrorReporter. For the most part this is done automatically whenever
248 * events like script loading happen. But, it is a good idea to call this
249 * from the embedding when new contexts come into use.
251 extern JSD_PUBLIC_API(void)
252 JSD_JSContextInUse(JSDContext
* jsdc
, JSContext
* context
);
255 * Find the JSDContext (if any) associated with the JSRuntime of a
258 extern JSD_PUBLIC_API(JSDContext
*)
259 JSD_JSDContextForJSContext(JSContext
* context
);
261 /***************************************************************************/
262 /* Script functions */
265 * Lock the entire script subsystem. This grabs a highlevel lock that
266 * protects the JSD internal information about scripts. It is important
267 * to wrap script related calls in this lock in multithreaded situations
268 * -- i.e. where the debugger is running on a different thread than the
269 * interpreter -- or when multiple debugger threads may be accessing this
270 * subsystem. It is safe (and best) to use this locking even if the
271 * environment might not be multi-threaded. Safely nestable.
273 extern JSD_PUBLIC_API(void)
274 JSD_LockScriptSubsystem(JSDContext
* jsdc
);
277 * Unlock the entire script subsystem -- see JSD_LockScriptSubsystem
279 extern JSD_PUBLIC_API(void)
280 JSD_UnlockScriptSubsystem(JSDContext
* jsdc
);
283 * Iterate through all the active scripts for this JSDContext.
284 * NOTE: must initialize iterp to NULL to start iteration.
285 * NOTE: must lock and unlock the subsystem
288 * JSDScript jsdscript;
289 * JSDScript iter = NULL;
291 * JSD_LockScriptSubsystem(jsdc);
292 * while((jsdscript = JSD_IterateScripts(jsdc, &iter)) != NULL) {
293 * *** use jsdscript here ***
295 * JSD_UnlockScriptSubsystem(jsdc);
297 extern JSD_PUBLIC_API(JSDScript
*)
298 JSD_IterateScripts(JSDContext
* jsdc
, JSDScript
**iterp
);
301 * Get the number of times this script has been called.
303 extern JSD_PUBLIC_API(uintN
)
304 JSD_GetScriptCallCount(JSDContext
* jsdc
, JSDScript
*script
);
307 * Get the max number of times this script called itself, directly or indirectly.
309 extern JSD_PUBLIC_API(uintN
)
310 JSD_GetScriptMaxRecurseDepth(JSDContext
* jsdc
, JSDScript
*script
);
313 * Get the shortest execution time recorded.
315 extern JSD_PUBLIC_API(jsdouble
)
316 JSD_GetScriptMinExecutionTime(JSDContext
* jsdc
, JSDScript
*script
);
319 * Get the longest execution time recorded.
321 extern JSD_PUBLIC_API(jsdouble
)
322 JSD_GetScriptMaxExecutionTime(JSDContext
* jsdc
, JSDScript
*script
);
325 * Get the total amount of time spent in this script.
327 extern JSD_PUBLIC_API(jsdouble
)
328 JSD_GetScriptTotalExecutionTime(JSDContext
* jsdc
, JSDScript
*script
);
331 * Get the shortest execution time recorded, excluding time spent in called
334 extern JSD_PUBLIC_API(jsdouble
)
335 JSD_GetScriptMinOwnExecutionTime(JSDContext
* jsdc
, JSDScript
*script
);
338 * Get the longest execution time recorded, excluding time spent in called
341 extern JSD_PUBLIC_API(jsdouble
)
342 JSD_GetScriptMaxOwnExecutionTime(JSDContext
* jsdc
, JSDScript
*script
);
345 * Get the total amount of time spent in this script, excluding time spent
346 * in called functions.
348 extern JSD_PUBLIC_API(jsdouble
)
349 JSD_GetScriptTotalOwnExecutionTime(JSDContext
* jsdc
, JSDScript
*script
);
352 * Clear profile data for this script.
354 extern JSD_PUBLIC_API(void)
355 JSD_ClearScriptProfileData(JSDContext
* jsdc
, JSDScript
*script
);
358 * Get the JSScript for a JSDScript
360 extern JSD_PUBLIC_API(JSScript
*)
361 JSD_GetJSScript(JSDContext
* jsdc
, JSDScript
*script
);
364 * Get the JSFunction for a JSDScript
366 extern JSD_PUBLIC_API(JSFunction
*)
367 JSD_GetJSFunction(JSDContext
* jsdc
, JSDScript
*script
);
370 * Determines whether or not to collect profile information for this
371 * script. The context flag JSD_PROFILE_WHEN_SET decides the logic.
373 #define JSD_SCRIPT_PROFILE_BIT 0x01
375 * Determines whether or not to ignore breakpoints, etc. in this script.
376 * The context flag JSD_DEBUG_WHEN_SET decides the logic.
378 #define JSD_SCRIPT_DEBUG_BIT 0x02
380 extern JSD_PUBLIC_API(uint32
)
381 JSD_GetScriptFlags(JSDContext
*jsdc
, JSDScript
* jsdscript
);
383 extern JSD_PUBLIC_API(void)
384 JSD_SetScriptFlags(JSDContext
*jsdc
, JSDScript
* jsdscript
, uint32 flags
);
387 * Set the private data for this script, returns previous value
389 extern JSD_PUBLIC_API(void *)
390 JSD_SetScriptPrivate(JSDScript
* jsdscript
, void *data
);
393 * Get the private data for this script
395 extern JSD_PUBLIC_API(void *)
396 JSD_GetScriptPrivate(JSDScript
* jsdscript
);
399 * Determine if this script is still loaded in the interpreter
401 extern JSD_PUBLIC_API(JSBool
)
402 JSD_IsActiveScript(JSDContext
* jsdc
, JSDScript
*jsdscript
);
405 * Get the filename associated with this script
407 extern JSD_PUBLIC_API(const char*)
408 JSD_GetScriptFilename(JSDContext
* jsdc
, JSDScript
*jsdscript
);
411 * Get the function name associated with this script (NULL if not a function)
413 extern JSD_PUBLIC_API(const char*)
414 JSD_GetScriptFunctionName(JSDContext
* jsdc
, JSDScript
*jsdscript
);
417 * Get the base linenumber of the sourcefile from which this script was loaded.
418 * This is one-based -- i.e. the first line of a file is line '1'. This may
419 * return 0 if this infomation is unknown.
421 extern JSD_PUBLIC_API(uintN
)
422 JSD_GetScriptBaseLineNumber(JSDContext
* jsdc
, JSDScript
*jsdscript
);
425 * Get the count of source lines associated with this script (1 or greater)
427 extern JSD_PUBLIC_API(uintN
)
428 JSD_GetScriptLineExtent(JSDContext
* jsdc
, JSDScript
*jsdscript
);
431 * Declaration of callback for notification of script creation and destruction.
432 * 'creating' is JS_TRUE if creating new script, JS_FALSE if destroying existing
433 * script (callback called just before actual destruction).
434 * 'callerdata' is what was passed to JSD_SetScriptHook to set the hook.
437 (* JS_DLL_CALLBACK JSD_ScriptHookProc
)(JSDContext
* jsdc
,
438 JSDScript
* jsdscript
,
443 * Set a hook to be called when scripts are created or destroyed (loaded or
445 * 'callerdata' can be whatever you want it to be.
447 extern JSD_PUBLIC_API(JSBool
)
448 JSD_SetScriptHook(JSDContext
* jsdc
, JSD_ScriptHookProc hook
, void* callerdata
);
451 * Get the current script hook.
453 extern JSD_PUBLIC_API(JSBool
)
454 JSD_GetScriptHook(JSDContext
* jsdc
, JSD_ScriptHookProc
* hook
, void** callerdata
);
457 * Get a 'Program Counter' value for a given line. This represents the location
458 * of the first bit of executable code for this line of source. This 'pc' should
459 * be considered an opaque handle.
460 * 0 is returned for invalid scripts, or lines that lie outside the script.
461 * If no code is on the given line, then the returned pc represents the first
462 * code within the script (if any) after the given line.
463 * This function can be used to set breakpoints -- see JSD_SetExecutionHook
465 extern JSD_PUBLIC_API(jsuword
)
466 JSD_GetClosestPC(JSDContext
* jsdc
, JSDScript
* jsdscript
, uintN line
);
469 * Get the source line number for a given 'Program Counter' location.
470 * Returns 0 if no source line information is appropriate (or available) for
473 extern JSD_PUBLIC_API(uintN
)
474 JSD_GetClosestLine(JSDContext
* jsdc
, JSDScript
* jsdscript
, jsuword pc
);
476 /* these are only used in cases where scripts are created outside of JS*/
479 * Direct call to notify JSD that a script has been created.
480 * Embeddings that use the normal jsapi script functions need not call this.
481 * Any embedding that follows the (discouraged!) practice of contructing script
482 * structures manually should call this function to inform JSD. (older ssjs
485 extern JSD_PUBLIC_API(void)
486 JSD_ScriptCreated(JSDContext
* jsdc
,
488 const char *filename
, /* URL this script loads from */
489 uintN lineno
, /* line where this script starts */
494 * see JSD_ScriptCreated
496 extern JSD_PUBLIC_API(void)
497 JSD_ScriptDestroyed(JSDContext
* jsdc
,
501 /***************************************************************************/
502 /* Source Text functions */
505 * In some embeddings (e.g. mozilla) JavaScript source code from a 'file' may be
506 * execute before the entire 'file' has even been loaded. This system supports
507 * access to such incrmentally loaded source. It also allows for the possibility
508 * that source loading may fail or be aborted (though the source that did load
509 * may still be usable). Remember that this source is the entire 'file'
510 * contents and that the JavaScript code may only be part of that source.
512 * For any given URL there can only be one source text item (the most recently
516 /* these coorespond to netscape.jsdebug.SourceTextItem.java values -
517 * change in both places if anywhere
522 JSD_SOURCE_INITED
= 0, /* initialized, but contains no source yet */
523 JSD_SOURCE_PARTIAL
= 1, /* some source loaded, more expected */
524 JSD_SOURCE_COMPLETED
= 2, /* all source finished loading */
525 JSD_SOURCE_ABORTED
= 3, /* user aborted loading, some may be loaded */
526 JSD_SOURCE_FAILED
= 4, /* loading failed, some may be loaded */
527 JSD_SOURCE_CLEARED
= 5 /* text has been cleared by debugger */
531 * Lock the entire source text subsystem. This grabs a highlevel lock that
532 * protects the JSD internal information about sources. It is important to
533 * wrap source text related calls in this lock in multithreaded situations
534 * -- i.e. where the debugger is running on a different thread than the
535 * interpreter (or the loader of sources) -- or when multiple debugger
536 * threads may be accessing this subsystem. It is safe (and best) to use
537 * this locking even if the environment might not be multi-threaded.
540 extern JSD_PUBLIC_API(void)
541 JSD_LockSourceTextSubsystem(JSDContext
* jsdc
);
544 * Unlock the entire source text subsystem. see JSD_LockSourceTextSubsystem.
546 extern JSD_PUBLIC_API(void)
547 JSD_UnlockSourceTextSubsystem(JSDContext
* jsdc
);
550 * Iterate the source test items. Use the same pattern of calls shown in
551 * the example for JSD_IterateScripts - NOTE that the SourceTextSubsystem.
552 * must be locked before and unlocked after iterating.
554 extern JSD_PUBLIC_API(JSDSourceText
*)
555 JSD_IterateSources(JSDContext
* jsdc
, JSDSourceText
**iterp
);
558 * Find the source text item for the given URL (or filename - or whatever
559 * string the given embedding uses to describe source locations).
560 * Returns NULL is not found.
562 extern JSD_PUBLIC_API(JSDSourceText
*)
563 JSD_FindSourceForURL(JSDContext
* jsdc
, const char* url
);
566 * Get the URL string associated with the given source text item
568 extern JSD_PUBLIC_API(const char*)
569 JSD_GetSourceURL(JSDContext
* jsdc
, JSDSourceText
* jsdsrc
);
572 * Get the actual source text. This gives access to the actual storage of
573 * the source - it sHould *not* be written to.
574 * The buffer is NOT zero terminated (nor is it guaranteed to have space to
575 * hold a zero terminating char).
576 * XXX this is 8-bit character data. Unicode source is not yet supported.
578 extern JSD_PUBLIC_API(JSBool
)
579 JSD_GetSourceText(JSDContext
* jsdc
, JSDSourceText
* jsdsrc
,
580 const char** ppBuf
, intN
* pLen
);
583 * Clear the text -- delete the text and set the status to JSD_SOURCE_CLEARED.
584 * This is useful if source is done loading and the debugger wishes to store
585 * the text data itself (e.g. in a Java String). This allows avoidance of
586 * storing the same text in multiple places.
588 extern JSD_PUBLIC_API(void)
589 JSD_ClearSourceText(JSDContext
* jsdc
, JSDSourceText
* jsdsrc
);
592 * Return the status of the source text item. see JSDSourceStatus enum.
594 extern JSD_PUBLIC_API(JSDSourceStatus
)
595 JSD_GetSourceStatus(JSDContext
* jsdc
, JSDSourceText
* jsdsrc
);
598 * Has the source been altered since the last call to JSD_SetSourceDirty?
599 * Use of JSD_IsSourceDirty and JSD_SetSourceDirty is still supported, but
600 * discouraged in favor of the JSD_GetSourceAlterCount system. This dirty
601 * scheme ASSUMES that there is only one consumer of the data.
603 extern JSD_PUBLIC_API(JSBool
)
604 JSD_IsSourceDirty(JSDContext
* jsdc
, JSDSourceText
* jsdsrc
);
607 * Clear the dirty flag
609 extern JSD_PUBLIC_API(void)
610 JSD_SetSourceDirty(JSDContext
* jsdc
, JSDSourceText
* jsdsrc
, JSBool dirty
);
613 * Each time a source text item is altered this value is incremented. Any
614 * consumer can store this value when they retieve other data about the
615 * source text item and then check later to see if the current value is
616 * different from their stored value. Thus they can know if they have stale
617 * data or not. NOTE: this value is not gauranteed to start at any given number.
619 extern JSD_PUBLIC_API(uintN
)
620 JSD_GetSourceAlterCount(JSDContext
* jsdc
, JSDSourceText
* jsdsrc
);
623 * Force an increment in the alter count for a source text item. This is
624 * normally automatic when the item changes, but a give consumer may want to
625 * force this to amke an item appear to have changed even if it has not.
627 extern JSD_PUBLIC_API(uintN
)
628 JSD_IncrementSourceAlterCount(JSDContext
* jsdc
, JSDSourceText
* jsdsrc
);
631 * Destroy *all* the source text items
632 * (new for server-side USE WITH CARE)
634 extern JSD_PUBLIC_API(void)
635 JSD_DestroyAllSources( JSDContext
* jsdc
);
637 /* functions for adding source items */
640 * Add a new item for a given URL. If an iten already exists for the given URL
641 * then the old item is removed.
642 * 'url' may not be NULL.
644 extern JSD_PUBLIC_API(JSDSourceText
*)
645 JSD_NewSourceText(JSDContext
* jsdc
, const char* url
);
648 * Append text (or change status -- e.g. set completed) for a source text
649 * item. Text need not be zero terminated. Callers should consider the returned
650 * JSDSourceText to be the 'current' item for future use. This may return NULL
651 * if called after this item has been replaced by a call to JSD_NewSourceText.
653 extern JSD_PUBLIC_API(JSDSourceText
*)
654 JSD_AppendSourceText(JSDContext
* jsdc
,
655 JSDSourceText
* jsdsrc
,
656 const char* text
, /* *not* zero terminated */
658 JSDSourceStatus status
);
661 * Unicode varient of JSD_AppendSourceText.
663 * NOTE: At this point text is stored in 8bit ASCII so this function just
664 * extracts the bottom 8bits from each jschar. At some future point we may
665 * switch to storing and exposing 16bit Unicode.
667 extern JSD_PUBLIC_API(JSDSourceText
*)
668 JSD_AppendUCSourceText(JSDContext
* jsdc
,
669 JSDSourceText
* jsdsrc
,
670 const jschar
* text
, /* *not* zero terminated */
672 JSDSourceStatus status
);
674 * Convienence function for adding complete source of url in one call.
676 * JSDSourceText* jsdsrc;
677 * JSD_LOCK_SOURCE_TEXT(jsdc);
678 * jsdsrc = jsd_NewSourceText(jsdc, url);
680 * jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc,
681 * text, length, JSD_SOURCE_PARTIAL);
683 * jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc,
684 * NULL, 0, JSD_SOURCE_COMPLETED);
685 * JSD_UNLOCK_SOURCE_TEXT(jsdc);
686 * return jsdsrc ? JS_TRUE : JS_FALSE;
688 extern JSD_PUBLIC_API(JSBool
)
689 JSD_AddFullSourceText(JSDContext
* jsdc
,
690 const char* text
, /* *not* zero terminated */
694 /***************************************************************************/
695 /* Execution/Interrupt Hook functions */
697 /* possible 'type' params for JSD_ExecutionHookProc */
698 #define JSD_HOOK_INTERRUPTED 0
699 #define JSD_HOOK_BREAKPOINT 1
700 #define JSD_HOOK_DEBUG_REQUESTED 2
701 #define JSD_HOOK_DEBUGGER_KEYWORD 3
702 #define JSD_HOOK_THROW 4
704 /* legal return values for JSD_ExecutionHookProc */
705 #define JSD_HOOK_RETURN_HOOK_ERROR 0
706 #define JSD_HOOK_RETURN_CONTINUE 1
707 #define JSD_HOOK_RETURN_ABORT 2
708 #define JSD_HOOK_RETURN_RET_WITH_VAL 3
709 #define JSD_HOOK_RETURN_THROW_WITH_VAL 4
710 #define JSD_HOOK_RETURN_CONTINUE_THROW 5
713 * Implement a callback of this form in order to hook execution.
716 (* JS_DLL_CALLBACK JSD_ExecutionHookProc
)(JSDContext
* jsdc
,
717 JSDThreadState
* jsdthreadstate
,
722 /* possible 'type' params for JSD_CallHookProc */
723 #define JSD_HOOK_TOPLEVEL_START 0 /* about to evaluate top level script */
724 #define JSD_HOOK_TOPLEVEL_END 1 /* done evaluting top level script */
725 #define JSD_HOOK_FUNCTION_CALL 2 /* about to call a function */
726 #define JSD_HOOK_FUNCTION_RETURN 3 /* done calling function */
729 * Implement a callback of this form in order to hook function call/returns.
730 * Return JS_TRUE from a TOPLEVEL_START or FUNCTION_CALL type call hook if you
731 * want to hear about the TOPLEVEL_END or FUNCTION_RETURN too. Return value is
732 * ignored to TOPLEVEL_END and FUNCTION_RETURN type hooks.
735 (* JS_DLL_CALLBACK JSD_CallHookProc
)(JSDContext
* jsdc
,
736 JSDThreadState
* jsdthreadstate
,
741 * Set Hook to be called whenever the given pc is about to be executed --
742 * i.e. for 'trap' or 'breakpoint'
744 extern JSD_PUBLIC_API(JSBool
)
745 JSD_SetExecutionHook(JSDContext
* jsdc
,
746 JSDScript
* jsdscript
,
748 JSD_ExecutionHookProc hook
,
752 * Clear the hook for this pc
754 extern JSD_PUBLIC_API(JSBool
)
755 JSD_ClearExecutionHook(JSDContext
* jsdc
,
756 JSDScript
* jsdscript
,
760 * Clear all the pc specific hooks for this script
762 extern JSD_PUBLIC_API(JSBool
)
763 JSD_ClearAllExecutionHooksForScript(JSDContext
* jsdc
, JSDScript
* jsdscript
);
766 * Clear all the pc specific hooks for the entire JSRuntime associated with
769 extern JSD_PUBLIC_API(JSBool
)
770 JSD_ClearAllExecutionHooks(JSDContext
* jsdc
);
773 * Set a hook to be called before the next instruction is executed. Depending
774 * on the threading situation and whether or not an JS code is currently
775 * executing the hook might be called before this call returns, or at some
776 * future time. The hook will continue to be called as each instruction
777 * executes until cleared.
779 extern JSD_PUBLIC_API(JSBool
)
780 JSD_SetInterruptHook(JSDContext
* jsdc
,
781 JSD_ExecutionHookProc hook
,
785 * Clear the current interrupt hook.
787 extern JSD_PUBLIC_API(JSBool
)
788 JSD_ClearInterruptHook(JSDContext
* jsdc
);
791 * Set the hook that should be called whenever a JSD_ErrorReporter hook
792 * returns JSD_ERROR_REPORTER_DEBUG.
794 extern JSD_PUBLIC_API(JSBool
)
795 JSD_SetDebugBreakHook(JSDContext
* jsdc
,
796 JSD_ExecutionHookProc hook
,
800 * Clear the debug break hook
802 extern JSD_PUBLIC_API(JSBool
)
803 JSD_ClearDebugBreakHook(JSDContext
* jsdc
);
806 * Set the hook that should be called when the 'debugger' keyword is
807 * encountered by the JavaScript interpreter during execution.
809 extern JSD_PUBLIC_API(JSBool
)
810 JSD_SetDebuggerHook(JSDContext
* jsdc
,
811 JSD_ExecutionHookProc hook
,
815 * Clear the 'debugger' keyword hook
817 extern JSD_PUBLIC_API(JSBool
)
818 JSD_ClearDebuggerHook(JSDContext
* jsdc
);
821 * Set the hook that should be called when a JS exception is thrown.
822 * NOTE: the 'do default' return value is: JSD_HOOK_RETURN_CONTINUE_THROW
824 extern JSD_PUBLIC_API(JSBool
)
825 JSD_SetThrowHook(JSDContext
* jsdc
,
826 JSD_ExecutionHookProc hook
,
829 * Clear the throw hook
831 extern JSD_PUBLIC_API(JSBool
)
832 JSD_ClearThrowHook(JSDContext
* jsdc
);
835 * Set the hook that should be called when a toplevel script begins or completes.
837 extern JSD_PUBLIC_API(JSBool
)
838 JSD_SetTopLevelHook(JSDContext
* jsdc
,
839 JSD_CallHookProc hook
,
842 * Clear the toplevel call hook
844 extern JSD_PUBLIC_API(JSBool
)
845 JSD_ClearTopLevelHook(JSDContext
* jsdc
);
848 * Set the hook that should be called when a function call or return happens.
850 extern JSD_PUBLIC_API(JSBool
)
851 JSD_SetFunctionHook(JSDContext
* jsdc
,
852 JSD_CallHookProc hook
,
855 * Clear the function call hook
857 extern JSD_PUBLIC_API(JSBool
)
858 JSD_ClearFunctionHook(JSDContext
* jsdc
);
860 /***************************************************************************/
861 /* Stack Frame functions */
864 * Get the count of call stack frames for the given JSDThreadState
866 extern JSD_PUBLIC_API(uintN
)
867 JSD_GetCountOfStackFrames(JSDContext
* jsdc
, JSDThreadState
* jsdthreadstate
);
870 * Get the 'current' call stack frame for the given JSDThreadState
872 extern JSD_PUBLIC_API(JSDStackFrameInfo
*)
873 JSD_GetStackFrame(JSDContext
* jsdc
, JSDThreadState
* jsdthreadstate
);
876 * Get the JSContext for the given JSDThreadState
878 extern JSD_PUBLIC_API(JSContext
*)
879 JSD_GetJSContext(JSDContext
* jsdc
, JSDThreadState
* jsdthreadstate
);
882 * Get the calling call stack frame for the given frame
884 extern JSD_PUBLIC_API(JSDStackFrameInfo
*)
885 JSD_GetCallingStackFrame(JSDContext
* jsdc
,
886 JSDThreadState
* jsdthreadstate
,
887 JSDStackFrameInfo
* jsdframe
);
890 * Get the script for the given call stack frame
892 extern JSD_PUBLIC_API(JSDScript
*)
893 JSD_GetScriptForStackFrame(JSDContext
* jsdc
,
894 JSDThreadState
* jsdthreadstate
,
895 JSDStackFrameInfo
* jsdframe
);
898 * Get the 'Program Counter' for the given call stack frame
900 extern JSD_PUBLIC_API(jsuword
)
901 JSD_GetPCForStackFrame(JSDContext
* jsdc
,
902 JSDThreadState
* jsdthreadstate
,
903 JSDStackFrameInfo
* jsdframe
);
906 * Get the JavaScript Call Object for the given call stack frame.
907 * *** new for version 1.1 ****
909 extern JSD_PUBLIC_API(JSDValue
*)
910 JSD_GetCallObjectForStackFrame(JSDContext
* jsdc
,
911 JSDThreadState
* jsdthreadstate
,
912 JSDStackFrameInfo
* jsdframe
);
915 * Get the head of the scope chain for the given call stack frame.
916 * the chain can be traversed using JSD_GetValueParent.
917 * *** new for version 1.1 ****
919 extern JSD_PUBLIC_API(JSDValue
*)
920 JSD_GetScopeChainForStackFrame(JSDContext
* jsdc
,
921 JSDThreadState
* jsdthreadstate
,
922 JSDStackFrameInfo
* jsdframe
);
925 * Get the 'this' Object for the given call stack frame.
926 * *** new for version 1.1 ****
928 extern JSD_PUBLIC_API(JSDValue
*)
929 JSD_GetThisForStackFrame(JSDContext
* jsdc
,
930 JSDThreadState
* jsdthreadstate
,
931 JSDStackFrameInfo
* jsdframe
);
934 * Get the name of the function executing in this stack frame. Especially useful
935 * for native frames (without script objects.)
937 extern JSD_PUBLIC_API(const char*)
938 JSD_GetNameForStackFrame(JSDContext
* jsdc
,
939 JSDThreadState
* jsdthreadstate
,
940 JSDStackFrameInfo
* jsdframe
);
943 * True if stack frame represents a native frame.
945 extern JSD_PUBLIC_API(JSBool
)
946 JSD_IsStackFrameNative(JSDContext
* jsdc
,
947 JSDThreadState
* jsdthreadstate
,
948 JSDStackFrameInfo
* jsdframe
);
951 * True if stack frame represents a frame created as a result of a debugger
954 extern JSD_PUBLIC_API(JSBool
)
955 JSD_IsStackFrameDebugger(JSDContext
* jsdc
,
956 JSDThreadState
* jsdthreadstate
,
957 JSDStackFrameInfo
* jsdframe
);
960 * True if stack frame is constructing a new object.
962 extern JSD_PUBLIC_API(JSBool
)
963 JSD_IsStackFrameConstructing(JSDContext
* jsdc
,
964 JSDThreadState
* jsdthreadstate
,
965 JSDStackFrameInfo
* jsdframe
);
968 * Evaluate the given unicode source code in the context of the given stack frame.
969 * returns JS_TRUE and puts result in rval on success, JS_FALSE on failure.
970 * NOTE: The ErrorReporter hook might be called if this fails.
972 extern JSD_PUBLIC_API(JSBool
)
973 JSD_EvaluateUCScriptInStackFrame(JSDContext
* jsdc
,
974 JSDThreadState
* jsdthreadstate
,
975 JSDStackFrameInfo
* jsdframe
,
976 const jschar
*bytes
, uintN length
,
977 const char *filename
, uintN lineno
,
981 * Same as above, but does not eat exceptions.
983 extern JSD_PUBLIC_API(JSBool
)
984 JSD_AttemptUCScriptInStackFrame(JSDContext
* jsdc
,
985 JSDThreadState
* jsdthreadstate
,
986 JSDStackFrameInfo
* jsdframe
,
987 const jschar
*bytes
, uintN length
,
988 const char *filename
, uintN lineno
,
991 /* single byte character version of JSD_EvaluateUCScriptInStackFrame */
992 extern JSD_PUBLIC_API(JSBool
)
993 JSD_EvaluateScriptInStackFrame(JSDContext
* jsdc
,
994 JSDThreadState
* jsdthreadstate
,
995 JSDStackFrameInfo
* jsdframe
,
996 const char *bytes
, uintN length
,
997 const char *filename
, uintN lineno
, jsval
*rval
);
1000 * Same as above, but does not eat exceptions.
1002 extern JSD_PUBLIC_API(JSBool
)
1003 JSD_AttemptScriptInStackFrame(JSDContext
* jsdc
,
1004 JSDThreadState
* jsdthreadstate
,
1005 JSDStackFrameInfo
* jsdframe
,
1006 const char *bytes
, uintN length
,
1007 const char *filename
, uintN lineno
, jsval
*rval
);
1010 * Convert the given jsval to a string
1011 * NOTE: The ErrorReporter hook might be called if this fails.
1013 extern JSD_PUBLIC_API(JSString
*)
1014 JSD_ValToStringInStackFrame(JSDContext
* jsdc
,
1015 JSDThreadState
* jsdthreadstate
,
1016 JSDStackFrameInfo
* jsdframe
,
1020 * Get the JSDValue currently being thrown as an exception (may be NULL).
1021 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1022 * *** new for version 1.1 ****
1024 extern JSD_PUBLIC_API(JSDValue
*)
1025 JSD_GetException(JSDContext
* jsdc
, JSDThreadState
* jsdthreadstate
);
1028 * Set the JSDValue currently being thrown as an exception.
1029 * *** new for version 1.1 ****
1031 extern JSD_PUBLIC_API(JSBool
)
1032 JSD_SetException(JSDContext
* jsdc
, JSDThreadState
* jsdthreadstate
,
1035 /***************************************************************************/
1036 /* Error Reporter functions */
1039 * XXX The ErrorReporter Hook scheme is going to change soon to more
1040 * Fully support exceptions.
1043 /* legal return values for JSD_ErrorReporter */
1044 #define JSD_ERROR_REPORTER_PASS_ALONG 0 /* pass along to regular reporter */
1045 #define JSD_ERROR_REPORTER_RETURN 1 /* don't pass to error reporter */
1046 #define JSD_ERROR_REPORTER_DEBUG 2 /* force call to DebugBreakHook */
1047 #define JSD_ERROR_REPORTER_CLEAR_RETURN 3 /* clear exception and don't pass */
1050 * Implement a callback of this form in order to hook the ErrorReporter
1053 (* JS_DLL_CALLBACK JSD_ErrorReporter
)(JSDContext
* jsdc
,
1055 const char* message
,
1056 JSErrorReport
* report
,
1059 /* Set ErrorReporter hook */
1060 extern JSD_PUBLIC_API(JSBool
)
1061 JSD_SetErrorReporter(JSDContext
* jsdc
,
1062 JSD_ErrorReporter reporter
,
1065 /* Get Current ErrorReporter hook */
1066 extern JSD_PUBLIC_API(JSBool
)
1067 JSD_GetErrorReporter(JSDContext
* jsdc
,
1068 JSD_ErrorReporter
* reporter
,
1071 /***************************************************************************/
1072 /* Generic locks that callers can use for their own purposes */
1075 * Is Locking and GetThread supported in this build?
1077 extern JSD_PUBLIC_API(JSBool
)
1078 JSD_IsLockingAndThreadIdSupported();
1081 * Create a reentrant/nestable lock
1083 extern JSD_PUBLIC_API(void*)
1087 * Aquire lock for this thread (or block until available). Increments a
1088 * counter if this thread already owns the lock.
1090 extern JSD_PUBLIC_API(void)
1091 JSD_Lock(void* lock
);
1094 * Release lock for this thread (or decrement the counter if JSD_Lock
1095 * was previous called more than once).
1097 extern JSD_PUBLIC_API(void)
1098 JSD_Unlock(void* lock
);
1101 * For debugging only if not (JS_THREADSAFE AND DEBUG) then returns JS_TRUE
1102 * So JSD_IsLocked(lock) may not equal !JSD_IsUnlocked(lock)
1104 extern JSD_PUBLIC_API(JSBool
)
1105 JSD_IsLocked(void* lock
);
1110 extern JSD_PUBLIC_API(JSBool
)
1111 JSD_IsUnlocked(void* lock
);
1114 * return an ID uniquely identifying this thread.
1116 extern JSD_PUBLIC_API(void*)
1117 JSD_CurrentThread();
1119 /***************************************************************************/
1120 /* Value and Property Functions --- All NEW for 1.1 --- */
1123 * NOTE: JSDValue and JSDProperty objects are reference counted. This allows
1124 * for rooting these objects AND any underlying garbage collected jsvals.
1125 * ALL JSDValue and JSDProperty objects returned by the functions below
1126 * MUST eventually be released using the appropriate JSD_Dropxxx function.
1130 * Create a new JSDValue to wrap the given jsval
1131 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1132 * *** new for version 1.1 ****
1134 extern JSD_PUBLIC_API(JSDValue
*)
1135 JSD_NewValue(JSDContext
* jsdc
, jsval val
);
1138 * Release the JSDValue. After this call the object MUST not be referenced again!
1139 * *** new for version 1.1 ****
1141 extern JSD_PUBLIC_API(void)
1142 JSD_DropValue(JSDContext
* jsdc
, JSDValue
* jsdval
);
1145 * Get the jsval wrapped by this JSDValue
1146 * *** new for version 1.1 ****
1148 extern JSD_PUBLIC_API(jsval
)
1149 JSD_GetValueWrappedJSVal(JSDContext
* jsdc
, JSDValue
* jsdval
);
1152 * Clear all property and association information about the given JSDValue.
1153 * Such information will be lazily regenerated when later accessed. This
1154 * function must be called to make changes to the properties of an object
1155 * visible to the accessor functions below (if the properties et.al. have
1156 * changed since a previous call to those accessors).
1157 * *** new for version 1.1 ****
1159 extern JSD_PUBLIC_API(void)
1160 JSD_RefreshValue(JSDContext
* jsdc
, JSDValue
* jsdval
);
1162 /**************************************************/
1165 * Does the JSDValue wrap a JSObject?
1166 * *** new for version 1.1 ****
1168 extern JSD_PUBLIC_API(JSBool
)
1169 JSD_IsValueObject(JSDContext
* jsdc
, JSDValue
* jsdval
);
1172 * Does the JSDValue wrap a number (int or double)?
1173 * *** new for version 1.1 ****
1175 extern JSD_PUBLIC_API(JSBool
)
1176 JSD_IsValueNumber(JSDContext
* jsdc
, JSDValue
* jsdval
);
1179 * Does the JSDValue wrap an int?
1180 * *** new for version 1.1 ****
1182 extern JSD_PUBLIC_API(JSBool
)
1183 JSD_IsValueInt(JSDContext
* jsdc
, JSDValue
* jsdval
);
1186 * Does the JSDValue wrap a double?
1187 * *** new for version 1.1 ****
1189 extern JSD_PUBLIC_API(JSBool
)
1190 JSD_IsValueDouble(JSDContext
* jsdc
, JSDValue
* jsdval
);
1193 * Does the JSDValue wrap a JSString?
1194 * *** new for version 1.1 ****
1196 extern JSD_PUBLIC_API(JSBool
)
1197 JSD_IsValueString(JSDContext
* jsdc
, JSDValue
* jsdval
);
1200 * Does the JSDValue wrap a JSBool?
1201 * *** new for version 1.1 ****
1203 extern JSD_PUBLIC_API(JSBool
)
1204 JSD_IsValueBoolean(JSDContext
* jsdc
, JSDValue
* jsdval
);
1207 * Does the JSDValue wrap a JSVAL_NULL?
1208 * *** new for version 1.1 ****
1210 extern JSD_PUBLIC_API(JSBool
)
1211 JSD_IsValueNull(JSDContext
* jsdc
, JSDValue
* jsdval
);
1214 * Does the JSDValue wrap a JSVAL_VOID?
1215 * *** new for version 1.1 ****
1217 extern JSD_PUBLIC_API(JSBool
)
1218 JSD_IsValueVoid(JSDContext
* jsdc
, JSDValue
* jsdval
);
1221 * Does the JSDValue wrap a primative (not a JSObject)?
1222 * *** new for version 1.1 ****
1224 extern JSD_PUBLIC_API(JSBool
)
1225 JSD_IsValuePrimitive(JSDContext
* jsdc
, JSDValue
* jsdval
);
1228 * Does the JSDValue wrap a function?
1229 * *** new for version 1.1 ****
1231 extern JSD_PUBLIC_API(JSBool
)
1232 JSD_IsValueFunction(JSDContext
* jsdc
, JSDValue
* jsdval
);
1235 * Does the JSDValue wrap a native function?
1236 * *** new for version 1.1 ****
1238 extern JSD_PUBLIC_API(JSBool
)
1239 JSD_IsValueNative(JSDContext
* jsdc
, JSDValue
* jsdval
);
1241 /**************************************************/
1244 * Return JSBool value (does NOT do conversion).
1245 * *** new for version 1.1 ****
1247 extern JSD_PUBLIC_API(JSBool
)
1248 JSD_GetValueBoolean(JSDContext
* jsdc
, JSDValue
* jsdval
);
1251 * Return int32 value (does NOT do conversion).
1252 * *** new for version 1.1 ****
1254 extern JSD_PUBLIC_API(int32
)
1255 JSD_GetValueInt(JSDContext
* jsdc
, JSDValue
* jsdval
);
1258 * Return double value (does NOT do conversion).
1259 * *** new for version 1.1 ****
1261 extern JSD_PUBLIC_API(jsdouble
*)
1262 JSD_GetValueDouble(JSDContext
* jsdc
, JSDValue
* jsdval
);
1265 * Return JSString value (DOES do conversion if necessary).
1266 * NOTE that the JSString returned is not protected from garbage
1267 * collection. It should be immediately read or wrapped using
1268 * JSD_NewValue(jsdc,STRING_TO_JSVAL(str)) if necessary.
1269 * *** new for version 1.1 ****
1271 extern JSD_PUBLIC_API(JSString
*)
1272 JSD_GetValueString(JSDContext
* jsdc
, JSDValue
* jsdval
);
1275 * Return name of function IFF JSDValue represents a function.
1276 * *** new for version 1.1 ****
1278 extern JSD_PUBLIC_API(const char*)
1279 JSD_GetValueFunctionName(JSDContext
* jsdc
, JSDValue
* jsdval
);
1281 /**************************************************/
1284 * Return the number of properties for the JSDValue.
1285 * *** new for version 1.1 ****
1287 extern JSD_PUBLIC_API(uintN
)
1288 JSD_GetCountOfProperties(JSDContext
* jsdc
, JSDValue
* jsdval
);
1291 * Iterate through the properties of the JSDValue.
1292 * Use form similar to that shown for JSD_IterateScripts (no locking required).
1293 * NOTE: each JSDProperty returned must eventually be released by calling
1295 * *** new for version 1.1 ****
1297 extern JSD_PUBLIC_API(JSDProperty
*)
1298 JSD_IterateProperties(JSDContext
* jsdc
, JSDValue
* jsdval
, JSDProperty
**iterp
);
1301 * Get the JSDProperty for the property of this JSDVal with this name.
1302 * NOTE: must eventually release by calling JSD_DropProperty (if not NULL)
1303 * *** new for version 1.1 ****
1305 extern JSD_PUBLIC_API(JSDProperty
*)
1306 JSD_GetValueProperty(JSDContext
* jsdc
, JSDValue
* jsdval
, JSString
* name
);
1309 * Get the prototype object for this JSDValue.
1310 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1311 * *** new for version 1.1 ****
1313 extern JSD_PUBLIC_API(JSDValue
*)
1314 JSD_GetValuePrototype(JSDContext
* jsdc
, JSDValue
* jsdval
);
1317 * Get the parent object for this JSDValue.
1318 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1319 * *** new for version 1.1 ****
1321 extern JSD_PUBLIC_API(JSDValue
*)
1322 JSD_GetValueParent(JSDContext
* jsdc
, JSDValue
* jsdval
);
1325 * Get the ctor object for this JSDValue (or likely its prototype's ctor).
1326 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1327 * *** new for version 1.1 ****
1329 extern JSD_PUBLIC_API(JSDValue
*)
1330 JSD_GetValueConstructor(JSDContext
* jsdc
, JSDValue
* jsdval
);
1333 * Get the name of the class for this object.
1334 * *** new for version 1.1 ****
1336 extern JSD_PUBLIC_API(const char*)
1337 JSD_GetValueClassName(JSDContext
* jsdc
, JSDValue
* jsdval
);
1339 /**************************************************/
1341 /* possible or'd together bitflags returned by JSD_GetPropertyFlags
1343 * XXX these must stay the same as the JSPD_ flags in jsdbgapi.h
1345 #define JSDPD_ENUMERATE JSPD_ENUMERATE /* visible to for/in loop */
1346 #define JSDPD_READONLY JSPD_READONLY /* assignment is error */
1347 #define JSDPD_PERMANENT JSPD_PERMANENT /* property cannot be deleted */
1348 #define JSDPD_ALIAS JSPD_ALIAS /* property has an alias id */
1349 #define JSDPD_ARGUMENT JSPD_ARGUMENT /* argument to function */
1350 #define JSDPD_VARIABLE JSPD_VARIABLE /* local variable in function */
1351 #define JSDPD_EXCEPTION JSPD_EXCEPTION /* exception occurred looking up */
1352 /* proprety, value is exception */
1353 #define JSDPD_ERROR JSPD_ERROR /* native getter returned JS_FALSE */
1354 /* without throwing an exception */
1355 /* this is not one of the JSPD_ flags in jsdbgapi.h - careful not to overlap*/
1356 #define JSDPD_HINTED 0x800 /* found via explicit lookup */
1359 * Release this JSDProperty
1360 * *** new for version 1.1 ****
1362 extern JSD_PUBLIC_API(void)
1363 JSD_DropProperty(JSDContext
* jsdc
, JSDProperty
* jsdprop
);
1366 * Get the JSDValue represeting the name of this property (int or string)
1367 * NOTE: must eventually release by calling JSD_DropValue
1368 * *** new for version 1.1 ****
1370 extern JSD_PUBLIC_API(JSDValue
*)
1371 JSD_GetPropertyName(JSDContext
* jsdc
, JSDProperty
* jsdprop
);
1374 * Get the JSDValue represeting the current value of this property
1375 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1376 * *** new for version 1.1 ****
1378 extern JSD_PUBLIC_API(JSDValue
*)
1379 JSD_GetPropertyValue(JSDContext
* jsdc
, JSDProperty
* jsdprop
);
1382 * Get the JSDValue represeting the alias of this property (if JSDPD_ALIAS set)
1383 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1384 * *** new for version 1.1 ****
1386 extern JSD_PUBLIC_API(JSDValue
*)
1387 JSD_GetPropertyAlias(JSDContext
* jsdc
, JSDProperty
* jsdprop
);
1390 * Get the flags for this property
1391 * *** new for version 1.1 ****
1393 extern JSD_PUBLIC_API(uintN
)
1394 JSD_GetPropertyFlags(JSDContext
* jsdc
, JSDProperty
* jsdprop
);
1397 * Get Variable or Argument slot number (if JSDPD_ARGUMENT or JSDPD_VARIABLE set)
1398 * *** new for version 1.1 ****
1400 extern JSD_PUBLIC_API(uintN
)
1401 JSD_GetPropertyVarArgSlot(JSDContext
* jsdc
, JSDProperty
* jsdprop
);
1403 /***************************************************************************/
1404 /* Object Functions --- All NEW for 1.1 --- */
1407 * JSDObjects exist to allow a means of iterating through all JSObjects in the
1408 * engine. They are created and destroyed as the wrapped JSObjects are created
1409 * and destroyed in the engine. JSDObjects additionally track the location in
1410 * the JavaScript source where their wrapped JSObjects were created and the name
1411 * and location of the (non-native) constructor used.
1413 * NOTE: JSDObjects are NOT reference counted. The have only weak links to
1414 * jsObjects - thus they do not inhibit garbage collection of JSObjects. If
1415 * you need a JSDObject to safely persist then wrap it in a JSDValue (using
1416 * jsd_GetValueForObject).
1420 * Lock the entire Object subsystem -- see JSD_UnlockObjectSubsystem
1421 * *** new for version 1.1 ****
1423 extern JSD_PUBLIC_API(void)
1424 JSD_LockObjectSubsystem(JSDContext
* jsdc
);
1427 * Unlock the entire Object subsystem -- see JSD_LockObjectSubsystem
1428 * *** new for version 1.1 ****
1430 extern JSD_PUBLIC_API(void)
1431 JSD_UnlockObjectSubsystem(JSDContext
* jsdc
);
1434 * Iterate through the known objects
1435 * Use form similar to that shown for JSD_IterateScripts.
1436 * NOTE: the ObjectSubsystem must be locked before and unlocked after iterating.
1437 * *** new for version 1.1 ****
1439 extern JSD_PUBLIC_API(JSDObject
*)
1440 JSD_IterateObjects(JSDContext
* jsdc
, JSDObject
** iterp
);
1443 * Get the JSObject represented by this JSDObject
1444 * *** new for version 1.1 ****
1446 extern JSD_PUBLIC_API(JSObject
*)
1447 JSD_GetWrappedObject(JSDContext
* jsdc
, JSDObject
* jsdobj
);
1450 * Get the URL of the line of source that caused this object to be created.
1452 * *** new for version 1.1 ****
1454 extern JSD_PUBLIC_API(const char*)
1455 JSD_GetObjectNewURL(JSDContext
* jsdc
, JSDObject
* jsdobj
);
1458 * Get the line number of the line of source that caused this object to be
1459 * created. May be 0 indicating that the line number is unknown.
1460 * *** new for version 1.1 ****
1462 extern JSD_PUBLIC_API(uintN
)
1463 JSD_GetObjectNewLineNumber(JSDContext
* jsdc
, JSDObject
* jsdobj
);
1466 * Get the URL of the line of source of the constructor for this object.
1468 * *** new for version 1.1 ****
1470 extern JSD_PUBLIC_API(const char*)
1471 JSD_GetObjectConstructorURL(JSDContext
* jsdc
, JSDObject
* jsdobj
);
1474 * Get the line number of the line of source of the constructor for this object.
1475 * created. May be 0 indicating that the line number is unknown.
1476 * *** new for version 1.1 ****
1478 extern JSD_PUBLIC_API(uintN
)
1479 JSD_GetObjectConstructorLineNumber(JSDContext
* jsdc
, JSDObject
* jsdobj
);
1482 * Get the name of the constructor for this object.
1484 * *** new for version 1.1 ****
1486 extern JSD_PUBLIC_API(const char*)
1487 JSD_GetObjectConstructorName(JSDContext
* jsdc
, JSDObject
* jsdobj
);
1490 * Get JSDObject representing this JSObject.
1492 * *** new for version 1.1 ****
1494 extern JSD_PUBLIC_API(JSDObject
*)
1495 JSD_GetJSDObjectForJSObject(JSDContext
* jsdc
, JSObject
* jsobj
);
1498 * Get JSDObject representing this JSDValue.
1500 * *** new for version 1.1 ****
1502 extern JSD_PUBLIC_API(JSDObject
*)
1503 JSD_GetObjectForValue(JSDContext
* jsdc
, JSDValue
* jsdval
);
1506 * Create a JSDValue to wrap (and root) this JSDObject.
1507 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1508 * *** new for version 1.1 ****
1510 extern JSD_PUBLIC_API(JSDValue
*)
1511 JSD_GetValueForObject(JSDContext
* jsdc
, JSDObject
* jsdobj
);
1513 /***************************************************************************/
1514 /* Livewire specific API */
1517 extern JSD_PUBLIC_API(LWDBGScript
*)
1518 JSDLW_GetLWScript(JSDContext
* jsdc
, JSDScript
* jsdscript
);
1520 extern JSD_PUBLIC_API(JSDSourceText
*)
1521 JSDLW_PreLoadSource(JSDContext
* jsdc
, LWDBGApp
* app
,
1522 const char* filename
, JSBool clear
);
1524 extern JSD_PUBLIC_API(JSDSourceText
*)
1525 JSDLW_ForceLoadSource(JSDContext
* jsdc
, JSDSourceText
* jsdsrc
);
1527 extern JSD_PUBLIC_API(JSBool
)
1528 JSDLW_RawToProcessedLineNumber(JSDContext
* jsdc
, JSDScript
* jsdscript
,
1529 uintN lineIn
, uintN
* lineOut
);
1531 extern JSD_PUBLIC_API(JSBool
)
1532 JSDLW_ProcessedToRawLineNumber(JSDContext
* jsdc
, JSDScript
* jsdscript
,
1533 uintN lineIn
, uintN
* lineOut
);
1536 /***************************************************************************/
1540 #endif /* jsdebug_h___ */