File tree 3 files changed +31
-0
lines changed
3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,8 @@ pub fn syntax_expander_table() -> SyntaxEnv {
139
139
@SE ( ItemDecorator ( ext:: auto_encode:: expand_auto_decode) ) ) ;
140
140
syntax_expanders. insert ( @~"env",
141
141
builtin_normal_tt ( ext:: env:: expand_syntax_ext) ) ;
142
+ syntax_expanders. insert ( @~"bytes",
143
+ builtin_normal_tt ( ext:: bytes:: expand_syntax_ext) ) ;
142
144
syntax_expanders. insert ( @~"concat_idents",
143
145
builtin_normal_tt (
144
146
ext:: concat_idents:: expand_syntax_ext) ) ;
Original file line number Diff line number Diff line change
1
+ // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ /* The compiler code necessary to support the bytes! extension. */
12
+
13
+ use ast;
14
+ use codemap:: span;
15
+ use ext:: base:: * ;
16
+ use ext:: base;
17
+ use ext:: build:: { mk_u8, mk_slice_vec_e} ;
18
+
19
+ pub fn expand_syntax_ext ( cx : @ext_ctxt , sp : span , tts : & [ ast:: token_tree ] )
20
+ -> base:: MacResult {
21
+ let var = get_single_str_from_tts ( cx, sp, tts, "bytes!" ) ;
22
+ let mut bytes = ~[ ] ;
23
+ for var. each |byte| {
24
+ bytes. push ( mk_u8 ( cx, sp, byte) ) ;
25
+ }
26
+ let e = mk_slice_vec_e ( cx, sp, bytes) ;
27
+ MRExpr ( e)
28
+ }
Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ pub mod ext {
78
78
79
79
pub mod fmt;
80
80
pub mod env;
81
+ pub mod bytes;
81
82
pub mod concat_idents;
82
83
pub mod log_syntax;
83
84
pub mod auto_encode;
You can’t perform that action at this time.
0 commit comments