Skip to content

Commit 90f6b74

Browse files
authored
Merge pull request capnproto#368 from danieleades/macro-braces
use standard macro braces
2 parents 3342c43 + 69b8331 commit 90f6b74

File tree

1 file changed

+55
-55
lines changed

1 file changed

+55
-55
lines changed

capnpc/src/codegen.rs

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,24 +1408,24 @@ fn generate_pipeline_getter(
14081408
let typ = reg_field.get_type()?;
14091409
match typ.which()? {
14101410
type_::Struct(_) | type_::AnyPointer(_) => {
1411-
Ok(Branch(vec!(
1411+
Ok(Branch(vec![
14121412
Line(format!("pub fn get_{}(&self) -> {} {{",
14131413
camel_to_snake_case(name),
14141414
typ.type_string(gen, Leaf::Pipeline)?)),
14151415
Indent(Box::new(Line(
14161416
format!("::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field({}))",
14171417
reg_field.get_offset())))),
1418-
Line("}".to_string()))))
1418+
Line("}".to_string())]))
14191419
}
14201420
type_::Interface(_) => {
1421-
Ok(Branch(vec!(
1421+
Ok(Branch(vec![
14221422
Line(format!("pub fn get_{}(&self) -> {} {{",
14231423
camel_to_snake_case(name),
14241424
typ.type_string(gen, Leaf::Client)?)),
14251425
Indent(Box::new(Line(
14261426
format!("::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field({}).as_cap())",
14271427
reg_field.get_offset())))),
1428-
Line("}".to_string()))))
1428+
Line("}".to_string())]))
14291429
}
14301430
_ => {
14311431
Ok(Branch(Vec::new()))
@@ -1674,12 +1674,12 @@ fn generate_node(
16741674
}
16751675

16761676
let builder_struct_size =
1677-
Branch(vec!(
1677+
Branch(vec![
16781678
Line(format!("impl <'a,{0}> ::capnp::traits::HasStructSize for Builder<'a,{0}> {1} {{",
16791679
params.params, params.where_clause)),
16801680
Indent(Box::new(Line(
16811681
format!("const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize {{ data: {}, pointers: {} }};", data_size as usize, pointer_size as usize)))),
1682-
Line("}".to_string())));
1682+
Line("}".to_string())]);
16831683

16841684
private_mod_interior.push(Line(format!(
16851685
"pub const TYPE_ID: u64 = {};",
@@ -1691,28 +1691,28 @@ fn generate_node(
16911691
Line(format!("impl <'a,{0}> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,{0}> {1} {{", params.params, params.where_clause)),
16921692
Indent(
16931693
Box::new(
1694-
Branch(vec!(
1694+
Branch(vec![
16951695
Line("fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Self {".to_string()),
16961696
Indent(Box::new(Line("builder.init_struct(<Self as ::capnp::traits::HasStructSize>::STRUCT_SIZE).into()".to_string()))),
16971697
Line("}".to_string()),
16981698
Line("fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Self> {".to_string()),
16991699
Indent(Box::new(Line("::core::result::Result::Ok(builder.get_struct(<Self as ::capnp::traits::HasStructSize>::STRUCT_SIZE, default)?.into())".to_string()))),
1700-
Line("}".to_string()))))),
1700+
Line("}".to_string())]))),
17011701
Line("}".to_string()),
17021702
BlankLine]);
17031703

17041704
let accessors = vec![
17051705
Branch(preamble),
17061706
(if !is_generic {
1707-
Branch(vec!(
1707+
Branch(vec![
17081708
Line("#[derive(Copy, Clone)]".into()),
17091709
Line("pub struct Owned(());".to_string()),
17101710
Line("impl ::capnp::traits::Owned for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; }".to_string()),
17111711
Line("impl ::capnp::traits::OwnedStruct for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; }".to_string()),
17121712
Line("impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; }".to_string())
1713-
))
1713+
])
17141714
} else {
1715-
Branch(vec!(
1715+
Branch(vec![
17161716
Line("#[derive(Copy, Clone)]".into()),
17171717
Line(format!("pub struct Owned<{}> {{", params.params)),
17181718
Indent(Box::new(Line(params.phantom_data_type.clone()))),
@@ -1723,62 +1723,62 @@ fn generate_node(
17231723
params.params, params.where_clause)),
17241724
Line(format!("impl <{0}> ::capnp::traits::Pipelined for Owned<{0}> {1} {{ type Pipeline = Pipeline{2}; }}",
17251725
params.params, params.where_clause, bracketed_params)),
1726-
))
1726+
])
17271727
}),
17281728
BlankLine,
17291729
Line("#[derive(Clone, Copy)]".to_string()),
17301730
(if !is_generic {
17311731
Line("pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> }".to_string())
17321732
} else {
1733-
Branch(vec!(
1733+
Branch(vec![
17341734
Line(format!("pub struct Reader<'a,{}> {} {{", params.params, params.where_clause)),
1735-
Indent(Box::new(Branch(vec!(
1735+
Indent(Box::new(Branch(vec![
17361736
Line("reader: ::capnp::private::layout::StructReader<'a>,".to_string()),
17371737
Line(params.phantom_data_type.clone()),
1738-
)))),
1738+
]))),
17391739
Line("}".to_string())
1740-
))
1740+
])
17411741
}),
17421742
BlankLine,
1743-
Branch(vec!(
1743+
Branch(vec![
17441744
Line(format!("impl <'a,{0}> ::capnp::traits::HasTypeId for Reader<'a,{0}> {1} {{",
17451745
params.params, params.where_clause)),
1746-
Indent(Box::new(Branch(vec!(Line("const TYPE_ID: u64 = _private::TYPE_ID;".to_string()))))),
1747-
Line("}".to_string()))),
1746+
Indent(Box::new(Branch(vec![Line("const TYPE_ID: u64 = _private::TYPE_ID;".to_string())]))),
1747+
Line("}".to_string())]),
17481748
Line(format!("impl <'a,{0}> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a,{0}> {1} {{",
17491749
params.params, params.where_clause)),
17501750
Indent(
1751-
Box::new(Branch(vec!(
1751+
Box::new(Branch(vec![
17521752
Line("fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self {".to_string()),
17531753
Indent(Box::new(Line(format!("Self {{ reader, {} }}", params.phantom_data_value)))),
1754-
Line("}".to_string()))))),
1754+
Line("}".to_string())]))),
17551755
Line("}".to_string()),
17561756
BlankLine,
17571757
Line(format!("impl <'a,{0}> ::capnp::traits::FromPointerReader<'a> for Reader<'a,{0}> {1} {{",
17581758
params.params, params.where_clause)),
17591759
Indent(
1760-
Box::new(Branch(vec!(
1760+
Box::new(Branch(vec![
17611761
Line("fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Self> {".to_string()),
17621762
Indent(Box::new(Line("::core::result::Result::Ok(reader.get_struct(default)?.into())".to_string()))),
1763-
Line("}".to_string()))))),
1763+
Line("}".to_string())]))),
17641764
Line("}".to_string()),
17651765
BlankLine,
17661766
Line(format!("impl <'a,{0}> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,{0}> {1} {{",
17671767
params.params, params.where_clause)),
17681768
Indent(
1769-
Box::new(Branch(vec!(
1769+
Box::new(Branch(vec![
17701770
Line("fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {".to_string()),
17711771
Indent(Box::new(Line("self.reader".to_string()))),
1772-
Line("}".to_string()))))),
1772+
Line("}".to_string())]))),
17731773
Line("}".to_string()),
17741774
BlankLine,
17751775
Line(format!("impl <'a,{0}> ::capnp::traits::Imbue<'a> for Reader<'a,{0}> {1} {{",
17761776
params.params, params.where_clause)),
17771777
Indent(
1778-
Box::new(Branch(vec!(
1778+
Box::new(Branch(vec![
17791779
Line("fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) {".to_string()),
17801780
Indent(Box::new(Line("self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table))".to_string()))),
1781-
Line("}".to_string()))))),
1781+
Line("}".to_string())]))),
17821782
Line("}".to_string()),
17831783
BlankLine,
17841784
Line(format!("impl <'a,{0}> Reader<'a,{0}> {1} {{", params.params, params.where_clause)),
@@ -1797,40 +1797,40 @@ fn generate_node(
17971797
(if !is_generic {
17981798
Line("pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> }".to_string())
17991799
} else {
1800-
Branch(vec!(
1800+
Branch(vec![
18011801
Line(format!("pub struct Builder<'a,{}> {} {{",
18021802
params.params, params.where_clause)),
1803-
Indent(Box::new(Branch(vec!(
1803+
Indent(Box::new(Branch(vec![
18041804
Line("builder: ::capnp::private::layout::StructBuilder<'a>,".to_string()),
18051805
Line(params.phantom_data_type.clone()),
1806-
)))),
1806+
]))),
18071807
Line("}".to_string())
1808-
))
1808+
])
18091809
}),
18101810
builder_struct_size,
1811-
Branch(vec!(
1811+
Branch(vec![
18121812
Line(format!("impl <'a,{0}> ::capnp::traits::HasTypeId for Builder<'a,{0}> {1} {{",
18131813
params.params, params.where_clause)),
1814-
Indent(Box::new(Branch(vec!(
1815-
Line("const TYPE_ID: u64 = _private::TYPE_ID;".to_string()))))),
1816-
Line("}".to_string()))),
1814+
Indent(Box::new(Branch(vec![
1815+
Line("const TYPE_ID: u64 = _private::TYPE_ID;".to_string())]))),
1816+
Line("}".to_string())]),
18171817
Line(format!(
18181818
"impl <'a,{0}> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a,{0}> {1} {{",
18191819
params.params, params.where_clause)),
18201820
Indent(
1821-
Box::new(Branch(vec!(
1821+
Box::new(Branch(vec![
18221822
Line("fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self {".to_string()),
18231823
Indent(Box::new(Line(format!("Self {{ builder, {} }}", params.phantom_data_value)))),
1824-
Line("}".to_string()))))),
1824+
Line("}".to_string())]))),
18251825
Line("}".to_string()),
18261826
BlankLine,
18271827
Line(format!("impl <'a,{0}> ::capnp::traits::ImbueMut<'a> for Builder<'a,{0}> {1} {{",
18281828
params.params, params.where_clause)),
18291829
Indent(
1830-
Box::new(Branch(vec!(
1830+
Box::new(Branch(vec![
18311831
Line("fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) {".to_string()),
18321832
Indent(Box::new(Line("self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table))".to_string()))),
1833-
Line("}".to_string()))))),
1833+
Line("}".to_string())]))),
18341834
Line("}".to_string()),
18351835
BlankLine,
18361836

