Back to index

lightning-sunbird  0.9+nobinonly
jsprvtd.h
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is Mozilla Communicator client code, released
00017  * March 31, 1998.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 1998
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef jsprvtd_h___
00041 #define jsprvtd_h___
00042 /*
00043  * JS private typename definitions.
00044  *
00045  * This header is included only in other .h files, for convenience and for
00046  * simplicity of type naming.  The alternative for structures is to use tags,
00047  * which are named the same as their typedef names (legal in C/C++, and less
00048  * noisy than suffixing the typedef name with "Struct" or "Str").  Instead,
00049  * all .h files that include this file may use the same typedef name, whether
00050  * declaring a pointer to struct type, or defining a member of struct type.
00051  *
00052  * A few fundamental scalar types are defined here too.  Neither the scalar
00053  * nor the struct typedefs should change much, therefore the nearly-global
00054  * make dependency induced by this file should not prove painful.
00055  */
00056 
00057 #include "jspubtd.h"
00058 
00059 /* Internal identifier (jsid) macros. */
00060 #define JSID_ATOM                   0x0
00061 #define JSID_INT                    0x1
00062 #define JSID_OBJECT                 0x2
00063 #define JSID_TAGMASK                0x3
00064 #define JSID_TAG(id)                ((id) & JSID_TAGMASK)
00065 #define JSID_SETTAG(id,t)           ((id) | (t))
00066 #define JSID_CLRTAG(id)             ((id) & ~(jsid)JSID_TAGMASK)
00067 
00068 #define JSID_IS_ATOM(id)            (JSID_TAG(id) == JSID_ATOM)
00069 #define JSID_TO_ATOM(id)            ((JSAtom *)(id))
00070 #define ATOM_TO_JSID(atom)          ((jsid)(atom))
00071 #define ATOM_JSID_TO_JSVAL(id)      ATOM_KEY(JSID_TO_ATOM(id))
00072 
00073 #define JSID_IS_INT(id)             ((id) & JSID_INT)
00074 #define JSID_TO_INT(id)             ((jsint)(id) >> 1)
00075 #define INT_TO_JSID(i)              (((jsint)(i) << 1) | JSID_INT)
00076 #define INT_JSID_TO_JSVAL(id)       (id)
00077 #define INT_JSVAL_TO_JSID(v)        (v)
00078 
00079 #define JSID_IS_OBJECT(id)          (JSID_TAG(id) == JSID_OBJECT)
00080 #define JSID_TO_OBJECT(id)          ((JSObject *) JSID_CLRTAG(id))
00081 #define OBJECT_TO_JSID(obj)         ((jsid)(obj) | JSID_OBJECT)
00082 #define OBJECT_JSID_TO_JSVAL(id)    OBJECT_TO_JSVAL(JSID_CLRTAG(id))
00083 #define OBJECT_JSVAL_TO_JSID(v)     OBJECT_TO_JSID(JSVAL_TO_OBJECT(v))
00084 
00085 /* Scalar typedefs. */
00086 typedef uint8  jsbytecode;
00087 typedef uint8  jssrcnote;
00088 typedef uint32 jsatomid;
00089 
00090 /* Struct typedefs. */
00091 typedef struct JSArgumentFormatMap  JSArgumentFormatMap;
00092 typedef struct JSCodeGenerator      JSCodeGenerator;
00093 typedef struct JSDependentString    JSDependentString;
00094 typedef struct JSGCThing            JSGCThing;
00095 typedef struct JSGenerator          JSGenerator;
00096 typedef struct JSParseNode          JSParseNode;
00097 typedef struct JSSharpObjectMap     JSSharpObjectMap;
00098 typedef struct JSTempValueRooter    JSTempValueRooter;
00099 typedef struct JSThread             JSThread;
00100 typedef struct JSToken              JSToken;
00101 typedef struct JSTokenPos           JSTokenPos;
00102 typedef struct JSTokenPtr           JSTokenPtr;
00103 typedef struct JSTokenStream        JSTokenStream;
00104 typedef struct JSTreeContext        JSTreeContext;
00105 typedef struct JSTryNote            JSTryNote;
00106 typedef struct JSWeakRoots          JSWeakRoots;
00107 
00108 /* Friend "Advanced API" typedefs. */
00109 typedef struct JSAtom               JSAtom;
00110 typedef struct JSAtomList           JSAtomList;
00111 typedef struct JSAtomListElement    JSAtomListElement;
00112 typedef struct JSAtomMap            JSAtomMap;
00113 typedef struct JSAtomState          JSAtomState;
00114 typedef struct JSCodeSpec           JSCodeSpec;
00115 typedef struct JSPrinter            JSPrinter;
00116 typedef struct JSRegExp             JSRegExp;
00117 typedef struct JSRegExpStatics      JSRegExpStatics;
00118 typedef struct JSScope              JSScope;
00119 typedef struct JSScopeOps           JSScopeOps;
00120 typedef struct JSScopeProperty      JSScopeProperty;
00121 typedef struct JSStackHeader        JSStackHeader;
00122 typedef struct JSStringBuffer       JSStringBuffer;
00123 typedef struct JSSubString          JSSubString;
00124 typedef struct JSXML                JSXML;
00125 typedef struct JSXMLNamespace       JSXMLNamespace;
00126 typedef struct JSXMLQName           JSXMLQName;
00127 typedef struct JSXMLArray           JSXMLArray;
00128 typedef struct JSXMLArrayCursor     JSXMLArrayCursor;
00129 
00130 /* "Friend" types used by jscntxt.h and jsdbgapi.h. */
00131 typedef enum JSTrapStatus {
00132     JSTRAP_ERROR,
00133     JSTRAP_CONTINUE,
00134     JSTRAP_RETURN,
00135     JSTRAP_THROW,
00136     JSTRAP_LIMIT
00137 } JSTrapStatus;
00138 
00139 typedef JSTrapStatus
00140 (* JS_DLL_CALLBACK JSTrapHandler)(JSContext *cx, JSScript *script,
00141                                   jsbytecode *pc, jsval *rval, void *closure);
00142 
00143 typedef JSBool
00144 (* JS_DLL_CALLBACK JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsval id,
00145                                         jsval old, jsval *newp, void *closure);
00146 
00147 /* called just after script creation */
00148 typedef void
00149 (* JS_DLL_CALLBACK JSNewScriptHook)(JSContext  *cx,
00150                                     const char *filename,  /* URL of script */
00151                                     uintN      lineno,     /* first line */
00152                                     JSScript   *script,
00153                                     JSFunction *fun,
00154                                     void       *callerdata);
00155 
00156 /* called just before script destruction */
00157 typedef void
00158 (* JS_DLL_CALLBACK JSDestroyScriptHook)(JSContext *cx,
00159                                         JSScript  *script,
00160                                         void      *callerdata);
00161 
00162 typedef void
00163 (* JS_DLL_CALLBACK JSSourceHandler)(const char *filename, uintN lineno,
00164                                     jschar *str, size_t length,
00165                                     void **listenerTSData, void *closure);
00166 
00167 /*
00168  * This hook captures high level script execution and function calls (JS or
00169  * native).  It is used by JS_SetExecuteHook to hook top level scripts and by
00170  * JS_SetCallHook to hook function calls.  It will get called twice per script
00171  * or function call: just before execution begins and just after it finishes.
00172  * In both cases the 'current' frame is that of the executing code.
00173  *
00174  * The 'before' param is JS_TRUE for the hook invocation before the execution
00175  * and JS_FALSE for the invocation after the code has run.
00176  *
00177  * The 'ok' param is significant only on the post execution invocation to
00178  * signify whether or not the code completed 'normally'.
00179  *
00180  * The 'closure' param is as passed to JS_SetExecuteHook or JS_SetCallHook
00181  * for the 'before'invocation, but is whatever value is returned from that
00182  * invocation for the 'after' invocation. Thus, the hook implementor *could*
00183  * allocate a structure in the 'before' invocation and return a pointer to that
00184  * structure. The pointer would then be handed to the hook for the 'after'
00185  * invocation. Alternately, the 'before' could just return the same value as
00186  * in 'closure' to cause the 'after' invocation to be called with the same
00187  * 'closure' value as the 'before'.
00188  *
00189  * Returning NULL in the 'before' hook will cause the 'after' hook *not* to
00190  * be called.
00191  */
00192 typedef void *
00193 (* JS_DLL_CALLBACK JSInterpreterHook)(JSContext *cx, JSStackFrame *fp, JSBool before,
00194                                       JSBool *ok, void *closure);
00195 
00196 typedef void
00197 (* JS_DLL_CALLBACK JSObjectHook)(JSContext *cx, JSObject *obj, JSBool isNew,
00198                                  void *closure);
00199 
00200 typedef JSBool
00201 (* JS_DLL_CALLBACK JSDebugErrorHook)(JSContext *cx, const char *message,
00202                                      JSErrorReport *report, void *closure);
00203 
00204 /*
00205  * Type definitions for temporary GC roots that register with GC local C
00206  * variables. See jscntxt.h for details.
00207  */
00208 typedef void
00209 (* JS_DLL_CALLBACK JSTempValueMarker)(JSContext *cx, JSTempValueRooter *tvr);
00210 
00211 typedef union JSTempValueUnion {
00212     jsval               value;
00213     JSObject            *object;
00214     JSString            *string;
00215     JSXML               *xml;
00216     JSXMLQName          *qname;
00217     JSXMLNamespace      *nspace;
00218     JSTempValueMarker   marker;
00219     JSScopeProperty     *sprop;
00220     JSWeakRoots         *weakRoots;
00221     JSScript            *script;
00222     jsval               *array;
00223 } JSTempValueUnion;
00224 
00225 struct JSTempValueRooter {
00226     JSTempValueRooter   *down;
00227     ptrdiff_t           count;
00228     JSTempValueUnion    u;
00229 };
00230 
00231 #endif /* jsprvtd_h___ */