/[jscoverage]/trunk/js/jsprvtd.h
ViewVC logotype

Contents of /trunk/js/jsprvtd.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 507 - (show annotations)
Sun Jan 10 07:23:34 2010 UTC (9 years, 11 months ago) by siliconforks
File MIME type: text/plain
File size: 14505 byte(s)
Update SpiderMonkey from Firefox 3.6rc1.

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 ***** */
39
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 */
56
57 #include "jspubtd.h"
58 #include "jsutil.h"
59
60 /* Internal identifier (jsid) macros. */
61
62 #define JSID_IS_ATOM(id) JSVAL_IS_STRING((jsval)(id))
63 #define JSID_TO_ATOM(id) ((JSAtom *)(id))
64 #define ATOM_TO_JSID(atom) (JS_ASSERT(ATOM_IS_STRING(atom)), \
65 (jsid)(atom))
66
67 #define JSID_IS_INT(id) JSVAL_IS_INT((jsval)(id))
68 #define JSID_TO_INT(id) JSVAL_TO_INT((jsval)(id))
69 #define INT_TO_JSID(i) ((jsid)INT_TO_JSVAL(i))
70 #define INT_JSVAL_TO_JSID(v) ((jsid)(v))
71 #define INT_JSID_TO_JSVAL(id) ((jsval)(id))
72
73 #define JSID_IS_OBJECT(id) JSVAL_IS_OBJECT((jsval)(id))
74 #define JSID_TO_OBJECT(id) JSVAL_TO_OBJECT((jsval)(id))
75 #define OBJECT_TO_JSID(obj) ((jsid)OBJECT_TO_JSVAL(obj))
76 #define OBJECT_JSVAL_TO_JSID(v) ((jsid)v)
77
78 #define ID_TO_VALUE(id) ((jsval)(id))
79
80 /*
81 * Convenience constants.
82 */
83 #define JS_BITS_PER_UINT32_LOG2 5
84 #define JS_BITS_PER_UINT32 32
85
86 /* Scalar typedefs. */
87 typedef uint8 jsbytecode;
88 typedef uint8 jssrcnote;
89 typedef uint32 jsatomid;
90
91 /* Struct typedefs. */
92 typedef struct JSArgumentFormatMap JSArgumentFormatMap;
93 typedef struct JSCodeGenerator JSCodeGenerator;
94 typedef struct JSGCThing JSGCThing;
95 typedef struct JSGenerator JSGenerator;
96 typedef struct JSNativeEnumerator JSNativeEnumerator;
97 typedef struct JSCompiler JSCompiler;
98 typedef struct JSFunctionBox JSFunctionBox;
99 typedef struct JSObjectBox JSObjectBox;
100 typedef struct JSParseNode JSParseNode;
101 typedef struct JSPropCacheEntry JSPropCacheEntry;
102 typedef struct JSProperty JSProperty;
103 typedef struct JSSharpObjectMap JSSharpObjectMap;
104 typedef struct JSTempValueRooter JSTempValueRooter;
105 typedef struct JSThread JSThread;
106 typedef struct JSThreadData JSThreadData;
107 typedef struct JSToken JSToken;
108 typedef struct JSTokenPos JSTokenPos;
109 typedef struct JSTokenPtr JSTokenPtr;
110 typedef struct JSTokenStream JSTokenStream;
111 typedef struct JSTraceMonitor JSTraceMonitor;
112 typedef struct JSTreeContext JSTreeContext;
113 typedef struct JSTryNote JSTryNote;
114 typedef struct JSWeakRoots JSWeakRoots;
115
116 /* Friend "Advanced API" typedefs. */
117 typedef struct JSAtom JSAtom;
118 typedef struct JSAtomList JSAtomList;
119 typedef struct JSAtomListElement JSAtomListElement;
120 typedef struct JSAtomMap JSAtomMap;
121 typedef struct JSAtomState JSAtomState;
122 typedef struct JSCodeSpec JSCodeSpec;
123 typedef struct JSPrinter JSPrinter;
124 typedef struct JSRegExp JSRegExp;
125 typedef struct JSRegExpStatics JSRegExpStatics;
126 typedef struct JSScope JSScope;
127 typedef struct JSScopeOps JSScopeOps;
128 typedef struct JSScopeProperty JSScopeProperty;
129 typedef struct JSStackHeader JSStackHeader;
130 typedef struct JSSubString JSSubString;
131 typedef struct JSNativeTraceInfo JSNativeTraceInfo;
132 typedef struct JSSpecializedNative JSSpecializedNative;
133 typedef struct JSXML JSXML;
134 typedef struct JSXMLArray JSXMLArray;
135 typedef struct JSXMLArrayCursor JSXMLArrayCursor;
136
137 /*
138 * Template declarations.
139 *
140 * jsprvtd.h can be included in both C and C++ translation units. For C++, it
141 * may possibly be wrapped in an extern "C" block which does not agree with
142 * templates.
143 */
144 #ifdef __cplusplus
145 extern "C++" {
146
147 namespace js {
148
149 class ContextAllocPolicy;
150 class SystemAllocPolicy;
151
152 template <class T,
153 size_t MinInlineCapacity = 0,
154 class AllocPolicy = ContextAllocPolicy>
155 class Vector;
156
157 } /* namespace js */
158
159 /* Common instantiations. */
160 typedef js::Vector<jschar, 32> JSCharBuffer;
161
162 } /* export "C++" */
163 #endif /* __cplusplus */
164
165 /* "Friend" types used by jscntxt.h and jsdbgapi.h. */
166 typedef enum JSTrapStatus {
167 JSTRAP_ERROR,
168 JSTRAP_CONTINUE,
169 JSTRAP_RETURN,
170 JSTRAP_THROW,
171 JSTRAP_LIMIT
172 } JSTrapStatus;
173
174 typedef JSTrapStatus
175 (* JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
176 void *closure);
177
178 typedef JSBool
179 (* JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsval id, jsval old,
180 jsval *newp, void *closure);
181
182 /* called just after script creation */
183 typedef void
184 (* JSNewScriptHook)(JSContext *cx,
185 const char *filename, /* URL of script */
186 uintN lineno, /* first line */
187 JSScript *script,
188 JSFunction *fun,
189 void *callerdata);
190
191 /* called just before script destruction */
192 typedef void
193 (* JSDestroyScriptHook)(JSContext *cx,
194 JSScript *script,
195 void *callerdata);
196
197 typedef void
198 (* JSSourceHandler)(const char *filename, uintN lineno, jschar *str,
199 size_t length, void **listenerTSData, void *closure);
200
201 /*
202 * This hook captures high level script execution and function calls (JS or
203 * native). It is used by JS_SetExecuteHook to hook top level scripts and by
204 * JS_SetCallHook to hook function calls. It will get called twice per script
205 * or function call: just before execution begins and just after it finishes.
206 * In both cases the 'current' frame is that of the executing code.
207 *
208 * The 'before' param is JS_TRUE for the hook invocation before the execution
209 * and JS_FALSE for the invocation after the code has run.
210 *
211 * The 'ok' param is significant only on the post execution invocation to
212 * signify whether or not the code completed 'normally'.
213 *
214 * The 'closure' param is as passed to JS_SetExecuteHook or JS_SetCallHook
215 * for the 'before'invocation, but is whatever value is returned from that
216 * invocation for the 'after' invocation. Thus, the hook implementor *could*
217 * allocate a structure in the 'before' invocation and return a pointer to that
218 * structure. The pointer would then be handed to the hook for the 'after'
219 * invocation. Alternately, the 'before' could just return the same value as
220 * in 'closure' to cause the 'after' invocation to be called with the same
221 * 'closure' value as the 'before'.
222 *
223 * Returning NULL in the 'before' hook will cause the 'after' hook *not* to
224 * be called.
225 */
226 typedef void *
227 (* JSInterpreterHook)(JSContext *cx, JSStackFrame *fp, JSBool before,
228 JSBool *ok, void *closure);
229
230 typedef void
231 (* JSObjectHook)(JSContext *cx, JSObject *obj, JSBool isNew, void *closure);
232
233 typedef JSBool
234 (* JSDebugErrorHook)(JSContext *cx, const char *message, JSErrorReport *report,
235 void *closure);
236
237 typedef struct JSDebugHooks {
238 JSTrapHandler interruptHandler;
239 void *interruptHandlerData;
240 JSNewScriptHook newScriptHook;
241 void *newScriptHookData;
242 JSDestroyScriptHook destroyScriptHook;
243 void *destroyScriptHookData;
244 JSTrapHandler debuggerHandler;
245 void *debuggerHandlerData;
246 JSSourceHandler sourceHandler;
247 void *sourceHandlerData;
248 JSInterpreterHook executeHook;
249 void *executeHookData;
250 JSInterpreterHook callHook;
251 void *callHookData;
252 JSObjectHook objectHook;
253 void *objectHookData;
254 JSTrapHandler throwHook;
255 void *throwHookData;
256 JSDebugErrorHook debugErrorHook;
257 void *debugErrorHookData;
258 } JSDebugHooks;
259
260 /*
261 * Type definitions for temporary GC roots that register with GC local C
262 * variables. See jscntxt.h for details.
263 */
264 typedef void
265 (* JSTempValueTrace)(JSTracer *trc, JSTempValueRooter *tvr);
266
267 typedef union JSTempValueUnion {
268 jsval value;
269 JSObject *object;
270 JSXML *xml;
271 JSTempValueTrace trace;
272 JSScopeProperty *sprop;
273 JSWeakRoots *weakRoots;
274 JSCompiler *compiler;
275 JSScript *script;
276 jsval *array;
277 } JSTempValueUnion;
278
279 struct JSTempValueRooter {
280 JSTempValueRooter *down;
281 ptrdiff_t count;
282 JSTempValueUnion u;
283 };
284
285 /* JSObjectOps function pointer typedefs. */
286
287 /*
288 * Look for id in obj and its prototype chain, returning false on error or
289 * exception, true on success. On success, return null in *propp if id was
290 * not found. If id was found, return the first object searching from obj
291 * along its prototype chain in which id names a direct property in *objp, and
292 * return a non-null, opaque property pointer in *propp.
293 *
294 * If JSLookupPropOp succeeds and returns with *propp non-null, that pointer
295 * may be passed as the prop parameter to a JSAttributesOp, as a short-cut
296 * that bypasses id re-lookup. In any case, a non-null *propp result after a
297 * successful lookup must be dropped via JSObjectOps.dropProperty.
298 *
299 * NB: successful return with non-null *propp means the implementation may
300 * have locked *objp and added a reference count associated with *propp, so
301 * callers should not risk deadlock by nesting or interleaving other lookups
302 * or any obj-bearing ops before dropping *propp.
303 */
304 typedef JSBool
305 (* JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
306 JSProperty **propp);
307
308 /*
309 * Define obj[id], a direct property of obj named id, having the given initial
310 * value, with the specified getter, setter, and attributes.
311 */
312 typedef JSBool
313 (* JSDefinePropOp)(JSContext *cx, JSObject *obj, jsid id, jsval value,
314 JSPropertyOp getter, JSPropertyOp setter, uintN attrs);
315
316 /*
317 * Get, set, or delete obj[id], returning false on error or exception, true
318 * on success. If getting or setting, the new value is returned in *vp on
319 * success. If deleting without error, *vp will be JSVAL_FALSE if obj[id] is
320 * permanent, and JSVAL_TRUE if id named a direct property of obj that was in
321 * fact deleted, or if id names no direct property of obj (id could name a
322 * prototype property, or no property in obj or its prototype chain).
323 */
324 typedef JSBool
325 (* JSPropertyIdOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
326
327 /*
328 * Get or set attributes of the property obj[id]. Return false on error or
329 * exception, true with current attributes in *attrsp. If prop is non-null,
330 * it must come from the *propp out parameter of a prior JSDefinePropOp or
331 * JSLookupPropOp call.
332 */
333 typedef JSBool
334 (* JSAttributesOp)(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
335 uintN *attrsp);
336
337 /*
338 * JSObjectOps.checkAccess type: check whether obj[id] may be accessed per
339 * mode, returning false on error/exception, true on success with obj[id]'s
340 * last-got value in *vp, and its attributes in *attrsp.
341 */
342 typedef JSBool
343 (* JSCheckAccessIdOp)(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
344 jsval *vp, uintN *attrsp);
345
346 /*
347 * A generic type for functions taking a context, object, and property, with
348 * no return value. Used by JSObjectOps.dropProperty currently (see above,
349 * JSDefinePropOp and JSLookupPropOp, for the object-locking protocol in which
350 * dropProperty participates).
351 */
352 typedef void
353 (* JSPropertyRefOp)(JSContext *cx, JSObject *obj, JSProperty *prop);
354
355 /*
356 * The following determines whether JS_EncodeCharacters and JS_DecodeBytes
357 * treat char[] as utf-8 or simply as bytes that need to be inflated/deflated.
358 */
359 #ifdef JS_C_STRINGS_ARE_UTF8
360 # define js_CStringsAreUTF8 JS_TRUE
361 #else
362 extern JSBool js_CStringsAreUTF8;
363 #endif
364
365 /*
366 * Maximum supported value of Arguments.length. It bounds the maximum number
367 * of arguments that can be supplied to the function call using
368 * Function.prototype.apply. This value also gives the maximum number of
369 * elements in the array initializer.
370 */
371 #define JS_ARGS_LENGTH_MAX (JS_BIT(24) - 1)
372
373 #endif /* jsprvtd_h___ */

  ViewVC Help
Powered by ViewVC 1.1.24