aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglshader.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2015-08-27 01:22:42 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2015-08-27 16:59:02 +0200
commitc831c2c0a528b6a04b355cc51169023f8c29b761 (patch)
treed443f7075709bdb222163aecc8ce1c3b81e107b9 /components/script/dom/webglshader.rs
parent1384ff5e9f4d98630d4ec1206049c8fb6d96f187 (diff)
downloadservo-c831c2c0a528b6a04b355cc51169023f8c29b761.tar.gz
servo-c831c2c0a528b6a04b355cc51169023f8c29b761.zip
Remove helper traits
Now that JSRef<T> 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, /</g } /^ *(unsafe )?fn /s/\(self([,)])/\(\&self\1/ } # Patch public helpers. /^impl.*Helpers/,/^\}$/ { s/^impl(<'a>)? ([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? for (&'a )?([^ ]+) \{$/impl \5 {/ /^ *(unsafe )?fn .*\(self.*[<&]'a/ { s/&'a /\&/g s/<'a, /</g } /^ *(unsafe )?fn .*\(&?self[,)]/s/(unsafe )?fn/pub &/ /^ *pub (unsafe )?fn /s/\(self([,)])/\(\&self\1/ } The few error cases were then fixed by hand.
Diffstat (limited to 'components/script/dom/webglshader.rs')
-rw-r--r--components/script/dom/webglshader.rs28
1 files changed, 9 insertions, 19 deletions
diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs
index d18836419eb..3920bcb7b7c 100644
--- a/components/script/dom/webglshader.rs
+++ b/components/script/dom/webglshader.rs
@@ -59,35 +59,25 @@ impl WebGLShader {
}
}
-pub trait WebGLShaderHelpers {
- fn id(self) -> u32;
- fn gl_type(self) -> u32;
- fn compile(self);
- fn delete(self);
- fn info_log(self) -> Option<String>;
- fn parameter(self, param_id: u32) -> WebGLResult<WebGLShaderParameter>;
- fn source(self) -> Option<String>;
- fn set_source(self, src: String);
-}
-impl<'a> WebGLShaderHelpers for &'a WebGLShader {
- fn id(self) -> u32 {
+impl WebGLShader {
+ pub fn id(&self) -> u32 {
self.id
}
- fn gl_type(self) -> u32 {
+ pub fn gl_type(&self) -> u32 {
self.gl_type
}
// TODO(ecoal95): Validate shaders to be conforming to the WebGL spec
/// glCompileShader
- fn compile(self) {
+ pub fn compile(&self) {
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::CompileShader(self.id))).unwrap()
}
/// Mark this shader as deleted (if it wasn't previously)
/// and delete it as if calling glDeleteShader.
- fn delete(self) {
+ pub fn delete(&self) {
if !self.is_deleted.get() {
self.is_deleted.set(true);
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteShader(self.id))).unwrap()
@@ -95,14 +85,14 @@ impl<'a> WebGLShaderHelpers for &'a WebGLShader {
}
/// glGetShaderInfoLog
- fn info_log(self) -> Option<String> {
+ pub fn info_log(&self) -> Option<String> {
let (sender, receiver) = ipc::channel().unwrap();
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::GetShaderInfoLog(self.id, sender))).unwrap();
receiver.recv().unwrap()
}
/// glGetShaderParameter
- fn parameter(self, param_id: u32) -> WebGLResult<WebGLShaderParameter> {
+ pub fn parameter(&self, param_id: u32) -> WebGLResult<WebGLShaderParameter> {
match param_id {
constants::SHADER_TYPE | constants::DELETE_STATUS | constants::COMPILE_STATUS => {},
_ => return Err(WebGLError::InvalidEnum),
@@ -114,12 +104,12 @@ impl<'a> WebGLShaderHelpers for &'a WebGLShader {
}
/// Get the shader source
- fn source(self) -> Option<String> {
+ pub fn source(&self) -> Option<String> {
self.source.borrow().clone()
}
/// glShaderSource
- fn set_source(self, source: String) {
+ pub fn set_source(&self, source: String) {
*self.source.borrow_mut() = Some(source.clone());
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::ShaderSource(self.id, source))).unwrap()
}