2011-03-30 03:10:12 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code, released
|
|
|
|
* March 31, 1998.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef jsprvtd_h___
|
|
|
|
#define jsprvtd_h___
|
|
|
|
/*
|
|
|
|
* JS private typename definitions.
|
|
|
|
*
|
|
|
|
* This header is included only in other .h files, for convenience and for
|
|
|
|
* simplicity of type naming. The alternative for structures is to use tags,
|
|
|
|
* which are named the same as their typedef names (legal in C/C++, and less
|
|
|
|
* noisy than suffixing the typedef name with "Struct" or "Str"). Instead,
|
|
|
|
* all .h files that include this file may use the same typedef name, whether
|
|
|
|
* declaring a pointer to struct type, or defining a member of struct type.
|
|
|
|
*
|
|
|
|
* A few fundamental scalar types are defined here too. Neither the scalar
|
|
|
|
* nor the struct typedefs should change much, therefore the nearly-global
|
|
|
|
* make dependency induced by this file should not prove painful.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "jspubtd.h"
|
2010-10-01 21:00:55 -07:00
|
|
|
#include "jsstaticcheck.h"
|
2009-02-19 00:33:37 -08:00
|
|
|
#include "jsutil.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
JS_BEGIN_EXTERN_C
|
2008-03-04 15:58:10 -08:00
|
|
|
|
2007-11-19 09:15:45 -08:00
|
|
|
/*
|
|
|
|
* Convenience constants.
|
|
|
|
*/
|
2007-11-27 00:38:47 -08:00
|
|
|
#define JS_BITS_PER_UINT32_LOG2 5
|
|
|
|
#define JS_BITS_PER_UINT32 32
|
2007-11-19 09:15:45 -08:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
/* The alignment required of objects stored in GC arenas. */
|
|
|
|
static const uintN JS_GCTHING_ALIGN = 8;
|
|
|
|
static const uintN JS_GCTHING_ZEROBITS = 3;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* Scalar typedefs. */
|
|
|
|
typedef uint8 jsbytecode;
|
|
|
|
typedef uint8 jssrcnote;
|
|
|
|
typedef uint32 jsatomid;
|
|
|
|
|
|
|
|
/* Struct typedefs. */
|
|
|
|
typedef struct JSArgumentFormatMap JSArgumentFormatMap;
|
|
|
|
typedef struct JSCodeGenerator JSCodeGenerator;
|
2010-07-26 11:44:04 -07:00
|
|
|
typedef struct JSGCThing JSGCThing;
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef struct JSGenerator JSGenerator;
|
2008-07-01 18:59:18 -07:00
|
|
|
typedef struct JSNativeEnumerator JSNativeEnumerator;
|
2009-04-05 21:17:22 -07:00
|
|
|
typedef struct JSFunctionBox JSFunctionBox;
|
|
|
|
typedef struct JSObjectBox JSObjectBox;
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef struct JSParseNode JSParseNode;
|
2009-04-03 00:53:17 -07:00
|
|
|
typedef struct JSProperty JSProperty;
|
2011-02-03 05:06:21 -08:00
|
|
|
typedef struct JSScript JSScript;
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef struct JSSharpObjectMap JSSharpObjectMap;
|
|
|
|
typedef struct JSThread JSThread;
|
|
|
|
typedef struct JSTreeContext JSTreeContext;
|
|
|
|
typedef struct JSTryNote JSTryNote;
|
|
|
|
|
|
|
|
/* Friend "Advanced API" typedefs. */
|
|
|
|
typedef struct JSAtomList JSAtomList;
|
|
|
|
typedef struct JSAtomListElement JSAtomListElement;
|
|
|
|
typedef struct JSAtomMap JSAtomMap;
|
|
|
|
typedef struct JSAtomState JSAtomState;
|
|
|
|
typedef struct JSCodeSpec JSCodeSpec;
|
|
|
|
typedef struct JSPrinter JSPrinter;
|
|
|
|
typedef struct JSRegExpStatics JSRegExpStatics;
|
|
|
|
typedef struct JSStackHeader JSStackHeader;
|
|
|
|
typedef struct JSSubString JSSubString;
|
2009-09-04 13:44:31 -07:00
|
|
|
typedef struct JSNativeTraceInfo JSNativeTraceInfo;
|
|
|
|
typedef struct JSSpecializedNative JSSpecializedNative;
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef struct JSXML JSXML;
|
|
|
|
typedef struct JSXMLArray JSXMLArray;
|
|
|
|
typedef struct JSXMLArrayCursor JSXMLArrayCursor;
|
|
|
|
|
2009-06-30 17:19:42 -07:00
|
|
|
/*
|
|
|
|
* Template declarations.
|
|
|
|
*
|
2009-08-07 20:09:11 -07:00
|
|
|
* jsprvtd.h can be included in both C and C++ translation units. For C++, it
|
2009-06-30 17:19:42 -07:00
|
|
|
* may possibly be wrapped in an extern "C" block which does not agree with
|
2009-07-01 16:15:01 -07:00
|
|
|
* templates.
|
2009-06-30 17:19:42 -07:00
|
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
2011-03-14 13:59:53 -07:00
|
|
|
|
2009-07-01 16:15:01 -07:00
|
|
|
extern "C++" {
|
2009-06-30 17:19:42 -07:00
|
|
|
|
2011-03-14 13:59:53 -07:00
|
|
|
class JSDependentString;
|
|
|
|
class JSExtensibleString;
|
2011-04-20 18:34:49 -07:00
|
|
|
class JSExternalString;
|
2011-03-14 13:59:53 -07:00
|
|
|
class JSLinearString;
|
|
|
|
class JSFixedString;
|
|
|
|
class JSStaticAtom;
|
|
|
|
class JSRope;
|
|
|
|
class JSAtom;
|
|
|
|
|
2009-09-01 18:46:19 -07:00
|
|
|
namespace js {
|
2009-08-07 20:09:11 -07:00
|
|
|
|
2010-08-29 11:57:08 -07:00
|
|
|
struct ArgumentsData;
|
|
|
|
|
2010-08-11 13:30:07 -07:00
|
|
|
class RegExp;
|
|
|
|
class RegExpStatics;
|
|
|
|
class AutoStringRooter;
|
2010-03-03 17:52:26 -08:00
|
|
|
class ExecuteArgsGuard;
|
|
|
|
class InvokeFrameGuard;
|
|
|
|
class InvokeArgsGuard;
|
2010-09-28 15:23:43 -07:00
|
|
|
class InvokeSessionGuard;
|
2011-04-13 09:27:37 -07:00
|
|
|
class StringBuffer;
|
2010-01-22 14:49:18 -08:00
|
|
|
class TraceRecorder;
|
2010-06-08 08:33:55 -07:00
|
|
|
struct TraceMonitor;
|
2011-04-13 09:27:37 -07:00
|
|
|
|
|
|
|
class FrameRegs;
|
|
|
|
class StackFrame;
|
2010-07-29 14:43:11 -07:00
|
|
|
class StackSegment;
|
2011-04-13 09:27:37 -07:00
|
|
|
class StackSpace;
|
|
|
|
class ContextStack;
|
2010-08-09 22:43:33 -07:00
|
|
|
class FrameRegsIter;
|
2011-04-13 09:27:37 -07:00
|
|
|
class CallReceiver;
|
|
|
|
class CallArgs;
|
2010-01-22 14:49:18 -08:00
|
|
|
|
2010-08-29 11:57:08 -07:00
|
|
|
struct Compiler;
|
|
|
|
struct Parser;
|
2010-04-01 12:41:01 -07:00
|
|
|
class TokenStream;
|
2010-03-21 16:07:48 -07:00
|
|
|
struct Token;
|
|
|
|
struct TokenPos;
|
|
|
|
struct TokenPtr;
|
|
|
|
|
2009-09-01 18:46:19 -07:00
|
|
|
class ContextAllocPolicy;
|
|
|
|
class SystemAllocPolicy;
|
2009-06-30 17:19:42 -07:00
|
|
|
|
2009-09-01 18:46:19 -07:00
|
|
|
template <class T,
|
|
|
|
size_t MinInlineCapacity = 0,
|
|
|
|
class AllocPolicy = ContextAllocPolicy>
|
|
|
|
class Vector;
|
|
|
|
|
2010-02-06 10:14:05 -08:00
|
|
|
template <class>
|
|
|
|
struct DefaultHasher;
|
|
|
|
|
|
|
|
template <class Key,
|
|
|
|
class Value,
|
|
|
|
class HashPolicy = DefaultHasher<Key>,
|
|
|
|
class AllocPolicy = ContextAllocPolicy>
|
|
|
|
class HashMap;
|
|
|
|
|
|
|
|
template <class T,
|
|
|
|
class HashPolicy = DefaultHasher<T>,
|
|
|
|
class AllocPolicy = ContextAllocPolicy>
|
|
|
|
class HashSet;
|
|
|
|
|
2010-03-26 16:38:33 -07:00
|
|
|
class PropertyCache;
|
2010-03-24 19:20:44 -07:00
|
|
|
struct PropertyCacheEntry;
|
2009-09-01 18:46:19 -07:00
|
|
|
|
2010-08-29 11:57:08 -07:00
|
|
|
struct Shape;
|
|
|
|
struct EmptyShape;
|
2011-03-15 12:18:36 -07:00
|
|
|
class Bindings;
|
2009-06-05 12:56:45 -07:00
|
|
|
|
2010-04-30 16:03:37 -07:00
|
|
|
} /* namespace js */
|
|
|
|
|
2009-09-01 18:46:19 -07:00
|
|
|
} /* export "C++" */
|
2011-03-14 13:59:53 -07:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
typedef struct JSAtom JSAtom;
|
|
|
|
|
2009-06-30 17:19:42 -07:00
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* "Friend" types used by jscntxt.h and jsdbgapi.h. */
|
|
|
|
typedef enum JSTrapStatus {
|
|
|
|
JSTRAP_ERROR,
|
|
|
|
JSTRAP_CONTINUE,
|
|
|
|
JSTRAP_RETURN,
|
|
|
|
JSTRAP_THROW,
|
|
|
|
JSTRAP_LIMIT
|
|
|
|
} JSTrapStatus;
|
|
|
|
|
|
|
|
typedef JSTrapStatus
|
2008-09-06 15:21:43 -07:00
|
|
|
(* JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
2010-04-30 17:34:54 -07:00
|
|
|
jsval closure);
|
|
|
|
|
|
|
|
typedef JSTrapStatus
|
|
|
|
(* JSInterruptHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
|
|
|
void *closure);
|
|
|
|
|
|
|
|
typedef JSTrapStatus
|
|
|
|
(* JSDebuggerHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
|
|
|
void *closure);
|
|
|
|
|
|
|
|
typedef JSTrapStatus
|
|
|
|
(* JSThrowHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
|
|
|
void *closure);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
typedef JSBool
|
2010-07-14 23:19:36 -07:00
|
|
|
(* JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsid id, jsval old,
|
2008-09-06 15:21:43 -07:00
|
|
|
jsval *newp, void *closure);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* called just after script creation */
|
|
|
|
typedef void
|
2008-09-06 15:21:43 -07:00
|
|
|
(* JSNewScriptHook)(JSContext *cx,
|
|
|
|
const char *filename, /* URL of script */
|
|
|
|
uintN lineno, /* first line */
|
|
|
|
JSScript *script,
|
|
|
|
JSFunction *fun,
|
|
|
|
void *callerdata);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* called just before script destruction */
|
|
|
|
typedef void
|
2008-09-06 15:21:43 -07:00
|
|
|
(* JSDestroyScriptHook)(JSContext *cx,
|
|
|
|
JSScript *script,
|
|
|
|
void *callerdata);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
typedef void
|
2011-05-25 06:48:11 -07:00
|
|
|
(* JSSourceHandler)(const char *filename, uintN lineno, const jschar *str,
|
2008-09-06 15:21:43 -07:00
|
|
|
size_t length, void **listenerTSData, void *closure);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This hook captures high level script execution and function calls (JS or
|
|
|
|
* native). It is used by JS_SetExecuteHook to hook top level scripts and by
|
|
|
|
* JS_SetCallHook to hook function calls. It will get called twice per script
|
|
|
|
* or function call: just before execution begins and just after it finishes.
|
|
|
|
* In both cases the 'current' frame is that of the executing code.
|
|
|
|
*
|
|
|
|
* The 'before' param is JS_TRUE for the hook invocation before the execution
|
|
|
|
* and JS_FALSE for the invocation after the code has run.
|
|
|
|
*
|
|
|
|
* The 'ok' param is significant only on the post execution invocation to
|
|
|
|
* signify whether or not the code completed 'normally'.
|
|
|
|
*
|
|
|
|
* The 'closure' param is as passed to JS_SetExecuteHook or JS_SetCallHook
|
|
|
|
* for the 'before'invocation, but is whatever value is returned from that
|
|
|
|
* invocation for the 'after' invocation. Thus, the hook implementor *could*
|
|
|
|
* allocate a structure in the 'before' invocation and return a pointer to that
|
|
|
|
* structure. The pointer would then be handed to the hook for the 'after'
|
|
|
|
* invocation. Alternately, the 'before' could just return the same value as
|
|
|
|
* in 'closure' to cause the 'after' invocation to be called with the same
|
|
|
|
* 'closure' value as the 'before'.
|
|
|
|
*
|
|
|
|
* Returning NULL in the 'before' hook will cause the 'after' hook *not* to
|
|
|
|
* be called.
|
|
|
|
*/
|
|
|
|
typedef void *
|
2008-09-06 15:21:43 -07:00
|
|
|
(* JSInterpreterHook)(JSContext *cx, JSStackFrame *fp, JSBool before,
|
|
|
|
JSBool *ok, void *closure);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
typedef JSBool
|
2008-09-06 15:21:43 -07:00
|
|
|
(* JSDebugErrorHook)(JSContext *cx, const char *message, JSErrorReport *report,
|
|
|
|
void *closure);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-06-14 23:44:18 -07:00
|
|
|
typedef struct JSDebugHooks {
|
2010-04-30 17:34:54 -07:00
|
|
|
JSInterruptHook interruptHook;
|
|
|
|
void *interruptHookData;
|
2007-06-14 23:44:18 -07:00
|
|
|
JSNewScriptHook newScriptHook;
|
|
|
|
void *newScriptHookData;
|
|
|
|
JSDestroyScriptHook destroyScriptHook;
|
|
|
|
void *destroyScriptHookData;
|
2010-04-30 17:34:54 -07:00
|
|
|
JSDebuggerHandler debuggerHandler;
|
2007-06-14 23:44:18 -07:00
|
|
|
void *debuggerHandlerData;
|
|
|
|
JSSourceHandler sourceHandler;
|
|
|
|
void *sourceHandlerData;
|
|
|
|
JSInterpreterHook executeHook;
|
|
|
|
void *executeHookData;
|
|
|
|
JSInterpreterHook callHook;
|
|
|
|
void *callHookData;
|
2010-04-30 17:34:54 -07:00
|
|
|
JSThrowHook throwHook;
|
2007-06-14 23:44:18 -07:00
|
|
|
void *throwHookData;
|
|
|
|
JSDebugErrorHook debugErrorHook;
|
|
|
|
void *debugErrorHookData;
|
|
|
|
} JSDebugHooks;
|
|
|
|
|
2010-08-29 11:57:08 -07:00
|
|
|
/* js::ObjectOps function pointer typedefs. */
|
2009-03-31 07:02:20 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for id in obj and its prototype chain, returning false on error or
|
|
|
|
* exception, true on success. On success, return null in *propp if id was
|
|
|
|
* not found. If id was found, return the first object searching from obj
|
|
|
|
* along its prototype chain in which id names a direct property in *objp, and
|
|
|
|
* return a non-null, opaque property pointer in *propp.
|
|
|
|
*
|
|
|
|
* If JSLookupPropOp succeeds and returns with *propp non-null, that pointer
|
|
|
|
* may be passed as the prop parameter to a JSAttributesOp, as a short-cut
|
2010-10-22 17:04:22 -07:00
|
|
|
* that bypasses id re-lookup.
|
2009-03-31 07:02:20 -07:00
|
|
|
*
|
|
|
|
* NB: successful return with non-null *propp means the implementation may
|
|
|
|
* have locked *objp and added a reference count associated with *propp, so
|
|
|
|
* callers should not risk deadlock by nesting or interleaving other lookups
|
|
|
|
* or any obj-bearing ops before dropping *propp.
|
|
|
|
*/
|
|
|
|
typedef JSBool
|
|
|
|
(* JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
|
|
|
|
JSProperty **propp);
|
|
|
|
|
|
|
|
/*
|
2010-06-05 14:24:54 -07:00
|
|
|
* Get or set attributes of the property obj[id]. Return false on error or
|
|
|
|
* exception, true with current attributes in *attrsp.
|
2009-03-31 07:02:20 -07:00
|
|
|
*/
|
|
|
|
typedef JSBool
|
2010-06-05 14:24:54 -07:00
|
|
|
(* JSAttributesOp)(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
|
2009-03-31 07:02:20 -07:00
|
|
|
|
2010-06-12 09:29:04 -07:00
|
|
|
/*
|
|
|
|
* A generic type for functions mapping an object to another object, or null
|
|
|
|
* if an error or exception was thrown on cx.
|
|
|
|
*/
|
|
|
|
typedef JSObject *
|
|
|
|
(* JSObjectOp)(JSContext *cx, JSObject *obj);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hook that creates an iterator object for a given object. Returns the
|
|
|
|
* iterator object or null if an error or exception was thrown on cx.
|
|
|
|
*/
|
|
|
|
typedef JSObject *
|
|
|
|
(* JSIteratorOp)(JSContext *cx, JSObject *obj, JSBool keysonly);
|
|
|
|
|
2007-12-11 02:09:58 -08:00
|
|
|
/*
|
|
|
|
* The following determines whether JS_EncodeCharacters and JS_DecodeBytes
|
|
|
|
* treat char[] as utf-8 or simply as bytes that need to be inflated/deflated.
|
|
|
|
*/
|
|
|
|
#ifdef JS_C_STRINGS_ARE_UTF8
|
|
|
|
# define js_CStringsAreUTF8 JS_TRUE
|
|
|
|
#else
|
|
|
|
extern JSBool js_CStringsAreUTF8;
|
|
|
|
#endif
|
2007-07-08 02:03:34 -07:00
|
|
|
|
2010-06-12 09:29:04 -07:00
|
|
|
/*
|
|
|
|
* Hack to expose obj->getOps()->outer to the C implementation of the debugger
|
|
|
|
* interface.
|
|
|
|
*/
|
|
|
|
extern JS_FRIEND_API(JSObject *)
|
|
|
|
js_ObjectToOuterObject(JSContext *cx, JSObject *obj);
|
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
JS_END_EXTERN_C
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /* jsprvtd_h___ */
|