diff --git a/hubbub.rc b/hubbub.rc index 8071c0e..5989db4 100644 --- a/hubbub.rc +++ b/hubbub.rc @@ -7,13 +7,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[crate_id = "github.com/mozilla-servo/rust-hubbub#hubbub:0.1"]; -#[crate_type = "lib"]; -#[crate_type = "dylib"]; -#[crate_type = "rlib"]; +#![crate_id = "github.com/mozilla-servo/rust-hubbub#hubbub:0.1"] +#![crate_type = "lib"] +#![crate_type = "dylib"] +#![crate_type = "rlib"] -#[feature(phase)]; -#[phase(syntax, link)] extern crate log; +#![feature(phase)] + +extern crate libc; +#[phase(syntax, link)] +extern crate log; pub mod hubbub; pub mod ll; diff --git a/hubbub.rs b/hubbub.rs index 3d543f4..757b66d 100644 --- a/hubbub.rs +++ b/hubbub.rs @@ -9,9 +9,9 @@ // High-level bindings to the Hubbub HTML5 parser. +use libc; +use libc::{c_void, size_t}; use std::cast; -use std::libc; -use std::libc::{c_void, size_t}; use std::ptr::null; use ll; @@ -55,25 +55,25 @@ pub struct Tag { pub type NodeDataPtr = uint; pub struct TreeHandler<'a> { - create_comment: 'a |data: ~str| -> NodeDataPtr, - create_doctype: 'a |doctype: ~Doctype| -> NodeDataPtr, - create_element: 'a |tag: ~Tag| -> NodeDataPtr, - create_text: 'a |data: ~str| -> NodeDataPtr, - ref_node: 'a |node: NodeDataPtr|, - unref_node: 'a |node: NodeDataPtr|, - append_child: 'a |parent: NodeDataPtr, child: NodeDataPtr| -> NodeDataPtr, - insert_before: 'a |parent: NodeDataPtr, child: NodeDataPtr| -> NodeDataPtr, - remove_child: 'a |parent: NodeDataPtr, child: NodeDataPtr| -> NodeDataPtr, - clone_node: 'a |node: NodeDataPtr, deep: bool| -> NodeDataPtr, - reparent_children: 'a |node: NodeDataPtr, new_parent: NodeDataPtr| -> NodeDataPtr, - get_parent: 'a |node: NodeDataPtr, element_only: bool| -> NodeDataPtr, - has_children: 'a |node: NodeDataPtr| -> bool, - form_associate: 'a |form: NodeDataPtr, node: NodeDataPtr|, - add_attributes: 'a |node: NodeDataPtr, attributes: ~[Attribute]|, - set_quirks_mode: 'a |mode: QuirksMode|, - encoding_change: 'a |encname: ~str|, - complete_script: 'a |script: NodeDataPtr|, - complete_style: 'a |style: NodeDataPtr|, + create_comment: |data: ~str|: 'a -> NodeDataPtr, + create_doctype: |doctype: ~Doctype|: 'a -> NodeDataPtr, + create_element: |tag: ~Tag|: 'a -> NodeDataPtr, + create_text: |data: ~str|: 'a -> NodeDataPtr, + ref_node: |node: NodeDataPtr|: 'a, + unref_node: |node: NodeDataPtr|: 'a, + append_child: |parent: NodeDataPtr, child: NodeDataPtr|: 'a -> NodeDataPtr, + insert_before: |parent: NodeDataPtr, child: NodeDataPtr|: 'a -> NodeDataPtr, + remove_child: |parent: NodeDataPtr, child: NodeDataPtr|: 'a -> NodeDataPtr, + clone_node: |node: NodeDataPtr, deep: bool|: 'a -> NodeDataPtr, + reparent_children: |node: NodeDataPtr, new_parent: NodeDataPtr|: 'a -> NodeDataPtr, + get_parent: |node: NodeDataPtr, element_only: bool|: 'a -> NodeDataPtr, + has_children: |node: NodeDataPtr|: 'a -> bool, + form_associate: |form: NodeDataPtr, node: NodeDataPtr|: 'a, + add_attributes: |node: NodeDataPtr, attributes: ~[Attribute]|: 'a, + set_quirks_mode: |mode: QuirksMode|: 'a, + encoding_change: |encname: ~str|: 'a, + complete_script: |script: NodeDataPtr|: 'a, + complete_style: |style: NodeDataPtr|: 'a, } pub struct TreeHandlerPair<'a> { @@ -208,8 +208,8 @@ impl<'a> Parser<'a> { pub mod tree_callbacks { + use libc::{c_void, c_char}; use std::cast; - use std::libc::{c_void, c_char}; use std::ptr::RawPtr; use std::slice; use std::str; diff --git a/ll.rs b/ll.rs index 6f6a860..1c642ee 100644 --- a/ll.rs +++ b/ll.rs @@ -7,7 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::libc::{c_int, c_void, size_t, c_char}; +use libc::{c_int, c_void, size_t, c_char}; // errors.h @@ -69,7 +69,7 @@ pub struct ParserOptParamsContentModel { } pub mod parser { - use std::libc::{c_void, size_t, c_char}; + use libc::{c_void, size_t, c_char}; use super::{Parser, Error, ParserOptType, CharsetSource}; #[nolink] @@ -93,26 +93,26 @@ pub mod parser { // tree.h pub struct TreeHandler { - create_comment: extern "C" fn(*c_void, *String, *mut *c_void) -> Error, - create_doctype: extern "C" fn(*c_void, *Doctype, *mut *c_void) -> Error, - create_element: extern "C" fn(*c_void, *Tag, *mut *c_void) -> Error, - create_text: extern "C" fn(*c_void, *String, *mut *c_void) -> Error, - ref_node: extern "C" fn(*c_void, *c_void) -> Error, - unref_node: extern "C" fn(*c_void, *c_void) -> Error, - append_child: extern "C" fn(*c_void, *c_void, *c_void, *mut *c_void) -> Error, - insert_before: extern "C" fn(*c_void, *c_void, *c_void, *mut *c_void) -> Error, - remove_child: extern "C" fn(*c_void, *c_void, *c_void, *mut *c_void) -> Error, - clone_node: extern "C" fn(*c_void, *c_void, bool, *mut *c_void) -> Error, - reparent_children: extern "C" fn(*c_void, *c_void, *c_void) -> Error, - get_parent: extern "C" fn(*c_void, *c_void, bool, *mut *c_void) -> Error, - has_children: extern "C" fn(*c_void, *c_void, *mut bool) -> Error, - form_associate: extern "C" fn(*c_void, *c_void, *c_void) -> Error, - add_attributes: extern "C" fn(*c_void, *c_void, *Attribute, u32) -> Error, - set_quirks_mode: extern "C" fn(*c_void, QuirksMode) -> Error, - encoding_change: extern "C" fn(*c_void, *c_char) -> Error, - complete_script: extern "C" fn(*c_void, *c_void) -> Error, - complete_style: extern "C" fn(*c_void, *c_void) -> Error, - ctx: *c_void, + pub create_comment: extern "C" fn(*c_void, *String, *mut *c_void) -> Error, + pub create_doctype: extern "C" fn(*c_void, *Doctype, *mut *c_void) -> Error, + pub create_element: extern "C" fn(*c_void, *Tag, *mut *c_void) -> Error, + pub create_text: extern "C" fn(*c_void, *String, *mut *c_void) -> Error, + pub ref_node: extern "C" fn(*c_void, *c_void) -> Error, + pub unref_node: extern "C" fn(*c_void, *c_void) -> Error, + pub append_child: extern "C" fn(*c_void, *c_void, *c_void, *mut *c_void) -> Error, + pub insert_before: extern "C" fn(*c_void, *c_void, *c_void, *mut *c_void) -> Error, + pub remove_child: extern "C" fn(*c_void, *c_void, *c_void, *mut *c_void) -> Error, + pub clone_node: extern "C" fn(*c_void, *c_void, bool, *mut *c_void) -> Error, + pub reparent_children: extern "C" fn(*c_void, *c_void, *c_void) -> Error, + pub get_parent: extern "C" fn(*c_void, *c_void, bool, *mut *c_void) -> Error, + pub has_children: extern "C" fn(*c_void, *c_void, *mut bool) -> Error, + pub form_associate: extern "C" fn(*c_void, *c_void, *c_void) -> Error, + pub add_attributes: extern "C" fn(*c_void, *c_void, *Attribute, u32) -> Error, + pub set_quirks_mode: extern "C" fn(*c_void, QuirksMode) -> Error, + pub encoding_change: extern "C" fn(*c_void, *c_char) -> Error, + pub complete_script: extern "C" fn(*c_void, *c_void) -> Error, + pub complete_style: extern "C" fn(*c_void, *c_void) -> Error, + pub ctx: *c_void, } // types.h @@ -156,36 +156,36 @@ pub static NS_XML: c_int = 5; pub static NS_XMLNS: c_int = 6; pub struct String { - ptr: *u8, - len: size_t + pub ptr: *u8, + pub len: size_t } pub struct Attribute { - ns: NS, - name: String, - value: String, + pub ns: NS, + pub name: String, + pub value: String, } pub struct Doctype { - name: String, - public_missing: bool, - public_id: String, - system_missing: bool, - system_id: String, - force_quirks: bool, + pub name: String, + pub public_missing: bool, + pub public_id: String, + pub system_missing: bool, + pub system_id: String, + pub force_quirks: bool, } pub struct Tag { - ns: NS, - name: String, - n_attributes: u32, - attributes: *Attribute, - self_closing: bool, + pub ns: NS, + pub name: String, + pub n_attributes: u32, + pub attributes: *Attribute, + pub self_closing: bool, } // Token data pub struct Token { - token_type: TokenType, - data: u8, // union: one of Doctype, Tag, Comment (string), or Character (string) + pub token_type: TokenType, + pub data: u8, // union: one of Doctype, Tag, Comment (string), or Character (string) }