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