servo: Merge #4679 - Stop calling is_not_null (from Ms2ger:is_not_null); r=larsbergstrom

It has been removed from Rust.

Source-Repo: https://github.com/servo/servo
Source-Revision: 2d5b0e085571594e7da2ee519605dd6fac2caa54
This commit is contained in:
Ms2ger 2015-01-20 06:00:47 -07:00
Родитель 003cea7472
Коммит 16be5944e2
6 изменённых файлов: 26 добавлений и 28 удалений

Просмотреть файл

@ -1149,7 +1149,7 @@ impl ScaledFontExtensionMethods for ScaledFont {
let target = rctx.get_draw_target(); let target = rctx.get_draw_target();
let pattern = ColorPattern::new(color); let pattern = ColorPattern::new(color);
let azure_pattern = pattern.azure_color_pattern; let azure_pattern = pattern.azure_color_pattern;
assert!(azure_pattern.is_not_null()); assert!(!azure_pattern.is_null());
let fields = if antialias { let fields = if antialias {
0x0200 0x0200

Просмотреть файл

@ -59,7 +59,7 @@ pub struct FontHandle {
#[unsafe_destructor] #[unsafe_destructor]
impl Drop for FontHandle { impl Drop for FontHandle {
fn drop(&mut self) { fn drop(&mut self) {
assert!(self.face.is_not_null()); assert!(!self.face.is_null());
unsafe { unsafe {
if !FT_Done_Face(self.face).succeeded() { if !FT_Done_Face(self.face).succeeded() {
panic!("FT_Done_Face failed"); panic!("FT_Done_Face failed");
@ -136,7 +136,7 @@ impl FontHandleMethods for FontHandle {
} else { } else {
unsafe { unsafe {
let os2 = FT_Get_Sfnt_Table(self.face, ft_sfnt_os2) as *mut TT_OS2; let os2 = FT_Get_Sfnt_Table(self.face, ft_sfnt_os2) as *mut TT_OS2;
let valid = os2.is_not_null() && (*os2).version != 0xffff; let valid = !os2.is_null() && (*os2).version != 0xffff;
if valid { if valid {
let weight =(*os2).usWeightClass; let weight =(*os2).usWeightClass;
match weight { match weight {
@ -158,9 +158,8 @@ impl FontHandleMethods for FontHandle {
} }
} }
fn glyph_index(&self, fn glyph_index(&self, codepoint: char) -> Option<GlyphId> {
codepoint: char) -> Option<GlyphId> { assert!(!self.face.is_null());
assert!(self.face.is_not_null());
unsafe { unsafe {
let idx = FT_Get_Char_Index(self.face, codepoint as FT_ULong); let idx = FT_Get_Char_Index(self.face, codepoint as FT_ULong);
return if idx != 0 as FT_UInt { return if idx != 0 as FT_UInt {
@ -173,8 +172,8 @@ impl FontHandleMethods for FontHandle {
} }
fn glyph_h_kerning(&self, first_glyph: GlyphId, second_glyph: GlyphId) fn glyph_h_kerning(&self, first_glyph: GlyphId, second_glyph: GlyphId)
-> FractionalPixel { -> FractionalPixel {
assert!(self.face.is_not_null()); assert!(!self.face.is_null());
let mut delta = struct_FT_Vector_ { x: 0, y: 0 }; let mut delta = struct_FT_Vector_ { x: 0, y: 0 };
unsafe { unsafe {
FT_Get_Kerning(self.face, first_glyph, second_glyph, FT_KERNING_DEFAULT, &mut delta); FT_Get_Kerning(self.face, first_glyph, second_glyph, FT_KERNING_DEFAULT, &mut delta);
@ -182,15 +181,14 @@ impl FontHandleMethods for FontHandle {
fixed_to_float_ft(delta.x as i32) fixed_to_float_ft(delta.x as i32)
} }
fn glyph_h_advance(&self, fn glyph_h_advance(&self, glyph: GlyphId) -> Option<FractionalPixel> {
glyph: GlyphId) -> Option<FractionalPixel> { assert!(!self.face.is_null());
assert!(self.face.is_not_null());
unsafe { unsafe {
let res = FT_Load_Glyph(self.face, glyph as FT_UInt, 0); let res = FT_Load_Glyph(self.face, glyph as FT_UInt, 0);
if res.succeeded() { if res.succeeded() {
let void_glyph = (*self.face).glyph; let void_glyph = (*self.face).glyph;
let slot: FT_GlyphSlot = mem::transmute(void_glyph); let slot: FT_GlyphSlot = mem::transmute(void_glyph);
assert!(slot.is_not_null()); assert!(!slot.is_null());
let advance = (*slot).metrics.horiAdvance; let advance = (*slot).metrics.horiAdvance;
debug!("h_advance for {} is {}", glyph, advance); debug!("h_advance for {} is {}", glyph, advance);
let advance = advance as i32; let advance = advance as i32;
@ -227,7 +225,7 @@ impl FontHandleMethods for FontHandle {
let mut x_height = geometry::from_pt(0.0); let mut x_height = geometry::from_pt(0.0);
unsafe { unsafe {
let os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2) as *mut TT_OS2; let os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2) as *mut TT_OS2;
let valid = os2.is_not_null() && (*os2).version != 0xffff; let valid = !os2.is_null() && (*os2).version != 0xffff;
if valid { if valid {
strikeout_size = self.font_units_to_au((*os2).yStrikeoutSize as f64); strikeout_size = self.font_units_to_au((*os2).yStrikeoutSize as f64);
strikeout_offset = self.font_units_to_au((*os2).yStrikeoutPosition as f64); strikeout_offset = self.font_units_to_au((*os2).yStrikeoutPosition as f64);

Просмотреть файл

@ -49,7 +49,7 @@ pub struct FontContextHandle {
impl Drop for FreeTypeLibraryHandle { impl Drop for FreeTypeLibraryHandle {
fn drop(&mut self) { fn drop(&mut self) {
assert!(self.ctx.is_not_null()); assert!(!self.ctx.is_null());
unsafe { FT_Done_FreeType(self.ctx) }; unsafe { FT_Done_FreeType(self.ctx) };
} }
} }

Просмотреть файл

@ -53,14 +53,14 @@ pub fn get_variations_for_family(family_name: &str, callback: |String|) {
let mut font_set = FcConfigGetFonts(config, FcSetSystem); let mut font_set = FcConfigGetFonts(config, FcSetSystem);
let font_set_array_ptr = &mut font_set; let font_set_array_ptr = &mut font_set;
let pattern = FcPatternCreate(); let pattern = FcPatternCreate();
assert!(pattern.is_not_null()); assert!(!pattern.is_null());
let mut family_name_c = family_name.to_c_str(); let mut family_name_c = family_name.to_c_str();
let family_name = family_name_c.as_mut_ptr(); let family_name = family_name_c.as_mut_ptr();
let ok = FcPatternAddString(pattern, FC_FAMILY.as_ptr() as *mut i8, family_name as *mut FcChar8); let ok = FcPatternAddString(pattern, FC_FAMILY.as_ptr() as *mut i8, family_name as *mut FcChar8);
assert!(ok != 0); assert!(ok != 0);
let object_set = FcObjectSetCreate(); let object_set = FcObjectSetCreate();
assert!(object_set.is_not_null()); assert!(!object_set.is_null());
FcObjectSetAdd(object_set, FC_FILE.as_ptr() as *mut i8); FcObjectSetAdd(object_set, FC_FILE.as_ptr() as *mut i8);
FcObjectSetAdd(object_set, FC_INDEX.as_ptr() as *mut i8); FcObjectSetAdd(object_set, FC_INDEX.as_ptr() as *mut i8);

Просмотреть файл

@ -78,11 +78,11 @@ impl ShapedGlyphData {
let mut glyph_count = 0; let mut glyph_count = 0;
let glyph_infos = RUST_hb_buffer_get_glyph_infos(buffer, &mut glyph_count); let glyph_infos = RUST_hb_buffer_get_glyph_infos(buffer, &mut glyph_count);
let glyph_count = glyph_count as int; let glyph_count = glyph_count as int;
assert!(glyph_infos.is_not_null()); assert!(!glyph_infos.is_null());
let mut pos_count = 0; let mut pos_count = 0;
let pos_infos = RUST_hb_buffer_get_glyph_positions(buffer, &mut pos_count); let pos_infos = RUST_hb_buffer_get_glyph_positions(buffer, &mut pos_count);
let pos_count = pos_count as int; let pos_count = pos_count as int;
assert!(pos_infos.is_not_null()); assert!(!pos_infos.is_null());
assert!(glyph_count == pos_count); assert!(glyph_count == pos_count);
ShapedGlyphData { ShapedGlyphData {
@ -160,13 +160,13 @@ pub struct Shaper {
impl Drop for Shaper { impl Drop for Shaper {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
assert!(self.hb_face.is_not_null()); assert!(!self.hb_face.is_null());
RUST_hb_face_destroy(self.hb_face); RUST_hb_face_destroy(self.hb_face);
assert!(self.hb_font.is_not_null()); assert!(!self.hb_font.is_null());
RUST_hb_font_destroy(self.hb_font); RUST_hb_font_destroy(self.hb_font);
assert!(self.hb_funcs.is_not_null()); assert!(!self.hb_funcs.is_null());
RUST_hb_font_funcs_destroy(self.hb_funcs); RUST_hb_font_funcs_destroy(self.hb_funcs);
} }
} }
@ -536,7 +536,7 @@ extern fn glyph_func(_: *mut hb_font_t,
_: *mut c_void) _: *mut c_void)
-> hb_bool_t { -> hb_bool_t {
let font: *const Font = font_data as *const Font; let font: *const Font = font_data as *const Font;
assert!(font.is_not_null()); assert!(!font.is_null());
unsafe { unsafe {
match (*font).glyph_index(char::from_u32(unicode).unwrap()) { match (*font).glyph_index(char::from_u32(unicode).unwrap()) {
@ -555,7 +555,7 @@ extern fn glyph_h_advance_func(_: *mut hb_font_t,
_: *mut c_void) _: *mut c_void)
-> hb_position_t { -> hb_position_t {
let font: *mut Font = font_data as *mut Font; let font: *mut Font = font_data as *mut Font;
assert!(font.is_not_null()); assert!(!font.is_null());
unsafe { unsafe {
let advance = (*font).glyph_h_advance(glyph as GlyphId); let advance = (*font).glyph_h_advance(glyph as GlyphId);
@ -570,7 +570,7 @@ extern fn glyph_h_kerning_func(_: *mut hb_font_t,
_: *mut c_void) _: *mut c_void)
-> hb_position_t { -> hb_position_t {
let font: *mut Font = font_data as *mut Font; let font: *mut Font = font_data as *mut Font;
assert!(font.is_not_null()); assert!(!font.is_null());
unsafe { unsafe {
let advance = (*font).glyph_h_kerning(first_glyph as GlyphId, second_glyph as GlyphId); let advance = (*font).glyph_h_kerning(first_glyph as GlyphId, second_glyph as GlyphId);
@ -587,8 +587,8 @@ extern fn get_font_table_func(_: *mut hb_face_t,
// NB: These asserts have security implications. // NB: These asserts have security implications.
let font_and_shaping_options: *const FontAndShapingOptions = let font_and_shaping_options: *const FontAndShapingOptions =
user_data as *const FontAndShapingOptions; user_data as *const FontAndShapingOptions;
assert!(font_and_shaping_options.is_not_null()); assert!(!font_and_shaping_options.is_null());
assert!((*font_and_shaping_options).font.is_not_null()); assert!(!(*font_and_shaping_options).font.is_null());
// TODO(Issue #197): reuse font table data, which will change the unsound trickery here. // TODO(Issue #197): reuse font table data, which will change the unsound trickery here.
match (*(*font_and_shaping_options).font).get_table_for_tag(tag as FontTableTag) { match (*(*font_and_shaping_options).font).get_table_for_tag(tag as FontTableTag) {
@ -606,7 +606,7 @@ extern fn get_font_table_func(_: *mut hb_face_t,
destroy_blob_func); destroy_blob_func);
}); });
assert!(blob.is_not_null()); assert!(!blob.is_null());
blob blob
} }
} }

Просмотреть файл

@ -61,7 +61,7 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
if !application.is_null() { if !application.is_null() {
(*application).get_browser_process_handler.map(|cb| { (*application).get_browser_process_handler.map(|cb| {
let handler = cb(application); let handler = cb(application);
if handler.is_not_null() { if !handler.is_null() {
(*handler).on_context_initialized.map(|hcb| hcb(handler)); (*handler).on_context_initialized.map(|hcb| hcb(handler));
} }
}); });