Skip to content

Commit 4045da9

Browse files
committed
syntax/ext: modernise ext_ctxt to be CamelCase and use new.
1 parent eea265e commit 4045da9

36 files changed

+331
-332
lines changed

src/librustc/front/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use syntax::ast_util::*;
1717
use syntax::attr;
1818
use syntax::codemap::{dummy_sp, span, ExpandedFrom, CallInfo, NameAndSpan};
1919
use syntax::codemap;
20-
use syntax::ext::base::{mk_ctxt, ext_ctxt};
20+
use syntax::ext::base::ExtCtxt;
2121
use syntax::fold;
2222
use syntax::print::pprust;
2323
use syntax::{ast, ast_util};
@@ -36,7 +36,7 @@ struct TestCtxt {
3636
sess: session::Session,
3737
crate: @ast::crate,
3838
path: ~[ast::ident],
39-
ext_cx: @ext_ctxt,
39+
ext_cx: @ExtCtxt,
4040
testfns: ~[Test]
4141
}
4242

@@ -64,7 +64,7 @@ fn generate_test_harness(sess: session::Session,
6464
let cx: @mut TestCtxt = @mut TestCtxt {
6565
sess: sess,
6666
crate: crate,
67-
ext_cx: mk_ctxt(sess.parse_sess, copy sess.opts.cfg),
67+
ext_cx: ExtCtxt::new(sess.parse_sess, copy sess.opts.cfg),
6868
path: ~[],
6969
testfns: ~[]
7070
};

src/librustpkg/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::semver;
1919
use std::term;
2020
use syntax::ast_util::*;
2121
use syntax::codemap::{dummy_sp, spanned, dummy_spanned};
22-
use syntax::ext::base::{mk_ctxt, ext_ctxt};
22+
use syntax::ext::base::ExtCtxt;
2323
use syntax::{ast, attr, codemap, diagnostic, fold};
2424
use syntax::ast::{meta_name_value, meta_list};
2525
use syntax::attr::{mk_attr};
@@ -178,7 +178,7 @@ struct ListenerFn {
178178
struct ReadyCtx {
179179
sess: session::Session,
180180
crate: @ast::crate,
181-
ext_cx: @ext_ctxt,
181+
ext_cx: @ExtCtxt,
182182
path: ~[ast::ident],
183183
fns: ~[ListenerFn]
184184
}
@@ -247,7 +247,7 @@ pub fn ready_crate(sess: session::Session,
247247
let ctx = @mut ReadyCtx {
248248
sess: sess,
249249
crate: crate,
250-
ext_cx: mk_ctxt(sess.parse_sess, copy sess.opts.cfg),
250+
ext_cx: ExtCtxt::new(sess.parse_sess, copy sess.opts.cfg),
251251
path: ~[],
252252
fns: ~[]
253253
};

src/libsyntax/ext/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn next_state(s: State) -> Option<State> {
3737
}
3838
}
3939

40-
pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
40+
pub fn expand_asm(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
4141
-> base::MacResult {
4242
let p = parse::new_parser_from_tts(cx.parse_sess(),
4343
cx.cfg(),

src/libsyntax/ext/auto_encode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use codemap::span;
1515
use ext::base::*;
1616

1717
pub fn expand_auto_encode(
18-
cx: @ext_ctxt,
18+
cx: @ExtCtxt,
1919
span: span,
2020
_mitem: @ast::meta_item,
2121
in_items: ~[@ast::item]
@@ -25,7 +25,7 @@ pub fn expand_auto_encode(
2525
}
2626

2727
pub fn expand_auto_decode(
28-
cx: @ext_ctxt,
28+
cx: @ExtCtxt,
2929
span: span,
3030
_mitem: @ast::meta_item,
3131
in_items: ~[@ast::item]

src/libsyntax/ext/base.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub struct MacroDef {
3333
ext: SyntaxExtension
3434
}
3535

36-
pub type ItemDecorator = @fn(@ext_ctxt,
36+
pub type ItemDecorator = @fn(@ExtCtxt,
3737
span,
3838
@ast::meta_item,
3939
~[@ast::item])
@@ -44,7 +44,7 @@ pub struct SyntaxExpanderTT {
4444
span: Option<span>
4545
}
4646

47-
pub type SyntaxExpanderTTFun = @fn(@ext_ctxt,
47+
pub type SyntaxExpanderTTFun = @fn(@ExtCtxt,
4848
span,
4949
&[ast::token_tree])
5050
-> MacResult;
@@ -54,7 +54,7 @@ pub struct SyntaxExpanderTTItem {
5454
span: Option<span>
5555
}
5656

57-
pub type SyntaxExpanderTTItemFun = @fn(@ext_ctxt,
57+
pub type SyntaxExpanderTTItemFun = @fn(@ExtCtxt,
5858
span,
5959
ast::ident,
6060
~[ast::token_tree])
@@ -202,7 +202,7 @@ pub fn syntax_expander_table() -> SyntaxEnv {
202202
// One of these is made during expansion and incrementally updated as we go;
203203
// when a macro expansion occurs, the resulting nodes have the backtrace()
204204
// -> expn_info of their expansion context stored into their span.
205-
pub struct ext_ctxt {
205+
pub struct ExtCtxt {
206206
parse_sess: @mut parse::ParseSess,
207207
cfg: ast::crate_cfg,
208208
backtrace: @mut Option<@ExpnInfo>,
@@ -216,7 +216,17 @@ pub struct ext_ctxt {
216216
trace_mac: @mut bool
217217
}
218218

219-
pub impl ext_ctxt {
219+
pub impl ExtCtxt {
220+
fn new(parse_sess: @mut parse::ParseSess, cfg: ast::crate_cfg) -> @ExtCtxt {
221+
@ExtCtxt {
222+
parse_sess: parse_sess,
223+
cfg: cfg,
224+
backtrace: @mut None,
225+
mod_path: @mut ~[],
226+
trace_mac: @mut false
227+
}
228+
}
229+
220230
fn codemap(&self) -> @CodeMap { self.parse_sess.cm }
221231
fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess }
222232
fn cfg(&self) -> ast::crate_cfg { copy self.cfg }
@@ -294,18 +304,7 @@ pub impl ext_ctxt {
294304
}
295305
}
296306

297-
pub fn mk_ctxt(parse_sess: @mut parse::ParseSess, cfg: ast::crate_cfg)
298-
-> @ext_ctxt {
299-
@ext_ctxt {
300-
parse_sess: parse_sess,
301-
cfg: cfg,
302-
backtrace: @mut None,
303-
mod_path: @mut ~[],
304-
trace_mac: @mut false
305-
}
306-
}
307-
308-
pub fn expr_to_str(cx: @ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
307+
pub fn expr_to_str(cx: @ExtCtxt, expr: @ast::expr, err_msg: ~str) -> ~str {
309308
match expr.node {
310309
ast::expr_lit(l) => match l.node {
311310
ast::lit_str(s) => copy *s,
@@ -315,7 +314,7 @@ pub fn expr_to_str(cx: @ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
315314
}
316315
}
317316

318-
pub fn expr_to_ident(cx: @ext_ctxt,
317+
pub fn expr_to_ident(cx: @ExtCtxt,
319318
expr: @ast::expr,
320319
err_msg: &str) -> ast::ident {
321320
match expr.node {
@@ -329,14 +328,14 @@ pub fn expr_to_ident(cx: @ext_ctxt,
329328
}
330329
}
331330

332-
pub fn check_zero_tts(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree],
331+
pub fn check_zero_tts(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree],
333332
name: &str) {
334333
if tts.len() != 0 {
335334
cx.span_fatal(sp, fmt!("%s takes no arguments", name));
336335
}
337336
}
338337

339-
pub fn get_single_str_from_tts(cx: @ext_ctxt,
338+
pub fn get_single_str_from_tts(cx: @ExtCtxt,
340339
sp: span,
341340
tts: &[ast::token_tree],
342341
name: &str) -> ~str {
@@ -351,7 +350,7 @@ pub fn get_single_str_from_tts(cx: @ext_ctxt,
351350
}
352351
}
353352

354-
pub fn get_exprs_from_tts(cx: @ext_ctxt, tts: &[ast::token_tree])
353+
pub fn get_exprs_from_tts(cx: @ExtCtxt, tts: &[ast::token_tree])
355354
-> ~[@ast::expr] {
356355
let p = parse::new_parser_from_tts(cx.parse_sess(),
357356
cx.cfg(),

0 commit comments

Comments
 (0)