Remove test functions from nsstring_vendor

These tests are run on the real nsstring anyway. They cause linux builds to
fail since the test functions are defined twice.
This commit is contained in:
Manish Goregaokar 2016-10-12 21:51:06 +05:30
parent b74d07bc78
commit 647f8e9c5d
2 changed files with 1 additions and 109 deletions

View file

@ -731,112 +731,3 @@ extern "C" {
fn Gecko_AppendUTF16toCString(this: *mut nsACString, other: *const nsAString); fn Gecko_AppendUTF16toCString(this: *mut nsACString, other: *const nsAString);
fn Gecko_AppendUTF8toString(this: *mut nsAString, other: *const nsACString); fn Gecko_AppendUTF8toString(this: *mut nsAString, other: *const nsACString);
} }
//////////////////////////////////////
// Repr Validation Helper Functions //
//////////////////////////////////////
pub mod test_helpers {
//! This module only exists to help with ensuring that the layout of the
//! structs inside of rust and C++ are identical.
//!
//! It is public to ensure that these testing functions are avaliable to
//! gtest code.
use super::{
nsFixedCStringRepr,
nsFixedStringRepr,
nsCStringRepr,
nsStringRepr,
F_NONE,
F_TERMINATED,
F_VOIDED,
F_SHARED,
F_OWNED,
F_FIXED,
F_LITERAL,
F_CLASS_FIXED,
};
use std::mem;
/// Generates an #[no_mangle] extern "C" function which returns the size and
/// alignment of the given type with the given name.
macro_rules! size_align_check {
($T:ty, $fname:ident) => {
#[no_mangle]
#[allow(non_snake_case)]
pub extern fn $fname(size: *mut usize, align: *mut usize) {
unsafe {
*size = mem::size_of::<$T>();
*align = mem::align_of::<$T>();
}
}
}
}
size_align_check!(nsStringRepr, Rust_Test_ReprSizeAlign_nsString);
size_align_check!(nsCStringRepr, Rust_Test_ReprSizeAlign_nsCString);
size_align_check!(nsFixedStringRepr, Rust_Test_ReprSizeAlign_nsFixedString);
size_align_check!(nsFixedCStringRepr, Rust_Test_ReprSizeAlign_nsFixedCString);
/// Generates a $[no_mangle] extern "C" function which returns the size,
/// alignment and offset in the parent struct of a given member, with the
/// given name.
///
/// This method can trigger Undefined Behavior if the accessing the member
/// $member on a given type would use that type's `Deref` implementation.
macro_rules! member_check {
($T:ty, $member:ident, $method:ident) => {
#[no_mangle]
#[allow(non_snake_case)]
pub extern fn $method(size: *mut usize,
align: *mut usize,
offset: *mut usize) {
unsafe {
// Create a temporary value of type T to get offsets, sizes
// and aligns off of
let tmp: $T = mem::zeroed();
*size = mem::size_of_val(&tmp.$member);
*align = mem::align_of_val(&tmp.$member);
*offset =
(&tmp.$member as *const _ as usize) -
(&tmp as *const _ as usize);
mem::forget(tmp);
}
}
}
}
member_check!(nsStringRepr, data, Rust_Test_Member_nsString_mData);
member_check!(nsStringRepr, length, Rust_Test_Member_nsString_mLength);
member_check!(nsStringRepr, flags, Rust_Test_Member_nsString_mFlags);
member_check!(nsCStringRepr, data, Rust_Test_Member_nsCString_mData);
member_check!(nsCStringRepr, length, Rust_Test_Member_nsCString_mLength);
member_check!(nsCStringRepr, flags, Rust_Test_Member_nsCString_mFlags);
member_check!(nsFixedStringRepr, capacity, Rust_Test_Member_nsFixedString_mFixedCapacity);
member_check!(nsFixedStringRepr, buffer, Rust_Test_Member_nsFixedString_mFixedBuf);
member_check!(nsFixedCStringRepr, capacity, Rust_Test_Member_nsFixedCString_mFixedCapacity);
member_check!(nsFixedCStringRepr, buffer, Rust_Test_Member_nsFixedCString_mFixedBuf);
#[no_mangle]
#[allow(non_snake_case)]
pub extern fn Rust_Test_NsStringFlags(f_none: *mut u32,
f_terminated: *mut u32,
f_voided: *mut u32,
f_shared: *mut u32,
f_owned: *mut u32,
f_fixed: *mut u32,
f_literal: *mut u32,
f_class_fixed: *mut u32) {
unsafe {
*f_none = F_NONE;
*f_terminated = F_TERMINATED;
*f_voided = F_VOIDED;
*f_shared = F_SHARED;
*f_owned = F_OWNED;
*f_fixed = F_FIXED;
*f_literal = F_LITERAL;
*f_class_fixed = F_CLASS_FIXED;
}
}
}

View file

@ -1984,6 +1984,7 @@ clip-path
${impl_coord_copy('column_width', 'mColumnWidth')} ${impl_coord_copy('column_width', 'mColumnWidth')}
#[allow(unused_unsafe)]
pub fn set_column_count(&mut self, v: longhands::column_count::computed_value::T) { pub fn set_column_count(&mut self, v: longhands::column_count::computed_value::T) {
use gecko_bindings::structs::{NS_STYLE_COLUMN_COUNT_AUTO, nsStyleColumn_kMaxColumnCount}; use gecko_bindings::structs::{NS_STYLE_COLUMN_COUNT_AUTO, nsStyleColumn_kMaxColumnCount};