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!
66 * The linkage of JSD API functions differs depending on whether the file is
67 * used within the JSD library or not. Any source file within the JSD
68 * libraray should define EXPORT_JSD_API whereas any client of the library
72 #define JSD_PUBLIC_API(t) JS_EXPORT_API(t)
73 #define JSD_PUBLIC_DATA(t) JS_EXPORT_DATA(t)
75 #define JSD_PUBLIC_API(t) JS_IMPORT_API(t)
76 #define JSD_PUBLIC_DATA(t) JS_IMPORT_DATA(t)
79 #define JSD_FRIEND_API(t) JSD_PUBLIC_API(t)
80 #define JSD_FRIEND_DATA(t) JSD_PUBLIC_DATA(t)
82 /***************************************************************************/
83 /* Opaque typedefs for handles */
85 typedef struct JSDContext JSDContext;
86 typedef struct JSDScript JSDScript;
87 typedef struct JSDSourceText JSDSourceText;
88 typedef struct JSDThreadState JSDThreadState;
89 typedef struct JSDStackFrameInfo JSDStackFrameInfo;
90 typedef struct JSDValue JSDValue;
91 typedef struct JSDProperty JSDProperty;
92 typedef struct JSDObject JSDObject;
94 /***************************************************************************/
95 /* High Level calls */
98 * callback stuff for calls in EXE to be accessed by this code
99 * when it lives in an explicitly loaded DLL
103 * This callback allows JSD to inform the embedding when JSD has been
104 * turned on or off. This is especially useful in the Java-based debugging
105 * system used in mozilla because the debugger applet controls starting
109 (* JSD_SetContextProc)(JSDContext* jsdc, void* user);
111 /* This struct could have more fields in future versions */
114 uintN size; /* size of this struct (init before use)*/
115 JSD_SetContextProc setContext;
119 * Used by an embedding to tell JSD what JSRuntime to use and to set
120 * callbacks without starting up JSD. This assumes only one JSRuntime
121 * will be used. This exists to support the mozilla Java-based debugger
124 extern JSD_PUBLIC_API(void)
125 JSD_SetUserCallbacks(JSRuntime* jsrt,
126 JSD_UserCallbacks* callbacks,
131 * This version of the init function requires that JSD_SetUserCallbacks()
132 * has been previously called (with a non-NULL callback struct pointer)
134 extern JSD_PUBLIC_API(JSDContext*)
135 JSD_DebuggerOn(void);
138 * Startup JSD on a particular JSRuntime with (optional) callbacks
140 extern JSD_PUBLIC_API(JSDContext*)
141 JSD_DebuggerOnForUser(JSRuntime* jsrt,
142 JSD_UserCallbacks* callbacks,
146 * Startup JSD in an application that uses compartments. Debugger
147 * objects will be allocated in the same compartment as scopeobj.
149 extern JSD_PUBLIC_API(JSDContext*)
150 JSD_DebuggerOnForUserWithCompartment(JSRuntime* jsrt,
151 JSD_UserCallbacks* callbacks,
156 * Shutdown JSD for this JSDContext
158 extern JSD_PUBLIC_API(void)
159 JSD_DebuggerOff(JSDContext* jsdc);
162 * Pause JSD for this JSDContext
164 extern JSD_PUBLIC_API(void)
165 JSD_DebuggerPause(JSDContext* jsdc);
168 * Unpause JSD for this JSDContext
170 extern JSD_PUBLIC_API(void)
171 JSD_DebuggerUnpause(JSDContext* jsdc);
174 * Get the Major Version (initial JSD release used major version = 1)
176 extern JSD_PUBLIC_API(uintN)
177 JSD_GetMajorVersion(void);
180 * Get the Minor Version (initial JSD release used minor version = 0)
182 extern JSD_PUBLIC_API(uintN)
183 JSD_GetMinorVersion(void);
186 * Returns a 'dumb' JSContext that can be used for utility purposes as needed
188 extern JSD_PUBLIC_API(JSContext*)
189 JSD_GetDefaultJSContext(JSDContext* jsdc);
192 * Set the private data for this context, returns previous value
194 extern JSD_PUBLIC_API(void *)
195 JSD_SetContextPrivate(JSDContext *jsdc, void *data);
198 * Get the private data for this context
200 extern JSD_PUBLIC_API(void *)
201 JSD_GetContextPrivate(JSDContext *jsdc);
204 * Clear profile data for all scripts
206 extern JSD_PUBLIC_API(void)
207 JSD_ClearAllProfileData(JSDContext* jsdc);
213 /* Include native frames in JSDThreadStates. */
214 #define JSD_INCLUDE_NATIVE_FRAMES 0x01
216 * Normally, if a script has a 0 in JSD_SCRIPT_PROFILE_BIT it is included in
217 * profile data, otherwise it is not profiled. Setting the JSD_PROFILE_WHEN_SET
218 * flag reverses this convention.
220 #define JSD_PROFILE_WHEN_SET 0x02
222 * Normally, when the script in the top frame of a thread state has a 1 in
223 * JSD_SCRIPT_DEBUG_BIT, the execution hook is ignored. Setting the
224 * JSD_DEBUG_WHEN_SET flag reverses this convention.
226 #define JSD_DEBUG_WHEN_SET 0x04
228 * When this flag is set the internal call hook will collect profile data.
230 #define JSD_COLLECT_PROFILE_DATA 0x08
232 * When this flag is set, stack frames that are disabled for debugging
233 * will not appear in the call stack chain.
235 #define JSD_HIDE_DISABLED_FRAMES 0x10
237 * When this flag is set, the debugger will only check the
238 * JSD_SCRIPT_DEBUG_BIT on the top (most recent) stack frame. This
239 * makes it possible to stop in an enabled frame which was called from
240 * a stack that contains a disabled frame.
242 * When this flag is *not* set, any stack that contains a disabled frame
243 * will not be debugged (the execution hook will not be invoked.)
245 * This only applies when the reason for calling the hook would have
246 * been JSD_HOOK_INTERRUPTED or JSD_HOOK_THROW. JSD_HOOK_BREAKPOINT,
247 * JSD_HOOK_DEBUG_REQUESTED, and JSD_HOOK_DEBUGGER_KEYWORD always stop,
248 * regardless of this setting, as long as the top frame is not disabled.
250 * If JSD_HIDE_DISABLED_FRAMES is set, this is effectively set as well.
252 #define JSD_MASK_TOP_FRAME_ONLY 0x20
255 * 0x40 was formerly used to hook into object creation.
257 #define JSD_DISABLE_OBJECT_TRACE_RETIRED 0x40
260 extern JSD_PUBLIC_API(void)
261 JSD_SetContextFlags (JSDContext* jsdc, uint32 flags);
263 extern JSD_PUBLIC_API(uint32)
264 JSD_GetContextFlags (JSDContext* jsdc);
267 * Notify JSD that this JSContext is 'in use'. This allows JSD to hook the
268 * ErrorReporter. For the most part this is done automatically whenever
269 * events like script loading happen. But, it is a good idea to call this
270 * from the embedding when new contexts come into use.
272 extern JSD_PUBLIC_API(void)
273 JSD_JSContextInUse(JSDContext* jsdc, JSContext* context);
276 * Find the JSDContext (if any) associated with the JSRuntime of a
279 extern JSD_PUBLIC_API(JSDContext*)
280 JSD_JSDContextForJSContext(JSContext* context);
282 /***************************************************************************/
283 /* Script functions */
286 * Lock the entire script subsystem. This grabs a highlevel lock that
287 * protects the JSD internal information about scripts. It is important
288 * to wrap script related calls in this lock in multithreaded situations
289 * -- i.e. where the debugger is running on a different thread than the
290 * interpreter -- or when multiple debugger threads may be accessing this
291 * subsystem. It is safe (and best) to use this locking even if the
292 * environment might not be multi-threaded. Safely nestable.
294 extern JSD_PUBLIC_API(void)
295 JSD_LockScriptSubsystem(JSDContext* jsdc);
298 * Unlock the entire script subsystem -- see JSD_LockScriptSubsystem
300 extern JSD_PUBLIC_API(void)
301 JSD_UnlockScriptSubsystem(JSDContext* jsdc);
304 * Iterate through all the active scripts for this JSDContext.
305 * NOTE: must initialize iterp to NULL to start iteration.
306 * NOTE: must lock and unlock the subsystem
309 * JSDScript jsdscript;
310 * JSDScript iter = NULL;
312 * JSD_LockScriptSubsystem(jsdc);
313 * while((jsdscript = JSD_IterateScripts(jsdc, &iter)) != NULL) {
314 * *** use jsdscript here ***
316 * JSD_UnlockScriptSubsystem(jsdc);
318 extern JSD_PUBLIC_API(JSDScript*)
319 JSD_IterateScripts(JSDContext* jsdc, JSDScript **iterp);
322 * Get the number of times this script has been called.
324 extern JSD_PUBLIC_API(uintN)
325 JSD_GetScriptCallCount(JSDContext* jsdc, JSDScript *script);
328 * Get the max number of times this script called itself, directly or indirectly.
330 extern JSD_PUBLIC_API(uintN)
331 JSD_GetScriptMaxRecurseDepth(JSDContext* jsdc, JSDScript *script);
334 * Get the shortest execution time recorded.
336 extern JSD_PUBLIC_API(jsdouble)
337 JSD_GetScriptMinExecutionTime(JSDContext* jsdc, JSDScript *script);
340 * Get the longest execution time recorded.
342 extern JSD_PUBLIC_API(jsdouble)
343 JSD_GetScriptMaxExecutionTime(JSDContext* jsdc, JSDScript *script);
346 * Get the total amount of time spent in this script.
348 extern JSD_PUBLIC_API(jsdouble)
349 JSD_GetScriptTotalExecutionTime(JSDContext* jsdc, JSDScript *script);
352 * Get the shortest execution time recorded, excluding time spent in called
355 extern JSD_PUBLIC_API(jsdouble)
356 JSD_GetScriptMinOwnExecutionTime(JSDContext* jsdc, JSDScript *script);
359 * Get the longest execution time recorded, excluding time spent in called
362 extern JSD_PUBLIC_API(jsdouble)
363 JSD_GetScriptMaxOwnExecutionTime(JSDContext* jsdc, JSDScript *script);
366 * Get the total amount of time spent in this script, excluding time spent
367 * in called functions.
369 extern JSD_PUBLIC_API(jsdouble)
370 JSD_GetScriptTotalOwnExecutionTime(JSDContext* jsdc, JSDScript *script);
373 * Clear profile data for this script.
375 extern JSD_PUBLIC_API(void)
376 JSD_ClearScriptProfileData(JSDContext* jsdc, JSDScript *script);
379 * Get the JSScript for a JSDScript
381 extern JSD_PUBLIC_API(JSScript*)
382 JSD_GetJSScript(JSDContext* jsdc, JSDScript *script);
385 * Get the JSFunction for a JSDScript
387 extern JSD_PUBLIC_API(JSFunction*)
388 JSD_GetJSFunction(JSDContext* jsdc, JSDScript *script);
391 * Determines whether or not to collect profile information for this
392 * script. The context flag JSD_PROFILE_WHEN_SET decides the logic.
394 #define JSD_SCRIPT_PROFILE_BIT 0x01
396 * Determines whether or not to ignore breakpoints, etc. in this script.
397 * The context flag JSD_DEBUG_WHEN_SET decides the logic.
399 #define JSD_SCRIPT_DEBUG_BIT 0x02
401 extern JSD_PUBLIC_API(uint32)
402 JSD_GetScriptFlags(JSDContext *jsdc, JSDScript* jsdscript);
404 extern JSD_PUBLIC_API(void)
405 JSD_SetScriptFlags(JSDContext *jsdc, JSDScript* jsdscript, uint32 flags);
408 * Set the private data for this script, returns previous value
410 extern JSD_PUBLIC_API(void *)
411 JSD_SetScriptPrivate(JSDScript* jsdscript, void *data);
414 * Get the private data for this script
416 extern JSD_PUBLIC_API(void *)
417 JSD_GetScriptPrivate(JSDScript* jsdscript);
420 * Determine if this script is still loaded in the interpreter
422 extern JSD_PUBLIC_API(JSBool)
423 JSD_IsActiveScript(JSDContext* jsdc, JSDScript *jsdscript);
426 * Get the filename associated with this script
428 extern JSD_PUBLIC_API(const char*)
429 JSD_GetScriptFilename(JSDContext* jsdc, JSDScript *jsdscript);
432 * Get the function name associated with this script (NULL if not a function).
433 * If the function does not have a name the result is the string "anonymous".
434 * *** new for gecko 2.0 ****
436 extern JSD_PUBLIC_API(JSString *)
437 JSD_GetScriptFunctionId(JSDContext* jsdc, JSDScript *jsdscript);
440 * Get the base linenumber of the sourcefile from which this script was loaded.
441 * This is one-based -- i.e. the first line of a file is line '1'. This may
442 * return 0 if this infomation is unknown.
444 extern JSD_PUBLIC_API(uintN)
445 JSD_GetScriptBaseLineNumber(JSDContext* jsdc, JSDScript *jsdscript);
448 * Get the count of source lines associated with this script (1 or greater)
450 extern JSD_PUBLIC_API(uintN)
451 JSD_GetScriptLineExtent(JSDContext* jsdc, JSDScript *jsdscript);
454 * Declaration of callback for notification of script creation and destruction.
455 * 'creating' is JS_TRUE if creating new script, JS_FALSE if destroying existing
456 * script (callback called just before actual destruction).
457 * 'callerdata' is what was passed to JSD_SetScriptHook to set the hook.
460 (* JSD_ScriptHookProc)(JSDContext* jsdc,
461 JSDScript* jsdscript,
466 * Set a hook to be called when scripts are created or destroyed (loaded or
468 * 'callerdata' can be whatever you want it to be.
470 extern JSD_PUBLIC_API(JSBool)
471 JSD_SetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc hook, void* callerdata);
474 * Get the current script hook.
476 extern JSD_PUBLIC_API(JSBool)
477 JSD_GetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc* hook, void** callerdata);
480 * Get a 'Program Counter' value for a given line. This represents the location
481 * of the first bit of executable code for this line of source. This 'pc' should
482 * be considered an opaque handle.
483 * 0 is returned for invalid scripts, or lines that lie outside the script.
484 * If no code is on the given line, then the returned pc represents the first
485 * code within the script (if any) after the given line.
486 * This function can be used to set breakpoints -- see JSD_SetExecutionHook
488 extern JSD_PUBLIC_API(jsuword)
489 JSD_GetClosestPC(JSDContext* jsdc, JSDScript* jsdscript, uintN line);
492 * Get the source line number for a given 'Program Counter' location.
493 * Returns 0 if no source line information is appropriate (or available) for
496 extern JSD_PUBLIC_API(uintN)
497 JSD_GetClosestLine(JSDContext* jsdc, JSDScript* jsdscript, jsuword pc);
499 /* these are only used in cases where scripts are created outside of JS*/
502 * Direct call to notify JSD that a script has been created.
503 * Embeddings that use the normal jsapi script functions need not call this.
504 * Any embedding that follows the (discouraged!) practice of contructing script
505 * structures manually should call this function to inform JSD. (older ssjs
508 extern JSD_PUBLIC_API(void)
509 JSD_ScriptCreated(JSDContext* jsdc,
511 const char *filename, /* URL this script loads from */
512 uintN lineno, /* line where this script starts */
517 * see JSD_ScriptCreated
519 extern JSD_PUBLIC_API(void)
520 JSD_ScriptDestroyed(JSDContext* jsdc,
524 /***************************************************************************/
525 /* Source Text functions */
528 * In some embeddings (e.g. mozilla) JavaScript source code from a 'file' may be
529 * execute before the entire 'file' has even been loaded. This system supports
530 * access to such incrmentally loaded source. It also allows for the possibility
531 * that source loading may fail or be aborted (though the source that did load
532 * may still be usable). Remember that this source is the entire 'file'
533 * contents and that the JavaScript code may only be part of that source.
535 * For any given URL there can only be one source text item (the most recently
539 /* these coorespond to netscape.jsdebug.SourceTextItem.java values -
540 * change in both places if anywhere
545 JSD_SOURCE_INITED = 0, /* initialized, but contains no source yet */
546 JSD_SOURCE_PARTIAL = 1, /* some source loaded, more expected */
547 JSD_SOURCE_COMPLETED = 2, /* all source finished loading */
548 JSD_SOURCE_ABORTED = 3, /* user aborted loading, some may be loaded */
549 JSD_SOURCE_FAILED = 4, /* loading failed, some may be loaded */
550 JSD_SOURCE_CLEARED = 5 /* text has been cleared by debugger */
554 * Lock the entire source text subsystem. This grabs a highlevel lock that
555 * protects the JSD internal information about sources. It is important to
556 * wrap source text related calls in this lock in multithreaded situations
557 * -- i.e. where the debugger is running on a different thread than the
558 * interpreter (or the loader of sources) -- or when multiple debugger
559 * threads may be accessing this subsystem. It is safe (and best) to use
560 * this locking even if the environment might not be multi-threaded.
563 extern JSD_PUBLIC_API(void)
564 JSD_LockSourceTextSubsystem(JSDContext* jsdc);
567 * Unlock the entire source text subsystem. see JSD_LockSourceTextSubsystem.
569 extern JSD_PUBLIC_API(void)
570 JSD_UnlockSourceTextSubsystem(JSDContext* jsdc);
573 * Iterate the source test items. Use the same pattern of calls shown in
574 * the example for JSD_IterateScripts - NOTE that the SourceTextSubsystem.
575 * must be locked before and unlocked after iterating.
577 extern JSD_PUBLIC_API(JSDSourceText*)
578 JSD_IterateSources(JSDContext* jsdc, JSDSourceText **iterp);
581 * Find the source text item for the given URL (or filename - or whatever
582 * string the given embedding uses to describe source locations).
583 * Returns NULL is not found.
585 extern JSD_PUBLIC_API(JSDSourceText*)
586 JSD_FindSourceForURL(JSDContext* jsdc, const char* url);
589 * Get the URL string associated with the given source text item
591 extern JSD_PUBLIC_API(const char*)
592 JSD_GetSourceURL(JSDContext* jsdc, JSDSourceText* jsdsrc);
595 * Get the actual source text. This gives access to the actual storage of
596 * the source - it sHould *not* be written to.
597 * The buffer is NOT zero terminated (nor is it guaranteed to have space to
598 * hold a zero terminating char).
599 * XXX this is 8-bit character data. Unicode source is not yet supported.
601 extern JSD_PUBLIC_API(JSBool)
602 JSD_GetSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc,
603 const char** ppBuf, intN* pLen);
606 * Clear the text -- delete the text and set the status to JSD_SOURCE_CLEARED.
607 * This is useful if source is done loading and the debugger wishes to store
608 * the text data itself (e.g. in a Java String). This allows avoidance of
609 * storing the same text in multiple places.
611 extern JSD_PUBLIC_API(void)
612 JSD_ClearSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc);
615 * Return the status of the source text item. see JSDSourceStatus enum.
617 extern JSD_PUBLIC_API(JSDSourceStatus)
618 JSD_GetSourceStatus(JSDContext* jsdc, JSDSourceText* jsdsrc);
621 * Has the source been altered since the last call to JSD_SetSourceDirty?
622 * Use of JSD_IsSourceDirty and JSD_SetSourceDirty is still supported, but
623 * discouraged in favor of the JSD_GetSourceAlterCount system. This dirty
624 * scheme ASSUMES that there is only one consumer of the data.
626 extern JSD_PUBLIC_API(JSBool)
627 JSD_IsSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc);
630 * Clear the dirty flag
632 extern JSD_PUBLIC_API(void)
633 JSD_SetSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc, JSBool dirty);
636 * Each time a source text item is altered this value is incremented. Any
637 * consumer can store this value when they retieve other data about the
638 * source text item and then check later to see if the current value is
639 * different from their stored value. Thus they can know if they have stale
640 * data or not. NOTE: this value is not gauranteed to start at any given number.
642 extern JSD_PUBLIC_API(uintN)
643 JSD_GetSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc);
646 * Force an increment in the alter count for a source text item. This is
647 * normally automatic when the item changes, but a give consumer may want to
648 * force this to amke an item appear to have changed even if it has not.
650 extern JSD_PUBLIC_API(uintN)
651 JSD_IncrementSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc);
654 * Destroy *all* the source text items
655 * (new for server-side USE WITH CARE)
657 extern JSD_PUBLIC_API(void)
658 JSD_DestroyAllSources( JSDContext* jsdc );
660 /* functions for adding source items */
663 * Add a new item for a given URL. If an iten already exists for the given URL
664 * then the old item is removed.
665 * 'url' may not be NULL.
667 extern JSD_PUBLIC_API(JSDSourceText*)
668 JSD_NewSourceText(JSDContext* jsdc, const char* url);
671 * Append text (or change status -- e.g. set completed) for a source text
672 * item. Text need not be zero terminated. Callers should consider the returned
673 * JSDSourceText to be the 'current' item for future use. This may return NULL
674 * if called after this item has been replaced by a call to JSD_NewSourceText.
676 extern JSD_PUBLIC_API(JSDSourceText*)
677 JSD_AppendSourceText(JSDContext* jsdc,
678 JSDSourceText* jsdsrc,
679 const char* text, /* *not* zero terminated */
681 JSDSourceStatus status);
684 * Unicode varient of JSD_AppendSourceText.
686 * NOTE: At this point text is stored in 8bit ASCII so this function just
687 * extracts the bottom 8bits from each jschar. At some future point we may
688 * switch to storing and exposing 16bit Unicode.
690 extern JSD_PUBLIC_API(JSDSourceText*)
691 JSD_AppendUCSourceText(JSDContext* jsdc,
692 JSDSourceText* jsdsrc,
693 const jschar* text, /* *not* zero terminated */
695 JSDSourceStatus status);
697 * Convienence function for adding complete source of url in one call.
699 * JSDSourceText* jsdsrc;
700 * JSD_LOCK_SOURCE_TEXT(jsdc);
701 * jsdsrc = jsd_NewSourceText(jsdc, url);
703 * jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc,
704 * text, length, JSD_SOURCE_PARTIAL);
706 * jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc,
707 * NULL, 0, JSD_SOURCE_COMPLETED);
708 * JSD_UNLOCK_SOURCE_TEXT(jsdc);
709 * return jsdsrc ? JS_TRUE : JS_FALSE;
711 extern JSD_PUBLIC_API(JSBool)
712 JSD_AddFullSourceText(JSDContext* jsdc,
713 const char* text, /* *not* zero terminated */
717 /***************************************************************************/
718 /* Execution/Interrupt Hook functions */
720 /* possible 'type' params for JSD_ExecutionHookProc */
721 #define JSD_HOOK_INTERRUPTED 0
722 #define JSD_HOOK_BREAKPOINT 1
723 #define JSD_HOOK_DEBUG_REQUESTED 2
724 #define JSD_HOOK_DEBUGGER_KEYWORD 3
725 #define JSD_HOOK_THROW 4
727 /* legal return values for JSD_ExecutionHookProc */
728 #define JSD_HOOK_RETURN_HOOK_ERROR 0
729 #define JSD_HOOK_RETURN_CONTINUE 1
730 #define JSD_HOOK_RETURN_ABORT 2
731 #define JSD_HOOK_RETURN_RET_WITH_VAL 3
732 #define JSD_HOOK_RETURN_THROW_WITH_VAL 4
733 #define JSD_HOOK_RETURN_CONTINUE_THROW 5
736 * Implement a callback of this form in order to hook execution.
739 (* JSD_ExecutionHookProc)(JSDContext* jsdc,
740 JSDThreadState* jsdthreadstate,
745 /* possible 'type' params for JSD_CallHookProc */
746 #define JSD_HOOK_TOPLEVEL_START 0 /* about to evaluate top level script */
747 #define JSD_HOOK_TOPLEVEL_END 1 /* done evaluting top level script */
748 #define JSD_HOOK_FUNCTION_CALL 2 /* about to call a function */
749 #define JSD_HOOK_FUNCTION_RETURN 3 /* done calling function */
752 * Implement a callback of this form in order to hook function call/returns.
753 * Return JS_TRUE from a TOPLEVEL_START or FUNCTION_CALL type call hook if you
754 * want to hear about the TOPLEVEL_END or FUNCTION_RETURN too. Return value is
755 * ignored to TOPLEVEL_END and FUNCTION_RETURN type hooks.
758 (* JSD_CallHookProc)(JSDContext* jsdc,
759 JSDThreadState* jsdthreadstate,
764 * Set Hook to be called whenever the given pc is about to be executed --
765 * i.e. for 'trap' or 'breakpoint'
767 extern JSD_PUBLIC_API(JSBool)
768 JSD_SetExecutionHook(JSDContext* jsdc,
769 JSDScript* jsdscript,
771 JSD_ExecutionHookProc hook,
775 * Clear the hook for this pc
777 extern JSD_PUBLIC_API(JSBool)
778 JSD_ClearExecutionHook(JSDContext* jsdc,
779 JSDScript* jsdscript,
783 * Clear all the pc specific hooks for this script
785 extern JSD_PUBLIC_API(JSBool)
786 JSD_ClearAllExecutionHooksForScript(JSDContext* jsdc, JSDScript* jsdscript);
789 * Clear all the pc specific hooks for the entire JSRuntime associated with
792 extern JSD_PUBLIC_API(JSBool)
793 JSD_ClearAllExecutionHooks(JSDContext* jsdc);
796 * Set a hook to be called before the next instruction is executed. Depending
797 * on the threading situation and whether or not an JS code is currently
798 * executing the hook might be called before this call returns, or at some
799 * future time. The hook will continue to be called as each instruction
800 * executes until cleared.
802 extern JSD_PUBLIC_API(JSBool)
803 JSD_SetInterruptHook(JSDContext* jsdc,
804 JSD_ExecutionHookProc hook,
808 * Call the interrupt hook at least once per source line
810 extern JSD_PUBLIC_API(JSBool)
811 JSD_EnableSingleStepInterrupts(JSDContext* jsdc, JSDScript *jsdscript, JSBool enable);
814 * Clear the current interrupt hook.
816 extern JSD_PUBLIC_API(JSBool)
817 JSD_ClearInterruptHook(JSDContext* jsdc);
820 * Set the hook that should be called whenever a JSD_ErrorReporter hook
821 * returns JSD_ERROR_REPORTER_DEBUG.
823 extern JSD_PUBLIC_API(JSBool)
824 JSD_SetDebugBreakHook(JSDContext* jsdc,
825 JSD_ExecutionHookProc hook,
829 * Clear the debug break hook
831 extern JSD_PUBLIC_API(JSBool)
832 JSD_ClearDebugBreakHook(JSDContext* jsdc);
835 * Set the hook that should be called when the 'debugger' keyword is
836 * encountered by the JavaScript interpreter during execution.
838 extern JSD_PUBLIC_API(JSBool)
839 JSD_SetDebuggerHook(JSDContext* jsdc,
840 JSD_ExecutionHookProc hook,
844 * Clear the 'debugger' keyword hook
846 extern JSD_PUBLIC_API(JSBool)
847 JSD_ClearDebuggerHook(JSDContext* jsdc);
850 * Set the hook that should be called when a JS exception is thrown.
851 * NOTE: the 'do default' return value is: JSD_HOOK_RETURN_CONTINUE_THROW
853 extern JSD_PUBLIC_API(JSBool)
854 JSD_SetThrowHook(JSDContext* jsdc,
855 JSD_ExecutionHookProc hook,
858 * Clear the throw hook
860 extern JSD_PUBLIC_API(JSBool)
861 JSD_ClearThrowHook(JSDContext* jsdc);
864 * Set the hook that should be called when a toplevel script begins or completes.
866 extern JSD_PUBLIC_API(JSBool)
867 JSD_SetTopLevelHook(JSDContext* jsdc,
868 JSD_CallHookProc hook,
871 * Clear the toplevel call hook
873 extern JSD_PUBLIC_API(JSBool)
874 JSD_ClearTopLevelHook(JSDContext* jsdc);
877 * Set the hook that should be called when a function call or return happens.
879 extern JSD_PUBLIC_API(JSBool)
880 JSD_SetFunctionHook(JSDContext* jsdc,
881 JSD_CallHookProc hook,
884 * Clear the function call hook
886 extern JSD_PUBLIC_API(JSBool)
887 JSD_ClearFunctionHook(JSDContext* jsdc);
889 /***************************************************************************/
890 /* Stack Frame functions */
893 * Get the count of call stack frames for the given JSDThreadState
895 extern JSD_PUBLIC_API(uintN)
896 JSD_GetCountOfStackFrames(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
899 * Get the 'current' call stack frame for the given JSDThreadState
901 extern JSD_PUBLIC_API(JSDStackFrameInfo*)
902 JSD_GetStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
905 * Get the JSContext for the given JSDThreadState
907 extern JSD_PUBLIC_API(JSContext*)
908 JSD_GetJSContext(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
911 * Get the calling call stack frame for the given frame
913 extern JSD_PUBLIC_API(JSDStackFrameInfo*)
914 JSD_GetCallingStackFrame(JSDContext* jsdc,
915 JSDThreadState* jsdthreadstate,
916 JSDStackFrameInfo* jsdframe);
919 * Get the script for the given call stack frame
921 extern JSD_PUBLIC_API(JSDScript*)
922 JSD_GetScriptForStackFrame(JSDContext* jsdc,
923 JSDThreadState* jsdthreadstate,
924 JSDStackFrameInfo* jsdframe);
927 * Get the 'Program Counter' for the given call stack frame
929 extern JSD_PUBLIC_API(jsuword)
930 JSD_GetPCForStackFrame(JSDContext* jsdc,
931 JSDThreadState* jsdthreadstate,
932 JSDStackFrameInfo* jsdframe);
935 * Get the JavaScript Call Object for the given call stack frame.
936 * *** new for version 1.1 ****
938 extern JSD_PUBLIC_API(JSDValue*)
939 JSD_GetCallObjectForStackFrame(JSDContext* jsdc,
940 JSDThreadState* jsdthreadstate,
941 JSDStackFrameInfo* jsdframe);
944 * Get the head of the scope chain for the given call stack frame.
945 * the chain can be traversed using JSD_GetValueParent.
946 * *** new for version 1.1 ****
948 extern JSD_PUBLIC_API(JSDValue*)
949 JSD_GetScopeChainForStackFrame(JSDContext* jsdc,
950 JSDThreadState* jsdthreadstate,
951 JSDStackFrameInfo* jsdframe);
954 * Get the 'this' Object for the given call stack frame.
955 * *** new for version 1.1 ****
957 extern JSD_PUBLIC_API(JSDValue*)
958 JSD_GetThisForStackFrame(JSDContext* jsdc,
959 JSDThreadState* jsdthreadstate,
960 JSDStackFrameInfo* jsdframe);
963 * Get the name of the function executing in this stack frame. Especially useful
964 * for native frames (without script objects.)
965 * *** new for gecko 2.0 ****
967 extern JSD_PUBLIC_API(JSString *)
968 JSD_GetIdForStackFrame(JSDContext* jsdc,
969 JSDThreadState* jsdthreadstate,
970 JSDStackFrameInfo* jsdframe);
973 * True if stack frame represents a frame created as a result of a debugger
976 extern JSD_PUBLIC_API(JSBool)
977 JSD_IsStackFrameDebugger(JSDContext* jsdc,
978 JSDThreadState* jsdthreadstate,
979 JSDStackFrameInfo* jsdframe);
982 * True if stack frame is constructing a new object.
984 extern JSD_PUBLIC_API(JSBool)
985 JSD_IsStackFrameConstructing(JSDContext* jsdc,
986 JSDThreadState* jsdthreadstate,
987 JSDStackFrameInfo* jsdframe);
990 * Evaluate the given unicode source code in the context of the given stack frame.
991 * returns JS_TRUE and puts result in rval on success, JS_FALSE on failure.
992 * NOTE: The ErrorReporter hook might be called if this fails.
994 extern JSD_PUBLIC_API(JSBool)
995 JSD_EvaluateUCScriptInStackFrame(JSDContext* jsdc,
996 JSDThreadState* jsdthreadstate,
997 JSDStackFrameInfo* jsdframe,
998 const jschar *bytes, uintN length,
999 const char *filename, uintN lineno,
1003 * Same as above, but does not eat exceptions.
1005 extern JSD_PUBLIC_API(JSBool)
1006 JSD_AttemptUCScriptInStackFrame(JSDContext* jsdc,
1007 JSDThreadState* jsdthreadstate,
1008 JSDStackFrameInfo* jsdframe,
1009 const jschar *bytes, uintN length,
1010 const char *filename, uintN lineno,
1013 /* single byte character version of JSD_EvaluateUCScriptInStackFrame */
1014 extern JSD_PUBLIC_API(JSBool)
1015 JSD_EvaluateScriptInStackFrame(JSDContext* jsdc,
1016 JSDThreadState* jsdthreadstate,
1017 JSDStackFrameInfo* jsdframe,
1018 const char *bytes, uintN length,
1019 const char *filename, uintN lineno, jsval *rval);
1022 * Same as above, but does not eat exceptions.
1024 extern JSD_PUBLIC_API(JSBool)
1025 JSD_AttemptScriptInStackFrame(JSDContext* jsdc,
1026 JSDThreadState* jsdthreadstate,
1027 JSDStackFrameInfo* jsdframe,
1028 const char *bytes, uintN length,
1029 const char *filename, uintN lineno, jsval *rval);
1032 * Convert the given jsval to a string
1033 * NOTE: The ErrorReporter hook might be called if this fails.
1035 extern JSD_PUBLIC_API(JSString*)
1036 JSD_ValToStringInStackFrame(JSDContext* jsdc,
1037 JSDThreadState* jsdthreadstate,
1038 JSDStackFrameInfo* jsdframe,
1042 * Get the JSDValue currently being thrown as an exception (may be NULL).
1043 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1044 * *** new for version 1.1 ****
1046 extern JSD_PUBLIC_API(JSDValue*)
1047 JSD_GetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
1050 * Set the JSDValue currently being thrown as an exception.
1051 * *** new for version 1.1 ****
1053 extern JSD_PUBLIC_API(JSBool)
1054 JSD_SetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate,
1057 /***************************************************************************/
1058 /* Error Reporter functions */
1061 * XXX The ErrorReporter Hook scheme is going to change soon to more
1062 * Fully support exceptions.
1065 /* legal return values for JSD_ErrorReporter */
1066 #define JSD_ERROR_REPORTER_PASS_ALONG 0 /* pass along to regular reporter */
1067 #define JSD_ERROR_REPORTER_RETURN 1 /* don't pass to error reporter */
1068 #define JSD_ERROR_REPORTER_DEBUG 2 /* force call to DebugBreakHook */
1069 #define JSD_ERROR_REPORTER_CLEAR_RETURN 3 /* clear exception and don't pass */
1072 * Implement a callback of this form in order to hook the ErrorReporter
1075 (* JSD_ErrorReporter)(JSDContext* jsdc,
1077 const char* message,
1078 JSErrorReport* report,
1081 /* Set ErrorReporter hook */
1082 extern JSD_PUBLIC_API(JSBool)
1083 JSD_SetErrorReporter(JSDContext* jsdc,
1084 JSD_ErrorReporter reporter,
1087 /* Get Current ErrorReporter hook */
1088 extern JSD_PUBLIC_API(JSBool)
1089 JSD_GetErrorReporter(JSDContext* jsdc,
1090 JSD_ErrorReporter* reporter,
1093 /***************************************************************************/
1094 /* Generic locks that callers can use for their own purposes */
1097 * Is Locking and GetThread supported in this build?
1099 extern JSD_PUBLIC_API(JSBool)
1100 JSD_IsLockingAndThreadIdSupported();
1103 * Create a reentrant/nestable lock
1105 extern JSD_PUBLIC_API(void*)
1109 * Aquire lock for this thread (or block until available). Increments a
1110 * counter if this thread already owns the lock.
1112 extern JSD_PUBLIC_API(void)
1113 JSD_Lock(void* lock);
1116 * Release lock for this thread (or decrement the counter if JSD_Lock
1117 * was previous called more than once).
1119 extern JSD_PUBLIC_API(void)
1120 JSD_Unlock(void* lock);
1123 * For debugging only if not (JS_THREADSAFE AND DEBUG) then returns JS_TRUE
1124 * So JSD_IsLocked(lock) may not equal !JSD_IsUnlocked(lock)
1126 extern JSD_PUBLIC_API(JSBool)
1127 JSD_IsLocked(void* lock);
1132 extern JSD_PUBLIC_API(JSBool)
1133 JSD_IsUnlocked(void* lock);
1136 * return an ID uniquely identifying this thread.
1138 extern JSD_PUBLIC_API(void*)
1139 JSD_CurrentThread();
1141 /***************************************************************************/
1142 /* Value and Property Functions --- All NEW for 1.1 --- */
1145 * NOTE: JSDValue and JSDProperty objects are reference counted. This allows
1146 * for rooting these objects AND any underlying garbage collected jsvals.
1147 * ALL JSDValue and JSDProperty objects returned by the functions below
1148 * MUST eventually be released using the appropriate JSD_Dropxxx function.
1152 * Create a new JSDValue to wrap the given jsval
1153 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1154 * *** new for version 1.1 ****
1156 extern JSD_PUBLIC_API(JSDValue*)
1157 JSD_NewValue(JSDContext* jsdc, jsval val);
1160 * Release the JSDValue. After this call the object MUST not be referenced again!
1161 * *** new for version 1.1 ****
1163 extern JSD_PUBLIC_API(void)
1164 JSD_DropValue(JSDContext* jsdc, JSDValue* jsdval);
1167 * Get the jsval wrapped by this JSDValue
1168 * *** new for version 1.1 ****
1170 extern JSD_PUBLIC_API(jsval)
1171 JSD_GetValueWrappedJSVal(JSDContext* jsdc, JSDValue* jsdval);
1174 * Clear all property and association information about the given JSDValue.
1175 * Such information will be lazily regenerated when later accessed. This
1176 * function must be called to make changes to the properties of an object
1177 * visible to the accessor functions below (if the properties et.al. have
1178 * changed since a previous call to those accessors).
1179 * *** new for version 1.1 ****
1181 extern JSD_PUBLIC_API(void)
1182 JSD_RefreshValue(JSDContext* jsdc, JSDValue* jsdval);
1184 /**************************************************/
1187 * Does the JSDValue wrap a JSObject?
1188 * *** new for version 1.1 ****
1190 extern JSD_PUBLIC_API(JSBool)
1191 JSD_IsValueObject(JSDContext* jsdc, JSDValue* jsdval);
1194 * Does the JSDValue wrap a number (int or double)?
1195 * *** new for version 1.1 ****
1197 extern JSD_PUBLIC_API(JSBool)
1198 JSD_IsValueNumber(JSDContext* jsdc, JSDValue* jsdval);
1201 * Does the JSDValue wrap an int?
1202 * *** new for version 1.1 ****
1204 extern JSD_PUBLIC_API(JSBool)
1205 JSD_IsValueInt(JSDContext* jsdc, JSDValue* jsdval);
1208 * Does the JSDValue wrap a double?
1209 * *** new for version 1.1 ****
1211 extern JSD_PUBLIC_API(JSBool)
1212 JSD_IsValueDouble(JSDContext* jsdc, JSDValue* jsdval);
1215 * Does the JSDValue wrap a JSString?
1216 * *** new for version 1.1 ****
1218 extern JSD_PUBLIC_API(JSBool)
1219 JSD_IsValueString(JSDContext* jsdc, JSDValue* jsdval);
1222 * Does the JSDValue wrap a JSBool?
1223 * *** new for version 1.1 ****
1225 extern JSD_PUBLIC_API(JSBool)
1226 JSD_IsValueBoolean(JSDContext* jsdc, JSDValue* jsdval);
1229 * Does the JSDValue wrap a JSVAL_NULL?
1230 * *** new for version 1.1 ****
1232 extern JSD_PUBLIC_API(JSBool)
1233 JSD_IsValueNull(JSDContext* jsdc, JSDValue* jsdval);
1236 * Does the JSDValue wrap a JSVAL_VOID?
1237 * *** new for version 1.1 ****
1239 extern JSD_PUBLIC_API(JSBool)
1240 JSD_IsValueVoid(JSDContext* jsdc, JSDValue* jsdval);
1243 * Does the JSDValue wrap a primative (not a JSObject)?
1244 * *** new for version 1.1 ****
1246 extern JSD_PUBLIC_API(JSBool)
1247 JSD_IsValuePrimitive(JSDContext* jsdc, JSDValue* jsdval);
1250 * Does the JSDValue wrap a function?
1251 * *** new for version 1.1 ****
1253 extern JSD_PUBLIC_API(JSBool)
1254 JSD_IsValueFunction(JSDContext* jsdc, JSDValue* jsdval);
1257 * Does the JSDValue wrap a native function?
1258 * *** new for version 1.1 ****
1260 extern JSD_PUBLIC_API(JSBool)
1261 JSD_IsValueNative(JSDContext* jsdc, JSDValue* jsdval);
1263 /**************************************************/
1266 * Return JSBool value (does NOT do conversion).
1267 * *** new for version 1.1 ****
1269 extern JSD_PUBLIC_API(JSBool)
1270 JSD_GetValueBoolean(JSDContext* jsdc, JSDValue* jsdval);
1273 * Return int32 value (does NOT do conversion).
1274 * *** new for version 1.1 ****
1276 extern JSD_PUBLIC_API(int32)
1277 JSD_GetValueInt(JSDContext* jsdc, JSDValue* jsdval);
1280 * Return double value (does NOT do conversion).
1281 * *** new for version 1.1 ****
1283 extern JSD_PUBLIC_API(jsdouble)
1284 JSD_GetValueDouble(JSDContext* jsdc, JSDValue* jsdval);
1287 * Return JSString value (DOES do conversion if necessary).
1288 * NOTE that the JSString returned is not protected from garbage
1289 * collection. It should be immediately read or wrapped using
1290 * JSD_NewValue(jsdc,STRING_TO_JSVAL(str)) if necessary.
1291 * *** new for version 1.1 ****
1293 extern JSD_PUBLIC_API(JSString*)
1294 JSD_GetValueString(JSDContext* jsdc, JSDValue* jsdval);
1297 * Return name of function IFF JSDValue represents a function.
1298 * *** new for gecko 2.0 ****
1300 extern JSD_PUBLIC_API(JSString *)
1301 JSD_GetValueFunctionId(JSDContext* jsdc, JSDValue* jsdval);
1304 * Return function object IFF JSDValue represents a function or an object
1305 * wrapping a function.
1306 * *** new for version 1.1 ****
1308 extern JSD_PUBLIC_API(JSFunction*)
1309 JSD_GetValueFunction(JSDContext* jsdc, JSDValue* jsdval);
1311 /**************************************************/
1314 * Return the number of properties for the JSDValue.
1315 * *** new for version 1.1 ****
1317 extern JSD_PUBLIC_API(uintN)
1318 JSD_GetCountOfProperties(JSDContext* jsdc, JSDValue* jsdval);
1321 * Iterate through the properties of the JSDValue.
1322 * Use form similar to that shown for JSD_IterateScripts (no locking required).
1323 * NOTE: each JSDProperty returned must eventually be released by calling
1325 * *** new for version 1.1 ****
1327 extern JSD_PUBLIC_API(JSDProperty*)
1328 JSD_IterateProperties(JSDContext* jsdc, JSDValue* jsdval, JSDProperty **iterp);
1331 * Get the JSDProperty for the property of this JSDVal with this name.
1332 * NOTE: must eventually release by calling JSD_DropProperty (if not NULL)
1333 * *** new for version 1.1 ****
1335 extern JSD_PUBLIC_API(JSDProperty*)
1336 JSD_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* name);
1339 * Get the prototype object for this JSDValue.
1340 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1341 * *** new for version 1.1 ****
1343 extern JSD_PUBLIC_API(JSDValue*)
1344 JSD_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval);
1347 * Get the parent object for this JSDValue.
1348 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1349 * *** new for version 1.1 ****
1351 extern JSD_PUBLIC_API(JSDValue*)
1352 JSD_GetValueParent(JSDContext* jsdc, JSDValue* jsdval);
1355 * Get the ctor object for this JSDValue (or likely its prototype's ctor).
1356 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1357 * *** new for version 1.1 ****
1359 extern JSD_PUBLIC_API(JSDValue*)
1360 JSD_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval);
1363 * Get the name of the class for this object.
1364 * *** new for version 1.1 ****
1366 extern JSD_PUBLIC_API(const char*)
1367 JSD_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval);
1370 * Get the script for the given value if the given value represents a
1371 * scripted function. Otherwise, return null.
1373 extern JSD_PUBLIC_API(JSDScript*)
1374 JSD_GetScriptForValue(JSDContext* jsdc, JSDValue* jsdval);
1376 /**************************************************/
1378 /* possible or'd together bitflags returned by JSD_GetPropertyFlags
1380 * XXX these must stay the same as the JSPD_ flags in jsdbgapi.h
1382 #define JSDPD_ENUMERATE JSPD_ENUMERATE /* visible to for/in loop */
1383 #define JSDPD_READONLY JSPD_READONLY /* assignment is error */
1384 #define JSDPD_PERMANENT JSPD_PERMANENT /* property cannot be deleted */
1385 #define JSDPD_ALIAS JSPD_ALIAS /* property has an alias id */
1386 #define JSDPD_ARGUMENT JSPD_ARGUMENT /* argument to function */
1387 #define JSDPD_VARIABLE JSPD_VARIABLE /* local variable in function */
1388 #define JSDPD_EXCEPTION JSPD_EXCEPTION /* exception occurred looking up */
1389 /* proprety, value is exception */
1390 #define JSDPD_ERROR JSPD_ERROR /* native getter returned JS_FALSE */
1391 /* without throwing an exception */
1392 /* this is not one of the JSPD_ flags in jsdbgapi.h - careful not to overlap*/
1393 #define JSDPD_HINTED 0x800 /* found via explicit lookup */
1396 * Release this JSDProperty
1397 * *** new for version 1.1 ****
1399 extern JSD_PUBLIC_API(void)
1400 JSD_DropProperty(JSDContext* jsdc, JSDProperty* jsdprop);
1403 * Get the JSDValue represeting the name of this property (int or string)
1404 * NOTE: must eventually release by calling JSD_DropValue
1405 * *** new for version 1.1 ****
1407 extern JSD_PUBLIC_API(JSDValue*)
1408 JSD_GetPropertyName(JSDContext* jsdc, JSDProperty* jsdprop);
1411 * Get the JSDValue represeting the current value of this property
1412 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1413 * *** new for version 1.1 ****
1415 extern JSD_PUBLIC_API(JSDValue*)
1416 JSD_GetPropertyValue(JSDContext* jsdc, JSDProperty* jsdprop);
1419 * Get the JSDValue represeting the alias of this property (if JSDPD_ALIAS set)
1420 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1421 * *** new for version 1.1 ****
1423 extern JSD_PUBLIC_API(JSDValue*)
1424 JSD_GetPropertyAlias(JSDContext* jsdc, JSDProperty* jsdprop);
1427 * Get the flags for this property
1428 * *** new for version 1.1 ****
1430 extern JSD_PUBLIC_API(uintN)
1431 JSD_GetPropertyFlags(JSDContext* jsdc, JSDProperty* jsdprop);
1434 * Get Variable or Argument slot number (if JSDPD_ARGUMENT or JSDPD_VARIABLE set)
1435 * *** new for version 1.1 ****
1437 extern JSD_PUBLIC_API(uintN)
1438 JSD_GetPropertyVarArgSlot(JSDContext* jsdc, JSDProperty* jsdprop);
1440 /***************************************************************************/
1441 /* Object Functions --- All NEW for 1.1 --- */
1444 * JSDObjects exist to allow a means of iterating through all JSObjects in the
1445 * engine. They are created and destroyed as the wrapped JSObjects are created
1446 * and destroyed in the engine. JSDObjects additionally track the location in
1447 * the JavaScript source where their wrapped JSObjects were created and the name
1448 * and location of the (non-native) constructor used.
1450 * NOTE: JSDObjects are NOT reference counted. The have only weak links to
1451 * jsObjects - thus they do not inhibit garbage collection of JSObjects. If
1452 * you need a JSDObject to safely persist then wrap it in a JSDValue (using
1453 * jsd_GetValueForObject).
1457 * Lock the entire Object subsystem -- see JSD_UnlockObjectSubsystem
1458 * *** new for version 1.1 ****
1460 extern JSD_PUBLIC_API(void)
1461 JSD_LockObjectSubsystem(JSDContext* jsdc);
1464 * Unlock the entire Object subsystem -- see JSD_LockObjectSubsystem
1465 * *** new for version 1.1 ****
1467 extern JSD_PUBLIC_API(void)
1468 JSD_UnlockObjectSubsystem(JSDContext* jsdc);
1471 * Iterate through the known objects
1472 * Use form similar to that shown for JSD_IterateScripts.
1473 * NOTE: the ObjectSubsystem must be locked before and unlocked after iterating.
1474 * *** new for version 1.1 ****
1476 extern JSD_PUBLIC_API(JSDObject*)
1477 JSD_IterateObjects(JSDContext* jsdc, JSDObject** iterp);
1480 * Get the JSObject represented by this JSDObject
1481 * *** new for version 1.1 ****
1483 extern JSD_PUBLIC_API(JSObject*)
1484 JSD_GetWrappedObject(JSDContext* jsdc, JSDObject* jsdobj);
1487 * Get the URL of the line of source that caused this object to be created.
1489 * *** new for version 1.1 ****
1491 extern JSD_PUBLIC_API(const char*)
1492 JSD_GetObjectNewURL(JSDContext* jsdc, JSDObject* jsdobj);
1495 * Get the line number of the line of source that caused this object to be
1496 * created. May be 0 indicating that the line number is unknown.
1497 * *** new for version 1.1 ****
1499 extern JSD_PUBLIC_API(uintN)
1500 JSD_GetObjectNewLineNumber(JSDContext* jsdc, JSDObject* jsdobj);
1503 * Get the URL of the line of source of the constructor for this object.
1505 * *** new for version 1.1 ****
1507 extern JSD_PUBLIC_API(const char*)
1508 JSD_GetObjectConstructorURL(JSDContext* jsdc, JSDObject* jsdobj);
1511 * Get the line number of the line of source of the constructor for this object.
1512 * created. May be 0 indicating that the line number is unknown.
1513 * *** new for version 1.1 ****
1515 extern JSD_PUBLIC_API(uintN)
1516 JSD_GetObjectConstructorLineNumber(JSDContext* jsdc, JSDObject* jsdobj);
1519 * Get the name of the constructor for this object.
1521 * *** new for version 1.1 ****
1523 extern JSD_PUBLIC_API(const char*)
1524 JSD_GetObjectConstructorName(JSDContext* jsdc, JSDObject* jsdobj);
1527 * Get JSDObject representing this JSObject.
1529 * *** new for version 1.1 ****
1531 extern JSD_PUBLIC_API(JSDObject*)
1532 JSD_GetJSDObjectForJSObject(JSDContext* jsdc, JSObject* jsobj);
1535 * Get JSDObject representing this JSDValue.
1537 * *** new for version 1.1 ****
1539 extern JSD_PUBLIC_API(JSDObject*)
1540 JSD_GetObjectForValue(JSDContext* jsdc, JSDValue* jsdval);
1543 * Create a JSDValue to wrap (and root) this JSDObject.
1544 * NOTE: must eventually release by calling JSD_DropValue (if not NULL)
1545 * *** new for version 1.1 ****
1547 extern JSD_PUBLIC_API(JSDValue*)
1548 JSD_GetValueForObject(JSDContext* jsdc, JSDObject* jsdobj);
1550 /***************************************************************************/
1551 /* Livewire specific API */
1554 extern JSD_PUBLIC_API(LWDBGScript*)
1555 JSDLW_GetLWScript(JSDContext* jsdc, JSDScript* jsdscript);
1557 extern JSD_PUBLIC_API(JSDSourceText*)
1558 JSDLW_PreLoadSource(JSDContext* jsdc, LWDBGApp* app,
1559 const char* filename, JSBool clear);
1561 extern JSD_PUBLIC_API(JSDSourceText*)
1562 JSDLW_ForceLoadSource(JSDContext* jsdc, JSDSourceText* jsdsrc);
1564 extern JSD_PUBLIC_API(JSBool)
1565 JSDLW_RawToProcessedLineNumber(JSDContext* jsdc, JSDScript* jsdscript,
1566 uintN lineIn, uintN* lineOut);
1568 extern JSD_PUBLIC_API(JSBool)
1569 JSDLW_ProcessedToRawLineNumber(JSDContext* jsdc, JSDScript* jsdscript,
1570 uintN lineIn, uintN* lineOut);
1573 /***************************************************************************/
1577 #endif /* jsdebug_h___ */