From 2bf4565c0186027a3e75e7ba7c6fee2a3ba9d06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 18 May 2016 11:56:15 +0200 Subject: [PATCH] geckolib: Support constants in classes Newest bindgen adds support for in-class statics. This patch updates this to take them into account. --- ports/geckolib/gecko_bindings/structs.rs | 177 ++++++++++++++---- .../tools/regen_style_structs.sh | 1 + 2 files changed, 143 insertions(+), 35 deletions(-) diff --git a/ports/geckolib/gecko_bindings/structs.rs b/ports/geckolib/gecko_bindings/structs.rs index 9d0aeb77ddb..f0a6ffffa24 100644 --- a/ports/geckolib/gecko_bindings/structs.rs +++ b/ports/geckolib/gecko_bindings/structs.rs @@ -1,6 +1,7 @@ /* automatically generated by rust-bindgen */ #[derive(Copy, Debug)] +#[repr(C)] pub struct __BindgenUnionField(::std::marker::PhantomData); impl __BindgenUnionField { #[inline] @@ -64,6 +65,8 @@ pub const NS_ERROR_MODULE_BASE_OFFSET: ::std::os::raw::c_uint = 69; pub const MOZ_STRING_WITH_OBSOLETE_API: ::std::os::raw::c_uint = 1; pub const NSID_LENGTH: ::std::os::raw::c_uint = 39; pub const NS_NUMBER_OF_FLAGS_IN_REFCNT: ::std::os::raw::c_uint = 2; +pub const _STL_PAIR_H: ::std::os::raw::c_uint = 1; +pub const _GLIBCXX_UTILITY: ::std::os::raw::c_uint = 1; pub const TWIPS_PER_POINT_INT: ::std::os::raw::c_uint = 20; pub const POINTS_PER_INCH_INT: ::std::os::raw::c_uint = 72; pub const NS_FONT_VARIANT_NORMAL: ::std::os::raw::c_uint = 0; @@ -1544,8 +1547,16 @@ fn bindgen_test_layout_nsAutoString() { assert_eq!(::std::mem::size_of::() , 160usize); assert_eq!(::std::mem::align_of::() , 8usize); } -pub enum Dont_Instantiate_nsTArray_of { } -pub enum Instead_Use_nsTArray_of { } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Dont_Instantiate_nsTArray_of { + pub _phantom0: ::std::marker::PhantomData, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Instead_Use_nsTArray_of { + pub _phantom0: ::std::marker::PhantomData, +} #[repr(C)] #[derive(Debug, Copy)] pub struct nsTArrayElementTraits; @@ -1911,7 +1922,12 @@ pub type nsCID = nsID; * interface. */ pub type nsIID = nsID; -pub enum COMTypeInfo { } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct COMTypeInfo { + pub _phantom0: ::std::marker::PhantomData, + pub _phantom1: ::std::marker::PhantomData, +} /** * Basic component object model interface. Objects which implement * this interface support runtime interface discovery (QueryInterface) @@ -1975,6 +1991,10 @@ fn bindgen_test_layout_nsAutoRefCnt() { assert_eq!(::std::mem::size_of::() , 8usize); assert_eq!(::std::mem::align_of::() , 8usize); } +extern "C" { + #[link_name = "_ZN12nsAutoRefCnt12isThreadSafeE"] + pub static nsAutoRefCnt_consts_isThreadSafe: bool; +} #[repr(C)] #[derive(Debug)] pub struct ThreadSafeAutoRefCnt { @@ -1985,6 +2005,10 @@ fn bindgen_test_layout_ThreadSafeAutoRefCnt() { assert_eq!(::std::mem::size_of::() , 8usize); assert_eq!(::std::mem::align_of::() , 8usize); } +extern "C" { + #[link_name = "_ZN7mozilla20ThreadSafeAutoRefCnt12isThreadSafeE"] + pub static ThreadSafeAutoRefCnt_consts_isThreadSafe: bool; +} /** * There are two ways of implementing QueryInterface, and we use both: * @@ -2040,7 +2064,6 @@ pub struct RefPtr_ConstRemovingRefPtrTraits { #[derive(Debug, Copy, Clone)] pub struct RefPtrGetterAddRefs { pub mTargetSmartPtr: *mut RefPtr, - pub _phantom0: ::std::marker::PhantomData, } #[repr(C)] #[derive(Debug, Copy)] @@ -2175,7 +2198,6 @@ pub struct nsCOMPtr { #[derive(Debug)] pub struct nsGetterAddRefs { pub mTargetSmartPtr: *mut nsCOMPtr, - pub _phantom0: ::std::marker::PhantomData, } #[repr(C)] #[derive(Debug)] @@ -2198,7 +2220,6 @@ pub struct nsAutoPtr_Proxy { #[derive(Debug, Copy, Clone)] pub struct nsAutoPtrGetterTransfers { pub mTargetSmartPtr: *mut nsAutoPtr, - pub _phantom0: ::std::marker::PhantomData, } pub type PLDHashNumber = u32; #[repr(C)] @@ -2225,6 +2246,16 @@ fn bindgen_test_layout_Checker() { assert_eq!(::std::mem::size_of::() , 8usize); assert_eq!(::std::mem::align_of::() , 4usize); } +extern "C" { + #[link_name = "_ZN7Checker5kIdleE"] + pub static Checker_consts_kIdle: ::std::os::raw::c_uint; + #[link_name = "_ZN7Checker6kRead1E"] + pub static Checker_consts_kRead1: ::std::os::raw::c_uint; + #[link_name = "_ZN7Checker8kReadMaxE"] + pub static Checker_consts_kReadMax: ::std::os::raw::c_uint; + #[link_name = "_ZN7Checker6kWriteE"] + pub static Checker_consts_kWrite: ::std::os::raw::c_uint; +} #[repr(C)] pub struct PLDHashTable { pub mOps: *const PLDHashTableOps, @@ -2268,6 +2299,23 @@ fn bindgen_test_layout_PLDHashTable() { assert_eq!(::std::mem::size_of::() , 48usize); assert_eq!(::std::mem::align_of::() , 8usize); } +extern "C" { + #[link_name = "_ZN12PLDHashTable12kMaxCapacityE"] + pub static PLDHashTable_consts_kMaxCapacity: ::std::os::raw::c_uint; + #[link_name = "_ZN12PLDHashTable12kMinCapacityE"] + pub static PLDHashTable_consts_kMinCapacity: ::std::os::raw::c_uint; + #[link_name = "_ZN12PLDHashTable17kMaxInitialLengthE"] + pub static PLDHashTable_consts_kMaxInitialLength: ::std::os::raw::c_uint; + #[link_name = "_ZN12PLDHashTable21kDefaultInitialLengthE"] + pub static PLDHashTable_consts_kDefaultInitialLength: + ::std::os::raw::c_uint; + #[link_name = "_ZN12PLDHashTable9kHashBitsE"] + pub static PLDHashTable_consts_kHashBits: ::std::os::raw::c_uint; + #[link_name = "_ZN12PLDHashTable12kGoldenRatioE"] + pub static PLDHashTable_consts_kGoldenRatio: ::std::os::raw::c_uint; + #[link_name = "_ZN12PLDHashTable14kCollisionFlagE"] + pub static PLDHashTable_consts_kCollisionFlag: ::std::os::raw::c_uint; +} pub type PLDHashHashKey = ::std::option::Option { + pub mRawPtr: *mut T, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct StaticRefPtr { + pub mRawPtr: *mut T, +} +pub enum Zero { } pub enum _cairo_surface { } pub type cairo_surface_t = _cairo_surface; pub enum _cairo_user_data_key { } @@ -2507,28 +2586,13 @@ pub struct piecewise_construct_t; impl ::std::clone::Clone for piecewise_construct_t { fn clone(&self) -> Self { *self } } +pub enum tuple { } #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct pair<_T1, _T2> { pub first: _T1, pub second: _T2, } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct __make_pair_return_impl<_Tp> { - pub _phantom0: ::std::marker::PhantomData<_Tp>, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct __make_pair_return<_Tp> { - pub _phantom0: ::std::marker::PhantomData<_Tp>, -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct __get_pair; -impl ::std::clone::Clone for __get_pair { - fn clone(&self) -> Self { *self } -} pub type Float = f32; #[repr(i8)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] @@ -2785,6 +2849,16 @@ pub enum SideBits { eSideBitsLeftRight = 10, eSideBitsAll = 15, } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tuple_size<_Tp> { + pub _phantom0: ::std::marker::PhantomData<_Tp>, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tuple_element<_Tp> { + pub _phantom0: ::std::marker::PhantomData<_Tp>, +} pub type nscoord = i32; #[repr(C)] pub struct nsIntPoint { @@ -3540,6 +3614,9 @@ pub enum nsCSSPropertyLogicalGroup { eCSSPropertyLogicalGroup_COUNT = 9, } pub type nscolor = u32; +#[repr(i8)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +pub enum nsHexColorType { NoAlpha = 0, AllowAlpha = 1, } /** * This structure precedes the string buffers "we" allocate. It may be the * case that nsTAString::mData does not point to one of these special @@ -3673,12 +3750,14 @@ pub enum nsCSSUnit { eCSSUnit_RGBAColor = 82, eCSSUnit_HexColor = 83, eCSSUnit_ShortHexColor = 84, - eCSSUnit_PercentageRGBColor = 85, - eCSSUnit_PercentageRGBAColor = 86, - eCSSUnit_HSLColor = 87, - eCSSUnit_HSLAColor = 88, - eCSSUnit_Percent = 90, - eCSSUnit_Number = 91, + eCSSUnit_HexColorAlpha = 85, + eCSSUnit_ShortHexColorAlpha = 86, + eCSSUnit_PercentageRGBColor = 87, + eCSSUnit_PercentageRGBAColor = 88, + eCSSUnit_HSLColor = 89, + eCSSUnit_HSLAColor = 90, + eCSSUnit_Percent = 100, + eCSSUnit_Number = 101, eCSSUnit_PhysicalMillimeter = 200, eCSSUnit_ViewportWidth = 700, eCSSUnit_ViewportHeight = 701, @@ -3814,6 +3893,10 @@ fn bindgen_test_layout_nsCSSRect() { assert_eq!(::std::mem::size_of::() , 64usize); assert_eq!(::std::mem::align_of::() , 8usize); } +extern "C" { + #[link_name = "_ZN9nsCSSRect5sidesE"] + pub static mut nsCSSRect_consts_sides: [::std::os::raw::c_void; 4usize]; +} #[repr(C)] #[derive(Debug)] pub struct nsCSSRect_heap { @@ -3975,6 +4058,11 @@ fn bindgen_test_layout_nsCSSCornerSizes() { assert_eq!(::std::mem::size_of::() , 64usize); assert_eq!(::std::mem::align_of::() , 8usize); } +extern "C" { + #[link_name = "_ZN16nsCSSCornerSizes7cornersE"] + pub static mut nsCSSCornerSizes_consts_corners: + [::std::os::raw::c_void; 4usize]; +} pub enum WritingMode { } pub type CounterValue = i32; pub enum NegativeType { } @@ -4174,7 +4262,6 @@ pub struct HandleRefPtr { #[derive(Debug)] pub struct ArenaRefPtr { pub mPtr: RefPtr, - pub _phantom0: ::std::marker::PhantomData, } #[repr(u32)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] @@ -4600,6 +4687,14 @@ fn bindgen_test_layout_nsStyleImageLayers() { assert_eq!(::std::mem::size_of::() , 168usize); assert_eq!(::std::mem::align_of::() , 8usize); } +extern "C" { + #[link_name = "_ZN18nsStyleImageLayers21kBackgroundLayerTableE"] + pub static mut nsStyleImageLayers_consts_kBackgroundLayerTable: + *const nsCSSProperty; + #[link_name = "_ZN18nsStyleImageLayers15kMaskLayerTableE"] + pub static mut nsStyleImageLayers_consts_kMaskLayerTable: + *const nsCSSProperty; +} #[repr(C)] pub struct nsStyleBackground { pub mImage: nsStyleImageLayers, @@ -4740,6 +4835,14 @@ fn bindgen_test_layout_nsStyleList() { assert_eq!(::std::mem::size_of::() , 48usize); assert_eq!(::std::mem::align_of::() , 8usize); } +extern "C" { + #[link_name = "_ZN11nsStyleList14sInitialQuotesE"] + pub static mut nsStyleList_consts_sInitialQuotes: + StaticRefPtr; + #[link_name = "_ZN11nsStyleList11sNoneQuotesE"] + pub static mut nsStyleList_consts_sNoneQuotes: + StaticRefPtr; +} #[repr(C)] #[derive(Debug)] pub struct nsStyleGridLine { @@ -4752,6 +4855,12 @@ fn bindgen_test_layout_nsStyleGridLine() { assert_eq!(::std::mem::size_of::() , 24usize); assert_eq!(::std::mem::align_of::() , 8usize); } +extern "C" { + #[link_name = "_ZN15nsStyleGridLine8kMinLineE"] + pub static nsStyleGridLine_consts_kMinLine: ::std::os::raw::c_int; + #[link_name = "_ZN15nsStyleGridLine8kMaxLineE"] + pub static nsStyleGridLine_consts_kMaxLine: ::std::os::raw::c_int; +} #[repr(C)] #[derive(Debug)] pub struct nsStyleGridTemplate { @@ -5286,6 +5395,10 @@ fn bindgen_test_layout_nsStyleColumn() { assert_eq!(::std::mem::size_of::() , 56usize); assert_eq!(::std::mem::align_of::() , 8usize); } +extern "C" { + #[link_name = "_ZN13nsStyleColumn15kMaxColumnCountE"] + pub static nsStyleColumn_consts_kMaxColumnCount: ::std::os::raw::c_uint; +} #[repr(u32)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum nsStyleSVGPaintType { @@ -5496,12 +5609,6 @@ fn bindgen_test_layout_nsStyleEffects() { assert_eq!(::std::mem::align_of::() , 8usize); } /** - * This class is used to replace nsTArray in order to allow generating rust - * bindings for it, and for related classes. - * - * If this class or some of the following asserts have to change, please ping - * bholley, heycam, or emilio first. - * *
*/ #[repr(C)] diff --git a/ports/geckolib/gecko_bindings/tools/regen_style_structs.sh b/ports/geckolib/gecko_bindings/tools/regen_style_structs.sh index 900822a5ca7..73be220be52 100755 --- a/ports/geckolib/gecko_bindings/tools/regen_style_structs.sh +++ b/ports/geckolib/gecko_bindings/tools/regen_style_structs.sh @@ -98,6 +98,7 @@ export RUST_BACKTRACE=1 -match "utility" \ -match "pair" \ -match "SheetParsingMode.h" \ + -match "StaticPtr.h" \ -blacklist-type "IsDestructibleFallbackImpl" \ -blacklist-type "IsDestructibleFallback" \ -opaque-type "nsIntMargin" \