From c831c2c0a528b6a04b355cc51169023f8c29b761 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 27 Aug 2015 01:22:42 +0200 Subject: Remove helper traits Now that JSRef is gone, there is no need to have helper traits. On components/script/*.rs: # Remove imports. /^ *use dom::[a-z]+::\{.*Helpers/ { s/\{(Raw[^L]|[^L][^a])[a-zA-Z]+Helpers, /\{/ s/, (Raw[^L]|[^L][^a])[a-zA-Z]+Helpers([,}])/\2/g s/\{([a-zA-Z]+)\}/\1/ /\{\}/d s/::self;$/;/ } /^ *use dom::[a-z]+::\{?(Raw[^L]|[^L][^a])[a-zA-Z]+Helpers\}?;$/d On components/script/dom/*.rs: # Ignore layout things. /^(pub )?(impl|trait).*Layout.* \{/,/^}$/ { P; D; } # Delete helpers traits. /^(pub )?trait ([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? \{$/,/^\}$/D # Patch private helpers. /^impl.*Private.*Helpers/,/^\}$/ { s/^impl<'a> Private([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? for &'a ([^ ]+) \{$/impl \3 {/ /^ *(unsafe )?fn .*\(self.*[<&]'a/ { s/&'a /\&/g s/<'a, /)? ([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? for (&'a )?([^ ]+) \{$/impl \5 {/ /^ *(unsafe )?fn .*\(self.*[<&]'a/ { s/&'a /\&/g s/<'a, / Vec; - fn get_size(self) -> Size2D; -} -impl<'a> ImageDataHelpers for &'a ImageData { +impl ImageData { #[allow(unsafe_code)] - fn get_data_array(self, global: &GlobalRef) -> Vec { + pub fn get_data_array(&self, global: &GlobalRef) -> Vec { unsafe { let cx = global.get_cx(); let data: *const uint8_t = JS_GetUint8ClampedArrayData(self.Data(cx), ptr::null()) as *const uint8_t; @@ -67,7 +63,7 @@ impl<'a> ImageDataHelpers for &'a ImageData { } } - fn get_size(self) -> Size2D { + pub fn get_size(&self) -> Size2D { Size2D::new(self.Width() as i32, self.Height() as i32) } } -- cgit v1.2.3