mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #10556 - bholley:keyword_setters, r=SimonSapin
Automatically generate Gecko style struct setters for most keyword properties <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10556) <!-- Reviewable:end -->
This commit is contained in:
commit
e21e5551ec
6 changed files with 278 additions and 147 deletions
|
@ -1,24 +1,10 @@
|
|||
/* automatically generated by rust-bindgen */
|
||||
|
||||
pub enum nsIAtom { }
|
||||
pub enum nsINode { }
|
||||
pub type RawGeckoNode = nsINode;
|
||||
pub enum Element { }
|
||||
pub type RawGeckoElement = Element;
|
||||
pub enum nsIDocument { }
|
||||
pub type RawGeckoDocument = nsIDocument;
|
||||
pub enum ServoNodeData { }
|
||||
pub enum ServoComputedValues { }
|
||||
pub enum RawServoStyleSheet { }
|
||||
pub enum RawServoStyleSet { }
|
||||
|
||||
// Temporary manual hack. This will be fixed soon in bindgen.
|
||||
use gecko_style_structs::nsStyleFont;
|
||||
use gecko_style_structs::nsStyleColor;
|
||||
use gecko_style_structs::nsStyleList;
|
||||
use gecko_style_structs::nsStyleText;
|
||||
use gecko_style_structs::nsStyleVisibility;
|
||||
use gecko_style_structs::nsStyleQuotes;
|
||||
use gecko_style_structs::nsStyleUserInterface;
|
||||
use gecko_style_structs::nsStyleTableBorder;
|
||||
use gecko_style_structs::nsStyleSVG;
|
||||
|
@ -37,7 +23,20 @@ use gecko_style_structs::nsStyleOutline;
|
|||
use gecko_style_structs::nsStyleXUL;
|
||||
use gecko_style_structs::nsStyleSVGReset;
|
||||
use gecko_style_structs::nsStyleColumn;
|
||||
use gecko_style_structs::nsStyleEffects;
|
||||
|
||||
|
||||
pub enum nsIAtom { }
|
||||
pub enum nsINode { }
|
||||
pub type RawGeckoNode = nsINode;
|
||||
pub enum Element { }
|
||||
pub type RawGeckoElement = Element;
|
||||
pub enum nsIDocument { }
|
||||
pub type RawGeckoDocument = nsIDocument;
|
||||
pub enum ServoNodeData { }
|
||||
pub enum ServoComputedValues { }
|
||||
pub enum RawServoStyleSheet { }
|
||||
pub enum RawServoStyleSet { }
|
||||
extern "C" {
|
||||
pub fn Gecko_ChildrenCount(node: *mut RawGeckoNode) -> u32;
|
||||
pub fn Gecko_NodeIsElement(node: *mut RawGeckoNode) -> bool;
|
||||
|
@ -121,10 +120,6 @@ extern "C" {
|
|||
other:
|
||||
*const nsStyleVisibility);
|
||||
pub fn Gecko_Destroy_nsStyleVisibility(ptr: *mut nsStyleVisibility);
|
||||
pub fn Gecko_Construct_nsStyleQuotes(ptr: *mut nsStyleQuotes);
|
||||
pub fn Gecko_CopyConstruct_nsStyleQuotes(ptr: *mut nsStyleQuotes,
|
||||
other: *const nsStyleQuotes);
|
||||
pub fn Gecko_Destroy_nsStyleQuotes(ptr: *mut nsStyleQuotes);
|
||||
pub fn Gecko_Construct_nsStyleUserInterface(ptr:
|
||||
*mut nsStyleUserInterface);
|
||||
pub fn Gecko_CopyConstruct_nsStyleUserInterface(ptr:
|
||||
|
@ -205,4 +200,8 @@ extern "C" {
|
|||
pub fn Gecko_CopyConstruct_nsStyleColumn(ptr: *mut nsStyleColumn,
|
||||
other: *const nsStyleColumn);
|
||||
pub fn Gecko_Destroy_nsStyleColumn(ptr: *mut nsStyleColumn);
|
||||
pub fn Gecko_Construct_nsStyleEffects(ptr: *mut nsStyleEffects);
|
||||
pub fn Gecko_CopyConstruct_nsStyleEffects(ptr: *mut nsStyleEffects,
|
||||
other: *const nsStyleEffects);
|
||||
pub fn Gecko_Destroy_nsStyleEffects(ptr: *mut nsStyleEffects);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,8 @@ try:
|
|||
style_template.render(PRODUCT='gecko')
|
||||
|
||||
geckolib_template = Template(filename=os.environ['GECKOLIB_TEMPLATE'], input_encoding='utf8')
|
||||
output = geckolib_template.render(STYLE_STRUCTS = style_template.module.STYLE_STRUCTS)
|
||||
output = geckolib_template.render(STYLE_STRUCTS = style_template.module.STYLE_STRUCTS,
|
||||
to_rust_ident = style_template.module.to_rust_ident)
|
||||
print(output.encode('utf8'))
|
||||
except:
|
||||
sys.stderr.write(exceptions.text_error_template().render().encode('utf8'))
|
||||
|
|
|
@ -1314,7 +1314,6 @@ pub enum nsresult {
|
|||
NS_ERROR_SIGNED_APP_MANIFEST_INVALID = -2140471295,
|
||||
NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR = -2140405759,
|
||||
NS_ERROR_DOM_ANIM_NO_TARGET_ERR = -2140405758,
|
||||
NS_ERROR_DOM_ANIM_TARGET_NOT_IN_DOC_ERR = -2140405757,
|
||||
NS_ERROR_DOM_PUSH_INVALID_REGISTRATION_ERR = -2140340223,
|
||||
NS_ERROR_DOM_PUSH_DENIED_ERR = -2140340222,
|
||||
NS_ERROR_DOM_PUSH_ABORT_ERR = -2140340221,
|
||||
|
@ -1529,6 +1528,8 @@ fn bindgen_test_layout_nsAutoString() {
|
|||
assert_eq!(::std::mem::size_of::<nsAutoString>() , 160usize);
|
||||
assert_eq!(::std::mem::align_of::<nsAutoString>() , 8usize);
|
||||
}
|
||||
pub enum Dont_Instantiate_nsTArray_of { }
|
||||
pub enum Instead_Use_nsTArray_of { }
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct nsTArrayElementTraits<> {
|
||||
|
@ -1887,6 +1888,7 @@ pub type nsCID = nsID;
|
|||
* interface.
|
||||
*/
|
||||
pub type nsIID = nsID;
|
||||
pub enum COMTypeInfo { }
|
||||
/**
|
||||
* Basic component object model interface. Objects which implement
|
||||
* this interface support runtime interface discovery (QueryInterface)
|
||||
|
@ -1998,6 +2000,19 @@ pub struct RefPtr<T> {
|
|||
}
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct RefPtr_Proxy<T, R, Args> {
|
||||
pub mRawPtr: *mut T,
|
||||
pub _phantom0: ::std::marker::PhantomData<R>,
|
||||
pub _phantom1: ::std::marker::PhantomData<Args>,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct RefPtr_ConstRemovingRefPtrTraits<T, U> {
|
||||
pub _phantom0: ::std::marker::PhantomData<T>,
|
||||
pub _phantom1: ::std::marker::PhantomData<U>,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct RefPtrGetterAddRefs<T> {
|
||||
pub mTargetSmartPtr: *mut RefPtr<T>,
|
||||
pub _phantom0: ::std::marker::PhantomData<T>,
|
||||
|
@ -2145,6 +2160,13 @@ pub struct nsAutoPtr_Ptr<T> {
|
|||
}
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct nsAutoPtr_Proxy<T, R, Args> {
|
||||
pub mRawPtr: *mut T,
|
||||
pub _phantom0: ::std::marker::PhantomData<R>,
|
||||
pub _phantom1: ::std::marker::PhantomData<Args>,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct nsAutoPtrGetterTransfers<T> {
|
||||
pub mTargetSmartPtr: *mut nsAutoPtr<T>,
|
||||
pub _phantom0: ::std::marker::PhantomData<T>,
|
||||
|
@ -4176,7 +4198,6 @@ fn bindgen_test_layout_nsCSSShadowArray() {
|
|||
#[repr(C)]
|
||||
pub struct nsStyleBorder {
|
||||
pub mBorderColors: *mut *mut nsBorderColors,
|
||||
pub mBoxShadow: RefPtr<nsCSSShadowArray>,
|
||||
pub mBorderRadius: nsStyleCorners,
|
||||
pub mBorderImageSource: nsStyleImage,
|
||||
pub mBorderImageSlice: nsStyleSides,
|
||||
|
@ -4195,7 +4216,7 @@ pub struct nsStyleBorder {
|
|||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_nsStyleBorder() {
|
||||
assert_eq!(::std::mem::size_of::<nsStyleBorder>() , 312usize);
|
||||
assert_eq!(::std::mem::size_of::<nsStyleBorder>() , 304usize);
|
||||
assert_eq!(::std::mem::align_of::<nsStyleBorder>() , 8usize);
|
||||
}
|
||||
#[repr(C)]
|
||||
|
@ -4214,17 +4235,34 @@ fn bindgen_test_layout_nsStyleOutline() {
|
|||
assert_eq!(::std::mem::size_of::<nsStyleOutline>() , 112usize);
|
||||
assert_eq!(::std::mem::align_of::<nsStyleOutline>() , 8usize);
|
||||
}
|
||||
/**
|
||||
* An object that allows sharing of arrays that store 'quotes' property
|
||||
* values. This is particularly important for inheritance, where we want
|
||||
* to share the same 'quotes' value with a parent style context.
|
||||
*/
|
||||
#[repr(C)]
|
||||
pub struct nsStyleQuoteValues {
|
||||
pub mRefCnt: nsAutoRefCnt,
|
||||
pub _mOwningThread: nsAutoOwningThread,
|
||||
pub mQuotePairs: u64,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_nsStyleQuoteValues() {
|
||||
assert_eq!(::std::mem::size_of::<nsStyleQuoteValues>() , 24usize);
|
||||
assert_eq!(::std::mem::align_of::<nsStyleQuoteValues>() , 8usize);
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct nsStyleList {
|
||||
pub mListStylePosition: u8,
|
||||
pub mListStyleType: nsString,
|
||||
pub mCounterStyle: RefPtr<CounterStyle>,
|
||||
pub mListStyleImage: RefPtr<imgRequestProxy>,
|
||||
pub mQuotes: RefPtr<nsStyleQuoteValues>,
|
||||
pub mImageRegion: nsRect,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_nsStyleList() {
|
||||
assert_eq!(::std::mem::size_of::<nsStyleList>() , 56usize);
|
||||
assert_eq!(::std::mem::size_of::<nsStyleList>() , 64usize);
|
||||
assert_eq!(::std::mem::align_of::<nsStyleList>() , 8usize);
|
||||
}
|
||||
#[repr(C)]
|
||||
|
@ -4321,7 +4359,6 @@ fn bindgen_test_layout_nsStyleTextOverflow() {
|
|||
}
|
||||
#[repr(C)]
|
||||
pub struct nsStyleTextReset {
|
||||
pub mVerticalAlign: nsStyleCoord,
|
||||
pub mTextOverflow: nsStyleTextOverflow,
|
||||
pub mTextDecorationLine: u8,
|
||||
pub mUnicodeBidi: u8,
|
||||
|
@ -4330,7 +4367,7 @@ pub struct nsStyleTextReset {
|
|||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_nsStyleTextReset() {
|
||||
assert_eq!(::std::mem::size_of::<nsStyleTextReset>() , 80usize);
|
||||
assert_eq!(::std::mem::size_of::<nsStyleTextReset>() , 64usize);
|
||||
assert_eq!(::std::mem::align_of::<nsStyleTextReset>() , 8usize);
|
||||
}
|
||||
#[repr(C)]
|
||||
|
@ -4350,6 +4387,7 @@ pub struct nsStyleText {
|
|||
pub mControlCharacterVisibility: u8,
|
||||
pub mTextEmphasisPosition: u8,
|
||||
pub mTextEmphasisStyle: u8,
|
||||
pub mTextRendering: u8,
|
||||
pub mTabSize: i32,
|
||||
pub mTextEmphasisColor: nscolor,
|
||||
pub mWebkitTextFillColor: nscolor,
|
||||
|
@ -4398,7 +4436,7 @@ pub struct nsStyleVisibility {
|
|||
pub mImageOrientation: nsStyleImageOrientation,
|
||||
pub mDirection: u8,
|
||||
pub mVisible: u8,
|
||||
pub mPointerEvents: u8,
|
||||
pub mImageRendering: u8,
|
||||
pub mWritingMode: u8,
|
||||
pub mTextOrientation: u8,
|
||||
pub mColorAdjust: u8,
|
||||
|
@ -4531,8 +4569,6 @@ fn bindgen_test_layout_StyleAnimation() {
|
|||
#[repr(C)]
|
||||
pub struct nsStyleDisplay {
|
||||
pub mBinding: RefPtr<URLValue>,
|
||||
pub mClip: nsRect,
|
||||
pub mOpacity: f32,
|
||||
pub mDisplay: u8,
|
||||
pub mOriginalDisplay: u8,
|
||||
pub mContain: u8,
|
||||
|
@ -4548,9 +4584,7 @@ pub struct nsStyleDisplay {
|
|||
pub mOverflowY: u8,
|
||||
pub mOverflowClipBox: u8,
|
||||
pub mResize: u8,
|
||||
pub mClipFlags: u8,
|
||||
pub mOrient: u8,
|
||||
pub mMixBlendMode: u8,
|
||||
pub mIsolation: u8,
|
||||
pub mTopLayer: u8,
|
||||
pub mWillChangeBitField: u8,
|
||||
|
@ -4570,6 +4604,7 @@ pub struct nsStyleDisplay {
|
|||
pub mTransformOrigin: [nsStyleCoord; 3usize],
|
||||
pub mChildPerspective: nsStyleCoord,
|
||||
pub mPerspectiveOrigin: [nsStyleCoord; 2usize],
|
||||
pub mVerticalAlign: nsStyleCoord,
|
||||
pub mTransitions: [u64; 7usize],
|
||||
pub mTransitionTimingFunctionCount: u32,
|
||||
pub mTransitionDurationCount: u32,
|
||||
|
@ -4587,7 +4622,7 @@ pub struct nsStyleDisplay {
|
|||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_nsStyleDisplay() {
|
||||
assert_eq!(::std::mem::size_of::<nsStyleDisplay>() , 456usize);
|
||||
assert_eq!(::std::mem::size_of::<nsStyleDisplay>() , 448usize);
|
||||
assert_eq!(::std::mem::align_of::<nsStyleDisplay>() , 8usize);
|
||||
}
|
||||
#[repr(C)]
|
||||
|
@ -4669,16 +4704,6 @@ fn bindgen_test_layout_nsStyleCounterData() {
|
|||
assert_eq!(::std::mem::align_of::<nsStyleCounterData>() , 8usize);
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct nsStyleQuotes {
|
||||
pub mQuotesCount: u32,
|
||||
pub mQuotes: *mut nsString,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_nsStyleQuotes() {
|
||||
assert_eq!(::std::mem::size_of::<nsStyleQuotes>() , 16usize);
|
||||
assert_eq!(::std::mem::align_of::<nsStyleQuotes>() , 8usize);
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct nsStyleContent {
|
||||
pub mMarkerOffset: nsStyleCoord,
|
||||
pub mContents: *mut nsStyleContentData,
|
||||
|
@ -4723,13 +4748,14 @@ pub struct nsStyleUserInterface {
|
|||
pub mUserInput: u8,
|
||||
pub mUserModify: u8,
|
||||
pub mUserFocus: u8,
|
||||
pub mPointerEvents: u8,
|
||||
pub mCursor: u8,
|
||||
pub mCursorArrayLength: u32,
|
||||
pub mCursorArray: *mut nsCursorImage,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_nsStyleUserInterface() {
|
||||
assert_eq!(::std::mem::size_of::<nsStyleUserInterface>() , 16usize);
|
||||
assert_eq!(::std::mem::size_of::<nsStyleUserInterface>() , 24usize);
|
||||
assert_eq!(::std::mem::align_of::<nsStyleUserInterface>() , 8usize);
|
||||
}
|
||||
#[repr(C)]
|
||||
|
@ -4827,13 +4853,11 @@ pub struct nsStyleSVG {
|
|||
pub mColorInterpolation: u8,
|
||||
pub mColorInterpolationFilters: u8,
|
||||
pub mFillRule: u8,
|
||||
pub mImageRendering: u8,
|
||||
pub mPaintOrder: u8,
|
||||
pub mShapeRendering: u8,
|
||||
pub mStrokeLinecap: u8,
|
||||
pub mStrokeLinejoin: u8,
|
||||
pub mTextAnchor: u8,
|
||||
pub mTextRendering: u8,
|
||||
pub _bitfield_1: u8,
|
||||
pub _bitfield_2: u8,
|
||||
}
|
||||
|
@ -4933,7 +4957,6 @@ impl ::std::clone::Clone for nsTArray_CopyChooser {
|
|||
pub struct nsStyleSVGReset {
|
||||
pub mMask: nsStyleImageLayers,
|
||||
pub mClipPath: nsStyleClipPath,
|
||||
pub mFilters: u64,
|
||||
pub mStopColor: nscolor,
|
||||
pub mFloodColor: nscolor,
|
||||
pub mLightingColor: nscolor,
|
||||
|
@ -4945,7 +4968,7 @@ pub struct nsStyleSVGReset {
|
|||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_nsStyleSVGReset() {
|
||||
assert_eq!(::std::mem::size_of::<nsStyleSVGReset>() , 224usize);
|
||||
assert_eq!(::std::mem::size_of::<nsStyleSVGReset>() , 216usize);
|
||||
assert_eq!(::std::mem::align_of::<nsStyleSVGReset>() , 8usize);
|
||||
}
|
||||
#[repr(C)]
|
||||
|
@ -4957,3 +4980,17 @@ fn bindgen_test_layout_nsStyleVariables() {
|
|||
assert_eq!(::std::mem::size_of::<nsStyleVariables>() , 56usize);
|
||||
assert_eq!(::std::mem::align_of::<nsStyleVariables>() , 8usize);
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct nsStyleEffects {
|
||||
pub mFilters: u64,
|
||||
pub mBoxShadow: RefPtr<nsCSSShadowArray>,
|
||||
pub mClip: nsRect,
|
||||
pub mOpacity: f32,
|
||||
pub mClipFlags: u8,
|
||||
pub mMixBlendMode: u8,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_nsStyleEffects() {
|
||||
assert_eq!(::std::mem::size_of::<nsStyleEffects>() , 40usize);
|
||||
assert_eq!(::std::mem::align_of::<nsStyleEffects>() , 8usize);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ use bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name};
|
|||
use bindings::Gecko_Destroy_${style_struct.gecko_ffi_name};
|
||||
% endif
|
||||
% endfor
|
||||
use gecko_style_structs;
|
||||
use heapsize::HeapSizeOf;
|
||||
use std::fmt::{self, Debug};
|
||||
use std::mem::zeroed;
|
||||
|
@ -110,7 +111,6 @@ pub struct ${style_struct.gecko_struct_name};
|
|||
impl ${style_struct.gecko_struct_name} {
|
||||
#[allow(dead_code, unused_variables)]
|
||||
fn initial() -> Arc<Self> {
|
||||
% if style_struct.gecko_ffi_name:
|
||||
// Some Gecko style structs have AutoTArray members, which have internal pointers and are
|
||||
// thus MOZ_NON_MEMMOVABLE. Since Rust is generally a very move-happy language, we need to
|
||||
// be very careful that nsStyle* structs are never moved after they are constructed.
|
||||
|
@ -127,9 +127,6 @@ impl ${style_struct.gecko_struct_name} {
|
|||
Gecko_Construct_${style_struct.gecko_ffi_name}(&mut Arc::make_mut(&mut result).gecko);
|
||||
}
|
||||
result
|
||||
% else:
|
||||
Arc::new(${style_struct.gecko_struct_name})
|
||||
% endif
|
||||
}
|
||||
}
|
||||
%if style_struct.gecko_ffi_name:
|
||||
|
@ -165,6 +162,37 @@ impl Debug for ${style_struct.gecko_ffi_name} {
|
|||
</%def>
|
||||
|
||||
<%def name="raw_impl_trait(style_struct, skip_longhands=None, skip_additionals=None)">
|
||||
<%
|
||||
longhands = [x for x in style_struct.longhands
|
||||
if not (skip_longhands and x.name in skip_longhands)]
|
||||
|
||||
#
|
||||
# Make a list of types we can't auto-generate.
|
||||
#
|
||||
force_stub = [];
|
||||
# These are currently being shuffled to a different style struct on the gecko side.
|
||||
force_stub += ["backface-visibility", "transform-box", "transform-style"]
|
||||
# These live in nsStyleImageLayers in gecko. Need to figure out what to do about that.
|
||||
force_stub += ["background-repeat", "background-attachment", "background-clip", "background-origin"];
|
||||
# These live in an nsFont member in Gecko. Should be straightforward to do manually.
|
||||
force_stub += ["font-kerning", "font-stretch", "font-style", "font-variant"]
|
||||
# These have unusual representations in gecko.
|
||||
force_stub += ["list-style-type", "text-overflow"]
|
||||
# Enum class instead of NS_STYLE_...
|
||||
force_stub += ["box-sizing"]
|
||||
# Inconsistent constant naming in gecko
|
||||
force_stub += ["unicode-bidi"]
|
||||
# Need to figure out why servo has sideways-left computed value and gecko doesn't
|
||||
force_stub += ["text-orientation"]
|
||||
# Automatic mapping generates NS_STYLE_TEXT_DECORATION_STYLE__MOZ_NONE instead of
|
||||
# NS_STYLE_TEXT_DECORATION_STYLE__NONE
|
||||
force_stub += ["text-decoration-style"]
|
||||
# These are booleans.
|
||||
force_stub += ["page-break-after", "page-break-before"]
|
||||
|
||||
keyword_longhands = [x for x in longhands if x.keyword and not x.name in force_stub]
|
||||
stub_longhands = [x for x in longhands if x not in keyword_longhands]
|
||||
%>
|
||||
impl ${style_struct.trait_name} for ${style_struct.gecko_struct_name} {
|
||||
/*
|
||||
* Manually-Implemented Methods.
|
||||
|
@ -174,9 +202,26 @@ impl ${style_struct.trait_name} for ${style_struct.gecko_struct_name} {
|
|||
/*
|
||||
* Auto-Generated Methods.
|
||||
*/
|
||||
<% longhands = [x for x in style_struct.longhands
|
||||
if not (skip_longhands and x.name in skip_longhands)] %>
|
||||
% for longhand in longhands:
|
||||
% for longhand in keyword_longhands:
|
||||
fn set_${longhand.ident}(&mut self, v: longhands::${longhand.ident}::computed_value::T) {
|
||||
use gecko_style_structs as gss;
|
||||
use style::properties::longhands::${longhand.ident}::computed_value::T as Keyword;
|
||||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||
self.gecko.${longhand.gecko_ffi_name} = match v {
|
||||
% for value in longhand.keyword.values_for('gecko'):
|
||||
Keyword::${to_rust_ident(value)} => gss::${longhand.keyword.gecko_constant(value)} as u8,
|
||||
% endfor
|
||||
};
|
||||
}
|
||||
fn copy_${longhand.ident}_from(&mut self, other: &Self) {
|
||||
self.gecko.${longhand.gecko_ffi_name} = other.gecko.${longhand.gecko_ffi_name};
|
||||
}
|
||||
% endfor
|
||||
|
||||
/*
|
||||
* Stubs.
|
||||
*/
|
||||
% for longhand in stub_longhands:
|
||||
fn set_${longhand.ident}(&mut self, _: longhands::${longhand.ident}::computed_value::T) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
|
|
@ -20,18 +20,34 @@ export DYLD_LIBRARY_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
|
|||
export LD_LIBRARY_PATH="$(pwd)/llvm/build/Release+Asserts/lib"
|
||||
export DIST_INCLUDE="$1/dist/include"
|
||||
|
||||
# Prevent bindgen from generating opaque types for the gecko style structs.
|
||||
export MAP_GECKO_STRUCTS=""
|
||||
for STRUCT in nsStyleFont nsStyleColor nsStyleList nsStyleText \
|
||||
nsStyleVisibility nsStyleUserInterface nsStyleTableBorder \
|
||||
nsStyleSVG nsStyleVariables nsStyleBackground nsStylePosition \
|
||||
nsStyleTextReset nsStyleDisplay nsStyleContent nsStyleUIReset \
|
||||
nsStyleTable nsStyleMargin nsStylePadding nsStyleBorder \
|
||||
nsStyleOutline nsStyleXUL nsStyleSVGReset nsStyleColumn nsStyleEffects
|
||||
do
|
||||
MAP_GECKO_STRUCTS=$MAP_GECKO_STRUCTS"-blacklist-type $STRUCT "
|
||||
MAP_GECKO_STRUCTS=$MAP_GECKO_STRUCTS"-raw-line 'use gecko_style_structs::$STRUCT;'$'\n' "
|
||||
done
|
||||
|
||||
# Check for the include directory.
|
||||
if [ ! -d "$DIST_INCLUDE" ]; then
|
||||
echo "$DIST_INCLUDE: directory not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# We need to use 'eval' here to make MAP_GECKO_STRUCTS evaluate properly as
|
||||
# multiple arguments.
|
||||
#
|
||||
# Uncomment the following line to run rust-bindgen in a debugger on mac.
|
||||
# The absolute path is required to allow launching lldb with an untrusted
|
||||
# library in DYLD_LIBRARY_PATH.
|
||||
#
|
||||
# /Applications/Xcode.app/Contents/Developer/usr/bin/lldb --
|
||||
./rust-bindgen/target/debug/bindgen \
|
||||
eval ./rust-bindgen/target/debug/bindgen \
|
||||
-x c++ -std=gnu++0x \
|
||||
"-I$DIST_INCLUDE" \
|
||||
-o ../bindings.rs \
|
||||
|
@ -39,3 +55,4 @@ fi
|
|||
"$DIST_INCLUDE/mozilla/ServoBindings.h" \
|
||||
-match "ServoBindings.h" \
|
||||
-match "nsStyleStructList.h" \
|
||||
$MAP_GECKO_STRUCTS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue