1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 2 * vim: set ts=8 sw=4 et tw=80: 3 * 4 * ***** BEGIN LICENSE BLOCK ***** 5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 6 * 7 * The contents of this file are subject to the Mozilla Public License Version 8 * 1.1 (the "License"); you may not use this file except in compliance with 9 * the License. You may obtain a copy of the License at 10 * http://www.mozilla.org/MPL/ 11 * 12 * Software distributed under the License is distributed on an "AS IS" basis, 13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 14 * for the specific language governing rights and limitations under the 15 * License. 16 * 17 * The Original Code is Mozilla Communicator client code, released 18 * March 31, 1998. 19 * 20 * The Initial Developer of the Original Code is 21 * Netscape Communications Corporation. 22 * Portions created by the Initial Developer are Copyright (C) 1998 23 * the Initial Developer. All Rights Reserved. 24 * 25 * Contributor(s): 26 * 27 * Alternatively, the contents of this file may be used under the terms of 28 * either of the GNU General Public License Version 2 or later (the "GPL"), 29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 30 * in which case the provisions of the GPL or the LGPL are applicable instead 31 * of those above. If you wish to allow use of your version of this file only 32 * under the terms of either the GPL or the LGPL, and not to allow others to 33 * use your version of this file under the terms of the MPL, indicate your 34 * decision by deleting the provisions above and replace them with the notice 35 * and other provisions required by the GPL or the LGPL. If you do not delete 36 * the provisions above, a recipient may use your version of this file under 37 * the terms of any one of the MPL, the GPL or the LGPL. 38 * 39 * ***** END LICENSE BLOCK ***** */ 40 41 #ifndef jsobj_h___ 42 #define jsobj_h___ 43 /* 44 * JS object definitions. 45 * 46 * A JS object consists of a possibly-shared object descriptor containing 47 * ordered property names, called the map; and a dense vector of property 48 * values, called slots. The map/slot pointer pair is GC'ed, while the map 49 * is reference counted and the slot vector is malloc'ed. 50 */ 51 #include "jshash.h" /* Added by JSIFY */ 52 #include "jsprvtd.h" 53 #include "jspubtd.h" 54 55 JS_BEGIN_EXTERN_C 56 57 struct JSObjectMap { 58 jsrefcount nrefs; /* count of all referencing objects */ 59 JSObjectOps *ops; /* high level object operation vtable */ 60 uint32 nslots; /* length of obj->slots vector */ 61 uint32 freeslot; /* index of next free obj->slots element */ 62 }; 63 64 /* Shorthand macros for frequently-made calls. */ 65 #define OBJ_LOOKUP_PROPERTY(cx,obj,id,objp,propp) \ 66 (obj)->map->ops->lookupProperty(cx,obj,id,objp,propp) 67 #define OBJ_DEFINE_PROPERTY(cx,obj,id,value,getter,setter,attrs,propp) \ 68 (obj)->map->ops->defineProperty(cx,obj,id,value,getter,setter,attrs,propp) 69 #define OBJ_GET_PROPERTY(cx,obj,id,vp) \ 70 (obj)->map->ops->getProperty(cx,obj,id,vp) 71 #define OBJ_SET_PROPERTY(cx,obj,id,vp) \ 72 (obj)->map->ops->setProperty(cx,obj,id,vp) 73 #define OBJ_GET_ATTRIBUTES(cx,obj,id,prop,attrsp) \ 74 (obj)->map->ops->getAttributes(cx,obj,id,prop,attrsp) 75 #define OBJ_SET_ATTRIBUTES(cx,obj,id,prop,attrsp) \ 76 (obj)->map->ops->setAttributes(cx,obj,id,prop,attrsp) 77 #define OBJ_DELETE_PROPERTY(cx,obj,id,rval) \ 78 (obj)->map->ops->deleteProperty(cx,obj,id,rval) 79 #define OBJ_DEFAULT_VALUE(cx,obj,hint,vp) \ 80 (obj)->map->ops->defaultValue(cx,obj,hint,vp) 81 #define OBJ_ENUMERATE(cx,obj,enum_op,statep,idp) \ 82 (obj)->map->ops->enumerate(cx,obj,enum_op,statep,idp) 83 #define OBJ_CHECK_ACCESS(cx,obj,id,mode,vp,attrsp) \ 84 (obj)->map->ops->checkAccess(cx,obj,id,mode,vp,attrsp) 85 86 /* These four are time-optimized to avoid stub calls. */ 87 #define OBJ_THIS_OBJECT(cx,obj) \ 88 ((obj)->map->ops->thisObject \ 89 ? (obj)->map->ops->thisObject(cx,obj) \ 90 : (obj)) 91 #define OBJ_DROP_PROPERTY(cx,obj,prop) \ 92 ((obj)->map->ops->dropProperty \ 93 ? (obj)->map->ops->dropProperty(cx,obj,prop) \ 94 : (void)0) 95 #define OBJ_GET_REQUIRED_SLOT(cx,obj,slot) \ 96 ((obj)->map->ops->getRequiredSlot \ 97 ? (obj)->map->ops->getRequiredSlot(cx, obj, slot) \ 98 : JSVAL_VOID) 99 #define OBJ_SET_REQUIRED_SLOT(cx,obj,slot,v) \ 100 ((obj)->map->ops->setRequiredSlot \ 101 ? (obj)->map->ops->setRequiredSlot(cx, obj, slot, v) \ 102 : JS_TRUE) 103 104 #define OBJ_TO_INNER_OBJECT(cx,obj) \ 105 JS_BEGIN_MACRO \ 106 JSClass *clasp_ = OBJ_GET_CLASS(cx, obj); \ 107 if (clasp_->flags & JSCLASS_IS_EXTENDED) { \ 108 JSExtendedClass *xclasp_ = (JSExtendedClass*)clasp_; \ 109 if (xclasp_->innerObject) \ 110 obj = xclasp_->innerObject(cx, obj); \ 111 } \ 112 JS_END_MACRO 113 114 /* 115 * In the original JS engine design, obj->slots pointed to a vector of length 116 * JS_INITIAL_NSLOTS words if obj->map was shared with a prototype object, 117 * else of length obj->map->nslots. With the advent of JS_GetReservedSlot, 118 * JS_SetReservedSlot, and JSCLASS_HAS_RESERVED_SLOTS (see jsapi.h), the size 119 * of the minimum length slots vector in the case where map is shared cannot 120 * be constant. This length starts at JS_INITIAL_NSLOTS, but may advance to 121 * include all the reserved slots. 122 * 123 * Therefore slots must be self-describing. Rather than tag its low order bit 124 * (a bit is all we need) to distinguish initial length from reserved length, 125 * we do "the BSTR thing": over-allocate slots by one jsval, and store the 126 * *net* length (counting usable slots, which have non-negative obj->slots[] 127 * indices) in obj->slots[-1]. All code that sets obj->slots must be aware of 128 * this hack -- you have been warned, and jsobj.c has been updated! 129 */ 130 struct JSObject { 131 JSObjectMap *map; 132 jsval *slots; 133 }; 134 135 #define JSSLOT_PROTO 0 136 #define JSSLOT_PARENT 1 137 #define JSSLOT_CLASS 2 138 #define JSSLOT_PRIVATE 3 139 #define JSSLOT_START(clasp) (((clasp)->flags & JSCLASS_HAS_PRIVATE) \ 140 ? JSSLOT_PRIVATE + 1 \ 141 : JSSLOT_CLASS + 1) 142 143 #define JSSLOT_FREE(clasp) (JSSLOT_START(clasp) \ 144 + JSCLASS_RESERVED_SLOTS(clasp)) 145 146 #define JS_INITIAL_NSLOTS 5 147 148 #ifdef DEBUG 149 #define MAP_CHECK_SLOT(map,slot) \ 150 JS_ASSERT((uint32)slot < JS_MIN((map)->freeslot, (map)->nslots)) 151 #define OBJ_CHECK_SLOT(obj,slot) \ 152 MAP_CHECK_SLOT((obj)->map, slot) 153 #else 154 #define OBJ_CHECK_SLOT(obj,slot) ((void)0) 155 #endif 156 157 /* Fast macros for accessing obj->slots while obj is locked (if thread-safe). */ 158 #define LOCKED_OBJ_GET_SLOT(obj,slot) \ 159 (OBJ_CHECK_SLOT(obj, slot), (obj)->slots[slot]) 160 #define LOCKED_OBJ_SET_SLOT(obj,slot,value) \ 161 (OBJ_CHECK_SLOT(obj, slot), (obj)->slots[slot] = (value)) 162 #define LOCKED_OBJ_GET_PROTO(obj) \ 163 JSVAL_TO_OBJECT(LOCKED_OBJ_GET_SLOT(obj, JSSLOT_PROTO)) 164 #define LOCKED_OBJ_GET_CLASS(obj) \ 165 ((JSClass *)JSVAL_TO_PRIVATE(LOCKED_OBJ_GET_SLOT(obj, JSSLOT_CLASS))) 166 167 #ifdef JS_THREADSAFE 168 169 /* Thread-safe functions and wrapper macros for accessing obj->slots. */ 170 #define OBJ_GET_SLOT(cx,obj,slot) \ 171 (OBJ_CHECK_SLOT(obj, slot), \ 172 (OBJ_IS_NATIVE(obj) && OBJ_SCOPE(obj)->ownercx == cx) \ 173 ? LOCKED_OBJ_GET_SLOT(obj, slot) \ 174 : js_GetSlotThreadSafe(cx, obj, slot)) 175 176 #define OBJ_SET_SLOT(cx,obj,slot,value) \ 177 (OBJ_CHECK_SLOT(obj, slot), \ 178 (OBJ_IS_NATIVE(obj) && OBJ_SCOPE(obj)->ownercx == cx) \ 179 ? (void) LOCKED_OBJ_SET_SLOT(obj, slot, value) \ 180 : js_SetSlotThreadSafe(cx, obj, slot, value)) 181 182 /* 183 * If thread-safe, define an OBJ_GET_SLOT wrapper that bypasses, for a native 184 * object, the lock-free "fast path" test of (OBJ_SCOPE(obj)->ownercx == cx), 185 * to avoid needlessly switching from lock-free to lock-full scope when doing 186 * GC on a different context from the last one to own the scope. The caller 187 * in this case is probably a JSClass.mark function, e.g., fun_mark, or maybe 188 * a finalizer. 189 * 190 * The GC runs only when all threads except the one on which the GC is active 191 * are suspended at GC-safe points, so there is no hazard in directly accessing 192 * obj->slots[slot] from the GC's thread, once rt->gcRunning has been set. See 193 * jsgc.c for details. 194 */ 195 #define THREAD_IS_RUNNING_GC(rt, thread) \ 196 ((rt)->gcRunning && (rt)->gcThread == (thread)) 197 198 #define CX_THREAD_IS_RUNNING_GC(cx) \ 199 THREAD_IS_RUNNING_GC((cx)->runtime, (cx)->thread) 200 201 #define GC_AWARE_GET_SLOT(cx, obj, slot) \ 202 ((OBJ_IS_NATIVE(obj) && CX_THREAD_IS_RUNNING_GC(cx)) \ 203 ? (obj)->slots[slot] \ 204 : OBJ_GET_SLOT(cx, obj, slot)) 205 206 #else /* !JS_THREADSAFE */ 207 208 #define OBJ_GET_SLOT(cx,obj,slot) LOCKED_OBJ_GET_SLOT(obj,slot) 209 #define OBJ_SET_SLOT(cx,obj,slot,value) LOCKED_OBJ_SET_SLOT(obj,slot,value) 210 #define GC_AWARE_GET_SLOT(cx,obj,slot) LOCKED_OBJ_GET_SLOT(obj,slot) 211 212 #endif /* !JS_THREADSAFE */ 213 214 /* Thread-safe proto, parent, and class access macros. */ 215 #define OBJ_GET_PROTO(cx,obj) \ 216 JSVAL_TO_OBJECT(OBJ_GET_SLOT(cx, obj, JSSLOT_PROTO)) 217 #define OBJ_SET_PROTO(cx,obj,proto) \ 218 OBJ_SET_SLOT(cx, obj, JSSLOT_PROTO, OBJECT_TO_JSVAL(proto)) 219 220 #define OBJ_GET_PARENT(cx,obj) \ 221 JSVAL_TO_OBJECT(OBJ_GET_SLOT(cx, obj, JSSLOT_PARENT)) 222 #define OBJ_SET_PARENT(cx,obj,parent) \ 223 OBJ_SET_SLOT(cx, obj, JSSLOT_PARENT, OBJECT_TO_JSVAL(parent)) 224 225 #define OBJ_GET_CLASS(cx,obj) \ 226 ((JSClass *)JSVAL_TO_PRIVATE(OBJ_GET_SLOT(cx, obj, JSSLOT_CLASS))) 227 228 /* Test whether a map or object is native. */ 229 #define MAP_IS_NATIVE(map) \ 230 ((map)->ops == &js_ObjectOps || \ 231 ((map)->ops && (map)->ops->newObjectMap == js_ObjectOps.newObjectMap)) 232 233 #define OBJ_IS_NATIVE(obj) MAP_IS_NATIVE((obj)->map) 234 235 extern JS_FRIEND_DATA(JSObjectOps) js_ObjectOps; 236 extern JS_FRIEND_DATA(JSObjectOps) js_WithObjectOps; 237 extern JSClass js_ObjectClass; 238 extern JSClass js_WithClass; 239 extern JSClass js_BlockClass; 240 241 /* 242 * Block scope object macros. The slots reserved by js_BlockClass are: 243 * 244 * JSSLOT_PRIVATE JSStackFrame * active frame pointer or null 245 * JSSLOT_BLOCK_DEPTH int depth of block slots in frame 246 * 247 * After JSSLOT_BLOCK_DEPTH come one or more slots for the block locals. 248 * OBJ_BLOCK_COUNT depends on this arrangement. 249 * 250 * A With object is like a Block object, in that both have one reserved slot 251 * telling the stack depth of the relevant slots (the slot whose value is the 252 * object named in the with statement, the slots containing the block's local 253 * variables); and both have a private slot referring to the JSStackFrame in 254 * whose activation they were created (or null if the with or block object 255 * outlives the frame). 256 */ 257 #define JSSLOT_BLOCK_DEPTH (JSSLOT_PRIVATE + 1) 258 259 #define OBJ_BLOCK_COUNT(cx,obj) \ 260 ((obj)->map->freeslot - (JSSLOT_BLOCK_DEPTH + 1)) 261 #define OBJ_BLOCK_DEPTH(cx,obj) \ 262 JSVAL_TO_INT(OBJ_GET_SLOT(cx, obj, JSSLOT_BLOCK_DEPTH)) 263 #define OBJ_SET_BLOCK_DEPTH(cx,obj,depth) \ 264 OBJ_SET_SLOT(cx, obj, JSSLOT_BLOCK_DEPTH, INT_TO_JSVAL(depth)) 265 266 /* 267 * To make sure this slot is well-defined, always call js_NewWithObject to 268 * create a With object, don't call js_NewObject directly. When creating a 269 * With object that does not correspond to a stack slot, pass -1 for depth. 270 * 271 * When popping the stack across this object's "with" statement, client code 272 * must call JS_SetPrivate(cx, withobj, NULL). 273 */ 274 extern JSObject * 275 js_NewWithObject(JSContext *cx, JSObject *proto, JSObject *parent, jsint depth); 276 277 /* 278 * Create a new block scope object not linked to any proto or parent object. 279 * Blocks are created by the compiler to reify let blocks and comprehensions. 280 * Only when dynamic scope is captured do they need to be cloned and spliced 281 * into an active scope chain. 282 */ 283 extern JSObject * 284 js_NewBlockObject(JSContext *cx); 285 286 extern JSObject * 287 js_CloneBlockObject(JSContext *cx, JSObject *proto, JSObject *parent, 288 JSStackFrame *fp); 289 290 extern JSBool 291 js_PutBlockObject(JSContext *cx, JSObject *obj); 292 293 struct JSSharpObjectMap { 294 jsrefcount depth; 295 jsatomid sharpgen; 296 JSHashTable *table; 297 }; 298 299 #define SHARP_BIT ((jsatomid) 1) 300 #define BUSY_BIT ((jsatomid) 2) 301 #define SHARP_ID_SHIFT 2 302 #define IS_SHARP(he) (JS_PTR_TO_UINT32((he)->value) & SHARP_BIT) 303 #define MAKE_SHARP(he) ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((he)->value)|SHARP_BIT)) 304 #define IS_BUSY(he) (JS_PTR_TO_UINT32((he)->value) & BUSY_BIT) 305 #define MAKE_BUSY(he) ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((he)->value)|BUSY_BIT)) 306 #define CLEAR_BUSY(he) ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((he)->value)&~BUSY_BIT)) 307 308 extern JSHashEntry * 309 js_EnterSharpObject(JSContext *cx, JSObject *obj, JSIdArray **idap, 310 jschar **sp); 311 312 extern void 313 js_LeaveSharpObject(JSContext *cx, JSIdArray **idap); 314 315 /* 316 * Mark objects stored in map if GC happens between js_EnterSharpObject 317 * and js_LeaveSharpObject. GC calls this when map->depth > 0. 318 */ 319 extern void 320 js_GCMarkSharpMap(JSContext *cx, JSSharpObjectMap *map); 321 322 extern JSBool 323 js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, 324 jsval *rval); 325 326 extern JSBool 327 js_obj_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, 328 jsval *rval); 329 330 extern JSBool 331 js_HasOwnPropertyHelper(JSContext *cx, JSObject *obj, JSLookupPropOp lookup, 332 uintN argc, jsval *argv, jsval *rval); 333 334 extern JSObject* 335 js_InitBlockClass(JSContext *cx, JSObject* obj); 336 337 extern JSObject * 338 js_InitObjectClass(JSContext *cx, JSObject *obj); 339 340 /* Select Object.prototype method names shared between jsapi.c and jsobj.c. */ 341 extern const char js_watch_str[]; 342 extern const char js_unwatch_str[]; 343 extern const char js_hasOwnProperty_str[]; 344 extern const char js_isPrototypeOf_str[]; 345 extern const char js_propertyIsEnumerable_str[]; 346 extern const char js_defineGetter_str[]; 347 extern const char js_defineSetter_str[]; 348 extern const char js_lookupGetter_str[]; 349 extern const char js_lookupSetter_str[]; 350 351 extern void 352 js_InitObjectMap(JSObjectMap *map, jsrefcount nrefs, JSObjectOps *ops, 353 JSClass *clasp); 354 355 extern JSObjectMap * 356 js_NewObjectMap(JSContext *cx, jsrefcount nrefs, JSObjectOps *ops, 357 JSClass *clasp, JSObject *obj); 358 359 extern void 360 js_DestroyObjectMap(JSContext *cx, JSObjectMap *map); 361 362 extern JSObjectMap * 363 js_HoldObjectMap(JSContext *cx, JSObjectMap *map); 364 365 extern JSObjectMap * 366 js_DropObjectMap(JSContext *cx, JSObjectMap *map, JSObject *obj); 367 368 extern JSBool 369 js_GetClassId(JSContext *cx, JSClass *clasp, jsid *idp); 370 371 extern JSObject * 372 js_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent); 373 374 /* 375 * Fast access to immutable standard objects (constructors and prototypes). 376 */ 377 extern JSBool 378 js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, 379 JSObject **objp); 380 381 extern JSBool 382 js_SetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject *cobj); 383 384 extern JSBool 385 js_FindClassObject(JSContext *cx, JSObject *start, jsid id, jsval *vp); 386 387 extern JSObject * 388 js_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *proto, 389 JSObject *parent, uintN argc, jsval *argv); 390 391 extern void 392 js_FinalizeObject(JSContext *cx, JSObject *obj); 393 394 extern JSBool 395 js_AllocSlot(JSContext *cx, JSObject *obj, uint32 *slotp); 396 397 extern void 398 js_FreeSlot(JSContext *cx, JSObject *obj, uint32 slot); 399 400 /* 401 * Native property add and lookup variants that hide id in the hidden atom 402 * subspace, so as to avoid collisions between internal properties such as 403 * formal arguments and local variables in function objects, and externally 404 * set properties with the same ids. 405 */ 406 extern JSScopeProperty * 407 js_AddHiddenProperty(JSContext *cx, JSObject *obj, jsid id, 408 JSPropertyOp getter, JSPropertyOp setter, uint32 slot, 409 uintN attrs, uintN flags, intN shortid); 410 411 extern JSBool 412 js_LookupHiddenProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, 413 JSProperty **propp); 414 415 /* 416 * Find or create a property named by id in obj's scope, with the given getter 417 * and setter, slot, attributes, and other members. 418 */ 419 extern JSScopeProperty * 420 js_AddNativeProperty(JSContext *cx, JSObject *obj, jsid id, 421 JSPropertyOp getter, JSPropertyOp setter, uint32 slot, 422 uintN attrs, uintN flags, intN shortid); 423 424 /* 425 * Change sprop to have the given attrs, getter, and setter in scope, morphing 426 * it into a potentially new JSScopeProperty. Return a pointer to the changed 427 * or identical property. 428 */ 429 extern JSScopeProperty * 430 js_ChangeNativePropertyAttrs(JSContext *cx, JSObject *obj, 431 JSScopeProperty *sprop, uintN attrs, uintN mask, 432 JSPropertyOp getter, JSPropertyOp setter); 433 434 /* 435 * On error, return false. On success, if propp is non-null, return true with 436 * obj locked and with a held property in *propp; if propp is null, return true 437 * but release obj's lock first. Therefore all callers who pass non-null propp 438 * result parameters must later call OBJ_DROP_PROPERTY(cx, obj, *propp) both to 439 * drop the held property, and to release the lock on obj. 440 */ 441 extern JSBool 442 js_DefineProperty(JSContext *cx, JSObject *obj, jsid id, jsval value, 443 JSPropertyOp getter, JSPropertyOp setter, uintN attrs, 444 JSProperty **propp); 445 446 extern JSBool 447 js_DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, jsval value, 448 JSPropertyOp getter, JSPropertyOp setter, uintN attrs, 449 uintN flags, intN shortid, JSProperty **propp); 450 451 /* 452 * Unlike js_DefineProperty, propp must be non-null. On success, and if id was 453 * found, return true with *objp non-null and locked, and with a held property 454 * stored in *propp. If successful but id was not found, return true with both 455 * *objp and *propp null. Therefore all callers who receive a non-null *propp 456 * must later call OBJ_DROP_PROPERTY(cx, *objp, *propp). 457 */ 458 extern JS_FRIEND_API(JSBool) 459 js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, 460 JSProperty **propp); 461 462 /* 463 * Specialized subroutine that allows caller to preset JSRESOLVE_* flags. 464 * JSRESOLVE_HIDDEN flags hidden function param/local name lookups, just for 465 * internal use by fun_resolve and similar built-ins. 466 */ 467 extern JSBool 468 js_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN flags, 469 JSObject **objp, JSProperty **propp); 470 471 #define JSRESOLVE_HIDDEN 0x8000 472 473 extern JS_FRIEND_API(JSBool) 474 js_FindProperty(JSContext *cx, jsid id, JSObject **objp, JSObject **pobjp, 475 JSProperty **propp); 476 477 extern JSObject * 478 js_FindIdentifierBase(JSContext *cx, jsid id); 479 480 extern JSObject * 481 js_FindVariableScope(JSContext *cx, JSFunction **funp); 482 483 /* 484 * NB: js_NativeGet and js_NativeSet are called with the scope containing sprop 485 * (pobj's scope for Get, obj's for Set) locked, and on successful return, that 486 * scope is again locked. But on failure, both functions return false with the 487 * scope containing sprop unlocked. 488 */ 489 extern JSBool 490 js_NativeGet(JSContext *cx, JSObject *obj, JSObject *pobj, 491 JSScopeProperty *sprop, jsval *vp); 492 493 extern JSBool 494 js_NativeSet(JSContext *cx, JSObject *obj, JSScopeProperty *sprop, jsval *vp); 495 496 extern JSBool 497 js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp); 498 499 extern JSBool 500 js_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp); 501 502 extern JSBool 503 js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop, 504 uintN *attrsp); 505 506 extern JSBool 507 js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop, 508 uintN *attrsp); 509 510 extern JSBool 511 js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *rval); 512 513 extern JSBool 514 js_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp); 515 516 extern JSIdArray * 517 js_NewIdArray(JSContext *cx, jsint length); 518 519 /* 520 * Unlike realloc(3), this function frees ida on failure. 521 */ 522 extern JSIdArray * 523 js_SetIdArrayLength(JSContext *cx, JSIdArray *ida, jsint length); 524 525 extern JSBool 526 js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, 527 jsval *statep, jsid *idp); 528 529 extern void 530 js_MarkNativeIteratorStates(JSContext *cx); 531 532 extern JSBool 533 js_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, 534 jsval *vp, uintN *attrsp); 535 536 extern JSBool 537 js_Call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval); 538 539 extern JSBool 540 js_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, 541 jsval *rval); 542 543 extern JSBool 544 js_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); 545 546 extern JSBool 547 js_SetProtoOrParent(JSContext *cx, JSObject *obj, uint32 slot, JSObject *pobj); 548 549 extern JSBool 550 js_IsDelegate(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); 551 552 extern JSBool 553 js_GetClassPrototype(JSContext *cx, JSObject *scope, jsid id, 554 JSObject **protop); 555 556 extern JSBool 557 js_SetClassPrototype(JSContext *cx, JSObject *ctor, JSObject *proto, 558 uintN attrs); 559 560 extern JSBool 561 js_ValueToObject(JSContext *cx, jsval v, JSObject **objp); 562 563 extern JSObject * 564 js_ValueToNonNullObject(JSContext *cx, jsval v); 565 566 extern JSBool 567 js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, jsval *rval); 568 569 extern JSBool 570 js_TryMethod(JSContext *cx, JSObject *obj, JSAtom *atom, 571 uintN argc, jsval *argv, jsval *rval); 572 573 extern JSBool 574 js_XDRObject(JSXDRState *xdr, JSObject **objp); 575 576 extern uint32 577 js_Mark(JSContext *cx, JSObject *obj, void *arg); 578 579 extern void 580 js_Clear(JSContext *cx, JSObject *obj); 581 582 extern jsval 583 js_GetRequiredSlot(JSContext *cx, JSObject *obj, uint32 slot); 584 585 extern JSBool 586 js_SetRequiredSlot(JSContext *cx, JSObject *obj, uint32 slot, jsval v); 587 588 extern JSObject * 589 js_CheckScopeChainValidity(JSContext *cx, JSObject *scopeobj, const char *caller); 590 591 extern JSBool 592 js_CheckPrincipalsAccess(JSContext *cx, JSObject *scopeobj, 593 JSPrincipals *principals, JSAtom *caller); 594 JS_END_EXTERN_C 595 596 #endif /* jsobj_h___ */ 597