Update gecko bindings.

I'm in the process of making the binding generator easier to use, so that we can check it
into the tree. More patches in that direction soon, but I wanted to first just update the
existing bindings to match the state of the world in gecko.
This commit is contained in:
Bobby Holley 2016-03-01 11:02:07 -08:00
parent 3ff5082798
commit c4aa7cd862
3 changed files with 64 additions and 90 deletions

View file

@ -1,25 +1,25 @@
/* automatically generated by rust-bindgen */ /* automatically generated by rust-bindgen */
pub type int64_t = ::libc::c_longlong; pub type int64_t = i64;
pub type uint64_t = ::libc::c_ulonglong; pub type uint64_t = u64;
pub type int_least64_t = int64_t; pub type int_least64_t = int64_t;
pub type uint_least64_t = uint64_t; pub type uint_least64_t = uint64_t;
pub type int_fast64_t = int64_t; pub type int_fast64_t = int64_t;
pub type uint_fast64_t = uint64_t; pub type uint_fast64_t = uint64_t;
pub type int32_t = ::libc::c_int; pub type int32_t = i32;
pub type uint32_t = ::libc::c_uint; pub type uint32_t = u32;
pub type int_least32_t = int32_t; pub type int_least32_t = int32_t;
pub type uint_least32_t = uint32_t; pub type uint_least32_t = uint32_t;
pub type int_fast32_t = int32_t; pub type int_fast32_t = int32_t;
pub type uint_fast32_t = uint32_t; pub type uint_fast32_t = uint32_t;
pub type int16_t = ::libc::c_short; pub type int16_t = i16;
pub type uint16_t = ::libc::c_ushort; pub type uint16_t = u16;
pub type int_least16_t = int16_t; pub type int_least16_t = int16_t;
pub type uint_least16_t = uint16_t; pub type uint_least16_t = uint16_t;
pub type int_fast16_t = int16_t; pub type int_fast16_t = int16_t;
pub type uint_fast16_t = uint16_t; pub type uint_fast16_t = uint16_t;
pub type int8_t = ::libc::c_char; pub type int8_t = ::libc::c_char;
pub type uint8_t = ::libc::c_uchar; pub type uint8_t = u8;
pub type int_least8_t = int8_t; pub type int_least8_t = int8_t;
pub type uint_least8_t = uint8_t; pub type uint_least8_t = uint8_t;
pub type int_fast8_t = int8_t; pub type int_fast8_t = int8_t;
@ -28,43 +28,16 @@ pub type intptr_t = int64_t;
pub type uintptr_t = uint64_t; pub type uintptr_t = uint64_t;
pub type intmax_t = ::libc::c_long; pub type intmax_t = ::libc::c_long;
pub type uintmax_t = ::libc::c_ulong; pub type uintmax_t = ::libc::c_ulong;
#[derive(Clone, Copy)] pub enum RawGeckoNode { }
#[repr(u32)] pub enum RawGeckoElement { }
pub enum Enum_NodeType { pub enum RawGeckoDocument { }
ELEMENT_NODE = 1, pub enum ServoNodeData { }
ATTRIBUTE_NODE = 2, pub enum RawServoStyleSheet { }
TEXT_NODE = 3, pub enum RawServoStyleSet { }
CDATA_SECTION_NODE = 4,
ENTITY_REFERENCE_NODE = 5,
ENTITY_NODE = 6,
PROCESSING_INSTRUCTION_NODE = 7,
COMMENT_NODE = 8,
DOCUMENT_NODE = 9,
DOCUMENT_TYPE_NODE = 10,
DOCUMENT_FRAGMENT_NODE = 11,
NOTATION_NODE = 12,
}
pub enum Struct_RawGeckoNode { }
pub type RawGeckoNode = Struct_RawGeckoNode;
pub enum Struct_RawGeckoElement { }
pub type RawGeckoElement = Struct_RawGeckoElement;
pub enum Struct_RawGeckoDocument { }
pub type RawGeckoDocument = Struct_RawGeckoDocument;
pub enum Struct_ServoNodeData { }
pub type ServoNodeData = Struct_ServoNodeData;
pub enum Struct_ServoArcStyleSheet { }
pub type ServoArcStyleSheet = Struct_ServoArcStyleSheet;
pub enum Struct_ServoStyleSetData { }
pub type ServoStyleSetData = Struct_ServoStyleSetData;
extern "C" { extern "C" {
pub fn Gecko_ElementState(element: *mut RawGeckoElement) -> uint8_t;
pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement,
ns: *const uint8_t, name: *const uint8_t,
length: *mut uint32_t)
-> *const ::libc::c_char;
pub fn Gecko_ChildrenCount(node: *mut RawGeckoNode) -> uint32_t; pub fn Gecko_ChildrenCount(node: *mut RawGeckoNode) -> uint32_t;
pub fn Gecko_GetDocumentElement(document: *mut RawGeckoDocument) pub fn Gecko_NodeIsElement(node: *mut RawGeckoNode) -> i32;
-> *mut RawGeckoElement; pub fn Gecko_GetParentNode(node: *mut RawGeckoNode) -> *mut RawGeckoNode;
pub fn Gecko_GetFirstChild(node: *mut RawGeckoNode) -> *mut RawGeckoNode; pub fn Gecko_GetFirstChild(node: *mut RawGeckoNode) -> *mut RawGeckoNode;
pub fn Gecko_GetLastChild(node: *mut RawGeckoNode) -> *mut RawGeckoNode; pub fn Gecko_GetLastChild(node: *mut RawGeckoNode) -> *mut RawGeckoNode;
pub fn Gecko_GetPrevSibling(node: *mut RawGeckoNode) -> *mut RawGeckoNode; pub fn Gecko_GetPrevSibling(node: *mut RawGeckoNode) -> *mut RawGeckoNode;
@ -79,40 +52,41 @@ extern "C" {
-> *mut RawGeckoElement; -> *mut RawGeckoElement;
pub fn Gecko_GetNextSiblingElement(element: *mut RawGeckoElement) pub fn Gecko_GetNextSiblingElement(element: *mut RawGeckoElement)
-> *mut RawGeckoElement; -> *mut RawGeckoElement;
pub fn Gecko_GetNodeData(node: *mut RawGeckoNode) -> *mut ServoNodeData; pub fn Gecko_GetDocumentElement(document: *mut RawGeckoDocument)
pub fn Gecko_GetParentNode(node: *mut RawGeckoNode) -> *mut RawGeckoNode; -> *mut RawGeckoElement;
pub fn Gecko_LocalName(element: *mut RawGeckoElement, pub fn Gecko_ElementState(element: *mut RawGeckoElement) -> uint8_t;
length: *mut uint32_t) -> *const uint16_t;
pub fn Gecko_IsHTMLElementInHTMLDocument(element: *mut RawGeckoElement) pub fn Gecko_IsHTMLElementInHTMLDocument(element: *mut RawGeckoElement)
-> ::libc::c_int; -> i32;
pub fn Gecko_IsLink(element: *mut RawGeckoElement) -> ::libc::c_int; pub fn Gecko_IsLink(element: *mut RawGeckoElement) -> i32;
pub fn Gecko_IsTextNode(node: *mut RawGeckoNode) -> ::libc::c_int; pub fn Gecko_IsTextNode(node: *mut RawGeckoNode) -> i32;
pub fn Gecko_IsVisitedLink(element: *mut RawGeckoElement) pub fn Gecko_IsVisitedLink(element: *mut RawGeckoElement) -> i32;
-> ::libc::c_int; pub fn Gecko_IsUnvisitedLink(element: *mut RawGeckoElement) -> i32;
pub fn Gecko_IsUnvisitedLink(element: *mut RawGeckoElement) pub fn Gecko_IsRootElement(element: *mut RawGeckoElement) -> i32;
-> ::libc::c_int; pub fn Gecko_GetNodeData(node: *mut RawGeckoNode) -> *mut ServoNodeData;
pub fn Gecko_IsRootElement(element: *mut RawGeckoElement)
-> ::libc::c_int;
pub fn Gecko_Namespace(element: *mut RawGeckoElement,
length: *mut uint32_t) -> *const uint16_t;
pub fn Gecko_NodeIsElement(node: *mut RawGeckoNode) -> ::libc::c_int;
pub fn Gecko_SetNodeData(node: *mut RawGeckoNode, pub fn Gecko_SetNodeData(node: *mut RawGeckoNode,
data: *mut ServoNodeData); data: *mut ServoNodeData);
pub fn Servo_RestyleDocument(doc: *mut RawGeckoDocument,
data: *mut ServoStyleSetData);
pub fn Servo_DropNodeData(data: *mut ServoNodeData); pub fn Servo_DropNodeData(data: *mut ServoNodeData);
pub fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t, pub fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t,
length: uint32_t) length: uint32_t)
-> *mut ServoArcStyleSheet; -> *mut RawServoStyleSheet;
pub fn Servo_AppendStyleSheet(sheet: *mut ServoArcStyleSheet, pub fn Servo_ReleaseStylesheet(sheet: *mut RawServoStyleSheet);
data: *mut ServoStyleSetData); pub fn Servo_AppendStyleSheet(sheet: *mut RawServoStyleSheet,
pub fn Servo_PrependStyleSheet(sheet: *mut ServoArcStyleSheet, set: *mut RawServoStyleSet);
data: *mut ServoStyleSetData); pub fn Servo_PrependStyleSheet(sheet: *mut RawServoStyleSheet,
pub fn Servo_RemoveStyleSheet(sheet: *mut ServoArcStyleSheet, set: *mut RawServoStyleSet);
data: *mut ServoStyleSetData); pub fn Servo_RemoveStyleSheet(sheet: *mut RawServoStyleSheet,
pub fn Servo_StyleSheetHasRules(sheet: *mut ServoArcStyleSheet) set: *mut RawServoStyleSet);
-> ::libc::c_int; pub fn Servo_StyleSheetHasRules(sheet: *mut RawServoStyleSheet) -> i32;
pub fn Servo_DropStylesheet(sheet: *mut ServoArcStyleSheet); pub fn Servo_InitStyleSet() -> *mut RawServoStyleSet;
pub fn Servo_InitStyleSetData() -> *mut ServoStyleSetData; pub fn Servo_DropStyleSet(set: *mut RawServoStyleSet);
pub fn Servo_DropStyleSetData(data: *mut ServoStyleSetData); pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement,
ns: *const uint8_t, name: *const uint8_t,
length: *mut uint32_t)
-> *const ::libc::c_char;
pub fn Gecko_LocalName(element: *mut RawGeckoElement,
length: *mut uint32_t) -> *const uint16_t;
pub fn Gecko_Namespace(element: *mut RawGeckoElement,
length: *mut uint32_t) -> *const uint16_t;
pub fn Servo_RestyleDocument(doc: *mut RawGeckoDocument,
set: *mut RawServoStyleSet);
} }

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use bindings::ServoStyleSetData; use bindings::RawServoStyleSet;
use euclid::Size2D; use euclid::Size2D;
use euclid::size::TypedSize2D; use euclid::size::TypedSize2D;
use num_cpus; use num_cpus;
@ -61,7 +61,7 @@ impl PerDocumentStyleData {
} }
} }
pub fn borrow_mut_from_raw<'a>(data: *mut ServoStyleSetData) -> &'a mut Self { pub fn borrow_mut_from_raw<'a>(data: *mut RawServoStyleSet) -> &'a mut Self {
unsafe { &mut *(data as *mut PerDocumentStyleData) } unsafe { &mut *(data as *mut PerDocumentStyleData) }
} }
} }

