Skip to content

Commit

Permalink
lib{std,core,debug,rustuv,collections,native,regex}: Fix snake_case e…
Browse files Browse the repository at this point in the history
…rrors.

A number of functions/methods have been moved or renamed to align
better with rust standard conventions.

std::reflect::MovePtrAdaptor => MovePtrAdaptor::new
debug::reflect::MovePtrAdaptor => MovePtrAdaptor::new
std::repr::ReprVisitor => ReprVisitor::new
debug::repr::ReprVisitor => ReprVisitor::new
rustuv::homing::HomingIO.go_to_IO_home => go_to_io_home

[breaking-change]
  • Loading branch information
Ryman committed May 30, 2014
1 parent 190d8bd commit 3faa676
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 69 deletions.
14 changes: 7 additions & 7 deletions src/libcollections/smallintmap.rs
Expand Up @@ -296,20 +296,20 @@ mod test_map {

// given a new key, initialize it with this new count,
// given an existing key, add more to its count
fn addMoreToCount(_k: uint, v0: uint, v1: uint) -> uint {
fn add_more_to_count(_k: uint, v0: uint, v1: uint) -> uint {
v0 + v1
}

fn addMoreToCount_simple(v0: uint, v1: uint) -> uint {
fn add_more_to_count_simple(v0: uint, v1: uint) -> uint {
v0 + v1
}

// count integers
map.update(3, 1, addMoreToCount_simple);
map.update_with_key(9, 1, addMoreToCount);
map.update(3, 7, addMoreToCount_simple);
map.update_with_key(5, 3, addMoreToCount);
map.update_with_key(3, 2, addMoreToCount);
map.update(3, 1, add_more_to_count_simple);
map.update_with_key(9, 1, add_more_to_count);
map.update(3, 7, add_more_to_count_simple);
map.update_with_key(5, 3, add_more_to_count);
map.update_with_key(3, 2, add_more_to_count);

// check the total counts
assert_eq!(map.find(&3).unwrap(), &10);
Expand Down
3 changes: 2 additions & 1 deletion src/libcore/char.rs
@@ -1,4 +1,4 @@
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -23,6 +23,7 @@
//! however the converse is not always true due to the above range limits
//! and, as such, should be performed via the `from_u32` function..

#![allow(non_snake_case_functions)]

use mem::transmute;
use option::{None, Option, Some};
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/unicode.rs
Expand Up @@ -10,7 +10,7 @@

// NOTE: The following code was generated by "src/etc/unicode.py", do not edit directly

#![allow(missing_doc, non_uppercase_statics)]
#![allow(missing_doc, non_uppercase_statics, non_snake_case_functions)]


fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
Expand Down
9 changes: 5 additions & 4 deletions src/libdebug/reflect.rs
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -42,11 +42,12 @@ pub fn align(size: uint, align: uint) -> uint {
pub struct MovePtrAdaptor<V> {
inner: V
}
pub fn MovePtrAdaptor<V:TyVisitor + MovePtr>(v: V) -> MovePtrAdaptor<V> {
MovePtrAdaptor { inner: v }
}

impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> {
pub fn new(v: V) -> MovePtrAdaptor<V> {
MovePtrAdaptor { inner: v }
}

#[inline]
pub fn bump(&mut self, sz: uint) {
self.inner.move_ptr(|p| ((p as uint) + sz) as *u8)
Expand Down
38 changes: 14 additions & 24 deletions src/libdebug/repr.rs
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -99,17 +99,6 @@ pub struct ReprVisitor<'a> {
last_err: Option<io::IoError>,
}

pub fn ReprVisitor<'a>(ptr: *u8,
writer: &'a mut io::Writer) -> ReprVisitor<'a> {
ReprVisitor {
ptr: ptr,
ptr_stk: vec!(),
var_stk: vec!(),
writer: writer,
last_err: None,
}
}

impl<'a> MovePtr for ReprVisitor<'a> {
#[inline]
fn move_ptr(&mut self, adjustment: |*u8| -> *u8) {
Expand All @@ -125,6 +114,15 @@ impl<'a> MovePtr for ReprVisitor<'a> {

impl<'a> ReprVisitor<'a> {
// Various helpers for the TyVisitor impl
pub fn new(ptr: *u8, writer: &'a mut io::Writer) -> ReprVisitor<'a> {
ReprVisitor {
ptr: ptr,
ptr_stk: vec!(),
var_stk: vec!(),
writer: writer,
last_err: None,
}
}

#[inline]
pub fn get<T>(&mut self, f: |&mut ReprVisitor, &T| -> bool) -> bool {
Expand All @@ -141,16 +139,8 @@ impl<'a> ReprVisitor<'a> {
#[inline]
pub fn visit_ptr_inner(&mut self, ptr: *u8, inner: *TyDesc) -> bool {
unsafe {
// This should call the constructor up above, but due to limiting
// issues we have to recreate it here.
let u = ReprVisitor {
ptr: ptr,
ptr_stk: vec!(),
var_stk: vec!(),
writer: mem::transmute_copy(&self.writer),
last_err: None,
};
let mut v = reflect::MovePtrAdaptor(u);
let u = ReprVisitor::new(ptr, mem::transmute_copy(&self.writer));
let mut v = reflect::MovePtrAdaptor::new(u);
// Obviously this should not be a thing, but blame #8401 for now
visit_tydesc(inner, &mut v as &mut TyVisitor);
match v.unwrap().last_err {
Expand Down Expand Up @@ -584,8 +574,8 @@ pub fn write_repr<T>(writer: &mut io::Writer, object: &T) -> io::IoResult<()> {
unsafe {
let ptr = object as *T as *u8;
let tydesc = get_tydesc::<T>();
let u = ReprVisitor(ptr, writer);
let mut v = reflect::MovePtrAdaptor(u);
let u = ReprVisitor::new(ptr, writer);
let mut v = reflect::MovePtrAdaptor::new(u);
visit_tydesc(tydesc, &mut v as &mut TyVisitor);
match v.unwrap().last_err {
Some(e) => Err(e),
Expand Down
3 changes: 2 additions & 1 deletion src/libnative/io/process.rs
@@ -1,4 +1,4 @@
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -758,6 +758,7 @@ fn free_handle(_handle: *()) {

#[cfg(unix)]
fn translate_status(status: c_int) -> p::ProcessExit {
#![allow(non_snake_case_functions)]
#[cfg(target_os = "linux")]
#[cfg(target_os = "android")]
mod imp {
Expand Down
1 change: 1 addition & 0 deletions src/libregex/test/bench.rs
Expand Up @@ -7,6 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(non_snake_case_functions)]

use std::rand::{Rng, task_rng};
use std::str;
Expand Down
6 changes: 3 additions & 3 deletions src/librustuv/homing.rs
@@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -88,7 +88,7 @@ pub trait HomingIO {
/// This function will move tasks to run on their home I/O scheduler. Note
/// that this function does *not* pin the task to the I/O scheduler, but
/// rather it simply moves it to running on the I/O scheduler.
fn go_to_IO_home(&mut self) -> uint {
fn go_to_io_home(&mut self) -> uint {
let _f = ForbidUnwind::new("going home");

let cur_loop_id = local_id();
Expand Down Expand Up @@ -118,7 +118,7 @@ pub trait HomingIO {
/// move the local task to its I/O scheduler and then return an RAII wrapper
/// which will return the task home.
fn fire_homing_missile(&mut self) -> HomingMissile {
HomingMissile { io_home: self.go_to_IO_home() }
HomingMissile { io_home: self.go_to_io_home() }
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/libstd/reflect.rs
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -42,11 +42,12 @@ pub fn align(size: uint, align: uint) -> uint {
pub struct MovePtrAdaptor<V> {
inner: V
}
pub fn MovePtrAdaptor<V:TyVisitor + MovePtr>(v: V) -> MovePtrAdaptor<V> {
MovePtrAdaptor { inner: v }
}

impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> {
pub fn new(v: V) -> MovePtrAdaptor<V> {
MovePtrAdaptor { inner: v }
}

#[inline]
pub fn bump(&mut self, sz: uint) {
self.inner.move_ptr(|p| ((p as uint) + sz) as *u8)
Expand Down
38 changes: 14 additions & 24 deletions src/libstd/repr.rs
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -110,17 +110,6 @@ pub struct ReprVisitor<'a> {
last_err: Option<io::IoError>,
}

pub fn ReprVisitor<'a>(ptr: *u8,
writer: &'a mut io::Writer) -> ReprVisitor<'a> {
ReprVisitor {
ptr: ptr,
ptr_stk: vec!(),
var_stk: vec!(),
writer: writer,
last_err: None,
}
}

impl<'a> MovePtr for ReprVisitor<'a> {
#[inline]
fn move_ptr(&mut self, adjustment: |*u8| -> *u8) {
Expand All @@ -136,6 +125,15 @@ impl<'a> MovePtr for ReprVisitor<'a> {

impl<'a> ReprVisitor<'a> {
// Various helpers for the TyVisitor impl
pub fn new(ptr: *u8, writer: &'a mut io::Writer) -> ReprVisitor<'a> {
ReprVisitor {
ptr: ptr,
ptr_stk: vec!(),
var_stk: vec!(),
writer: writer,
last_err: None,
}
}

#[inline]
pub fn get<T>(&mut self, f: |&mut ReprVisitor, &T| -> bool) -> bool {
Expand All @@ -152,16 +150,8 @@ impl<'a> ReprVisitor<'a> {
#[inline]
pub fn visit_ptr_inner(&mut self, ptr: *u8, inner: *TyDesc) -> bool {
unsafe {
// This should call the constructor up above, but due to limiting
// issues we have to recreate it here.
let u = ReprVisitor {
ptr: ptr,
ptr_stk: vec!(),
var_stk: vec!(),
writer: ::mem::transmute_copy(&self.writer),
last_err: None,
};
let mut v = reflect::MovePtrAdaptor(u);
let u = ReprVisitor::new(ptr, ::mem::transmute_copy(&self.writer));
let mut v = reflect::MovePtrAdaptor::new(u);
// Obviously this should not be a thing, but blame #8401 for now
visit_tydesc(inner, &mut v as &mut TyVisitor);
match v.unwrap().last_err {
Expand Down Expand Up @@ -592,8 +582,8 @@ pub fn write_repr<T>(writer: &mut io::Writer, object: &T) -> io::IoResult<()> {
unsafe {
let ptr = object as *T as *u8;
let tydesc = get_tydesc::<T>();
let u = ReprVisitor(ptr, writer);
let mut v = reflect::MovePtrAdaptor(u);
let u = ReprVisitor::new(ptr, writer);
let mut v = reflect::MovePtrAdaptor::new(u);
visit_tydesc(tydesc, &mut v as &mut TyVisitor);
match v.unwrap().last_err {
Some(e) => Err(e),
Expand Down

0 comments on commit 3faa676

Please sign in to comment.