From ee2ce036ccd53d8c19689d86cf8b3bd5cf37f40f Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 29 Aug 2012 16:09:41 -0700 Subject: [PATCH] Camel case more std types --- src/libstd/sha1.rs | 24 +++++++-------- src/libstd/std.rc | 14 +++++++++ src/libstd/time.rs | 54 +++++++++++++++++----------------- src/rustc/middle/trans/base.rs | 4 +-- 4 files changed, 55 insertions(+), 41 deletions(-) diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index e3c1b173c19..8b91f54be99 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -23,7 +23,7 @@ export sha1; /// The SHA-1 interface -trait sha1 { +trait Sha1 { /// Provide message input as bytes fn input((&[u8])); /// Provide message input as string @@ -53,8 +53,8 @@ const k3: u32 = 0xCA62C1D6u32; /// Construct a `sha` object -fn sha1() -> sha1 { - type sha1state = +fn sha1() -> Sha1 { + type Sha1State = {h: ~[mut u32], mut len_low: u32, mut len_high: u32, @@ -63,7 +63,7 @@ fn sha1() -> sha1 { mut computed: bool, work_buf: @~[mut u32]}; - fn add_input(st: &sha1state, msg: &[u8]) { + fn add_input(st: &Sha1State, msg: &[u8]) { assert (!st.computed); for vec::each(msg) |element| { st.msg_block[st.msg_block_idx] = element; @@ -79,7 +79,7 @@ fn sha1() -> sha1 { if st.msg_block_idx == msg_block_len { process_msg_block(st); } } } - fn process_msg_block(st: &sha1state) { + fn process_msg_block(st: &Sha1State) { assert (vec::len(st.h) == digest_buf_len); assert (vec::len(*st.work_buf) == work_buf_len); let mut t: int; // Loop counter @@ -158,7 +158,7 @@ fn sha1() -> sha1 { fn circular_shift(bits: u32, word: u32) -> u32 { return word << bits | word >> 32u32 - bits; } - fn mk_result(st: &sha1state) -> ~[u8] { + fn mk_result(st: &Sha1State) -> ~[u8] { if !(*st).computed { pad_msg(st); (*st).computed = true; } let mut rs: ~[u8] = ~[]; for vec::each_mut((*st).h) |ptr_hpart| { @@ -181,7 +181,7 @@ fn sha1() -> sha1 { * call process_msg_block() appropriately. When it returns, it * can be assumed that the message digest has been computed. */ - fn pad_msg(st: &sha1state) { + fn pad_msg(st: &Sha1State) { assert (vec::len((*st).msg_block) == msg_block_len); /* @@ -218,7 +218,7 @@ fn sha1() -> sha1 { process_msg_block(st); } - impl sha1state: sha1 { + impl Sha1State: Sha1 { fn reset() { assert (vec::len(self.h) == digest_buf_len); self.len_low = 0u32; @@ -253,7 +253,7 @@ fn sha1() -> sha1 { mut computed: false, work_buf: @vec::to_mut(vec::from_elem(work_buf_len, 0u32)) }; - let sh = st as sha1; + let sh = st as Sha1; sh.reset(); return sh; } @@ -263,7 +263,7 @@ mod tests { #[test] fn test() unsafe { - type test = {input: ~str, output: ~[u8]}; + type Test = {input: ~str, output: ~[u8]}; fn a_million_letter_a() -> ~str { let mut i = 0; @@ -273,7 +273,7 @@ mod tests { } // Test messages from FIPS 180-1 - let fips_180_1_tests: ~[test] = + let fips_180_1_tests: ~[Test] = ~[{input: ~"abc", output: ~[0xA9u8, 0x99u8, 0x3Eu8, 0x36u8, @@ -299,7 +299,7 @@ mod tests { 0x65u8, 0x34u8, 0x01u8, 0x6Fu8]}]; // Examples from wikipedia - let wikipedia_tests: ~[test] = + let wikipedia_tests: ~[Test] = ~[{input: ~"The quick brown fox jumps over the lazy dog", output: ~[0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8, diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 0dd139250fb..7af5d68d648 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -70,19 +70,33 @@ mod treemap; // And ... other stuff +#[warn(non_camel_case_types)] mod ebml; +#[warn(non_camel_case_types)] mod dbg; +#[warn(non_camel_case_types)] mod getopts; +#[warn(non_camel_case_types)] mod json; +#[warn(non_camel_case_types)] mod sha1; +#[warn(non_camel_case_types)] mod md4; +#[warn(non_camel_case_types)] mod tempfile; +#[warn(non_camel_case_types)] mod term; +#[warn(non_camel_case_types)] mod time; +#[warn(non_camel_case_types)] mod prettyprint; +#[warn(non_camel_case_types)] mod arena; +#[warn(non_camel_case_types)] mod par; +#[warn(non_camel_case_types)] mod cmp; +#[warn(non_camel_case_types)] mod base64; #[cfg(unicode)] diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 174f92a3486..fec45cfc178 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -6,12 +6,12 @@ import io::Reader; import result::{Result, Ok, Err}; export - timespec, + Timespec, get_time, precise_time_ns, precise_time_s, tzset, - tm, + Tm, empty_tm, now, at, @@ -26,20 +26,20 @@ extern mod rustrt { fn rust_tzset(); // FIXME: The i64 values can be passed by-val when #2064 is fixed. - fn rust_gmtime(&&sec: i64, &&nsec: i32, &&result: tm); - fn rust_localtime(&&sec: i64, &&nsec: i32, &&result: tm); - fn rust_timegm(&&tm: tm, &sec: i64); - fn rust_mktime(&&tm: tm, &sec: i64); + fn rust_gmtime(&&sec: i64, &&nsec: i32, &&result: Tm); + fn rust_localtime(&&sec: i64, &&nsec: i32, &&result: Tm); + fn rust_timegm(&&tm: Tm, &sec: i64); + fn rust_mktime(&&tm: Tm, &sec: i64); } /// A record specifying a time value in seconds and nanoseconds. -type timespec = {sec: i64, nsec: i32}; +type Timespec = {sec: i64, nsec: i32}; /** * Returns the current time as a `timespec` containing the seconds and * nanoseconds since 1970-01-01T00:00:00Z. */ -fn get_time() -> timespec { +fn get_time() -> Timespec { let mut sec = 0i64; let mut nsec = 0i32; rustrt::get_time(sec, nsec); @@ -68,7 +68,7 @@ fn tzset() { rustrt::rust_tzset(); } -type tm_ = { +type Tm_ = { tm_sec: i32, // seconds after the minute ~[0-60] tm_min: i32, // minutes after the hour ~[0-59] tm_hour: i32, // hours after midnight ~[0-23] @@ -83,12 +83,12 @@ type tm_ = { tm_nsec: i32, // nanoseconds }; -enum tm { - tm_(tm_) +enum Tm { + Tm_(Tm_) } -fn empty_tm() -> tm { - tm_({ +fn empty_tm() -> Tm { + Tm_({ tm_sec: 0_i32, tm_min: 0_i32, tm_hour: 0_i32, @@ -105,7 +105,7 @@ fn empty_tm() -> tm { } /// Returns the specified time in UTC -fn at_utc(clock: timespec) -> tm { +fn at_utc(clock: Timespec) -> Tm { let mut {sec, nsec} = clock; let mut tm = empty_tm(); rustrt::rust_gmtime(sec, nsec, tm); @@ -113,12 +113,12 @@ fn at_utc(clock: timespec) -> tm { } /// Returns the current time in UTC -fn now_utc() -> tm { +fn now_utc() -> Tm { at_utc(get_time()) } /// Returns the specified time in the local timezone -fn at(clock: timespec) -> tm { +fn at(clock: Timespec) -> Tm { let mut {sec, nsec} = clock; let mut tm = empty_tm(); rustrt::rust_localtime(sec, nsec, tm); @@ -126,13 +126,13 @@ fn at(clock: timespec) -> tm { } /// Returns the current time in the local timezone -fn now() -> tm { +fn now() -> Tm { at(get_time()) } /// Parses the time from the string according to the format string. -fn strptime(s: &str, format: &str) -> Result { - type tm_mut = { +fn strptime(s: &str, format: &str) -> Result { + type TmMut = { mut tm_sec: i32, mut tm_min: i32, mut tm_hour: i32, @@ -209,7 +209,7 @@ fn strptime(s: &str, format: &str) -> Result { } } - fn parse_type(s: &str, pos: uint, ch: char, tm: &tm_mut) + fn parse_type(s: &str, pos: uint, ch: char, tm: &TmMut) -> Result { match ch { 'A' => match match_strs(s, pos, ~[ @@ -554,7 +554,7 @@ fn strptime(s: &str, format: &str) -> Result { } if pos == len && rdr.eof() { - Ok(tm_({ + Ok(Tm_({ tm_sec: tm.tm_sec, tm_min: tm.tm_min, tm_hour: tm.tm_hour, @@ -572,8 +572,8 @@ fn strptime(s: &str, format: &str) -> Result { } } -fn strftime(format: &str, +tm: tm) -> ~str { - fn parse_type(ch: char, tm: &tm) -> ~str { +fn strftime(format: &str, +tm: Tm) -> ~str { + fn parse_type(ch: char, tm: &Tm) -> ~str { //FIXME (#2350): Implement missing types. let die = || #fmt("strftime: can't understand this format %c ", ch); @@ -740,9 +740,9 @@ fn strftime(format: &str, +tm: tm) -> ~str { buf } -impl tm { +impl Tm { /// Convert time to the seconds from January 1, 1970 - fn to_timespec() -> timespec { + fn to_timespec() -> Timespec { let mut sec = 0i64; if self.tm_gmtoff == 0_i32 { rustrt::rust_timegm(self, sec); @@ -753,12 +753,12 @@ impl tm { } /// Convert time to the local timezone - fn to_local() -> tm { + fn to_local() -> Tm { at(self.to_timespec()) } /// Convert time to the UTC - fn to_utc() -> tm { + fn to_utc() -> Tm { at_utc(self.to_timespec()) } diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index a25b5e28410..a624f470378 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -168,8 +168,8 @@ fn get_dest_addr(dest: dest) -> ValueRef { } } -fn log_fn_time(ccx: @crate_ctxt, name: ~str, start: time::timespec, - end: time::timespec) { +fn log_fn_time(ccx: @crate_ctxt, name: ~str, start: time::Timespec, + end: time::Timespec) { let elapsed = 1000 * ((end.sec - start.sec) as int) + ((end.nsec as int) - (start.nsec as int)) / 1000000; vec::push(*ccx.stats.fn_times, {ident: name, time: elapsed});