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

Lots of work on bindings #397

Merged
merged 10 commits into from Apr 24, 2013
Next

Generate DOMParser bindings.

  • Loading branch information
jdm committed Apr 23, 2013
commit 886eb35dfde369cbba6b98e210a5b09c045990ec
@@ -3,9 +3,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use content::content_task::task_from_context;
use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, OpaqueBindingReference};
use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
use dom::bindings::codegen::ClientRectBinding;
use js::jsapi::{JSObject, JSContext};
use js::jsapi::{JSObject, JSContext, JSVal};
use js::glue::bindgen::RUST_OBJECT_TO_JSVAL;

pub trait ClientRect {
fn Top(&self) -> f32;
@@ -62,19 +63,35 @@ impl CacheableWrapper for ClientRectImpl {
unsafe { cast::transmute(&self.wrapper) }
}

fn wrap_object_unique(~self, cx: *JSContext, scope: *JSObject) -> *JSObject {
let mut unused = false;
ClientRectBinding::Wrap(cx, scope, self, &mut unused)
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"nyi")
}

fn wrap_object_shared(@self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"nyi")
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
let mut unused = false;
ClientRectBinding::Wrap(cx, scope, self, &mut unused)
}
}

impl BindingObject for ClientRectImpl {
fn GetParentObject(&self, cx: *JSContext) -> OpaqueBindingReference {
fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
let content = task_from_context(cx);
unsafe { OpaqueBindingReference(Right((*content).window.get() as @CacheableWrapper)) }
unsafe { (*content).window.get() as @mut CacheableWrapper }
}
}
}

impl DerivedWrapper for ClientRectImpl {
fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, _vp: *mut JSVal) -> i32 {
fail!(~"nyi")
}

fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
let obj = self.wrap_object_shared(cx, scope);
if obj.is_null() {
return 0;
} else {
unsafe { *vp = RUST_OBJECT_TO_JSVAL(obj) };
return 1;
}
}
}
@@ -5,13 +5,13 @@
use content::content_task::task_from_context;
use dom::bindings::clientrect::{ClientRect, ClientRectImpl};
use dom::bindings::codegen::ClientRectListBinding;
use dom::bindings::utils::{WrapperCache, CacheableWrapper, BindingObject, OpaqueBindingReference};
use dom::bindings::utils::{WrapperCache, CacheableWrapper, BindingObject};
use js::jsapi::{JSObject, JSContext};

pub trait ClientRectList {
fn Length(&self) -> u32;
fn Item(&self, index: u32) -> Option<~ClientRectImpl>;
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<~ClientRectImpl>;
fn Item(&self, index: u32) -> Option<@mut ClientRectImpl>;
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<@mut ClientRectImpl>;
}

pub struct ClientRectListImpl {
@@ -24,16 +24,16 @@ impl ClientRectList for ClientRectListImpl {
self.rects.len() as u32
}

fn Item(&self, index: u32) -> Option<~ClientRectImpl> {
fn Item(&self, index: u32) -> Option<@mut ClientRectImpl> {
if index < self.rects.len() as u32 {
let (top, bottom, left, right) = self.rects[index];
Some(~ClientRect(top, bottom, left, right))
Some(@mut ClientRect(top, bottom, left, right))
} else {
None
}
}

fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<~ClientRectImpl> {
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<@mut ClientRectImpl> {
*found = index < self.rects.len() as u32;
self.Item(index)
}
@@ -53,19 +53,19 @@ impl CacheableWrapper for ClientRectListImpl {
unsafe { cast::transmute(&self.wrapper) }
}

fn wrap_object_unique(~self, cx: *JSContext, scope: *JSObject) -> *JSObject {
let mut unused = false;
ClientRectListBinding::Wrap(cx, scope, self, &mut unused)
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"nyi")
}

fn wrap_object_shared(@self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"nyi")
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
let mut unused = false;
ClientRectListBinding::Wrap(cx, scope, self, &mut unused)
}
}

impl BindingObject for ClientRectListImpl {
fn GetParentObject(&self, cx: *JSContext) -> OpaqueBindingReference {
fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
let content = task_from_context(cx);
unsafe { OpaqueBindingReference(Right((*content).window.get() as @CacheableWrapper)) }
unsafe { (*content).window.get() as @mut CacheableWrapper }
}
}
}
@@ -116,14 +116,13 @@ DOMInterfaces = {
'ClientRect': [
{
'nativeType': 'ClientRectImpl',
'pointerType': '@mut '
}],

'ClientRectList': [
{
'nativeType': 'ClientRectListImpl',
#'headerFile': 'nsClientRect.h',
#'prefable': True,
#'resultNotAddRefed': [ 'item' ]
'pointerType': '@mut '
}],

'CSS2Properties': {
@@ -136,13 +135,10 @@ DOMInterfaces = {
'prefable': True
},

'Document': [
{
'nativeType': 'nsIDocument',
'DOMParser': {
'nativeType': 'DOMParser',
'pointerType': '@mut '
},
{
'workers': True,
}],

'DOMSettableTokenList': [
{
@@ -213,8 +209,7 @@ DOMInterfaces = {
'HTMLCollection': [
{
'nativeType': 'HTMLCollection',
#'prefable': True,
#'resultNotAddRefed': [ 'item' ]
'pointerType': '@mut '
}],

'HTMLOptionsCollection': [
@@ -516,9 +511,9 @@ addExternalHTMLElement('HTMLOptGroupElement')
addExternalHTMLElement('HTMLVideoElement')
addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h')
addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h')
#addExternalIface('ClientRect')
addExternalIface('CSSRule')
addExternalIface('CSSValue')
addExternalIface('Document', nativeType='Document', pointerType='@mut ')
addExternalIface('DOMStringList', nativeType='nsDOMStringList',
headerFile='nsDOMLists.h')
addExternalIface('Element', nativeType='AbstractNode', pointerType='')
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.