@@ -1880,10 +1880,10 @@ fn generate_node(
18801880
}),
18811881
Line(format!("impl{bracketed_params} ::capnp::capability::FromTypelessPipeline for Pipeline{bracketed_params} {{")),
18821882
Indent(
1883-
Box::new(Branch(vec!(
1883+
Box::new(Branch(vec![
18841884
Line("fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self {".to_string()),
18851885
Indent(Box::new(Line(format!("Self {{ _typeless: typeless, {} }}", params.phantom_data_value)))),
1886-
Line("}".to_string()))))),
1886+
Line("}".to_string())]))),
18871887
Line("}".to_string()),
18881888
Line(format!("impl{0} Pipeline{0} {1} {{", bracketed_params,
18891889
params.pipeline_where_clause)),
@@ -2143,7 +2143,7 @@ fn generate_node(
21432143
}
21442144
mod_interior.push(Line("}".to_string()));
21452145
mod_interior.push(
2146-
Branch(vec!(
2146+
Branch(vec![
21472147
Line(format!("impl {bracketed_params} ::capnp::capability::FromClientHook for Client{bracketed_params} {{")),
21482148
Indent(Box::new(Line("fn new(hook: Box<dyn (::capnp::private::capability::ClientHook)>) -> Self {".to_string()))),
21492149
Indent(Box::new(Indent(Box::new(Line(format!("Self {{ client: ::capnp::capability::Client::new(hook), {} }}", params.phantom_data_value)))))),
@@ -2154,16 +2154,16 @@ fn generate_node(
21542154
Indent(Box::new(Line("fn as_client_hook(&self) -> &dyn (::capnp::private::capability::ClientHook) {".to_string()))),
21552155
Indent(Box::new(Indent(Box::new(Line("&*self.client.hook".to_string()))))),
21562156
Indent(Box::new(Line("}".to_string()))),
2157-
Line("}".to_string()))));
2157+
Line("}".to_string())]));
21582158

