diff options
author | Josh Matthews <josh@joshmatthews.net> | 2013-08-30 13:13:46 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2013-08-30 13:13:46 -0400 |
commit | 75f1cbd76fadeb31a987647cb6436c0fdf1c9ce6 (patch) | |
tree | 834390ec88c0fb1de908424779ecb720526b3f56 /src/components/script/dom/bindings/node.rs | |
parent | 7584aee98e71fa60a136b57b1611a376318646ef (diff) | |
download | servo-75f1cbd76fadeb31a987647cb6436c0fdf1c9ce6.tar.gz servo-75f1cbd76fadeb31a987647cb6436c0fdf1c9ce6.zip |
Remove all handwritten bindings code.
Diffstat (limited to 'src/components/script/dom/bindings/node.rs')
-rw-r--r-- | src/components/script/dom/bindings/node.rs | 118 |
1 files changed, 3 insertions, 115 deletions
diff --git a/src/components/script/dom/bindings/node.rs b/src/components/script/dom/bindings/node.rs index ffd072493d9..26c0d29a528 100644 --- a/src/components/script/dom/bindings/node.rs +++ b/src/components/script/dom/bindings/node.rs @@ -2,66 +2,17 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use dom::bindings::element; -use dom::bindings::utils; -use dom::bindings::utils::{CacheableWrapper, WrapperCache, DerivedWrapper}; +use dom::bindings::utils::{CacheableWrapper, WrapperCache}; use dom::element::*; use dom::types::*; -use dom::node::{AbstractNode, Node, ElementNodeTypeId, TextNodeTypeId, CommentNodeTypeId}; +use dom::node::{AbstractNode, ElementNodeTypeId, TextNodeTypeId, CommentNodeTypeId}; use dom::node::{DoctypeNodeTypeId, ScriptView}; use std::cast; -use std::libc::c_uint; use std::ptr; -use std::ptr::null; -use js::jsapi::*; -use js::jsapi::{JSContext, JSVal, JSObject, JSBool, JSPropertySpec}; -use js::jsapi::{JSPropertyOpWrapper, JSStrictPropertyOpWrapper}; -use js::jsval::{INT_TO_JSVAL}; -use js::rust::{Compartment}; -use js::{JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL}; -use js::{JS_THIS_OBJECT, JSPROP_NATIVE_ACCESSORS}; +use js::jsapi::{JSContext, JSObject}; use servo_util::tree::TreeNodeRef; -pub fn init(compartment: @mut Compartment) { - let obj = utils::define_empty_prototype(~"Node", None, compartment); - - let attrs = @~[ - JSPropertySpec { - name: compartment.add_name(~"firstChild"), - tinyid: 0, - flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, - getter: JSPropertyOpWrapper {op: getFirstChild, info: null()}, - setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}, - - JSPropertySpec { - name: compartment.add_name(~"nextSibling"), - tinyid: 0, - flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, - getter: JSPropertyOpWrapper {op: getNextSibling, info: null()}, - setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}, - - JSPropertySpec { - name: compartment.add_name(~"nodeType"), - tinyid: 0, - flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, - getter: JSPropertyOpWrapper {op: getNodeType, info: null()}, - setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}, - - JSPropertySpec { - name: null(), - tinyid: 0, - flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, - getter: JSPropertyOpWrapper {op: null(), info: null()}, - setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}]; - compartment.global_props.push(attrs); - do attrs.as_imm_buf |specs, _len| { - unsafe { - JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs); - } - } -} - macro_rules! generate_element( ($name: path) => ({ let node: @mut $name = unsafe { cast::transmute(node.raw_object()) }; @@ -135,69 +86,6 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject } } -pub unsafe fn unwrap(obj: *JSObject) -> AbstractNode<ScriptView> { - let raw = utils::unwrap::<*mut Node<ScriptView>>(obj); - AbstractNode::from_raw(raw) -} - -extern fn getFirstChild(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool { - unsafe { - let obj = JS_THIS_OBJECT(cx, cast::transmute(vp)); - if obj.is_null() { - return 0; - } - - let node = unwrap(obj); - let rval = do node.with_mut_base |base| { - base.getFirstChild() - }; - match rval { - Some(n) => { - n.wrap(cx, ptr::null(), vp); //XXXjdm pass a real scope - } - None => *vp = JSVAL_NULL - }; - } - return 1; -} - -extern fn getNextSibling(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool { - unsafe { - let obj = JS_THIS_OBJECT(cx, cast::transmute(vp)); - if obj.is_null() { - return 0; - } - - let node = unwrap(obj); - let rval = do node.with_mut_base |base| { - base.getNextSibling() - }; - match rval { - Some(n) => { - n.wrap(cx, ptr::null(), vp); //XXXjdm pass a real scope - } - None => *vp = JSVAL_NULL - }; - } - return 1; -} - -extern fn getNodeType(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool { - unsafe { - let obj = JS_THIS_OBJECT(cx, cast::transmute(vp)); - if obj.is_null() { - return 0; - } - - let node = unwrap(obj); - let rval = do node.with_base |base| { - base.getNodeType() - }; - *vp = INT_TO_JSVAL(rval); - } - return 1; -} - impl CacheableWrapper for AbstractNode<ScriptView> { fn get_wrappercache(&mut self) -> &mut WrapperCache { do self.with_mut_base |base| { |