PageRenderTime 58ms CodeModel.GetById 22ms app.highlight 28ms RepoModel.GetById 1ms app.codeStats 1ms

/js/src/jspubtd.h

http://github.com/zpao/v8monkey
C Header | 255 lines | 140 code | 28 blank | 87 comment | 7 complexity | 93a96c72f3a6f5dd1a4102a16bb90d4a MD5 | raw file
  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 jspubtd_h___
 41#define jspubtd_h___
 42
 43/*
 44 * JS public API typedefs.
 45 */
 46#include "jstypes.h"
 47#include "jscompat.h"
 48
 49/*
 50 * Allow headers to reference JS::Value without #including the whole jsapi.h.
 51 * Unfortunately, typedefs (hence jsval) cannot be declared.
 52 */
 53#ifdef __cplusplus
 54namespace JS { class Value; }
 55#endif
 56
 57/*
 58 * In release builds, jsid is defined to be an integral type. This
 59 * prevents many bugs from being caught at compile time. E.g.:
 60 *
 61 *  jsid id = ...
 62 *  if (id == JS_TRUE)  // error
 63 *    ...
 64 *
 65 *  size_t n = id;      // error
 66 *
 67 * To catch more errors, jsid is given a struct type in C++ debug builds.
 68 * Struct assignment and (in C++) operator== allow correct code to be mostly
 69 * oblivious to the change. This feature can be explicitly disabled in debug
 70 * builds by defining JS_NO_JSVAL_JSID_STRUCT_TYPES.
 71 */
 72#ifdef __cplusplus
 73
 74# if defined(DEBUG) && !defined(JS_NO_JSVAL_JSID_STRUCT_TYPES)
 75#  define JS_USE_JSID_STRUCT_TYPES
 76# endif
 77
 78# ifdef JS_USE_JSID_STRUCT_TYPES
 79struct jsid
 80{
 81    size_t asBits;
 82    bool operator==(jsid rhs) const { return asBits == rhs.asBits; }
 83    bool operator!=(jsid rhs) const { return asBits != rhs.asBits; }
 84};
 85#  define JSID_BITS(id) (id.asBits)
 86# else  /* defined(JS_USE_JSID_STRUCT_TYPES) */
 87typedef ptrdiff_t jsid;
 88#  define JSID_BITS(id) (id)
 89# endif  /* defined(JS_USE_JSID_STRUCT_TYPES) */
 90#else  /* defined(__cplusplus) */
 91typedef ptrdiff_t jsid;
 92# define JSID_BITS(id) (id)
 93#endif
 94
 95JS_BEGIN_EXTERN_C
 96
 97/* Scalar typedefs. */
 98typedef int32_t   jsint;
 99typedef uint32_t  jsuint;
