PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/jspubtd.h

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
C++ Header | 727 lines | 246 code | 81 blank | 400 comment | 4 complexity | 7fbd325b9feda3d4dd032dacd41c18a7 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  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. JS_BEGIN_EXTERN_C
  47. /* Scalar typedefs. */
  48. typedef uint16 jschar;
  49. typedef int32 jsint;
  50. typedef uint32 jsuint;
  51. typedef float64 jsdouble;
  52. typedef jsword jsval;
  53. typedef jsword jsid;
  54. typedef int32 jsrefcount; /* PRInt32 if JS_THREADSAFE, see jslock.h */
  55. /*
  56. * Run-time version enumeration. See jsversion.h for compile-time counterparts
  57. * to these values that may be selected by the JS_VERSION macro, and tested by
  58. * #if expressions.
  59. */
  60. typedef enum JSVersion {
  61. JSVERSION_1_0 = 100,
  62. JSVERSION_1_1 = 110,
  63. JSVERSION_1_2 = 120,
  64. JSVERSION_1_3 = 130,
  65. JSVERSION_1_4 = 140,
  66. JSVERSION_ECMA_3 = 148,
  67. JSVERSION_1_5 = 150,
  68. JSVERSION_1_6 = 160,
  69. JSVERSION_1_7 = 170,
  70. JSVERSION_1_8 = 180,
  71. JSVERSION_DEFAULT = 0,
  72. JSVERSION_UNKNOWN = -1,
  73. JSVERSION_LATEST = JSVERSION_1_8
  74. } JSVersion;
  75. #define JSVERSION_IS_ECMA(version) \
  76. ((version) == JSVERSION_DEFAULT || (version) >= JSVERSION_1_3)
  77. /* Result of typeof operator enumeration. */
  78. typedef enum JSType {
  79. JSTYPE_VOID, /* undefined */
  80. JSTYPE_OBJECT, /* object */
  81. JSTYPE_FUNCTION, /* function */
  82. JSTYPE_STRING, /* string */
  83. JSTYPE_NUMBER, /* number */
  84. JSTYPE_BOOLEAN, /* boolean */
  85. JSTYPE_NULL, /* null */
  86. JSTYPE_XML, /* xml object */
  87. JSTYPE_LIMIT
  88. } JSType;
  89. /* Dense index into cached prototypes and class atoms for standard objects. */
  90. typedef enum JSProtoKey {
  91. #define JS_PROTO(name,code,init) JSProto_##name = code,
  92. #include "jsproto.tbl"
  93. #undef JS_PROTO
  94. JSProto_LIMIT
  95. } JSProtoKey;
  96. /* JSObjectOps.checkAccess mode enumeration. */
  97. typedef enum JSAccessMode {
  98. JSACC_PROTO = 0, /* XXXbe redundant w.r.t. id */
  99. JSACC_PARENT = 1, /* XXXbe redundant w.r.t. id */
  100. /*
  101. * enum value #2 formerly called JSACC_IMPORT,
  102. * gap preserved for liveconnect ABI compatibility.
  103. */
  104. JSACC_WATCH = 3, /* a watchpoint on object foo for id 'bar' */
  105. JSACC_READ = 4, /* a "get" of foo.bar */
  106. JSACC_WRITE = 8, /* a "set" of foo.bar = baz */
  107. JSACC_LIMIT
  108. } JSAccessMode;
  109. #define JSACC_TYPEMASK (JSACC_WRITE - 1)
  110. /*
  111. * This enum type is used to control the behavior of a JSObject property
  112. * iterator function that has type JSNewEnumerate.
  113. */
  114. typedef enum JSIterateOp {
  115. JSENUMERATE_INIT, /* Create new iterator state */
  116. JSENUMERATE_NEXT, /* Iterate once */
  117. JSENUMERATE_DESTROY /* Destroy iterator state */
  118. } JSIterateOp;
  119. /* Struct typedefs. */
  120. typedef struct JSClass JSClass;
  121. typedef struct JSExtendedClass JSExtendedClass;
  122. typedef struct JSConstDoubleSpec JSConstDoubleSpec;
  123. typedef struct JSContext JSContext;
  124. typedef struct JSErrorReport JSErrorReport;
  125. typedef struct JSFunction JSFunction;
  126. typedef struct JSFunctionSpec JSFunctionSpec;
  127. typedef struct JSTracer JSTracer;
  128. typedef struct JSIdArray JSIdArray;
  129. typedef struct JSProperty JSProperty;
  130. typedef struct JSPropertySpec JSPropertySpec;
  131. typedef struct JSObject JSObject;
  132. typedef struct JSObjectMap JSObjectMap;
  133. typedef struct JSObjectOps JSObjectOps;
  134. typedef struct JSXMLObjectOps JSXMLObjectOps;
  135. typedef struct JSRuntime JSRuntime;
  136. typedef struct JSRuntime JSTaskState; /* XXX deprecated name */
  137. typedef struct JSScript JSScript;
  138. typedef struct JSStackFrame JSStackFrame;
  139. typedef struct JSString JSString;
  140. typedef struct JSXDRState JSXDRState;
  141. typedef struct JSExceptionState JSExceptionState;
  142. typedef struct JSLocaleCallbacks JSLocaleCallbacks;
  143. typedef struct JSSecurityCallbacks JSSecurityCallbacks;
  144. typedef struct JSONParser JSONParser;
  145. /* JSClass (and JSObjectOps where appropriate) function pointer typedefs. */
  146. /*
  147. * Add, delete, get or set a property named by id in obj. Note the jsval id
  148. * type -- id may be a string (Unicode property identifier) or an int (element
  149. * index). The *vp out parameter, on success, is the new property value after
  150. * an add, get, or set. After a successful delete, *vp is JSVAL_FALSE iff
  151. * obj[id] can't be deleted (because it's permanent).
  152. */
  153. typedef JSBool
  154. (* JSPropertyOp)(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
  155. /*
  156. * This function type is used for callbacks that enumerate the properties of
  157. * a JSObject. The behavior depends on the value of enum_op:
  158. *
  159. * JSENUMERATE_INIT
  160. * A new, opaque iterator state should be allocated and stored in *statep.
  161. * (You can use PRIVATE_TO_JSVAL() to tag the pointer to be stored).
  162. *
  163. * The number of properties that will be enumerated should be returned as
  164. * an integer jsval in *idp, if idp is non-null, and provided the number of
  165. * enumerable properties is known. If idp is non-null and the number of
  166. * enumerable properties can't be computed in advance, *idp should be set
  167. * to JSVAL_ZERO.
  168. *
  169. * JSENUMERATE_NEXT
  170. * A previously allocated opaque iterator state is passed in via statep.
  171. * Return the next jsid in the iteration using *idp. The opaque iterator
  172. * state pointed at by statep is destroyed and *statep is set to JSVAL_NULL
  173. * if there are no properties left to enumerate.
  174. *
  175. * JSENUMERATE_DESTROY
  176. * Destroy the opaque iterator state previously allocated in *statep by a
  177. * call to this function when enum_op was JSENUMERATE_INIT.
  178. *
  179. * The return value is used to indicate success, with a value of JS_FALSE
  180. * indicating failure.
  181. */
  182. typedef JSBool
  183. (* JSNewEnumerateOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
  184. jsval *statep, jsid *idp);
  185. /*
  186. * The old-style JSClass.enumerate op should define all lazy properties not
  187. * yet reflected in obj.
  188. */
  189. typedef JSBool
  190. (* JSEnumerateOp)(JSContext *cx, JSObject *obj);
  191. /*
  192. * Resolve a lazy property named by id in obj by defining it directly in obj.
  193. * Lazy properties are those reflected from some peer native property space
  194. * (e.g., the DOM attributes for a given node reflected as obj) on demand.
  195. *
  196. * JS looks for a property in an object, and if not found, tries to resolve
  197. * the given id. If resolve succeeds, the engine looks again in case resolve
  198. * defined obj[id]. If no such property exists directly in obj, the process
  199. * is repeated with obj's prototype, etc.
  200. *
  201. * NB: JSNewResolveOp provides a cheaper way to resolve lazy properties.
  202. */
  203. typedef JSBool
  204. (* JSResolveOp)(JSContext *cx, JSObject *obj, jsval id);
  205. /*
  206. * Like JSResolveOp, but flags provide contextual information as follows:
  207. *
  208. * JSRESOLVE_QUALIFIED a qualified property id: obj.id or obj[id], not id
  209. * JSRESOLVE_ASSIGNING obj[id] is on the left-hand side of an assignment
  210. * JSRESOLVE_DETECTING 'if (o.p)...' or similar detection opcode sequence
  211. * JSRESOLVE_DECLARING var, const, or function prolog declaration opcode
  212. * JSRESOLVE_CLASSNAME class name used when constructing
  213. *
  214. * The *objp out parameter, on success, should be null to indicate that id
  215. * was not resolved; and non-null, referring to obj or one of its prototypes,
  216. * if id was resolved.
  217. *
  218. * This hook instead of JSResolveOp is called via the JSClass.resolve member
  219. * if JSCLASS_NEW_RESOLVE is set in JSClass.flags.
  220. *
  221. * Setting JSCLASS_NEW_RESOLVE and JSCLASS_NEW_RESOLVE_GETS_START further
  222. * extends this hook by passing in the starting object on the prototype chain
  223. * via *objp. Thus a resolve hook implementation may define the property id
  224. * being resolved in the object in which the id was first sought, rather than
  225. * in a prototype object whose class led to the resolve hook being called.
  226. *
  227. * When using JSCLASS_NEW_RESOLVE_GETS_START, the resolve hook must therefore
  228. * null *objp to signify "not resolved". With only JSCLASS_NEW_RESOLVE and no
  229. * JSCLASS_NEW_RESOLVE_GETS_START, the hook can assume *objp is null on entry.
  230. * This is not good practice, but enough existing hook implementations count
  231. * on it that we can't break compatibility by passing the starting object in
  232. * *objp without a new JSClass flag.
  233. */
  234. typedef JSBool
  235. (* JSNewResolveOp)(JSContext *cx, JSObject *obj, jsval id, uintN flags,
  236. JSObject **objp);
  237. /*
  238. * Convert obj to the given type, returning true with the resulting value in
  239. * *vp on success, and returning false on error or exception.
  240. */
  241. typedef JSBool
  242. (* JSConvertOp)(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
  243. /*
  244. * Finalize obj, which the garbage collector has determined to be unreachable
  245. * from other live objects or from GC roots. Obviously, finalizers must never
  246. * store a reference to obj.
  247. */
  248. typedef void
  249. (* JSFinalizeOp)(JSContext *cx, JSObject *obj);
  250. /*
  251. * Used by JS_AddExternalStringFinalizer and JS_RemoveExternalStringFinalizer
  252. * to extend and reduce the set of string types finalized by the GC.
  253. */
  254. typedef void
  255. (* JSStringFinalizeOp)(JSContext *cx, JSString *str);
  256. /*
  257. * The signature for JSClass.getObjectOps, used by JS_NewObject's internals
  258. * to discover the set of high-level object operations to use for new objects
  259. * of the given class. All native objects have a JSClass, which is stored as
  260. * a private (int-tagged) pointer in obj slots. In contrast, all native and
  261. * host objects have a JSObjectMap at obj->map, which may be shared among a
  262. * number of objects, and which contains the JSObjectOps *ops pointer used to
  263. * dispatch object operations from API calls.
  264. *
  265. * Thus JSClass (which pre-dates JSObjectOps in the API) provides a low-level
  266. * interface to class-specific code and data, while JSObjectOps allows for a
  267. * higher level of operation, which does not use the object's class except to
  268. * find the class's JSObjectOps struct, by calling clasp->getObjectOps, and to
  269. * finalize the object.
  270. *
  271. * If this seems backwards, that's because it is! API compatibility requires
  272. * a JSClass *clasp parameter to JS_NewObject, etc. Most host objects do not
  273. * need to implement the larger JSObjectOps, and can share the common JSScope
  274. * code and data used by the native (js_ObjectOps, see jsobj.c) ops.
  275. *
  276. * Further extension to preserve API compatibility: if this function returns
  277. * a pointer to JSXMLObjectOps.base, not to JSObjectOps, then the engine calls
  278. * extended hooks needed for E4X.
  279. */
  280. typedef JSObjectOps *
  281. (* JSGetObjectOps)(JSContext *cx, JSClass *clasp);
  282. /*
  283. * JSClass.checkAccess type: check whether obj[id] may be accessed per mode,
  284. * returning false on error/exception, true on success with obj[id]'s last-got
  285. * value in *vp, and its attributes in *attrsp. As for JSPropertyOp above, id
  286. * is either a string or an int jsval.
  287. *
  288. * See JSCheckAccessIdOp, below, for the JSObjectOps counterpart, which takes
  289. * a jsid (a tagged int or aligned, unique identifier pointer) rather than a
  290. * jsval. The native js_ObjectOps.checkAccess simply forwards to the object's
  291. * clasp->checkAccess, so that both JSClass and JSObjectOps implementors may
  292. * specialize access checks.
  293. */
  294. typedef JSBool
  295. (* JSCheckAccessOp)(JSContext *cx, JSObject *obj, jsval id, JSAccessMode mode,
  296. jsval *vp);
  297. /*
  298. * Encode or decode an object, given an XDR state record representing external
  299. * data. See jsxdrapi.h.
  300. */
  301. typedef JSBool
  302. (* JSXDRObjectOp)(JSXDRState *xdr, JSObject **objp);
  303. /*
  304. * Check whether v is an instance of obj. Return false on error or exception,
  305. * true on success with JS_TRUE in *bp if v is an instance of obj, JS_FALSE in
  306. * *bp otherwise.
  307. */
  308. typedef JSBool
  309. (* JSHasInstanceOp)(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
  310. /*
  311. * Deprecated function type for JSClass.mark. All new code should define
  312. * JSTraceOp instead to ensure the traversal of traceable things stored in
  313. * the native structures.
  314. */
  315. typedef uint32
  316. (* JSMarkOp)(JSContext *cx, JSObject *obj, void *arg);
  317. /*
  318. * Function type for trace operation of the class called to enumerate all
  319. * traceable things reachable from obj's private data structure. For each such
  320. * thing, a trace implementation must call
  321. *
  322. * JS_CallTracer(trc, thing, kind);
  323. *
  324. * or one of its convenience macros as described in jsapi.h.
  325. *
  326. * JSTraceOp implementation can assume that no other threads mutates object
  327. * state. It must not change state of the object or corresponding native
  328. * structures. The only exception for this rule is the case when the embedding
  329. * needs a tight integration with GC. In that case the embedding can check if
  330. * the traversal is a part of the marking phase through calling
  331. * JS_IsGCMarkingTracer and apply a special code like emptying caches or
  332. * marking its native structures.
  333. *
  334. * To define the tracer for a JSClass, the implementation must add
  335. * JSCLASS_MARK_IS_TRACE to class flags and use JS_CLASS_TRACE(method)
  336. * macro below to convert JSTraceOp to JSMarkOp when initializing or
  337. * assigning JSClass.mark field.
  338. */
  339. typedef void
  340. (* JSTraceOp)(JSTracer *trc, JSObject *obj);
  341. #if defined __GNUC__ && __GNUC__ >= 4 && !defined __cplusplus
  342. # define JS_CLASS_TRACE(method) \
  343. (__builtin_types_compatible_p(JSTraceOp, __typeof(&(method))) \
  344. ? (JSMarkOp)(method) \
  345. : js_WrongTypeForClassTracer)
  346. extern JSMarkOp js_WrongTypeForClassTracer;
  347. #else
  348. # define JS_CLASS_TRACE(method) ((JSMarkOp)(method))
  349. #endif
  350. /*
  351. * Tracer callback, called for each traceable thing directly refrenced by a
  352. * particular object or runtime structure. It is the callback responsibility
  353. * to ensure the traversal of the full object graph via calling eventually
  354. * JS_TraceChildren on the passed thing. In this case the callback must be
  355. * prepared to deal with cycles in the traversal graph.
  356. *
  357. * kind argument is one of JSTRACE_OBJECT, JSTRACE_DOUBLE, JSTRACE_STRING or
  358. * a tag denoting internal implementation-specific traversal kind. In the
  359. * latter case the only operations on thing that the callback can do is to call
  360. * JS_TraceChildren or DEBUG-only JS_PrintTraceThingInfo.
  361. */
  362. typedef void
  363. (* JSTraceCallback)(JSTracer *trc, void *thing, uint32 kind);
  364. /*
  365. * DEBUG only callback that JSTraceOp implementation can provide to return
  366. * a string describing the reference traced with JS_CallTracer.
  367. */
  368. #ifdef DEBUG
  369. typedef void
  370. (* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize);
  371. #endif
  372. /*
  373. * The optional JSClass.reserveSlots hook allows a class to make computed
  374. * per-instance object slots reservations, in addition to or instead of using
  375. * JSCLASS_HAS_RESERVED_SLOTS(n) in the JSClass.flags initializer to reserve
  376. * a constant-per-class number of slots. Implementations of this hook should
  377. * return the number of slots to reserve, not including any reserved by using
  378. * JSCLASS_HAS_RESERVED_SLOTS(n) in JSClass.flags.
  379. *
  380. * NB: called with obj locked by the JSObjectOps-specific mutual exclusion
  381. * mechanism appropriate for obj, so don't nest other operations that might
  382. * also lock obj.
  383. */
  384. typedef uint32
  385. (* JSReserveSlotsOp)(JSContext *cx, JSObject *obj);
  386. /* JSObjectOps function pointer typedefs. */
  387. /*
  388. * Create a new subclass of JSObjectMap (see jsobj.h), with the nrefs and ops
  389. * members initialized from the same-named parameters, and with the nslots and
  390. * freeslot members initialized according to ops and clasp. Return null on
  391. * error, non-null on success.
  392. *
  393. * JSObjectMaps are reference-counted by generic code in the engine. Usually,
  394. * the nrefs parameter to JSObjectOps.newObjectMap will be 1, to count the ref
  395. * returned to the caller on success. After a successful construction, some
  396. * number of js_HoldObjectMap and js_DropObjectMap calls ensue. When nrefs
  397. * reaches 0 due to a js_DropObjectMap call, JSObjectOps.destroyObjectMap will
  398. * be called to dispose of the map.
  399. */
  400. typedef JSObjectMap *
  401. (* JSNewObjectMapOp)(JSContext *cx, jsrefcount nrefs, JSObjectOps *ops,
  402. JSClass *clasp, JSObject *obj);
  403. /*
  404. * Generic type for an infallible JSObjectMap operation, used currently by
  405. * JSObjectOps.destroyObjectMap.
  406. */
  407. typedef void
  408. (* JSObjectMapOp)(JSContext *cx, JSObjectMap *map);
  409. /*
  410. * Look for id in obj and its prototype chain, returning false on error or
  411. * exception, true on success. On success, return null in *propp if id was
  412. * not found. If id was found, return the first object searching from obj
  413. * along its prototype chain in which id names a direct property in *objp, and
  414. * return a non-null, opaque property pointer in *propp.
  415. *
  416. * If JSLookupPropOp succeeds and returns with *propp non-null, that pointer
  417. * may be passed as the prop parameter to a JSAttributesOp, as a short-cut
  418. * that bypasses id re-lookup. In any case, a non-null *propp result after a
  419. * successful lookup must be dropped via JSObjectOps.dropProperty.
  420. *
  421. * NB: successful return with non-null *propp means the implementation may
  422. * have locked *objp and added a reference count associated with *propp, so
  423. * callers should not risk deadlock by nesting or interleaving other lookups
  424. * or any obj-bearing ops before dropping *propp.
  425. */
  426. typedef JSBool
  427. (* JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
  428. JSProperty **propp);
  429. /*
  430. * Define obj[id], a direct property of obj named id, having the given initial
  431. * value, with the specified getter, setter, and attributes. If the propp out
  432. * param is non-null, *propp on successful return contains an opaque property
  433. * pointer usable as a speedup hint with JSAttributesOp. But note that propp
  434. * may be null, indicating that the caller is not interested in recovering an
  435. * opaque pointer to the newly-defined property.
  436. *
  437. * If propp is non-null and JSDefinePropOp succeeds, its caller must be sure
  438. * to drop *propp using JSObjectOps.dropProperty in short order, just as with
  439. * JSLookupPropOp.
  440. */
  441. typedef JSBool
  442. (* JSDefinePropOp)(JSContext *cx, JSObject *obj, jsid id, jsval value,
  443. JSPropertyOp getter, JSPropertyOp setter, uintN attrs,
  444. JSProperty **propp);
  445. /*
  446. * Get, set, or delete obj[id], returning false on error or exception, true
  447. * on success. If getting or setting, the new value is returned in *vp on
  448. * success. If deleting without error, *vp will be JSVAL_FALSE if obj[id] is
  449. * permanent, and JSVAL_TRUE if id named a direct property of obj that was in
  450. * fact deleted, or if id names no direct property of obj (id could name a
  451. * prototype property, or no property in obj or its prototype chain).
  452. */
  453. typedef JSBool
  454. (* JSPropertyIdOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
  455. /*
  456. * Get or set attributes of the property obj[id]. Return false on error or
  457. * exception, true with current attributes in *attrsp. If prop is non-null,
  458. * it must come from the *propp out parameter of a prior JSDefinePropOp or
  459. * JSLookupPropOp call.
  460. */
  461. typedef JSBool
  462. (* JSAttributesOp)(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
  463. uintN *attrsp);
  464. /*
  465. * JSObjectOps.checkAccess type: check whether obj[id] may be accessed per
  466. * mode, returning false on error/exception, true on success with obj[id]'s
  467. * last-got value in *vp, and its attributes in *attrsp.
  468. */
  469. typedef JSBool
  470. (* JSCheckAccessIdOp)(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
  471. jsval *vp, uintN *attrsp);
  472. /*
  473. * A generic type for functions mapping an object to another object, or null
  474. * if an error or exception was thrown on cx. Used by JSObjectOps.thisObject
  475. * at present.
  476. */
  477. typedef JSObject *
  478. (* JSObjectOp)(JSContext *cx, JSObject *obj);
  479. /*
  480. * Hook that creates an iterator object for a given object. Returns the
  481. * iterator object or null if an error or exception was thrown on cx.
  482. */
  483. typedef JSObject *
  484. (* JSIteratorOp)(JSContext *cx, JSObject *obj, JSBool keysonly);
  485. /*
  486. * A generic type for functions taking a context, object, and property, with
  487. * no return value. Used by JSObjectOps.dropProperty currently (see above,
  488. * JSDefinePropOp and JSLookupPropOp, for the object-locking protocol in which
  489. * dropProperty participates).
  490. */
  491. typedef void
  492. (* JSPropertyRefOp)(JSContext *cx, JSObject *obj, JSProperty *prop);
  493. /*
  494. * Function pointer type for JSObjectOps.setProto and JSObjectOps.setParent.
  495. * These hooks must check for cycles without deadlocking, and otherwise take
  496. * special steps. See jsobj.c and jsgc.c for details.
  497. */
  498. typedef JSBool
  499. (* JSSetObjectSlotOp)(JSContext *cx, JSObject *obj, uint32 slot,
  500. JSObject *pobj);
  501. /*
  502. * Get and set a required slot, one that should already have been allocated.
  503. * These operations are infallible, so required slots must be pre-allocated,
  504. * or implementations must suppress out-of-memory errors. The native ops
  505. * (js_ObjectOps, see jsobj.c) access slots reserved by including a call to
  506. * the JSCLASS_HAS_RESERVED_SLOTS(n) macro in the JSClass.flags initializer.
  507. *
  508. * NB: the slot parameter is a zero-based index into obj slots, unlike the
  509. * index parameter to the JS_GetReservedSlot and JS_SetReservedSlot API entry
  510. * points, which is a zero-based index into the JSCLASS_RESERVED_SLOTS(clasp)
  511. * reserved slots that come after the initial well-known slots: proto, parent,
  512. * class, and optionally, the private data slot.
  513. */
  514. typedef jsval
  515. (* JSGetRequiredSlotOp)(JSContext *cx, JSObject *obj, uint32 slot);
  516. typedef JSBool
  517. (* JSSetRequiredSlotOp)(JSContext *cx, JSObject *obj, uint32 slot, jsval v);
  518. typedef JSObject *
  519. (* JSGetMethodOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
  520. typedef JSBool
  521. (* JSSetMethodOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
  522. typedef JSBool
  523. (* JSEnumerateValuesOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
  524. jsval *statep, jsid *idp, jsval *vp);
  525. typedef JSBool
  526. (* JSEqualityOp)(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
  527. typedef JSBool
  528. (* JSConcatenateOp)(JSContext *cx, JSObject *obj, jsval v, jsval *vp);
  529. /* Typedef for native functions called by the JS VM. */
  530. typedef JSBool
  531. (* JSNative)(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
  532. jsval *rval);
  533. /* See jsapi.h, the JS_CALLEE, JS_THIS, etc. macros. */
  534. typedef JSBool
  535. (* JSFastNative)(JSContext *cx, uintN argc, jsval *vp);
  536. /* Callbacks and their arguments. */
  537. typedef enum JSContextOp {
  538. JSCONTEXT_NEW,
  539. JSCONTEXT_DESTROY
  540. } JSContextOp;
  541. /*
  542. * The possible values for contextOp when the runtime calls the callback are:
  543. * JSCONTEXT_NEW JS_NewContext successfully created a new JSContext
  544. * instance. The callback can initialize the instance as
  545. * required. If the callback returns false, the instance
  546. * will be destroyed and JS_NewContext returns null. In
  547. * this case the callback is not called again.
  548. * JSCONTEXT_DESTROY One of JS_DestroyContext* methods is called. The
  549. * callback may perform its own cleanup and must always
  550. * return true.
  551. * Any other value For future compatibility the callback must do nothing
  552. * and return true in this case.
  553. */
  554. typedef JSBool
  555. (* JSContextCallback)(JSContext *cx, uintN contextOp);
  556. typedef enum JSGCStatus {
  557. JSGC_BEGIN,
  558. JSGC_END,
  559. JSGC_MARK_END,
  560. JSGC_FINALIZE_END
  561. } JSGCStatus;
  562. typedef JSBool
  563. (* JSGCCallback)(JSContext *cx, JSGCStatus status);
  564. /*
  565. * Generic trace operation that calls JS_CallTracer on each traceable thing
  566. * stored in data.
  567. */
  568. typedef void
  569. (* JSTraceDataOp)(JSTracer *trc, void *data);
  570. typedef JSBool
  571. (* JSOperationCallback)(JSContext *cx);
  572. /*
  573. * Deprecated form of JSOperationCallback.
  574. */
  575. typedef JSBool
  576. (* JSBranchCallback)(JSContext *cx, JSScript *script);
  577. typedef void
  578. (* JSErrorReporter)(JSContext *cx, const char *message, JSErrorReport *report);
  579. /*
  580. * Possible exception types. These types are part of a JSErrorFormatString
  581. * structure. They define which error to throw in case of a runtime error.
  582. * JSEXN_NONE marks an unthrowable error.
  583. */
  584. typedef enum JSExnType {
  585. JSEXN_NONE = -1,
  586. JSEXN_ERR,
  587. JSEXN_INTERNALERR,
  588. JSEXN_EVALERR,
  589. JSEXN_RANGEERR,
  590. JSEXN_REFERENCEERR,
  591. JSEXN_SYNTAXERR,
  592. JSEXN_TYPEERR,
  593. JSEXN_URIERR,
  594. JSEXN_LIMIT
  595. } JSExnType;
  596. typedef struct JSErrorFormatString {
  597. /* The error format string (UTF-8 if js_CStringsAreUTF8). */
  598. const char *format;
  599. /* The number of arguments to expand in the formatted error message. */
  600. uint16 argCount;
  601. /* One of the JSExnType constants above. */
  602. int16 exnType;
  603. } JSErrorFormatString;
  604. typedef const JSErrorFormatString *
  605. (* JSErrorCallback)(void *userRef, const char *locale,
  606. const uintN errorNumber);
  607. #ifdef va_start
  608. #define JS_ARGUMENT_FORMATTER_DEFINED 1
  609. typedef JSBool
  610. (* JSArgumentFormatter)(JSContext *cx, const char *format, JSBool fromJS,
  611. jsval **vpp, va_list *app);
  612. #endif
  613. typedef JSBool
  614. (* JSLocaleToUpperCase)(JSContext *cx, JSString *src, jsval *rval);
  615. typedef JSBool
  616. (* JSLocaleToLowerCase)(JSContext *cx, JSString *src, jsval *rval);
  617. typedef JSBool
  618. (* JSLocaleCompare)(JSContext *cx, JSString *src1, JSString *src2,
  619. jsval *rval);
  620. typedef JSBool
  621. (* JSLocaleToUnicode)(JSContext *cx, char *src, jsval *rval);
  622. /*
  623. * Security protocol types.
  624. */
  625. typedef struct JSPrincipals JSPrincipals;
  626. /*
  627. * XDR-encode or -decode a principals instance, based on whether xdr->mode is
  628. * JSXDR_ENCODE, in which case *principalsp should be encoded; or JSXDR_DECODE,
  629. * in which case implementations must return a held (via JSPRINCIPALS_HOLD),
  630. * non-null *principalsp out parameter. Return true on success, false on any
  631. * error, which the implementation must have reported.
  632. */
  633. typedef JSBool
  634. (* JSPrincipalsTranscoder)(JSXDRState *xdr, JSPrincipals **principalsp);
  635. /*
  636. * Return a weak reference to the principals associated with obj, possibly via
  637. * the immutable parent chain leading from obj to a top-level container (e.g.,
  638. * a window object in the DOM level 0). If there are no principals associated
  639. * with obj, return null. Therefore null does not mean an error was reported;
  640. * in no event should an error be reported or an exception be thrown by this
  641. * callback's implementation.
  642. */
  643. typedef JSPrincipals *
  644. (* JSObjectPrincipalsFinder)(JSContext *cx, JSObject *obj);
  645. JS_END_EXTERN_C
  646. #endif /* jspubtd_h___ */