1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is Mozilla Communicator client code, released
17 * March 31, 1998.
18 *
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1998
22 * the Initial Developer. All Rights Reserved.
23 *
24 * Contributor(s):
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef jsprvtd_h___
41 #define jsprvtd_h___
42 /*
43 * JS private typename definitions.
44 *
45 * This header is included only in other .h files, for convenience and for
46 * simplicity of type naming. The alternative for structures is to use tags,
47 * which are named the same as their typedef names (legal in C/C++, and less
48 * noisy than suffixing the typedef name with "Struct" or "Str"). Instead,
49 * all .h files that include this file may use the same typedef name, whether
50 * declaring a pointer to struct type, or defining a member of struct type.
51 *
52 * A few fundamental scalar types are defined here too. Neither the scalar
53 * nor the struct typedefs should change much, therefore the nearly-global
54 * make dependency induced by this file should not prove painful.
55 */
57 #include "jspubtd.h"
59 /* Scalar typedefs. */
60 typedef uint8 jsbytecode;
61 typedef uint8 jssrcnote;
62 typedef uint32 jsatomid;
64 /* Struct typedefs. */
65 typedef struct JSArgumentFormatMap JSArgumentFormatMap;
66 typedef struct JSCodeGenerator JSCodeGenerator;
67 typedef struct JSDependentString JSDependentString;
68 typedef struct JSGCLockHashEntry JSGCLockHashEntry;
69 typedef struct JSGCRootHashEntry JSGCRootHashEntry;
70 typedef struct JSGCThing JSGCThing;
71 typedef struct JSParseNode JSParseNode;
72 typedef struct JSSharpObjectMap JSSharpObjectMap;
73 typedef struct JSToken JSToken;
74 typedef struct JSTokenPos JSTokenPos;
75 typedef struct JSTokenPtr JSTokenPtr;
76 typedef struct JSTokenStream JSTokenStream;
77 typedef struct JSTreeContext JSTreeContext;
78 typedef struct JSTryNote JSTryNote;
80 /* Friend "Advanced API" typedefs. */
81 typedef struct JSAtom JSAtom;
82 typedef struct JSAtomList JSAtomList;
83 typedef struct JSAtomListElement JSAtomListElement;
84 typedef struct JSAtomMap JSAtomMap;
85 typedef struct JSAtomState JSAtomState;
86 typedef struct JSCodeSpec JSCodeSpec;
87 typedef struct JSPrinter JSPrinter;
88 typedef struct JSRegExp JSRegExp;
89 typedef struct JSRegExpStatics JSRegExpStatics;
90 typedef struct JSScope JSScope;
91 typedef struct JSScopeOps JSScopeOps;
92 typedef struct JSScopeProperty JSScopeProperty;
93 typedef struct JSStackFrame JSStackFrame;
94 typedef struct JSStackHeader JSStackHeader;
95 typedef struct JSSubString JSSubString;
97 /* "Friend" types used by jscntxt.h and jsdbgapi.h. */
98 typedef enum JSTrapStatus {
99 JSTRAP_ERROR,
100 JSTRAP_CONTINUE,
101 JSTRAP_RETURN,
102 JSTRAP_THROW,
103 JSTRAP_LIMIT
104 } JSTrapStatus;
106 typedef JSTrapStatus
107 (* JS_DLL_CALLBACK JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc,
108 jsval *rval, void *closure);
110 typedef JSBool
111 (* JS_DLL_CALLBACK JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsval id,
112 jsval old, jsval *newp, void *closure);
114 /* called just after script creation */
115 typedef void
116 (* JS_DLL_CALLBACK JSNewScriptHook)(JSContext *cx,
117 const char *filename, /* URL of script */
118 uintN lineno, /* line script starts */
119 JSScript *script,
120 JSFunction *fun,
121 void *callerdata);
123 /* called just before script destruction */
124 typedef void
125 (* JS_DLL_CALLBACK JSDestroyScriptHook)(JSContext *cx,
126 JSScript *script,
127 void *callerdata);
129 typedef void
130 (* JS_DLL_CALLBACK JSSourceHandler)(const char *filename, uintN lineno,
131 jschar *str, size_t length,
132 void **listenerTSData, void *closure);
134 /*
135 * This hook captures high level script execution and function calls
136 * (JS or native).
137 * It is used by JS_SetExecuteHook to hook top level scripts and by
138 * JS_SetCallHook to hook function calls.
139 * It will get called twice per script or function call:
140 * just before execution begins and just after it finishes. In both cases
141 * the 'current' frame is that of the executing code.
142 *
143 * The 'before' param is JS_TRUE for the hook invocation before the execution
144 * and JS_FALSE for the invocation after the code has run.
145 *
146 * The 'ok' param is significant only on the post execution invocation to
147 * signify whether or not the code completed 'normally'.
148 *
149 * The 'closure' param is as passed to JS_SetExecuteHook or JS_SetCallHook
150 * for the 'before'invocation, but is whatever value is returned from that
151 * invocation for the 'after' invocation. Thus, the hook implementor *could*
152 * allocate a stucture in the 'before' invocation and return a pointer
153 * to that structure. The pointer would then be handed to the hook for
154 * the 'after' invocation. Alternately, the 'before' could just return the
155 * same value as in 'closure' to cause the 'after' invocation to be called
156 * with the same 'closure' value as the 'before'.
157 *
158 * Returning NULL in the 'before' hook will cause the 'after' hook to
159 * NOT be called.
160 */
162 typedef void *
163 (* JS_DLL_CALLBACK JSInterpreterHook)(JSContext *cx, JSStackFrame *fp, JSBool before,
164 JSBool *ok, void *closure);
166 typedef void
167 (* JS_DLL_CALLBACK JSObjectHook)(JSContext *cx, JSObject *obj, JSBool isNew,
168 void *closure);
170 typedef JSBool
171 (* JS_DLL_CALLBACK JSDebugErrorHook)(JSContext *cx, const char *message,
172 JSErrorReport *report, void *closure);
174 #endif /* jsprvtd_h___ */