stdlib: "tag" -> "enum"
This commit is contained in:
parent
7e21be5304
commit
c5a407b11b
15 changed files with 39 additions and 39 deletions
|
@ -37,12 +37,12 @@ export ptr;
|
||||||
/*
|
/*
|
||||||
Type: t
|
Type: t
|
||||||
|
|
||||||
The type representing a native chunk of memory. Wrapped in a tag for
|
The type representing a native chunk of memory. Wrapped in a enum for
|
||||||
opacity; FIXME #818 when it is possible to have truly opaque types, this
|
opacity; FIXME #818 when it is possible to have truly opaque types, this
|
||||||
should be revisited.
|
should be revisited.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tag t<T> {
|
enum t<T> {
|
||||||
t({ base: *mutable T, len: uint, rsrc: @dtor_res});
|
t({ base: *mutable T, len: uint, rsrc: @dtor_res});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,9 +241,9 @@ mod tests {
|
||||||
assert (e(deq.get(3), d));
|
assert (e(deq.get(3), d));
|
||||||
}
|
}
|
||||||
|
|
||||||
tag taggy { one(int); two(int, int); three(int, int, int); }
|
enum taggy { one(int); two(int, int); three(int, int, int); }
|
||||||
|
|
||||||
tag taggypar<T> {
|
enum taggypar<T> {
|
||||||
onepar(int); twopar(int, int); threepar(int, int, int);
|
onepar(int); twopar(int, int); threepar(int, int, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ fn get_doc(d: doc, tg: uint) -> doc {
|
||||||
alt maybe_get_doc(d, tg) {
|
alt maybe_get_doc(d, tg) {
|
||||||
some(d) { ret d; }
|
some(d) { ret d; }
|
||||||
none {
|
none {
|
||||||
#error("failed to find block with tag %u", tg);
|
#error("failed to find block with enum %u", tg);
|
||||||
fail;
|
fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ fn create_writer(w: io::writer) -> writer {
|
||||||
|
|
||||||
// TODO: Provide a function to write the standard ebml header.
|
// TODO: Provide a function to write the standard ebml header.
|
||||||
fn start_tag(w: writer, tag_id: uint) {
|
fn start_tag(w: writer, tag_id: uint) {
|
||||||
// Write the tag ID:
|
// Write the enum ID:
|
||||||
|
|
||||||
write_vint(w.writer, tag_id);
|
write_vint(w.writer, tag_id);
|
||||||
// Write a placeholder four-byte size.
|
// Write a placeholder four-byte size.
|
||||||
|
|
|
@ -39,9 +39,9 @@ import option::{some, none};
|
||||||
|
|
||||||
// Functions used by the fmt extension at compile time
|
// Functions used by the fmt extension at compile time
|
||||||
mod ct {
|
mod ct {
|
||||||
tag signedness { signed; unsigned; }
|
enum signedness { signed; unsigned; }
|
||||||
tag caseness { case_upper; case_lower; }
|
enum caseness { case_upper; case_lower; }
|
||||||
tag ty {
|
enum ty {
|
||||||
ty_bool;
|
ty_bool;
|
||||||
ty_str;
|
ty_str;
|
||||||
ty_char;
|
ty_char;
|
||||||
|
@ -52,14 +52,14 @@ mod ct {
|
||||||
ty_float;
|
ty_float;
|
||||||
// FIXME: More types
|
// FIXME: More types
|
||||||
}
|
}
|
||||||
tag flag {
|
enum flag {
|
||||||
flag_left_justify;
|
flag_left_justify;
|
||||||
flag_left_zero_pad;
|
flag_left_zero_pad;
|
||||||
flag_space_for_sign;
|
flag_space_for_sign;
|
||||||
flag_sign_always;
|
flag_sign_always;
|
||||||
flag_alternate;
|
flag_alternate;
|
||||||
}
|
}
|
||||||
tag count {
|
enum count {
|
||||||
count_is(int);
|
count_is(int);
|
||||||
count_is_param(int);
|
count_is_param(int);
|
||||||
count_is_next_param;
|
count_is_next_param;
|
||||||
|
@ -76,7 +76,7 @@ mod ct {
|
||||||
|
|
||||||
|
|
||||||
// A fragment of the output sequence
|
// A fragment of the output sequence
|
||||||
tag piece { piece_string(str); piece_conv(conv); }
|
enum piece { piece_string(str); piece_conv(conv); }
|
||||||
type error_fn = fn@(str) -> ! ;
|
type error_fn = fn@(str) -> ! ;
|
||||||
|
|
||||||
fn parse_fmt_string(s: str, error: error_fn) -> [piece] {
|
fn parse_fmt_string(s: str, error: error_fn) -> [piece] {
|
||||||
|
@ -260,7 +260,7 @@ mod ct {
|
||||||
// conditions can be evaluated at compile-time. For now though it's cleaner to
|
// conditions can be evaluated at compile-time. For now though it's cleaner to
|
||||||
// implement it this way, I think.
|
// implement it this way, I think.
|
||||||
mod rt {
|
mod rt {
|
||||||
tag flag {
|
enum flag {
|
||||||
flag_left_justify;
|
flag_left_justify;
|
||||||
flag_left_zero_pad;
|
flag_left_zero_pad;
|
||||||
flag_space_for_sign;
|
flag_space_for_sign;
|
||||||
|
@ -273,8 +273,8 @@ mod rt {
|
||||||
// comments in front::extfmt::make_flags
|
// comments in front::extfmt::make_flags
|
||||||
flag_none;
|
flag_none;
|
||||||
}
|
}
|
||||||
tag count { count_is(int); count_implied; }
|
enum count { count_is(int); count_implied; }
|
||||||
tag ty { ty_default; ty_bits; ty_hex_upper; ty_hex_lower; ty_octal; }
|
enum ty { ty_default; ty_bits; ty_hex_upper; ty_hex_lower; ty_octal; }
|
||||||
|
|
||||||
// FIXME: May not want to use a vector here for flags;
|
// FIXME: May not want to use a vector here for flags;
|
||||||
// instead just use a bool per flag
|
// instead just use a bool per flag
|
||||||
|
@ -384,7 +384,7 @@ mod rt {
|
||||||
|
|
||||||
ret str::unsafe_from_bytes(svec);
|
ret str::unsafe_from_bytes(svec);
|
||||||
}
|
}
|
||||||
tag pad_mode { pad_signed; pad_unsigned; pad_nozero; }
|
enum pad_mode { pad_signed; pad_unsigned; pad_nozero; }
|
||||||
fn pad(cv: conv, s: str, mode: pad_mode) -> str {
|
fn pad(cv: conv, s: str, mode: pad_mode) -> str {
|
||||||
let uwidth;
|
let uwidth;
|
||||||
alt cv.width {
|
alt cv.width {
|
||||||
|
|
|
@ -31,7 +31,7 @@ type treemap<K, V> = @tree_node<K, V>;
|
||||||
/*
|
/*
|
||||||
Tag: tree_node
|
Tag: tree_node
|
||||||
*/
|
*/
|
||||||
tag tree_node<K, V> {
|
enum tree_node<K, V> {
|
||||||
empty;
|
empty;
|
||||||
node(@K, @V, @tree_node<K, V>, @tree_node<K, V>);
|
node(@K, @V, @tree_node<K, V>, @tree_node<K, V>);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,11 +65,11 @@ export opt_strs;
|
||||||
export opt_maybe_str;
|
export opt_maybe_str;
|
||||||
export opt_default;
|
export opt_default;
|
||||||
|
|
||||||
tag name { long(str); short(char); }
|
enum name { long(str); short(char); }
|
||||||
|
|
||||||
tag hasarg { yes; no; maybe; }
|
enum hasarg { yes; no; maybe; }
|
||||||
|
|
||||||
tag occur { req; optional; multi; }
|
enum occur { req; optional; multi; }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Type: opt
|
Type: opt
|
||||||
|
@ -130,7 +130,7 @@ fn optmulti(name: str) -> opt {
|
||||||
ret {name: mkname(name), hasarg: yes, occur: multi};
|
ret {name: mkname(name), hasarg: yes, occur: multi};
|
||||||
}
|
}
|
||||||
|
|
||||||
tag optval { val(str); given; }
|
enum optval { val(str); given; }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Type: match
|
Type: match
|
||||||
|
@ -158,7 +158,7 @@ Type: fail_
|
||||||
The type returned when the command line does not conform to the
|
The type returned when the command line does not conform to the
|
||||||
expected format. Pass this value to <fail_str> to get an error message.
|
expected format. Pass this value to <fail_str> to get an error message.
|
||||||
*/
|
*/
|
||||||
tag fail_ {
|
enum fail_ {
|
||||||
argument_missing(str);
|
argument_missing(str);
|
||||||
unrecognized_option(str);
|
unrecognized_option(str);
|
||||||
option_missing(str);
|
option_missing(str);
|
||||||
|
@ -169,7 +169,7 @@ tag fail_ {
|
||||||
/*
|
/*
|
||||||
Function: fail_str
|
Function: fail_str
|
||||||
|
|
||||||
Convert a <fail_> tag into an error string
|
Convert a <fail_> enum into an error string
|
||||||
*/
|
*/
|
||||||
fn fail_str(f: fail_) -> str {
|
fn fail_str(f: fail_) -> str {
|
||||||
ret alt f {
|
ret alt f {
|
||||||
|
@ -381,7 +381,7 @@ mod tests {
|
||||||
import opt = getopts;
|
import opt = getopts;
|
||||||
import result::{err, ok};
|
import result::{err, ok};
|
||||||
|
|
||||||
tag fail_type {
|
enum fail_type {
|
||||||
argument_missing_;
|
argument_missing_;
|
||||||
unrecognized_option_;
|
unrecognized_option_;
|
||||||
option_missing_;
|
option_missing_;
|
||||||
|
|
|
@ -17,7 +17,7 @@ native mod rustrt {
|
||||||
// Reading
|
// Reading
|
||||||
|
|
||||||
// FIXME This is all buffered. We might need an unbuffered variant as well
|
// FIXME This is all buffered. We might need an unbuffered variant as well
|
||||||
tag seek_style { seek_set; seek_end; seek_cur; }
|
enum seek_style { seek_set; seek_end; seek_cur; }
|
||||||
|
|
||||||
|
|
||||||
// The raw underlying reader iface. All readers must implement this.
|
// The raw underlying reader iface. All readers must implement this.
|
||||||
|
@ -264,7 +264,7 @@ fn string_reader(s: str) -> reader {
|
||||||
|
|
||||||
|
|
||||||
// Writing
|
// Writing
|
||||||
tag fileflag { append; create; truncate; none; }
|
enum fileflag { append; create; truncate; none; }
|
||||||
|
|
||||||
// FIXME: Seekable really should be orthogonal.
|
// FIXME: Seekable really should be orthogonal.
|
||||||
// FIXME: eventually u64
|
// FIXME: eventually u64
|
||||||
|
@ -495,7 +495,7 @@ fn read_whole_file(file: str) -> result::t<[u8], str> {
|
||||||
|
|
||||||
mod fsync {
|
mod fsync {
|
||||||
|
|
||||||
tag level {
|
enum level {
|
||||||
// whatever fsync does on that platform
|
// whatever fsync does on that platform
|
||||||
fsync;
|
fsync;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ Tag: json
|
||||||
|
|
||||||
Represents a json value.
|
Represents a json value.
|
||||||
*/
|
*/
|
||||||
tag json {
|
enum json {
|
||||||
/* Variant: num */
|
/* Variant: num */
|
||||||
num(float);
|
num(float);
|
||||||
/* Variant: string */
|
/* Variant: string */
|
||||||
|
|
|
@ -13,7 +13,7 @@ import option::{some, none};
|
||||||
/*
|
/*
|
||||||
Tag: list
|
Tag: list
|
||||||
*/
|
*/
|
||||||
tag list<T> {
|
enum list<T> {
|
||||||
/* Variant: cons */
|
/* Variant: cons */
|
||||||
cons(T, @list<T>);
|
cons(T, @list<T>);
|
||||||
/* Variant: nil */
|
/* Variant: nil */
|
||||||
|
|
|
@ -112,7 +112,7 @@ mod chained {
|
||||||
mutable next: chain<K, V>
|
mutable next: chain<K, V>
|
||||||
};
|
};
|
||||||
|
|
||||||
tag chain<K, V> {
|
enum chain<K, V> {
|
||||||
present(@entry<K, V>);
|
present(@entry<K, V>);
|
||||||
absent;
|
absent;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ mod chained {
|
||||||
eqer: eqfn<K>
|
eqer: eqfn<K>
|
||||||
};
|
};
|
||||||
|
|
||||||
tag search_result<K, V> {
|
enum search_result<K, V> {
|
||||||
not_found;
|
not_found;
|
||||||
found_first(uint, @entry<K,V>);
|
found_first(uint, @entry<K,V>);
|
||||||
found_after(@entry<K,V>, @entry<K,V>);
|
found_after(@entry<K,V>, @entry<K,V>);
|
||||||
|
|
|
@ -12,7 +12,7 @@ Tag: ip_addr
|
||||||
|
|
||||||
An IP address
|
An IP address
|
||||||
*/
|
*/
|
||||||
tag ip_addr {
|
enum ip_addr {
|
||||||
/*
|
/*
|
||||||
Variant: ipv4
|
Variant: ipv4
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ Function: parse_addr
|
||||||
|
|
||||||
Convert a str to <ip_addr>
|
Convert a str to <ip_addr>
|
||||||
|
|
||||||
Converts a string of the format "x.x.x.x" into an ip_addr tag.
|
Converts a string of the format "x.x.x.x" into an ip_addr enum.
|
||||||
|
|
||||||
Failure:
|
Failure:
|
||||||
|
|
||||||
|
|
|
@ -585,7 +585,7 @@ mod node {
|
||||||
empty - An empty rope
|
empty - An empty rope
|
||||||
content - A non-empty rope
|
content - A non-empty rope
|
||||||
*/
|
*/
|
||||||
tag root {
|
enum root {
|
||||||
empty;
|
empty;
|
||||||
content(@node);
|
content(@node);
|
||||||
}
|
}
|
||||||
|
@ -688,7 +688,7 @@ mod node {
|
||||||
leaf - A leaf consisting in a `str`
|
leaf - A leaf consisting in a `str`
|
||||||
concat - The concatenation of two ropes
|
concat - The concatenation of two ropes
|
||||||
*/
|
*/
|
||||||
tag node {
|
enum node {
|
||||||
leaf(leaf);
|
leaf(leaf);
|
||||||
concat(concat);
|
concat(concat);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ fn parse_opts(args: [str]) : vec::is_not_empty(args) -> opt_res {
|
||||||
ret either::left(test_opts);
|
ret either::left(test_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
tag test_result { tr_ok; tr_failed; tr_ignored; }
|
enum test_result { tr_ok; tr_failed; tr_ignored; }
|
||||||
|
|
||||||
// A simple console test runner
|
// A simple console test runner
|
||||||
fn run_tests_console(opts: test_opts,
|
fn run_tests_console(opts: test_opts,
|
||||||
|
@ -186,7 +186,7 @@ fn run_tests_console(opts: test_opts,
|
||||||
|
|
||||||
fn use_color() -> bool { ret get_concurrency() == 1u; }
|
fn use_color() -> bool { ret get_concurrency() == 1u; }
|
||||||
|
|
||||||
tag testevent {
|
enum testevent {
|
||||||
te_filtered([test_desc]);
|
te_filtered([test_desc]);
|
||||||
te_wait(test_desc);
|
te_wait(test_desc);
|
||||||
te_result(test_desc, test_result);
|
te_result(test_desc, test_result);
|
||||||
|
|
|
@ -28,7 +28,7 @@ type treemap<K, V> = @mutable tree_node<K, V>;
|
||||||
/*
|
/*
|
||||||
Tag: tree_node
|
Tag: tree_node
|
||||||
*/
|
*/
|
||||||
tag tree_node<K, V> { empty; node(@K, @V, treemap<K, V>, treemap<K, V>); }
|
enum tree_node<K, V> { empty; node(@K, @V, treemap<K, V>, treemap<K, V>); }
|
||||||
|
|
||||||
/* Section: Operations */
|
/* Section: Operations */
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ fn path_is_absolute(p: str) -> bool {
|
||||||
* different semantics for each. Since we build on mingw, we are usually
|
* different semantics for each. Since we build on mingw, we are usually
|
||||||
* dealing with /-separated paths. But the whole interface to splitting and
|
* dealing with /-separated paths. But the whole interface to splitting and
|
||||||
* joining pathnames needs a bit more abstraction on win32. Possibly a vec or
|
* joining pathnames needs a bit more abstraction on win32. Possibly a vec or
|
||||||
* tag type.
|
* enum type.
|
||||||
*/
|
*/
|
||||||
const path_sep: char = '/';
|
const path_sep: char = '/';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue