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 59 /* Internal identifier (jsid) macros. */ 60 #define JSID_ATOM 0x0 61 #define JSID_INT 0x1 62 #define JSID_OBJECT 0x2 63 #define JSID_TAGMASK 0x3 64 #define JSID_TAG(id) ((id) & JSID_TAGMASK) 65 #define JSID_SETTAG(id,t) ((id) | (t)) 66 #define JSID_CLRTAG(id) ((id) & ~(jsid)JSID_TAGMASK) 67 68 #define JSID_IS_ATOM(id) (JSID_TAG(id) == JSID_ATOM) 69 #define JSID_TO_ATOM(id) ((JSAtom *)(id)) 70 #define ATOM_TO_JSID(atom) ((jsid)(atom)) 71 #define ATOM_JSID_TO_JSVAL(id) ATOM_KEY(JSID_TO_ATOM(id)) 72 73 #define JSID_IS_INT(id) ((id) & JSID_INT) 74 #define JSID_TO_INT(id) ((jsint)(id) >> 1) 75 #define INT_TO_JSID(i) (((jsint)(i) << 1) | JSID_INT) 76 #define INT_JSID_TO_JSVAL(id) (id) 77 #define INT_JSVAL_TO_JSID(v) (v) 78 79 #define JSID_IS_OBJECT(id) (JSID_TAG(id) == JSID_OBJECT) 80 #define JSID_TO_OBJECT(id) ((JSObject *) JSID_CLRTAG(id)) 81 #define OBJECT_TO_JSID(obj) ((jsid)(obj) | JSID_OBJECT) 82 #define OBJECT_JSID_TO_JSVAL(id) OBJECT_TO_JSVAL(JSID_CLRTAG(id)) 83 #define OBJECT_JSVAL_TO_JSID(v) OBJECT_TO_JSID(JSVAL_TO_OBJECT(v)) 84 85 /* Scalar typedefs. */ 86 typedef uint8 jsbytecode; 87 typedef uint8 jssrcnote; 88 typedef uint32 jsatomid; 89 90 /* Struct typedefs. */ 91 typedef struct JSArgumentFormatMap JSArgumentFormatMap; 92 typedef struct JSCodeGenerator JSCodeGenerator; 93 typedef struct JSDependentString JSDependentString; 94 typedef struct JSGCThing JSGCThing; 95 typedef struct JSGenerator JSGenerator; 96 typedef struct JSParseNode JSParseNode; 97 typedef struct JSSharpObjectMap JSSharpObjectMap; 98 typedef struct JSThread JSThread; 99 typedef struct JSToken JSToken; 100 typedef struct JSTokenPos JSTokenPos; 101 typedef struct JSTokenPtr JSTokenPtr; 102 typedef struct JSTokenStream JSTokenStream; 103 typedef struct JSTreeContext JSTreeContext; 104 typedef struct JSTryNote JSTryNote; 105 106 /* Friend "Advanced API" typedefs. */ 107 typedef struct JSAtom JSAtom; 108 typedef struct JSAtomList JSAtomList; 109 typedef struct JSAtomListElement JSAtomListElement; 110 typedef struct JSAtomMap JSAtomMap; 111 typedef struct JSAtomState JSAtomState; 112 typedef struct JSCodeSpec JSCodeSpec; 113 typedef struct JSPrinter JSPrinter; 114 typedef struct JSRegExp JSRegExp; 115 typedef struct JSRegExpStatics JSRegExpStatics; 116 typedef struct JSScope JSScope; 117 typedef struct JSScopeOps JSScopeOps; 118 typedef struct JSScopeProperty JSScopeProperty; 119 typedef struct JSStackHeader JSStackHeader; 120 typedef struct JSStringBuffer JSStringBuffer; 121 typedef struct JSSubString JSSubString; 122 typedef struct JSXML JSXML; 123 typedef struct JSXMLNamespace JSXMLNamespace; 124 typedef struct JSXMLQName JSXMLQName; 125 typedef struct JSXMLArray JSXMLArray; 126 typedef struct JSXMLArrayCursor JSXMLArrayCursor; 127 128 /* "Friend" types used by jscntxt.h and jsdbgapi.h. */ 129 typedef enum JSTrapStatus { 130 JSTRAP_ERROR, 131 JSTRAP_CONTINUE, 132 JSTRAP_RETURN, 133 JSTRAP_THROW, 134 JSTRAP_LIMIT 135 } JSTrapStatus; 136 137 typedef JSTrapStatus 138 (* JS_DLL_CALLBACK JSTrapHandler)(JSContext *cx, JSScript *script, 139 jsbytecode *pc, jsval *rval, void *closure); 140 141 typedef JSBool 142 (* JS_DLL_CALLBACK JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsval id, 143 jsval old, jsval *newp, void *closure); 144 145 /* called just after script creation */ 146 typedef void 147 (* JS_DLL_CALLBACK JSNewScriptHook)(JSContext *cx, 148 const char *filename, /* URL of script */ 149 uintN lineno, /* first line */ 150 JSScript *script, 151 JSFunction *fun, 152 void *callerdata); 153 154 /* called just before script destruction */ 155 typedef void 156 (* JS_DLL_CALLBACK JSDestroyScriptHook)(JSContext *cx, 157 JSScript *script, 158 void *callerdata); 159 160 typedef void 161 (* JS_DLL_CALLBACK JSSourceHandler)(const char *filename, uintN lineno, 162 jschar *str, size_t length, 163 void **listenerTSData, void *closure); 164 165 /* 166 * This hook captures high level script execution and function calls (JS or 167 * native). It is used by JS_SetExecuteHook to hook top level scripts and by 168 * JS_SetCallHook to hook function calls. It will get called twice per script 169 * or function call: just before execution begins and just after it finishes. 170 * In both cases the 'current' frame is that of the executing code. 171 * 172 * The 'before' param is JS_TRUE for the hook invocation before the execution 173 * and JS_FALSE for the invocation after the code has run. 174 * 175 * The 'ok' param is significant only on the post execution invocation to 176 * signify whether or not the code completed 'normally'. 177 * 178 * The 'closure' param is as passed to JS_SetExecuteHook or JS_SetCallHook 179 * for the 'before'invocation, but is whatever value is returned from that 180 * invocation for the 'after' invocation. Thus, the hook implementor *could* 181 * allocate a structure in the 'before' invocation and return a pointer to that 182 * structure. The pointer would then be handed to the hook for the 'after' 183 * invocation. Alternately, the 'before' could just return the same value as 184 * in 'closure' to cause the 'after' invocation to be called with the same 185 * 'closure' value as the 'before'. 186 * 187 * Returning NULL in the 'before' hook will cause the 'after' hook *not* to 188 * be called. 189 */ 190 typedef void * 191 (* JS_DLL_CALLBACK JSInterpreterHook)(JSContext *cx, JSStackFrame *fp, JSBool before, 192 JSBool *ok, void *closure); 193 194 typedef void 195 (* JS_DLL_CALLBACK JSObjectHook)(JSContext *cx, JSObject *obj, JSBool isNew, 196 void *closure); 197 198 typedef JSBool 199 (* JS_DLL_CALLBACK JSDebugErrorHook)(JSContext *cx, const char *message, 200 JSErrorReport *report, void *closure); 201 202 #endif /* jsprvtd_h___ */ 203