mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 580128 - Small cleanups in XrayWrapper and first stab at enumeration. r=mrbkap
This commit is contained in:
parent
a44ad43150
commit
3d567b4e1a
@ -372,6 +372,8 @@ Snapshot(JSContext *cx, JSObject *obj, uintN flags, typename EnumPolicy::ResultV
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace js {
|
||||
|
||||
bool
|
||||
VectorToIdArray(JSContext *cx, AutoIdVector &props, JSIdArray **idap)
|
||||
{
|
||||
@ -389,12 +391,14 @@ VectorToIdArray(JSContext *cx, AutoIdVector &props, JSIdArray **idap)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
JS_FRIEND_API(bool)
|
||||
GetPropertyNames(JSContext *cx, JSObject *obj, uintN flags, AutoIdVector *props)
|
||||
{
|
||||
return Snapshot<KeyEnumeration>(cx, obj, flags & (JSITER_OWNONLY | JSITER_HIDDEN), props);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static inline bool
|
||||
GetCustomIterator(JSContext *cx, JSObject *obj, uintN flags, Value *vp)
|
||||
{
|
||||
@ -559,6 +563,8 @@ VectorToKeyIterator(JSContext *cx, JSObject *obj, uintN flags, AutoIdVector &key
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace js {
|
||||
|
||||
bool
|
||||
VectorToKeyIterator(JSContext *cx, JSObject *obj, uintN flags, AutoIdVector &props, Value *vp)
|
||||
{
|
||||
@ -725,6 +731,8 @@ GetIterator(JSContext *cx, JSObject *obj, uintN flags, Value *vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static JSObject *
|
||||
iterator_iterator(JSContext *cx, JSObject *obj, JSBool keysonly)
|
||||
{
|
||||
|
@ -64,6 +64,8 @@
|
||||
*/
|
||||
#define JSITER_ACTIVE 0x1000
|
||||
|
||||
namespace js {
|
||||
|
||||
struct NativeIterator {
|
||||
JSObject *obj;
|
||||
void *props_array;
|
||||
@ -137,7 +139,7 @@ struct NativeIterator {
|
||||
bool
|
||||
VectorToIdArray(JSContext *cx, js::AutoIdVector &props, JSIdArray **idap);
|
||||
|
||||
bool
|
||||
JS_FRIEND_API(bool)
|
||||
GetPropertyNames(JSContext *cx, JSObject *obj, uintN flags, js::AutoIdVector *props);
|
||||
|
||||
bool
|
||||
@ -156,6 +158,8 @@ VectorToValueIterator(JSContext *cx, JSObject *obj, uintN flags, js::AutoValueVe
|
||||
bool
|
||||
EnumeratedIdVectorToIterator(JSContext *cx, JSObject *obj, uintN flags, js::AutoIdVector &props, js::Value *vp);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert the value stored in *vp to its iteration object. The flags should
|
||||
* contain JSITER_ENUMERATE if js_ValueToIterator is called when enumerating
|
||||
|
@ -231,8 +231,12 @@ js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
||||
extern JSType
|
||||
js_TypeOf(JSContext *cx, JSObject *obj);
|
||||
|
||||
namespace js {
|
||||
|
||||
struct NativeIterator;
|
||||
|
||||
}
|
||||
|
||||
const uint32 JS_INITIAL_NSLOTS = 3;
|
||||
|
||||
/*
|
||||
@ -909,8 +913,8 @@ struct JSObject : js::gc::Cell {
|
||||
* Iterator-specific getters and setters.
|
||||
*/
|
||||
|
||||
inline NativeIterator *getNativeIterator() const;
|
||||
inline void setNativeIterator(NativeIterator *);
|
||||
inline js::NativeIterator *getNativeIterator() const;
|
||||
inline void setNativeIterator(js::NativeIterator *);
|
||||
|
||||
/*
|
||||
* XML-related getters and setters.
|
||||
|
@ -563,14 +563,14 @@ JSObject::setMethodObj(JSObject& obj)
|
||||
fslots[JSSLOT_FUN_METHOD_OBJ].setObject(obj);
|
||||
}
|
||||
|
||||
inline NativeIterator *
|
||||
inline js::NativeIterator *
|
||||
JSObject::getNativeIterator() const
|
||||
{
|
||||
return (NativeIterator *) getPrivate();
|
||||
return (js::NativeIterator *) getPrivate();
|
||||
}
|
||||
|
||||
inline void
|
||||
JSObject::setNativeIterator(NativeIterator *ni)
|
||||
JSObject::setNativeIterator(js::NativeIterator *ni)
|
||||
{
|
||||
setPrivate(ni);
|
||||
}
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "WrapperFactory.h"
|
||||
|
||||
#include "jscntxt.h"
|
||||
#include "jsiter.h"
|
||||
|
||||
#include "XPCWrapper.h"
|
||||
#include "xpcprivate.h"
|
||||
@ -484,7 +485,7 @@ XrayWrapper<Base, Policy>::defineProperty(JSContext *cx, JSObject *wrapper, jsid
|
||||
return false;
|
||||
|
||||
if (existing_desc.obj && (existing_desc.attrs & JSPROP_PERMANENT))
|
||||
return true; // XXX throw?
|
||||
return true; // silently ignore attempt to overwrite native property
|
||||
|
||||
JSPropertyDescriptor *jsdesc = Jsvalify(desc);
|
||||
if (!(jsdesc->attrs & (JSPROP_GETTER | JSPROP_SETTER))) {
|
||||
@ -503,15 +504,20 @@ bool
|
||||
XrayWrapper<Base, Policy>::getOwnPropertyNames(JSContext *cx, JSObject *wrapper,
|
||||
js::AutoIdVector &props)
|
||||
{
|
||||
// XXX implement me.
|
||||
return true;
|
||||
JSObject *holder = GetHolder(wrapper);
|
||||
return js::GetPropertyNames(cx, holder, JSITER_OWNONLY | JSITER_HIDDEN, &props);
|
||||
}
|
||||
|
||||
template <typename Base, typename Policy>
|
||||
bool
|
||||
XrayWrapper<Base, Policy>::delete_(JSContext *cx, JSObject *wrapper, jsid id, bool *bp)
|
||||
{
|
||||
// XXX implement me.
|
||||
JSObject *holder = GetHolder(wrapper);
|
||||
jsval v;
|
||||
JSBool b;
|
||||
if (!JS_DeletePropertyById2(cx, holder, id, &v) || !JS_ValueToBoolean(cx, v, &b))
|
||||
return false;
|
||||
*bp = !!b;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -519,8 +525,8 @@ template <typename Base, typename Policy>
|
||||
bool
|
||||
XrayWrapper<Base, Policy>::enumerate(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props)
|
||||
{
|
||||
// XXX implement me.
|
||||
return true;
|
||||
JSObject *holder = GetHolder(wrapper);
|
||||
return js::GetPropertyNames(cx, holder, 0, &props);
|
||||
}
|
||||
|
||||
template <typename Base, typename Policy>
|
||||
@ -604,7 +610,6 @@ CrossCompartmentXray::enter(JSContext *cx, JSObject *wrapper, jsid *idp,
|
||||
return false;
|
||||
|
||||
*priv = call;
|
||||
// XXX wrap id
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user