Skip to content

Update to latest Rust #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/examples/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use glfw::Context;
use std::cast;
use std::mem;
use std::ptr;
use std::slice;
use std::str;

// Vertex data
Expand Down Expand Up @@ -69,9 +68,9 @@ fn compile_shader(src: &str, ty: GLenum) -> GLuint {
if status != (gl::TRUE as GLint) {
let mut len = 0;
gl::GetShaderiv(shader, gl::INFO_LOG_LENGTH, &mut len);
let mut buf = slice::from_elem(len as uint - 1, 0u8); // subtract 1 to skip the trailing null character
let mut buf = Vec::from_elem(len as uint - 1, 0u8); // subtract 1 to skip the trailing null character
gl::GetShaderInfoLog(shader, len, ptr::mut_null(), buf.as_mut_ptr() as *mut GLchar);
fail!(str::from_utf8_owned(buf).expect("ShaderInfoLog not valid utf8"));
fail!("{}", str::from_utf8(buf.as_slice()).expect("ShaderInfoLog not valid utf8"));
}
}
shader
Expand All @@ -91,9 +90,9 @@ fn link_program(vs: GLuint, fs: GLuint) -> GLuint {
if status != (gl::TRUE as GLint) {
let mut len: GLint = 0;
gl::GetProgramiv(program, gl::INFO_LOG_LENGTH, &mut len);
let mut buf = slice::from_elem(len as uint - 1, 0u8); // subtract 1 to skip the trailing null character
let mut buf = Vec::from_elem(len as uint - 1, 0u8); // subtract 1 to skip the trailing null character
gl::GetProgramInfoLog(program, len, ptr::mut_null(), buf.as_mut_ptr() as *mut GLchar);
fail!(str::from_utf8_owned(buf).expect("ProgramInfoLog not valid utf8"));
fail!("{}", str::from_utf8(buf.as_slice()).expect("ProgramInfoLog not valid utf8"));
}
}
program
Expand Down
16 changes: 8 additions & 8 deletions src/gen/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn main() {
return;
}

let ns = match args.opt_str("namespace").unwrap_or(~"gl").as_slice() {
let ns = match args.opt_str("namespace").unwrap_or("gl".to_owned()).as_slice() {
"gl" => Gl,
"glx" => fail!("glx generation unimplemented"),
"wgl" => fail!("wgl generation unimplemented"),
Expand All @@ -85,9 +85,9 @@ fn main() {
} else {
Some(Filter {
extensions: args.opt_strs("extension"),
profile: args.opt_str("profile").unwrap_or(~"core"),
version: args.opt_str("version").unwrap_or(~"4.3"),
api: args.opt_str("api").unwrap_or(~"gl"),
profile: args.opt_str("profile").unwrap_or("core".to_owned()),
version: args.opt_str("version").unwrap_or("4.3".to_owned()),
api: args.opt_str("api").unwrap_or("gl".to_owned()),
})
};

Expand Down Expand Up @@ -115,13 +115,13 @@ fn gen_binding_ident(binding: &Binding, use_idents: bool) -> ~str {
// fixed
if use_idents {
match binding.ident.as_slice() {
"in" => ~"in_",
"ref" => ~"ref_",
"type" => ~"type_",
"in" => "in_".to_owned(),
"ref" => "ref_".to_owned(),
"type" => "type_".to_owned(),
ident => ident.to_owned(),
}
} else {
~"_"
"_".to_owned()
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/gen/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ impl<'a> RegistryBuilder {
match self.recv() {
// ignores
Characters(_) | Comment(_) => (),
StartElement(ref s, _) if s.as_slice() == "comment" => self.skip_until(EndElement(~"comment")),
StartElement(ref s, _) if s.as_slice() == "types" => self.skip_until(EndElement(~"types")),
StartElement(ref s, _) if s.as_slice() == "comment" => self.skip_until(EndElement("comment".to_owned())),
StartElement(ref s, _) if s.as_slice() == "types" => self.skip_until(EndElement("types".to_owned())),

// add groups
StartElement(ref s, _) if s.as_slice() == "groups" => {
Expand Down Expand Up @@ -428,8 +428,8 @@ impl<'a> RegistryBuilder {

Registry {
groups: groups,
enums: enums.move_iter().filter(|e| desired_enums.contains(&(~"GL_" + e.ident))).collect::<Vec<Enum>>(),
cmds: cmds.move_iter().filter(|c| desired_cmds.contains(&(~"gl" + c.proto.ident))).collect::<Vec<Cmd>>(),
enums: enums.move_iter().filter(|e| desired_enums.contains(&("GL_".to_owned() + e.ident))).collect::<Vec<Enum>>(),
cmds: cmds.move_iter().filter(|c| desired_cmds.contains(&("gl".to_owned() + c.proto.ident))).collect::<Vec<Cmd>>(),
// these aren't important after this step
features: Vec::new(),
extensions: Vec::new(),
Expand Down Expand Up @@ -512,7 +512,7 @@ impl<'a> RegistryBuilder {
match self.recv() {
// ignores
Characters(_) | Comment(_) => (),
StartElement(ref s, _) if s.as_slice() == "unused" => self.skip_until(EndElement(~"unused")),
StartElement(ref s, _) if s.as_slice() == "unused" => self.skip_until(EndElement("unused".to_owned())),

// add enum definition
StartElement(ref s, ref atts) if s.as_slice() == "enum" => {
Expand Down
2 changes: 1 addition & 1 deletion src/gen/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

pub fn to_return_suffix(ty: &str) -> ~str {
match ty {
"c_void" | "VOID" | "GLvoid" => ~"",
"c_void" | "VOID" | "GLvoid" => "".to_owned(),
ty_str => " -> " + ty_str.replace("*mut ", "*"),
}
}
Expand Down