21592159
mod_interior.push(if !is_generic {
2160-
Branch(vec!(
2160+
Branch(vec![
21612161
Line("#[derive(Copy, Clone)]".into()),
21622162
Line("pub struct Owned(());".to_string()),
21632163
Line("impl ::capnp::traits::Owned for Owned { type Reader<'a> = Client; type Builder<'a> = Client; }".to_string()),
2164-
Line("impl ::capnp::traits::Pipelined for Owned { type Pipeline = Client; }".to_string())))
2164+
Line("impl ::capnp::traits::Pipelined for Owned { type Pipeline = Client; }".to_string())])
21652165
} else {
2166-
Branch(vec!(
2166+
Branch(vec![
21672167
Line("#[derive(Copy, Clone)]".into()),
21682168
Line(format!("pub struct Owned<{}> {} {{", params.params, params.where_clause)),
21692169
Indent(Box::new(Line(params.phantom_data_type.clone()))),
@@ -2173,18 +2173,18 @@ fn generate_node(
21732173
params.params, params.where_clause)),
21742174
Line(format!(
21752175
"impl <{0}> ::capnp::traits::Pipelined for Owned <{0}> {1} {{ type Pipeline = Client{2}; }}",
2176-
params.params, params.where_clause, bracketed_params))))
2176+
params.params, params.where_clause, bracketed_params))])
21772177
});
21782178

