Skip to content

Commit 1d0d67f

Browse files
committed
Merge pull request #115 from AngryLawyer/strbuf-to-string
Updated to match latest changes to strings
2 parents fc10658 + 06e566c commit 1d0d67f

File tree

13 files changed

+101
-101
lines changed

13 files changed

+101
-101
lines changed

src/codegen/branchify.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::vec::Vec;
77

88
struct ParseBranch {
99
matches: Vec<u8>,
10-
result: Option<StrBuf>,
10+
result: Option<String>,
1111
children: Vec<ParseBranch>,
1212
}
1313

@@ -28,7 +28,7 @@ pub fn branchify(options: &[(&str, &str)], case_sensitive: bool) -> Vec<ParseBra
2828
fn go_down_moses(branch: &mut ParseBranch, mut chariter: Chars, result: &str, case_sensitive: bool) {
2929
match chariter.next() {
3030
Some(c) => {
31-
let first_case = if case_sensitive { c as u8 } else { c.to_ascii().to_upper().to_byte() };
31+
let first_case = if case_sensitive { c as u8 } else { c.to_ascii().to_uppercase().to_byte() };
3232
for next_branch in branch.children.mut_iter() {
3333
if next_branch.matches.as_slice()[0] == first_case {
3434
go_down_moses(next_branch, chariter, result, case_sensitive);
@@ -38,7 +38,7 @@ pub fn branchify(options: &[(&str, &str)], case_sensitive: bool) -> Vec<ParseBra
3838
let mut subbranch = ParseBranch::new();
3939
subbranch.matches.push(first_case);
4040
if !case_sensitive {
41-
let second_case = c.to_ascii().to_lower().to_byte();
41+
let second_case = c.to_ascii().to_lowercase().to_byte();
4242
if first_case != second_case {
4343
subbranch.matches.push(second_case);
4444
}

src/codegen/keycode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ fn Key(code: uint, ident: &'static str) -> Key {
4545
}
4646

4747
impl Key {
48-
fn ident(&self) -> StrBuf {
48+
fn ident(&self) -> String {
4949
self.ident.to_owned()
5050
}
5151

52-
fn padded_ident(&self) -> StrBuf {
52+
fn padded_ident(&self) -> String {
5353
self.ident().append(" ".repeat(unsafe { longest_ident } - self.ident().len()).as_slice())
5454
}
5555

src/codegen/scancode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ fn ScanCode(code: uint, ident: &'static str) -> ScanCode {
4444
}
4545

4646
impl ScanCode {
47-
fn ident(&self) -> StrBuf {
47+
fn ident(&self) -> String {
4848
self.ident.to_owned()
4949
}
5050

51-
fn padded_ident(&self) -> StrBuf {
51+
fn padded_ident(&self) -> String {
5252
self.ident().append(" ".repeat(unsafe { longest_ident } - self.ident().len()).as_slice())
5353
}
5454

src/sdl2/audio.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub fn get_num_audio_drivers() -> int {
152152
unsafe { ll::SDL_GetNumAudioDrivers() as int }
153153
}
154154

155-
pub fn get_audio_driver(index: int) -> StrBuf {
155+
pub fn get_audio_driver(index: int) -> String {
156156
unsafe {
157157
let buf = ll::SDL_GetAudioDriver(index as c_int);
158158
CString::new(buf, false).as_str().unwrap().into_owned()
@@ -163,14 +163,14 @@ pub fn get_num_audio_devices(iscapture: int) -> int {
163163
unsafe { ll::SDL_GetNumAudioDevices(iscapture as c_int) as int }
164164
}
165165

166-
pub fn get_audio_device_name(index: int, iscapture: int) -> StrBuf {
166+
pub fn get_audio_device_name(index: int, iscapture: int) -> String {
167167
unsafe {
168168
let buf = ll::SDL_GetAudioDeviceName(index as c_int, iscapture as c_int);
169169
CString::new(buf, false).as_str().unwrap().into_owned()
170170
}
171171
}
172172

173-
pub fn audio_init(name: &str) -> Result<(), StrBuf> {
173+
pub fn audio_init(name: &str) -> Result<(), String> {
174174
let ret = name.with_c_str(|buf| {
175175
unsafe { ll::SDL_AudioInit(buf) }
176176
});
@@ -185,7 +185,7 @@ pub fn audio_quit() {
185185
unsafe { ll::SDL_AudioQuit() }
186186
}
187187

188-
pub fn get_current_audio_driver() -> StrBuf {
188+
pub fn get_current_audio_driver() -> String {
189189
unsafe {
190190
let buf = ll::SDL_GetCurrentAudioDriver();
191191
CString::new(buf, false).as_str().unwrap().into_owned()
@@ -221,13 +221,13 @@ extern "C" fn c_audio_callback(userdata: *c_void, stream: *uint8_t, len: c_int)
221221

222222

223223
impl<'a> AudioSpec<'a> {
224-
pub fn load_wav(path: &Path) -> Result<(AudioSpec, CVec<u8>), StrBuf> {
224+
pub fn load_wav(path: &Path) -> Result<(AudioSpec, CVec<u8>), String> {
225225
AudioSpec::load_wav_rw(&try!(RWops::from_file(path, "rb")))
226226
}
227227

228-
pub fn load_wav_rw(src: &RWops) -> Result<(AudioSpec, CVec<u8>), StrBuf> {
228+
pub fn load_wav_rw(src: &RWops) -> Result<(AudioSpec, CVec<u8>), String> {
229229
assert_eq!(mem::size_of::<AudioSpec>(), mem::size_of::<ll::SDL_AudioSpec>());
230-
let mut spec = unsafe { mem::uninit::<AudioSpec>() };
230+
let mut spec = unsafe { mem::uninitialized::<AudioSpec>() };
231231
let audio_buf = ptr::null::<u8>();
232232
let audio_len = 0u32;
233233
unsafe {
@@ -261,9 +261,9 @@ impl AudioDevice {
261261
}
262262
}
263263

264-
pub fn open(device: Option<&str>, iscapture: int, spec: &AudioSpec) -> Result<(AudioDevice, AudioSpec), StrBuf> {
264+
pub fn open(device: Option<&str>, iscapture: int, spec: &AudioSpec) -> Result<(AudioDevice, AudioSpec), String> {
265265
//! SDL_OpenAudioDevice
266-
let obtained = unsafe { mem::uninit::<AudioSpec>() };
266+
let obtained = unsafe { mem::uninitialized::<AudioSpec>() };
267267
unsafe {
268268
let device_c_str = match device {
269269
None => ptr::null(),
@@ -334,7 +334,7 @@ impl Drop for AudioCVT {
334334

335335
impl AudioCVT {
336336
pub fn new(src_format: AudioFormat, src_channels: u8, src_rate: int,
337-
dst_format: AudioFormat, dst_channels: u8, dst_rate: int) -> Result<AudioCVT, StrBuf> {
337+
dst_format: AudioFormat, dst_channels: u8, dst_rate: int) -> Result<AudioCVT, String> {
338338
unsafe {
339339
let c_cvt_p = libc::malloc(mem::size_of::<ll::SDL_AudioCVT>() as size_t) as *mut ll::SDL_AudioCVT;
340340
let ret = ll::SDL_BuildAudioCVT(c_cvt_p,
@@ -348,7 +348,7 @@ impl AudioCVT {
348348
}
349349
}
350350

351-
pub fn convert(&self, src: CVec<u8>) -> Result<CVec<u8>, StrBuf> {
351+
pub fn convert(&self, src: CVec<u8>) -> Result<CVec<u8>, String> {
352352
//! Convert audio data to a desired audio format.
353353
354354
unsafe {

src/sdl2/event.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,9 @@ pub enum Event {
563563
KeyDownEvent(uint, video::Window, KeyCode, ScanCode, Mod),
564564
KeyUpEvent(uint, video::Window, KeyCode, ScanCode, Mod),
565565
/// (timestamp, window, text, start, length)
566-
TextEditingEvent(uint, video::Window, StrBuf, int, int),
566+
TextEditingEvent(uint, video::Window, String, int, int),
567567
/// (timestamp, window, text)
568-
TextInputEvent(uint, video::Window, StrBuf),
568+
TextInputEvent(uint, video::Window, String),
569569

570570
/// (timestamp, window, which, [MouseState], x, y, xrel, yrel)
571571
MouseMotionEvent(uint, video::Window, uint, MouseState, int, int,
@@ -614,7 +614,7 @@ pub enum Event {
614614
ClipboardUpdateEvent(uint),
615615

616616
/// (timestamp, filename)
617-
DropFileEvent(uint, StrBuf),
617+
DropFileEvent(uint, String),
618618

619619
/// (timestamp, Window, type, code)
620620
UserEvent(uint, video::Window, uint, int),
@@ -1062,7 +1062,7 @@ pub fn poll_event() -> Event {
10621062
}
10631063

10641064
/// Wait indefinitely for the next available event.
1065-
pub fn wait_event() -> Result<Event, StrBuf> {
1065+
pub fn wait_event() -> Result<Event, String> {
10661066
let raw = null_event();
10671067
let success = unsafe { ll::SDL_WaitEvent(&raw) == 1 as c_int };
10681068

@@ -1071,7 +1071,7 @@ pub fn wait_event() -> Result<Event, StrBuf> {
10711071
}
10721072

10731073
/// Wait until the specified timeout (in milliseconds) for the next available event.
1074-
pub fn wait_event_timeout(timeout: int) -> Result<Event, StrBuf> {
1074+
pub fn wait_event_timeout(timeout: int) -> Result<Event, String> {
10751075
let raw = null_event();
10761076
let success = unsafe { ll::SDL_WaitEventTimeout(&raw, timeout as c_int) ==
10771077
1 as c_int };
@@ -1133,7 +1133,7 @@ pub fn register_events(num: int) -> Option<uint> {
11331133
}
11341134

11351135
/// add an event to the event queue
1136-
pub fn push_event(event: Event) -> Result<(), StrBuf> {
1136+
pub fn push_event(event: Event) -> Result<(), String> {
11371137
match event.to_ll() {
11381138
Some(raw_event) => {
11391139
let ok = unsafe { ll::SDL_PushEvent(&raw_event) == 1 };

src/sdl2/keyboard.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub fn get_scancode_from_key(key: KeyCode) -> ScanCode {
114114
}
115115
}
116116

117-
pub fn get_scancode_name(scancode: ScanCode) -> StrBuf {
117+
pub fn get_scancode_name(scancode: ScanCode) -> String {
118118
unsafe {
119119
str::raw::from_c_str(ll::SDL_GetScancodeName(scancode.code() as u32))
120120
}
@@ -128,7 +128,7 @@ pub fn get_scancode_from_name(name: &str) -> ScanCode {
128128
}
129129
}
130130

131-
pub fn get_key_name(key: KeyCode) -> StrBuf {
131+
pub fn get_key_name(key: KeyCode) -> String {
132132
unsafe {
133133
str::raw::from_c_str(ll::SDL_GetKeyName(key.code()))
134134
}

src/sdl2/mouse.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl Drop for Cursor {
8787
}
8888

8989
impl Cursor {
90-
pub fn new(data: &[u8], mask: &[u8], width: int, height: int, hot_x: int, hot_y: int) -> Result<Cursor, StrBuf> {
90+
pub fn new(data: &[u8], mask: &[u8], width: int, height: int, hot_x: int, hot_y: int) -> Result<Cursor, String> {
9191
unsafe {
9292
let raw = ll::SDL_CreateCursor(data.as_ptr(),
9393
mask.as_ptr(),
@@ -103,7 +103,7 @@ impl Cursor {
103103
}
104104

105105
// TODO: figure out how to pass Surface in here correctly
106-
pub fn from_surface(surface: &surface::Surface, hot_x: int, hot_y: int) -> Result<Cursor, StrBuf> {
106+
pub fn from_surface(surface: &surface::Surface, hot_x: int, hot_y: int) -> Result<Cursor, String> {
107107
unsafe {
108108
let raw = ll::SDL_CreateColorCursor(surface.raw(), hot_x as i32,
109109
hot_y as i32);
@@ -116,7 +116,7 @@ impl Cursor {
116116
}
117117
}
118118

119-
pub fn from_system(cursor: SystemCursor) -> Result<Cursor, StrBuf> {
119+
pub fn from_system(cursor: SystemCursor) -> Result<Cursor, String> {
120120
unsafe {
121121
let raw = ll::SDL_CreateSystemCursor(cursor as u32);
122122

0 commit comments

Comments
 (0)