diff options
| author | bors <bors@rust-lang.org> | 2013-06-30 21:14:13 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-06-30 21:14:13 -0700 |
| commit | 07feeb95c5e73c5d871c7e365cf4a7138774d449 (patch) | |
| tree | 8b7f2a06b1a86a57dc3bc00bb53da5e96b1a243b /src/etc | |
| parent | d5c5ce3f8d07ba7f9059727a790ce19f7a1599b7 (diff) | |
| parent | c0a20d2929a7c0d6af0de899198df4f26453d877 (diff) | |
auto merge of #7487 : huonw/rust/vec-kill, r=cmr
Continuation of #7430. I haven't removed the `map` method, since the replacement `v.iter().transform(f).collect::<~[SomeType]>()` is a little ridiculous at the moment.
Diffstat (limited to 'src/etc')
| -rwxr-xr-x | src/etc/unicode.py | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/etc/unicode.py b/src/etc/unicode.py index afb3d168480..2a252f3f1f3 100755 --- a/src/etc/unicode.py +++ b/src/etc/unicode.py @@ -122,14 +122,14 @@ def ch_prefix(ix): def emit_bsearch_range_table(f): f.write(""" - pure fn bsearch_range_table(c: char, r: &[(char,char)]) -> bool { - use cmp::{EQ, LT, GT}; - use vec::bsearch; + fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { + use cmp::{Equal, Less, Greater}; + use vec::ImmutableVector; use option::None; - (do bsearch(r) |&(lo,hi)| { - if lo <= c && c <= hi { EQ } - else if hi < c { LT } - else { GT } + (do r.bsearch |&(lo,hi)| { + if lo <= c && c <= hi { Equal } + else if hi < c { Less } + else { Greater } }) != None }\n\n """); @@ -140,7 +140,7 @@ def emit_property_module(f, mod, tbl): keys.sort() emit_bsearch_range_table(f); for cat in keys: - f.write(" const %s_table : &[(char,char)] = &[\n" % cat) + f.write(" static %s_table : &'static [(char,char)] = &[\n" % cat) ix = 0 for pair in tbl[cat]: f.write(ch_prefix(ix)) @@ -148,7 +148,7 @@ def emit_property_module(f, mod, tbl): ix += 1 f.write("\n ];\n\n") - f.write(" pub pure fn %s(c: char) -> bool {\n" % cat) + f.write(" pub fn %s(c: char) -> bool {\n" % cat) f.write(" bsearch_range_table(c, %s_table)\n" % cat) f.write(" }\n\n") f.write("}\n") @@ -159,7 +159,7 @@ def emit_property_module_old(f, mod, tbl): keys = tbl.keys() keys.sort() for cat in keys: - f.write(" pure fn %s(c: char) -> bool {\n" % cat) + f.write(" fn %s(c: char) -> bool {\n" % cat) f.write(" ret alt c {\n") prefix = ' ' for pair in tbl[cat]: @@ -236,8 +236,22 @@ rf = open(r, "w") (canon_decomp, compat_decomp, gencats) = load_unicode_data("UnicodeData.txt") -# Explain that the source code was generated by this script. -rf.write('// The following code was generated by "src/etc/unicode.py"\n\n') +# Preamble +rf.write('''// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <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. + +// The following code was generated by "src/etc/unicode.py" + +#[allow(missing_doc)]; + +''') emit_property_module(rf, "general_category", gencats) |