100typedef double    jsdouble;
101typedef int32_t   jsrefcount;   /* PRInt32 if JS_THREADSAFE, see jslock.h */
102
103#ifdef WIN32
104typedef wchar_t   jschar;
105#else
106typedef uint16_t  jschar;
107#endif
108
109/*
110 * Run-time version enumeration.  See jsversion.h for compile-time counterparts
111 * to these values that may be selected by the JS_VERSION macro, and tested by
112 * #if expressions.
113 */
114typedef enum JSVersion {
115    JSVERSION_1_0     = 100,
116    JSVERSION_1_1     = 110,
117    JSVERSION_1_2     = 120,
118    JSVERSION_1_3     = 130,
119    JSVERSION_1_4     = 140,
120    JSVERSION_ECMA_3  = 148,
121    JSVERSION_1_5     = 150,
122    JSVERSION_1_6     = 160,
123    JSVERSION_1_7     = 170,
124    JSVERSION_1_8     = 180,
125    JSVERSION_ECMA_5  = 185,
126    JSVERSION_DEFAULT = 0,
127    JSVERSION_UNKNOWN = -1,
128    JSVERSION_LATEST  = JSVERSION_ECMA_5
129} JSVersion;
130
131#define JSVERSION_IS_ECMA(version) \
132    ((version) == JSVERSION_DEFAULT || (version) >= JSVERSION_1_3)
133
134/* Result of typeof operator enumeration. */
135typedef enum JSType {
136    JSTYPE_VOID,                /* undefined */
137    JSTYPE_OBJECT,              /* object */
138    JSTYPE_FUNCTION,            /* function */
139    JSTYPE_STRING,              /* string */
140    JSTYPE_NUMBER,              /* number */
141    JSTYPE_BOOLEAN,             /* boolean */
142    JSTYPE_NULL,                /* null */
143    JSTYPE_XML,                 /* xml object */
144    JSTYPE_LIMIT
145} JSType;
146
147/* Dense index into cached prototypes and class atoms for standard objects. */
148typedef enum JSProtoKey {
149#define JS_PROTO(name,code,init) JSProto_##name = code,
150#include "jsproto.tbl"
151#undef JS_PROTO
152    JSProto_LIMIT
153} JSProtoKey;
154
155/* js_CheckAccess mode enumeration. */
156typedef enum JSAccessMode {
157    JSACC_PROTO  = 0,           /* XXXbe redundant w.r.t. id */
158    JSACC_PARENT = 1,           /* XXXbe redundant w.r.t. id */
159
160                                /*
161                                 * enum value #2 formerly called JSACC_IMPORT,
162                                 * gap preserved for ABI compatibility.
163                                 */
164
165    JSACC_WATCH  = 3,           /* a watchpoint on object foo for id 'bar' */
166    JSACC_READ   = 4,           /* a "get" of foo.bar */
167    JSACC_WRITE  = 8,           /* a "set" of foo.bar = baz */
168    JSACC_LIMIT
169} JSAccessMode;
170
171#define JSACC_TYPEMASK          (JSACC_WRITE - 1)
172
173/*
174 * This enum type is used to control the behavior of a JSObject property
175 * iterator function that has type JSNewEnumerate.
176 */
177typedef enum JSIterateOp {
178    /* Create new iterator state over enumerable properties. */
179    JSENUMERATE_INIT,
180
181    /* Create new iterator state over all properties. */
182    JSENUMERATE_INIT_ALL,
183
184    /* Iterate once. */
185    JSENUMERATE_NEXT,
186
187    /* Destroy iterator state. */
188    JSENUMERATE_DESTROY
189} JSIterateOp;
190
191/* See JSVAL_TRACE_KIND and JSTraceCallback in jsapi.h. */
192typedef enum {
193    JSTRACE_OBJECT,
194    JSTRACE_STRING,
195    JSTRACE_SCRIPT,
196
197    /*
198     * Trace kinds internal to the engine. The embedding can only them if it
199     * implements JSTraceCallback.
200     */
201#if JS_HAS_XML_SUPPORT
202    JSTRACE_XML,
203#endif
204    JSTRACE_SHAPE,
205    JSTRACE_BASE_SHAPE,
206    JSTRACE_TYPE_OBJECT,
207    JSTRACE_LAST = JSTRACE_TYPE_OBJECT
208} JSGCTraceKind;
209
210/* Struct typedefs. */
211typedef struct JSClass                      JSClass;
212typedef struct JSCompartment                JSCompartment;
213typedef struct JSConstDoubleSpec            JSConstDoubleSpec;
214typedef struct JSContext                    JSContext;
215typedef struct JSCrossCompartmentCall       JSCrossCompartmentCall;
216typedef struct JSErrorReport                JSErrorReport;
217typedef struct JSExceptionState             JSExceptionState;
218typedef struct JSFunction                   JSFunction;
219typedef struct JSFunctionSpec               JSFunctionSpec;
220typedef struct JSIdArray                    JSIdArray;
221typedef struct JSLocaleCallbacks            JSLocaleCallbacks;
222typedef struct JSObject                     JSObject;
223typedef struct JSObjectMap                  JSObjectMap;
224typedef struct JSPrincipals                 JSPrincipals;
225typedef struct JSPropertyDescriptor         JSPropertyDescriptor;
226typedef struct JSPropertyName               JSPropertyName;
227typedef struct JSPropertySpec               JSPropertySpec;
228typedef struct JSRuntime                    JSRuntime;
229typedef struct JSSecurityCallbacks          JSSecurityCallbacks;
230typedef struct JSStackFrame                 JSStackFrame;
231typedef struct JSScript          JSScript;
232typedef struct JSStructuredCloneCallbacks   JSStructuredCloneCallbacks;
233typedef struct JSStructuredCloneReader      JSStructuredCloneReader;
234typedef struct JSStructuredCloneWriter      JSStructuredCloneWriter;
235typedef struct JSTracer                     JSTracer;
236typedef struct JSXDRState                   JSXDRState;
237
238#ifdef __cplusplus
239class                                       JSFlatString;
240class                                       JSString;
241#else
242typedef struct JSFlatString                 JSFlatString;
243typedef struct JSString                     JSString;
244#endif
245
246#ifdef JS_THREADSAFE
247typedef struct PRCallOnceType    JSCallOnceType;
248#else
249typedef JSBool                   JSCallOnceType;
250#endif
251typedef JSBool                 (*JSInitCallback)(void);
252
253JS_END_EXTERN_C
254
255#endif /* jspubtd_h___ */