mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 362910 - js_GetMethod cleanup. r=brendan
This commit is contained in:
parent
74847db9cd
commit
20e6be9c80
@ -653,7 +653,7 @@ JS_TypeOfValue(JSContext *cx, jsval v)
|
||||
|
||||
ops = obj->map->ops;
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
if (ops == &js_XMLObjectOps.base) {
|
||||
if (ops == &js_XMLObjectOps) {
|
||||
type = JSTYPE_XML;
|
||||
} else
|
||||
#endif
|
||||
@ -3611,22 +3611,10 @@ JS_GetMethodById(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
|
||||
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
if (OBJECT_IS_XML(cx, obj)) {
|
||||
JSXMLObjectOps *ops;
|
||||
|
||||
ops = (JSXMLObjectOps *) obj->map->ops;
|
||||
obj = ops->getMethod(cx, obj, id, vp);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (!OBJ_GET_PROPERTY(cx, obj, id, vp))
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*objp = obj;
|
||||
if (!js_GetMethod(cx, obj, id, vp, NULL))
|
||||
return JS_FALSE;
|
||||
if (objp)
|
||||
*objp = obj;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@ -5179,27 +5167,14 @@ JS_PUBLIC_API(JSBool)
|
||||
JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, uintN argc,
|
||||
jsval *argv, jsval *rval)
|
||||
{
|
||||
JSBool ok;
|
||||
jsval fval;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
if (OBJECT_IS_XML(cx, obj)) {
|
||||
JSXMLObjectOps *ops;
|
||||
JSAtom *atom;
|
||||
|
||||
ops = (JSXMLObjectOps *) obj->map->ops;
|
||||
atom = js_Atomize(cx, name, strlen(name), 0);
|
||||
if (!atom)
|
||||
return JS_FALSE;
|
||||
obj = ops->getMethod(cx, obj, ATOM_TO_JSID(atom), &fval);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
} else
|
||||
#endif
|
||||
if (!JS_GetProperty(cx, obj, name, &fval))
|
||||
return JS_FALSE;
|
||||
ok = js_InternalCall(cx, obj, fval, argc, argv, rval);
|
||||
JSAutoTempValueRooter tvr(cx);
|
||||
JSAtom *atom = js_Atomize(cx, name, strlen(name), 0);
|
||||
JSBool ok = atom &&
|
||||
JS_GetMethodById(cx, obj, ATOM_TO_JSID(atom), NULL,
|
||||
tvr.addr()) &&
|
||||
js_InternalCall(cx, obj, tvr.value(), argc, argv, rval);
|
||||
LAST_FRAME_CHECKS(cx, ok);
|
||||
return ok;
|
||||
}
|
||||
|
@ -1430,15 +1430,6 @@ struct JSObjectOps {
|
||||
JSSetRequiredSlotOp setRequiredSlot;
|
||||
};
|
||||
|
||||
struct JSXMLObjectOps {
|
||||
JSObjectOps base;
|
||||
JSGetMethodOp getMethod;
|
||||
JSSetMethodOp setMethod;
|
||||
JSEnumerateValuesOp enumerateValues;
|
||||
JSEqualityOp equality;
|
||||
JSConcatenateOp concatenate;
|
||||
};
|
||||
|
||||
/*
|
||||
* Classes that expose JSObjectOps via a non-null getObjectOps class hook may
|
||||
* derive a property structure from this struct, return a pointer to it from
|
||||
|
@ -936,24 +936,9 @@ js_OnUnknownMethod(JSContext *cx, jsval *vp)
|
||||
|
||||
MUST_FLOW_THROUGH("out");
|
||||
id = ATOM_TO_JSID(cx->runtime->atomState.noSuchMethodAtom);
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
if (OBJECT_IS_XML(cx, obj)) {
|
||||
JSXMLObjectOps *ops;
|
||||
|
||||
ops = (JSXMLObjectOps *) obj->map->ops;
|
||||
obj = ops->getMethod(cx, obj, id, &tvr.u.value);
|
||||
if (!obj) {
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
}
|
||||
vp[1] = OBJECT_TO_JSVAL(obj);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ok = OBJ_GET_PROPERTY(cx, obj, id, &tvr.u.value);
|
||||
if (!ok)
|
||||
goto out;
|
||||
}
|
||||
ok = js_GetMethod(cx, obj, id, &tvr.u.value, NULL);
|
||||
if (!ok)
|
||||
goto out;
|
||||
if (JSVAL_IS_PRIMITIVE(tvr.u.value)) {
|
||||
vp[0] = tvr.u.value;
|
||||
} else {
|
||||
@ -3582,12 +3567,9 @@ js_Interpret(JSContext *cx)
|
||||
(rtmp == JSVAL_OBJECT && \
|
||||
(obj2 = JSVAL_TO_OBJECT(rval)) && \
|
||||
OBJECT_IS_XML(cx, obj2))) { \
|
||||
JSXMLObjectOps *ops; \
|
||||
\
|
||||
ops = (JSXMLObjectOps *) obj2->map->ops; \
|
||||
if (JSVAL_IS_OBJECT(rval) && obj2 == JSVAL_TO_OBJECT(rval)) \
|
||||
rval = lval; \
|
||||
if (!ops->equality(cx, obj2, rval, &cond)) \
|
||||
if (!js_TestXMLEquality(cx, obj2, rval, &cond)) \
|
||||
goto error; \
|
||||
cond = cond OP JS_TRUE; \
|
||||
} else
|
||||
@ -3761,10 +3743,7 @@ js_Interpret(JSContext *cx)
|
||||
if (!JSVAL_IS_PRIMITIVE(lval) &&
|
||||
(obj2 = JSVAL_TO_OBJECT(lval), OBJECT_IS_XML(cx, obj2)) &&
|
||||
VALUE_IS_XML(cx, rval)) {
|
||||
JSXMLObjectOps *ops;
|
||||
|
||||
ops = (JSXMLObjectOps *) obj2->map->ops;
|
||||
if (!ops->concatenate(cx, obj2, rval, &rval))
|
||||
if (!js_ConcatenateXML(cx, obj2, rval, &rval))
|
||||
goto error;
|
||||
regs.sp--;
|
||||
STORE_OPND(-1, rval);
|
||||
@ -4386,22 +4365,8 @@ js_Interpret(JSContext *cx)
|
||||
id = ATOM_TO_JSID(atom);
|
||||
PUSH(JSVAL_NULL);
|
||||
if (!JSVAL_IS_PRIMITIVE(lval)) {
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
/* Special-case XML object method lookup, per ECMA-357. */
|
||||
if (OBJECT_IS_XML(cx, obj)) {
|
||||
JSXMLObjectOps *ops;
|
||||
|
||||
ops = (JSXMLObjectOps *) obj->map->ops;
|
||||
obj = ops->getMethod(cx, obj, id, &rval);
|
||||
if (!obj)
|
||||
goto error;
|
||||
} else
|
||||
#endif
|
||||
if (entry
|
||||
? !js_GetPropertyHelper(cx, obj, id, &rval, &entry)
|
||||
: !OBJ_GET_PROPERTY(cx, obj, id, &rval)) {
|
||||
if (!js_GetMethod(cx, obj, id, &rval, entry ? &entry : NULL))
|
||||
goto error;
|
||||
}
|
||||
STORE_OPND(-1, OBJECT_TO_JSVAL(obj));
|
||||
STORE_OPND(-2, rval);
|
||||
} else {
|
||||
@ -4699,11 +4664,7 @@ js_Interpret(JSContext *cx)
|
||||
END_CASE(JSOP_GETELEM)
|
||||
|
||||
BEGIN_CASE(JSOP_CALLELEM)
|
||||
/*
|
||||
* FIXME: JSOP_CALLELEM should call getMethod on XML objects as
|
||||
* CALLPROP does. See bug 362910.
|
||||
*/
|
||||
ELEMENT_OP(-1, OBJ_GET_PROPERTY(cx, obj, id, &rval));
|
||||
ELEMENT_OP(-1, js_GetMethod(cx, obj, id, &rval, NULL));
|
||||
#if JS_HAS_NO_SUCH_METHOD
|
||||
if (JS_UNLIKELY(JSVAL_IS_VOID(rval))) {
|
||||
regs.sp[-2] = regs.sp[-1];
|
||||
|
@ -104,9 +104,8 @@ js_CloseNativeIterator(JSContext *cx, JSObject *iterobj)
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
uintN flags = JSVAL_TO_INT(STOBJ_GET_SLOT(iterobj, JSSLOT_ITER_FLAGS));
|
||||
if ((flags & JSITER_FOREACH) && OBJECT_IS_XML(cx, iterable)) {
|
||||
((JSXMLObjectOps *) iterable->map->ops)->
|
||||
enumerateValues(cx, iterable, JSENUMERATE_DESTROY, &state,
|
||||
NULL, NULL);
|
||||
js_EnumerateXMLValues(cx, iterable, JSENUMERATE_DESTROY, &state,
|
||||
NULL, NULL);
|
||||
} else
|
||||
#endif
|
||||
OBJ_ENUMERATE(cx, iterable, JSENUMERATE_DESTROY, &state, NULL);
|
||||
@ -143,8 +142,7 @@ InitNativeIterator(JSContext *cx, JSObject *iterobj, JSObject *obj, uintN flags)
|
||||
ok =
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
((flags & JSITER_FOREACH) && OBJECT_IS_XML(cx, obj))
|
||||
? ((JSXMLObjectOps *) obj->map->ops)->
|
||||
enumerateValues(cx, obj, JSENUMERATE_INIT, &state, NULL, NULL)
|
||||
? js_EnumerateXMLValues(cx, obj, JSENUMERATE_INIT, &state, NULL, NULL)
|
||||
:
|
||||
#endif
|
||||
OBJ_ENUMERATE(cx, obj, JSENUMERATE_INIT, &state, NULL);
|
||||
@ -233,9 +231,8 @@ IteratorNextImpl(JSContext *cx, JSObject *obj, jsval *rval)
|
||||
ok =
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
(foreach && OBJECT_IS_XML(cx, iterable))
|
||||
? ((JSXMLObjectOps *) iterable->map->ops)->
|
||||
enumerateValues(cx, iterable, JSENUMERATE_NEXT, &state,
|
||||
&id, rval)
|
||||
? js_EnumerateXMLValues(cx, iterable, JSENUMERATE_NEXT, &state,
|
||||
&id, rval)
|
||||
:
|
||||
#endif
|
||||
OBJ_ENUMERATE(cx, iterable, JSENUMERATE_NEXT, &state, &id);
|
||||
@ -377,17 +374,8 @@ js_ValueToIterator(JSContext *cx, uintN flags, jsval *vp)
|
||||
*vp = OBJECT_TO_JSVAL(iterobj);
|
||||
} else {
|
||||
atom = cx->runtime->atomState.iteratorAtom;
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
if (OBJECT_IS_XML(cx, obj)) {
|
||||
if (!js_GetXMLFunction(cx, obj, ATOM_TO_JSID(atom), vp))
|
||||
goto bad;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (!OBJ_GET_PROPERTY(cx, obj, ATOM_TO_JSID(atom), vp))
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!js_GetMethod(cx, obj, ATOM_TO_JSID(atom), vp, NULL))
|
||||
goto bad;
|
||||
if (JSVAL_IS_VOID(*vp)) {
|
||||
default_iter:
|
||||
/*
|
||||
@ -486,10 +474,8 @@ CallEnumeratorNext(JSContext *cx, JSObject *iterobj, uintN flags, jsval *rval)
|
||||
*/
|
||||
if (obj == origobj && OBJECT_IS_XML(cx, obj)) {
|
||||
if (foreach) {
|
||||
JSXMLObjectOps *xmlops = (JSXMLObjectOps *) obj->map->ops;
|
||||
|
||||
if (!xmlops->enumerateValues(cx, obj, JSENUMERATE_NEXT, &state,
|
||||
&id, rval)) {
|
||||
if (!js_EnumerateXMLValues(cx, obj, JSENUMERATE_NEXT, &state,
|
||||
&id, rval)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
} else {
|
||||
|
@ -4322,6 +4322,22 @@ js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
return js_GetPropertyHelper(cx, obj, id, vp, NULL);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_GetMethod(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
|
||||
JSPropCacheEntry **entryp)
|
||||
{
|
||||
if (obj->map->ops == &js_ObjectOps ||
|
||||
obj->map->ops->getProperty == js_GetProperty) {
|
||||
return js_GetPropertyHelper(cx, obj, id, vp, entryp);
|
||||
}
|
||||
JS_ASSERT_IF(entryp, OBJ_IS_DENSE_ARRAY(cx, obj));
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
if (OBJECT_IS_XML(cx, obj))
|
||||
return js_GetXMLMethod(cx, obj, id, vp);
|
||||
#endif
|
||||
return OBJ_GET_PROPERTY(cx, obj, id, vp);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
|
||||
JSPropCacheEntry **entryp)
|
||||
@ -5438,18 +5454,7 @@ js_TryMethod(JSContext *cx, JSObject *obj, JSAtom *atom,
|
||||
older = JS_SetErrorReporter(cx, NULL);
|
||||
id = ATOM_TO_JSID(atom);
|
||||
fval = JSVAL_VOID;
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
if (OBJECT_IS_XML(cx, obj)) {
|
||||
JSXMLObjectOps *ops;
|
||||
|
||||
ops = (JSXMLObjectOps *) obj->map->ops;
|
||||
obj = ops->getMethod(cx, obj, id, &fval);
|
||||
ok = (obj != NULL);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ok = OBJ_GET_PROPERTY(cx, obj, id, &fval);
|
||||
}
|
||||
ok = js_GetMethod(cx, obj, id, &fval, NULL);
|
||||
if (!ok)
|
||||
JS_ClearPendingException(cx);
|
||||
JS_SetErrorReporter(cx, older);
|
||||
|
@ -674,6 +674,10 @@ js_GetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
|
||||
extern JSBool
|
||||
js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
extern JSBool
|
||||
js_GetMethod(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
|
||||
JSPropCacheEntry **entryp);
|
||||
|
||||
extern JSBool
|
||||
js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
|
||||
JSPropCacheEntry **entryp);
|
||||
|
@ -145,7 +145,6 @@ typedef struct JSPropertySpec JSPropertySpec;
|
||||
typedef struct JSObject JSObject;
|
||||
typedef struct JSObjectMap JSObjectMap;
|
||||
typedef struct JSObjectOps JSObjectOps;
|
||||
typedef struct JSXMLObjectOps JSXMLObjectOps;
|
||||
typedef struct JSRuntime JSRuntime;
|
||||
typedef struct JSRuntime JSTaskState; /* XXX deprecated name */
|
||||
typedef struct JSScript JSScript;
|
||||
@ -296,10 +295,6 @@ typedef void
|
||||
* a JSClass *clasp parameter to JS_NewObject, etc. Most host objects do not
|
||||
* need to implement the larger JSObjectOps, and can share the common JSScope
|
||||
* code and data used by the native (js_ObjectOps, see jsobj.c) ops.
|
||||
*
|
||||
* Further extension to preserve API compatibility: if this function returns
|
||||
* a pointer to JSXMLObjectOps.base, not to JSObjectOps, then the engine calls
|
||||
* extended hooks needed for E4X.
|
||||
*/
|
||||
typedef JSObjectOps *
|
||||
(* JSGetObjectOps)(JSContext *cx, JSClass *clasp);
|
||||
|
@ -132,6 +132,9 @@ const uint32 JSSLOT_LOCAL_NAME = JSSLOT_PRIVATE + 2;
|
||||
const uint32 NAMESPACE_RESERVED_SLOTS = 3;
|
||||
const uint32 QNAME_RESERVED_SLOTS = 3;
|
||||
|
||||
static JSBool
|
||||
GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
IsQNameClass(JSClass *clasp)
|
||||
{
|
||||
@ -3496,9 +3499,6 @@ Descendants(JSContext *cx, JSXML *xml, jsval id)
|
||||
return list;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
xml_equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||
|
||||
/* Recursive (JSXML *) parameterized version of Equals. */
|
||||
static JSBool
|
||||
XMLEquals(JSContext *cx, JSXML *xml, JSXML *vxml, JSBool *bp)
|
||||
@ -3556,7 +3556,7 @@ retry:
|
||||
xobj = js_GetXMLObject(cx, kid);
|
||||
vobj = js_GetXMLObject(cx, vkid);
|
||||
ok = xobj && vobj &&
|
||||
xml_equality(cx, xobj, OBJECT_TO_JSVAL(vobj), bp);
|
||||
js_TestXMLEquality(cx, xobj, OBJECT_TO_JSVAL(vobj), bp);
|
||||
if (!ok || !*bp)
|
||||
break;
|
||||
}
|
||||
@ -3606,7 +3606,7 @@ Equals(JSContext *cx, JSXML *xml, jsval v, JSBool *bp)
|
||||
vobj = js_GetXMLObject(cx, vxml);
|
||||
if (!vobj)
|
||||
return JS_FALSE;
|
||||
return js_XMLObjectOps.equality(cx, vobj, v, bp);
|
||||
return js_TestXMLEquality(cx, vobj, v, bp);
|
||||
}
|
||||
if (JSVAL_IS_VOID(v) && xml->xml_kids.length == 0)
|
||||
*bp = JS_TRUE;
|
||||
@ -3991,7 +3991,7 @@ GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
if (!nameqn)
|
||||
return JS_FALSE;
|
||||
if (funid)
|
||||
return js_GetXMLFunction(cx, obj, funid, vp);
|
||||
return GetXMLFunction(cx, obj, funid, vp);
|
||||
|
||||
roots[0] = OBJECT_TO_JSVAL(nameqn);
|
||||
JS_PUSH_TEMP_ROOT(cx, 1, roots, &tvr);
|
||||
@ -4837,7 +4837,7 @@ HasFunctionProperty(JSContext *cx, JSObject *obj, jsid funid, JSBool *found)
|
||||
if (HasSimpleContent(xml)) {
|
||||
/*
|
||||
* Search in String.prototype to set found whenever
|
||||
* js_GetXMLFunction returns existing function.
|
||||
* GetXMLFunction returns existing function.
|
||||
*/
|
||||
JS_PUSH_TEMP_ROOT_OBJECT(cx, NULL, &tvr);
|
||||
ok = js_GetClassPrototype(cx, NULL, INT_TO_JSID(JSProto_String),
|
||||
@ -4927,7 +4927,7 @@ xml_trace_vector(JSTracer *trc, JSXML **vec, uint32 len)
|
||||
* FIXME This clashes with the function namespace implementation which also
|
||||
* uses native properties. Effectively after xml_lookupProperty any property
|
||||
* stored previously using assignments to xml.function::name will be removed.
|
||||
* We partially workaround the problem in js_GetXMLFunction. There we take
|
||||
* We partially workaround the problem in GetXMLFunction. There we take
|
||||
* advantage of the fact that typically function:: is used to access the
|
||||
* functions from XML.prototype. So when js_GetProperty returns a non-function
|
||||
* property, we assume that it represents the result of GetProperty setter
|
||||
@ -5222,40 +5222,40 @@ again:
|
||||
/*
|
||||
* 11.2.2.1 Step 3(d) onward.
|
||||
*/
|
||||
static JSObject *
|
||||
xml_getMethod(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
JSBool
|
||||
js_GetXMLMethod(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
JSTempValueRooter tvr;
|
||||
|
||||
JS_ASSERT(JS_InstanceOf(cx, obj, &js_XMLClass, NULL));
|
||||
|
||||
if (JSID_IS_OBJECT(id)) {
|
||||
jsid funid;
|
||||
|
||||
if (!js_IsFunctionQName(cx, JSID_TO_OBJECT(id), &funid))
|
||||
return JS_FALSE;
|
||||
if (funid != 0)
|
||||
id = funid;
|
||||
}
|
||||
|
||||
/*
|
||||
* As our callers have a bad habit of passing a pointer to an unrooted
|
||||
* local value as vp, we use a proper root here.
|
||||
*/
|
||||
JS_PUSH_SINGLE_TEMP_ROOT(cx, JSVAL_NULL, &tvr);
|
||||
if (!js_GetXMLFunction(cx, obj, id, &tvr.u.value))
|
||||
obj = NULL;
|
||||
*vp = tvr.u.value;
|
||||
JS_POP_TEMP_ROOT(cx, &tvr);
|
||||
return obj;
|
||||
JSAutoTempValueRooter tvr(cx);
|
||||
JSBool ok = GetXMLFunction(cx, obj, id, tvr.addr());
|
||||
*vp = tvr.value();
|
||||
return ok;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
xml_setMethod(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return js_SetProperty(cx, obj, id, vp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
xml_enumerateValues(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
||||
jsval *statep, jsid *idp, jsval *vp)
|
||||
JSBool
|
||||
js_EnumerateXMLValues(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
||||
jsval *statep, jsid *idp, jsval *vp)
|
||||
{
|
||||
JSXML *xml, *kid;
|
||||
uint32 length, index;
|
||||
JSXMLArrayCursor *cursor;
|
||||
JSObject *kidobj;
|
||||
|
||||
JS_ASSERT(JS_InstanceOf(cx, obj, &js_XMLClass, NULL));
|
||||
xml = (JSXML *) JS_GetPrivate(cx, obj);
|
||||
length = JSXML_LENGTH(xml);
|
||||
JS_ASSERT(INT_FITS_IN_JSVAL(length));
|
||||
@ -5308,8 +5308,8 @@ xml_enumerateValues(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
xml_equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
JSBool
|
||||
js_TestXMLEquality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
{
|
||||
JSXML *xml, *vxml;
|
||||
JSObject *vobj;
|
||||
@ -5317,6 +5317,7 @@ xml_equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
JSString *str, *vstr;
|
||||
jsdouble d, d2;
|
||||
|
||||
JS_ASSERT(JS_InstanceOf(cx, obj, &js_XMLClass, NULL));
|
||||
xml = (JSXML *) JS_GetPrivate(cx, obj);
|
||||
vxml = NULL;
|
||||
if (!JSVAL_IS_PRIMITIVE(v)) {
|
||||
@ -5382,13 +5383,14 @@ xml_equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
return ok;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
xml_concatenate(JSContext *cx, JSObject *obj, jsval v, jsval *vp)
|
||||
JSBool
|
||||
js_ConcatenateXML(JSContext *cx, JSObject *obj, jsval v, jsval *vp)
|
||||
{
|
||||
JSBool ok;
|
||||
JSObject *listobj, *robj;
|
||||
JSXML *list, *lxml, *rxml;
|
||||
|
||||
JS_ASSERT(JS_InstanceOf(cx, obj, &js_XMLClass, NULL));
|
||||
ok = js_EnterLocalRootScope(cx);
|
||||
if (!ok)
|
||||
return JS_FALSE;
|
||||
@ -5426,8 +5428,8 @@ out:
|
||||
}
|
||||
|
||||
/* Use js_NewObjectMap so XML objects satisfy OBJ_IS_NATIVE tests. */
|
||||
JS_FRIEND_DATA(JSXMLObjectOps) js_XMLObjectOps = {
|
||||
{ js_NewObjectMap, js_DestroyObjectMap,
|
||||
JS_FRIEND_DATA(JSObjectOps) js_XMLObjectOps = {
|
||||
js_NewObjectMap, js_DestroyObjectMap,
|
||||
xml_lookupProperty, xml_defineProperty,
|
||||
xml_getProperty, xml_setProperty,
|
||||
xml_getAttributes, xml_setAttributes,
|
||||
@ -5438,16 +5440,13 @@ JS_FRIEND_DATA(JSXMLObjectOps) js_XMLObjectOps = {
|
||||
NULL, xml_hasInstance,
|
||||
js_SetProtoOrParent, js_SetProtoOrParent,
|
||||
js_TraceObject, xml_clear,
|
||||
NULL, NULL },
|
||||
xml_getMethod, xml_setMethod,
|
||||
xml_enumerateValues, xml_equality,
|
||||
xml_concatenate
|
||||
NULL, NULL
|
||||
};
|
||||
|
||||
static JSObjectOps *
|
||||
xml_getObjectOps(JSContext *cx, JSClass *clasp)
|
||||
{
|
||||
return &js_XMLObjectOps.base;
|
||||
return &js_XMLObjectOps;
|
||||
}
|
||||
|
||||
JS_FRIEND_DATA(JSClass) js_XMLClass = {
|
||||
@ -5812,7 +5811,7 @@ xml_contains(JSContext *cx, uintN argc, jsval *vp)
|
||||
XMLArrayCursorInit(&cursor, &xml->xml_kids);
|
||||
while ((kid = (JSXML *) XMLArrayCursorNext(&cursor)) != NULL) {
|
||||
kidobj = js_GetXMLObject(cx, kid);
|
||||
if (!kidobj || !xml_equality(cx, kidobj, value, &eq))
|
||||
if (!kidobj || !js_TestXMLEquality(cx, kidobj, value, &eq))
|
||||
break;
|
||||
if (eq)
|
||||
break;
|
||||
@ -5821,7 +5820,7 @@ xml_contains(JSContext *cx, uintN argc, jsval *vp)
|
||||
if (kid && !eq)
|
||||
return JS_FALSE;
|
||||
} else {
|
||||
if (!xml_equality(cx, obj, value, &eq))
|
||||
if (!js_TestXMLEquality(cx, obj, value, &eq))
|
||||
return JS_FALSE;
|
||||
}
|
||||
*vp = BOOLEAN_TO_JSVAL(eq);
|
||||
@ -7995,8 +7994,8 @@ js_FindXMLProperty(JSContext *cx, jsval nameval, JSObject **objp, jsid *idp)
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
static JSBool
|
||||
GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
JSObject *target;
|
||||
JSXML *xml;
|
||||
|
@ -168,7 +168,7 @@ js_NewXMLObject(JSContext *cx, JSXMLClass xml_class);
|
||||
extern JSObject *
|
||||
js_GetXMLObject(JSContext *cx, JSXML *xml);
|
||||
|
||||
extern JS_FRIEND_DATA(JSXMLObjectOps) js_XMLObjectOps;
|
||||
extern JS_FRIEND_DATA(JSObjectOps) js_XMLObjectOps;
|
||||
extern JS_FRIEND_DATA(JSClass) js_XMLClass;
|
||||
extern JS_FRIEND_DATA(JSExtendedClass) js_NamespaceClass;
|
||||
extern JS_FRIEND_DATA(JSExtendedClass) js_QNameClass;
|
||||
@ -181,7 +181,7 @@ extern JSClass js_XMLFilterClass;
|
||||
* NB: jsobj.h must be included before any call to OBJECT_IS_XML, and jsapi.h
|
||||
* and jsobj.h must be included before any call to VALUE_IS_XML.
|
||||
*/
|
||||
#define OBJECT_IS_XML(cx,obj) ((obj)->map->ops == &js_XMLObjectOps.base)
|
||||
#define OBJECT_IS_XML(cx,obj) ((obj)->map->ops == &js_XMLObjectOps)
|
||||
#define VALUE_IS_XML(cx,v) (!JSVAL_IS_PRIMITIVE(v) && \
|
||||
OBJECT_IS_XML(cx, JSVAL_TO_OBJECT(v)))
|
||||
|
||||
@ -256,7 +256,7 @@ extern JSBool
|
||||
js_FindXMLProperty(JSContext *cx, jsval nameval, JSObject **objp, jsid *idp);
|
||||
|
||||
extern JSBool
|
||||
js_GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
js_GetXMLMethod(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
extern JSBool
|
||||
js_GetXMLDescendants(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
@ -292,6 +292,16 @@ js_MakeXMLCommentString(JSContext *cx, JSString *str);
|
||||
extern JSString *
|
||||
js_MakeXMLPIString(JSContext *cx, JSString *name, JSString *str);
|
||||
|
||||
extern JSBool
|
||||
js_EnumerateXMLValues(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
||||
jsval *statep, jsid *idp, jsval *vp);
|
||||
|
||||
extern JSBool
|
||||
js_TestXMLEquality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
|
||||
|
||||
extern JSBool
|
||||
js_ConcatenateXML(JSContext *cx, JSObject *obj, jsval v, jsval *vp);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsxml_h___ */
|
||||
|
Loading…
Reference in New Issue
Block a user