2179-
mod_interior.push(Branch(vec!(
2179+
mod_interior.push(Branch(vec![
21802180
Line(format!("impl <'a,{0}> ::capnp::traits::FromPointerReader<'a> for Client<{0}> {1} {{",
21812181
params.params, params.where_clause)),
21822182
Indent(
21832183
Box::new(Branch(vec![
21842184
Line("fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, _default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Self> {".to_string()),
21852185
Indent(Box::new(Line("::core::result::Result::Ok(::capnp::capability::FromClientHook::new(reader.get_capability()?))".to_string()))),
21862186
Line("}".to_string())]))),
2187-
Line("}".to_string()))));
2187+
Line("}".to_string())]));
21882188

21892189
mod_interior.push(Branch(vec![
21902190
Line(format!("impl <'a,{0}> ::capnp::traits::FromPointerBuilder<'a> for Client<{0}> {1} {{",
@@ -2227,12 +2227,12 @@ fn generate_node(
22272227
]));
22282228

22292229
mod_interior.push(
2230-
Branch(vec!(
2230+
Branch(vec![
22312231
Line(format!("impl {bracketed_params} Clone for Client{bracketed_params} {{")),
22322232
Indent(Box::new(Line("fn clone(&self) -> Self {".to_string()))),
22332233
Indent(Box::new(Indent(Box::new(Line(format!("Self {{ client: ::capnp::capability::Client::new(self.client.hook.add_ref()), {} }}", params.phantom_data_value)))))),
22342234
Indent(Box::new(Line("}".to_string()))),
2235-
Line("}".to_string()))));
2235+
Line("}".to_string())]));
22362236

22372237
mod_interior.push(Branch(vec![
22382238
Line(format!(
@@ -2302,7 +2302,7 @@ fn generate_node(
23022302
]));
23032303

23042304
mod_interior.push(
2305-
Branch(vec!(
2305+
Branch(vec![
23062306
(if is_generic {
23072307
Line(format!("impl <{}, _T: Server{}> ::capnp::capability::Server for ServerDispatch<_T,{}> {} {{", params.params, bracketed_params, params.params, params.where_clause))
23082308
} else {
@@ -2316,10 +2316,10 @@ fn generate_node(
23162316
Indent(Box::new(Indent(Box::new(Indent(Box::new(Line("_ => { ::capnp::capability::Promise::err(::capnp::Error::unimplemented(\"Method not implemented.\".to_string())) }".to_string()))))))),
23172317
Indent(Box::new(Indent(Box::new(Line("}".to_string()))))),
23182318
Indent(Box::new(Line("}".to_string()))),
2319-
Line("}".to_string()))));
2319+
Line("}".to_string())]));
23202320

23212321
mod_interior.push(
2322-
Branch(vec!(
2322+
Branch(vec![
23232323
(if is_generic {
23242324
Line(format!("impl <{}, _T: Server{}> ServerDispatch<_T,{}> {} {{", params.params, bracketed_params, params.params, params.where_clause))
23252325
} else {
@@ -2331,7 +2331,7 @@ fn generate_node(
23312331
Indent(Box::new(Indent(Box::new(Indent(Box::new(Line("_ => { ::capnp::capability::Promise::err(::capnp::Error::unimplemented(\"Method not implemented.\".to_string())) }".to_string()))))))),
23322332
Indent(Box::new(Indent(Box::new(Line("}".to_string()))))),
23332333
Indent(Box::new(Line("}".to_string()))),
2334-
Line("}".to_string()))));
2334+
Line("}".to_string())]));
23352335

23362336
mod_interior.push(Branch(vec![
23372337
Line("pub mod _private {".to_string()),

0 commit comments

Comments
 (0)