Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a representation for AutoIdVector. #126

Merged
merged 1 commit into from Dec 24, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Introduce a representation for AutoIdVector.

  • Loading branch information
Ms2ger committed Dec 24, 2014
commit 2d86d6fb7ece49ff2f469c391e15e13f2b02af42
@@ -15,15 +15,15 @@ pub struct ProxyTraps {
pub getPropertyDescriptor: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, jsid, bool, *mut JSPropertyDescriptor) -> bool>,
pub getOwnPropertyDescriptor: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, jsid, bool, *mut JSPropertyDescriptor) -> bool>,
pub defineProperty: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, jsid, *mut JSPropertyDescriptor) -> bool>,
pub getOwnPropertyNames: *const u8, //XXX need a representation for AutoIdVector&
pub getOwnPropertyNames: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, *mut AutoIdVector) -> bool>,
pub delete_: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, jsid, *mut bool) -> bool>,
pub enumerate: *const u8, //XXX need a representation for AutoIdVector&
pub enumerate: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, *mut AutoIdVector) -> bool>,

pub has: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, jsid, *mut bool) -> bool>,
pub hasOwn: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, jsid, *mut bool) -> bool>,
pub get: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, *mut JSObject, jsid, *mut JSVal) -> bool>,
pub set: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, *mut JSObject, jsid, bool, *mut JSVal) -> bool>,
pub keys: *const u8, //XXX need a representation for AutoIdVector&
pub keys: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, *mut AutoIdVector) -> bool>,
pub iterate: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, uint, *mut JSVal) -> bool>,

pub call: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, uint, *mut JSVal) -> bool>,
@@ -43,6 +43,8 @@ pub struct ProxyTraps {
pub trace: Option<unsafe extern "C" fn(*mut JSTracer, *mut JSObject)>,
}

pub enum AutoIdVector {}

#[link(name = "jsglue")]
extern { }

@@ -110,4 +112,6 @@ pub fn GetGlobalForObjectCrossCompartment(obj: *mut JSObject) -> *mut JSObject;
pub fn ReportError(cx: *mut JSContext, error: *const libc::c_char);
pub fn IsWrapper(obj: *mut JSObject) -> JSBool;
pub fn UnwrapObject(obj: *mut JSObject, stopAtOuter: JSBool, flags: *mut libc::c_uint) -> *mut JSObject;

pub fn AppendToAutoIdVector(v: *mut AutoIdVector, id: jsid) -> bool;
}
@@ -22,18 +22,18 @@ struct ProxyTraps {
bool (*defineProperty)(JSContext *cx, JSObject *proxy, jsid id,
JSPropertyDescriptor *desc);
bool (*getOwnPropertyNames)(JSContext *cx, JSObject *proxy,
JS::AutoIdVector &props);
JS::AutoIdVector *props);
bool (*delete_)(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
bool (*enumerate)(JSContext *cx, JSObject *proxy,
JS::AutoIdVector &props);
JS::AutoIdVector *props);

bool (*has)(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
bool (*hasOwn)(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
bool (*get)(JSContext *cx, JSObject *proxy, JSObject *receiver,
jsid id, JS::Value *vp);
bool (*set)(JSContext *cx, JSObject *proxy, JSObject *receiver,
jsid id, bool strict, JS::Value *vp);
bool (*keys)(JSContext *cx, JSObject *proxy, JS::AutoIdVector &props);
bool (*keys)(JSContext *cx, JSObject *proxy, JS::AutoIdVector *props);
bool (*iterate)(JSContext *cx, JSObject *proxy, unsigned flags,
JS::Value *vp);

@@ -92,7 +92,7 @@ int HandlerFamily = js::JSSLOT_PROXY_EXTRA + 0 /*JSPROXYSLOT_EXPANDO*/;
virtual bool keys(JSContext* cx, JSObject* proxy, JS::AutoIdVector& props) \
{ \
return mTraps.keys \
? mTraps.keys(cx, proxy, props) \
? mTraps.keys(cx, proxy, &props) \
: _base::keys(cx, proxy, props); \
} \
\
@@ -255,7 +255,7 @@ class WrapperProxyHandler : public js::DirectWrapper
JS::AutoIdVector &props)
{
return mTraps.getOwnPropertyNames ?
mTraps.getOwnPropertyNames(cx, proxy, props) :
mTraps.getOwnPropertyNames(cx, proxy, &props) :
DirectWrapper::getOwnPropertyNames(cx, proxy, props);
}

@@ -270,7 +270,7 @@ class WrapperProxyHandler : public js::DirectWrapper
JS::AutoIdVector &props)
{
return mTraps.enumerate ?
mTraps.enumerate(cx, proxy, props) :
mTraps.enumerate(cx, proxy, &props) :
DirectWrapper::enumerate(cx, proxy, props);
}

@@ -311,7 +311,7 @@ class ForwardingProxyHandler : public js::BaseProxyHandler
virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy,
JS::AutoIdVector &props)
{
return mTraps.getOwnPropertyNames(cx, proxy, props);
return mTraps.getOwnPropertyNames(cx, proxy, &props);
}

virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
@@ -322,7 +322,7 @@ class ForwardingProxyHandler : public js::BaseProxyHandler
virtual bool enumerate(JSContext *cx, JSObject *proxy,
JS::AutoIdVector &props)
{
return mTraps.enumerate(cx, proxy, props);
return mTraps.enumerate(cx, proxy, &props);
}

DEFER_TO_TRAP_OR_BASE_CLASS(BaseProxyHandler)
@@ -558,4 +558,10 @@ UnwrapObject(JSObject* obj, JSBool stopAtOuter, unsigned* flags)
return js::UnwrapObject(obj, stopAtOuter, flags);
}

bool
AppendToAutoIdVector(JS::AutoIdVector* v, jsid id)
{
return v->append(id);
}

} // extern "C"
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.