Skip to content

Commit

Permalink
Auto merge of servo#240 - Ms2ger:NewWindowProxy, r=jdm
Browse files Browse the repository at this point in the history
Introduce a NewWindowProxy API.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/rust-mozjs/240)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Feb 9, 2016
2 parents 62d23de + 6b53c49 commit 374a660
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ extern "C" {
aHandler: *const ::libc::c_void, aClass: *const JSClass,
aSingleton: bool)
-> *mut JSObject;
pub fn NewWindowProxy(aCx: *mut JSContext, aObj: HandleObject,
aHandler: *const ::libc::c_void)
-> *mut JSObject;
pub fn GetProxyExtra(obj: *mut JSObject, slot: u32) -> Value;
pub fn GetProxyPrivate(obj: *mut JSObject) -> Value;
pub fn SetProxyExtra(obj: *mut JSObject, slot: u32, val: Value);
Expand Down
22 changes: 22 additions & 0 deletions src/jsglue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,28 @@ WrapperNew(JSContext* aCx, JS::HandleObject aObj, const void* aHandler,
return js::Wrapper::New(aCx, aObj, (const js::Wrapper*)aHandler, options);
}

void WindowProxyObjectMoved(JSObject*, const JSObject*)
{
abort();
}

const js::Class WindowProxyClass =
PROXY_CLASS_WITH_EXT(
"Proxy",
0, /* additional class flags */
PROXY_MAKE_EXT(
nullptr, /* outerObject */
js::proxy_innerObject,
false, /* isWrappedNative */
WindowProxyObjectMoved
));

JSObject*
NewWindowProxy(JSContext* aCx, JS::HandleObject aObj, const void* aHandler)
{
return WrapperNew(aCx, aObj, aHandler, Jsvalify(&WindowProxyClass), true);
}

jsval
GetProxyExtra(JSObject* obj, uint32_t slot)
{
Expand Down

0 comments on commit 374a660

Please sign in to comment.