View file

@ -6,7 +6,7 @@
use app_units::Au; use app_units::Au;
use bindings::RawGeckoDocument; use bindings::RawGeckoDocument;
use bindings::{ServoArcStyleSheet, ServoNodeData, ServoStyleSetData, uint8_t, uint32_t}; use bindings::{ServoNodeData, RawServoStyleSet, RawServoStyleSheet, uint8_t, uint32_t};
use data::PerDocumentStyleData; use data::PerDocumentStyleData;
use euclid::Size2D; use euclid::Size2D;
use selector_impl::{SharedStyleContext, Stylesheet}; use selector_impl::{SharedStyleContext, Stylesheet};
@ -34,7 +34,7 @@ use wrapper::{GeckoDocument, GeckoNode, NonOpaqueStyleData};
*/ */
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *mut ServoStyleSetData) -> () { pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *mut RawServoStyleSet) -> () {
let document = unsafe { GeckoDocument::from_raw(doc) }; let document = unsafe { GeckoDocument::from_raw(doc) };
let node = match document.root_node() { let node = match document.root_node() {
Some(x) => x, Some(x) => x,
@ -75,7 +75,7 @@ pub extern "C" fn Servo_DropNodeData(data: *mut ServoNodeData) -> () {
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t, pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t,
length: uint32_t) -> *mut ServoArcStyleSheet { length: uint32_t) -> *mut RawServoStyleSheet {
let input = unsafe { from_utf8_unchecked(slice::from_raw_parts(bytes, length as usize)) }; let input = unsafe { from_utf8_unchecked(slice::from_raw_parts(bytes, length as usize)) };
@ -87,7 +87,7 @@ pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t,
} }
} }
fn with_arc_stylesheet<F, Output>(raw: *mut ServoArcStyleSheet, cb: F) -> Output fn with_arc_stylesheet<F, Output>(raw: *mut RawServoStyleSheet, cb: F) -> Output
where F: FnOnce(&Arc<Stylesheet>) -> Output { where F: FnOnce(&Arc<Stylesheet>) -> Output {
let owned = unsafe { consume_arc_stylesheet(raw) }; let owned = unsafe { consume_arc_stylesheet(raw) };
let result = cb(&owned); let result = cb(&owned);
@ -95,13 +95,13 @@ fn with_arc_stylesheet<F, Output>(raw: *mut ServoArcStyleSheet, cb: F) -> Output
result result
} }
unsafe fn consume_arc_stylesheet(raw: *mut ServoArcStyleSheet) -> Arc<Stylesheet> { unsafe fn consume_arc_stylesheet(raw: *mut RawServoStyleSheet) -> Arc<Stylesheet> {
transmute(raw) transmute(raw)
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_AppendStyleSheet(raw_sheet: *mut ServoArcStyleSheet, pub extern "C" fn Servo_AppendStyleSheet(raw_sheet: *mut RawServoStyleSheet,
raw_data: *mut ServoStyleSetData) { raw_data: *mut RawServoStyleSet) {
let data = PerDocumentStyleData::borrow_mut_from_raw(raw_data); let data = PerDocumentStyleData::borrow_mut_from_raw(raw_data);
with_arc_stylesheet(raw_sheet, |sheet| { with_arc_stylesheet(raw_sheet, |sheet| {
data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet)); data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet));
@ -111,8 +111,8 @@ pub extern "C" fn Servo_AppendStyleSheet(raw_sheet: *mut ServoArcStyleSheet,
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_PrependStyleSheet(raw_sheet: *mut ServoArcStyleSheet, pub extern "C" fn Servo_PrependStyleSheet(raw_sheet: *mut RawServoStyleSheet,
raw_data: *mut ServoStyleSetData) { raw_data: *mut RawServoStyleSet) {
let data = PerDocumentStyleData::borrow_mut_from_raw(raw_data); let data = PerDocumentStyleData::borrow_mut_from_raw(raw_data);
with_arc_stylesheet(raw_sheet, |sheet| { with_arc_stylesheet(raw_sheet, |sheet| {
data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet)); data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet));
@ -122,8 +122,8 @@ pub extern "C" fn Servo_PrependStyleSheet(raw_sheet: *mut ServoArcStyleSheet,
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_RemoveStyleSheet(raw_sheet: *mut ServoArcStyleSheet, pub extern "C" fn Servo_RemoveStyleSheet(raw_sheet: *mut RawServoStyleSheet,
raw_data: *mut ServoStyleSetData) { raw_data: *mut RawServoStyleSet) {
let data = PerDocumentStyleData::borrow_mut_from_raw(raw_data); let data = PerDocumentStyleData::borrow_mut_from_raw(raw_data);
with_arc_stylesheet(raw_sheet, |sheet| { with_arc_stylesheet(raw_sheet, |sheet| {
data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet)); data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet));
@ -132,27 +132,27 @@ pub extern "C" fn Servo_RemoveStyleSheet(raw_sheet: *mut ServoArcStyleSheet,
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_StyleSheetHasRules(raw_sheet: *mut ServoArcStyleSheet) -> ::libc::c_int { pub extern "C" fn Servo_StyleSheetHasRules(raw_sheet: *mut RawServoStyleSheet) -> ::libc::c_int {
with_arc_stylesheet(raw_sheet, |sheet| if sheet.rules.is_empty() { 0 } else { 1 }) with_arc_stylesheet(raw_sheet, |sheet| if sheet.rules.is_empty() { 0 } else { 1 })
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_DropStylesheet(sheet: *mut ServoArcStyleSheet) -> () { pub extern "C" fn Servo_ReleaseStylesheet(sheet: *mut RawServoStyleSheet) -> () {
unsafe { unsafe {
let _ = consume_arc_stylesheet(sheet); let _ = consume_arc_stylesheet(sheet);
} }
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_InitStyleSetData() -> *mut ServoStyleSetData { pub extern "C" fn Servo_InitStyleSet() -> *mut RawServoStyleSet {
let data = Box::new(PerDocumentStyleData::new()); let data = Box::new(PerDocumentStyleData::new());
Box::into_raw(data) as *mut ServoStyleSetData Box::into_raw(data) as *mut RawServoStyleSet
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_DropStyleSetData(data: *mut ServoStyleSetData) -> () { pub extern "C" fn Servo_DropStyleSet(data: *mut RawServoStyleSet) -> () {
unsafe { unsafe {
let _ = Box::<PerDocumentStyleData>::from_raw(data as *mut PerDocumentStyleData); let _ = Box::<PerDocumentStyleData>::from_raw(data as *mut PerDocumentStyleData);
} }