Fix JS_[GS]etContextThread return type; add JSCLASS_NEW_RESOLVE_GETS_START (196966, r=shaver).

This commit is contained in:
brendan%mozilla.org 2003-03-12 20:29:16 +00:00
Родитель 3b01ed08a0
Коммит dd545c2cb9
4 изменённых файлов: 29 добавлений и 7 удалений

Просмотреть файл

@ -3982,13 +3982,13 @@ JS_ErrorFromException(JSContext *cx, jsval v)
}
#ifdef JS_THREADSAFE
JS_PUBLIC_API(intN)
JS_PUBLIC_API(jsword)
JS_GetContextThread(JSContext *cx)
{
return cx->thread;
}
JS_PUBLIC_API(intN)
JS_PUBLIC_API(jsword)
JS_SetContextThread(JSContext *cx)
{
intN old = cx->thread;

Просмотреть файл

@ -721,6 +721,10 @@ struct JSClass {
#define JSCLASS_NEW_RESOLVE (1<<2) /* has JSNewResolveOp hook */
#define JSCLASS_PRIVATE_IS_NSISUPPORTS (1<<3) /* private is (nsISupports *) */
#define JSCLASS_SHARE_ALL_PROPERTIES (1<<4) /* all properties are SHARED */
#define JSCLASS_NEW_RESOLVE_GETS_START (1<<5) /* JSNewResolveOp gets starting
object in prototype chain
passed in via *objp in/out
parameter */
/*
* To reserve slots fetched and stored via JS_Get/SetReservedSlot, bitwise-or
@ -1692,11 +1696,10 @@ JS_ErrorFromException(JSContext *cx, jsval v);
* indicates that ClearContextThread has been called on this context
* since the last SetContextThread, or non-0, which indicates the opposite.
*/
extern JS_PUBLIC_API(intN)
extern JS_PUBLIC_API(jsword)
JS_GetContextThread(JSContext *cx);
extern JS_PUBLIC_API(intN)
extern JS_PUBLIC_API(jsword)
JS_SetContextThread(JSContext *cx);
extern JS_PUBLIC_API(intN)

Просмотреть файл

@ -2178,6 +2178,7 @@ js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
JSProperty **propp)
#endif
{
JSObject *start, *obj2, *proto;
JSScope *scope;
JSScopeProperty *sprop;
JSClass *clasp;
@ -2189,7 +2190,6 @@ js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
JSNewResolveOp newresolve;
uintN flags;
uint32 format;
JSObject *obj2, *proto;
JSBool ok;
/*
@ -2199,6 +2199,7 @@ js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
CHECK_FOR_FUNNY_INDEX(id);
/* Search scopes starting with obj and following the prototype link. */
start = obj;
for (;;) {
JS_LOCK_OBJ(cx, obj);
SET_OBJ_INFO(obj, file, line);
@ -2269,7 +2270,9 @@ js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
flags |= JSRESOLVE_ASSIGNING;
}
}
obj2 = NULL;
obj2 = (clasp->flags & JSCLASS_NEW_RESOLVE_GETS_START)
? start
: NULL;
JS_UNLOCK_OBJ(cx, obj);
ok = newresolve(cx, obj, ID_TO_VALUE(id), flags, &obj2);
if (!ok)

Просмотреть файл

@ -196,6 +196,22 @@ typedef JSBool
* The *objp out parameter, on success, should be null to indicate that id
* was not resolved; and non-null, referring to obj or one of its prototypes,
* if id was resolved.
*
* This hook instead of JSResolveOp is called via the JSClass.resolve member
* if JSCLASS_NEW_RESOLVE is set in JSClass.flags.
*
* Setting JSCLASS_NEW_RESOLVE and JSCLASS_NEW_RESOLVE_GETS_START further
* extends this hook by passing in the starting object on the prototype chain
* via *objp. Thus a resolve hook implementation may define the property id
* being resolved in the object in which the id was first sought, rather than
* in a prototype object whose class led to the resolve hook being called.
*
* When using JSCLASS_NEW_RESOLVE_GETS_START, the resolve hook must therefore
* null *objp to signify "not resolved". With only JSCLASS_NEW_RESOLVE and no
* JSCLASS_NEW_RESOLVE_GETS_START, the hook can assume *objp is null on entry.
* This is not good practice, but enough existing hook implementations count
* on it that we can't break compatibility by passing the starting object in
* *objp without a new JSClass flag.
*/
typedef JSBool
(* JS_DLL_CALLBACK JSNewResolveOp)(JSContext *cx, JSObject *obj, jsval id,