diff --git a/capnp/src/any_pointer.rs b/capnp/src/any_pointer.rs index 9f46e0c51..a06f1bb68 100644 --- a/capnp/src/any_pointer.rs +++ b/capnp/src/any_pointer.rs @@ -157,7 +157,7 @@ impl <'a> Builder<'a> { } #[inline] - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a> { self.into_reader() } diff --git a/capnp/src/capability_list.rs b/capnp/src/capability_list.rs index 36a031831..430d4564c 100644 --- a/capnp/src/capability_list.rs +++ b/capnp/src/capability_list.rs @@ -101,7 +101,7 @@ impl <'a, T> Builder<'a, T> where T: FromClientHook { pub fn len(&self) -> u32 { self.builder.len() } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a, T> { self.into_reader() } diff --git a/capnp/src/data_list.rs b/capnp/src/data_list.rs index 58e41967e..d0fe126e9 100644 --- a/capnp/src/data_list.rs +++ b/capnp/src/data_list.rs @@ -81,7 +81,7 @@ impl <'a> Builder<'a> { pub fn len(&self) -> u32 { self.builder.len() } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a> { self.into_reader() } diff --git a/capnp/src/enum_list.rs b/capnp/src/enum_list.rs index cbf1bae8d..061eb7185 100644 --- a/capnp/src/enum_list.rs +++ b/capnp/src/enum_list.rs @@ -90,7 +90,7 @@ impl <'a, T : ToU16 + FromU16> Builder<'a, T> { pub fn len(&self) -> u32 { self.builder.len() } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a, T> { self.into_reader() } diff --git a/capnp/src/list_list.rs b/capnp/src/list_list.rs index 2cf1cb39f..804f0e181 100644 --- a/capnp/src/list_list.rs +++ b/capnp/src/list_list.rs @@ -92,7 +92,7 @@ impl <'a, T> Builder<'a, T> where T: for<'b> ::traits::Owned<'b> { pub fn len(&self) -> u32 { self.builder.len() } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a, T> { self.into_reader() } diff --git a/capnp/src/primitive_list.rs b/capnp/src/primitive_list.rs index 66ce10b44..3c90942dc 100644 --- a/capnp/src/primitive_list.rs +++ b/capnp/src/primitive_list.rs @@ -89,7 +89,7 @@ impl <'a, T> Builder<'a, T> where T: PrimitiveElement { pub fn len(&self) -> u32 { self.builder.len() } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a, T> { self.into_reader() } diff --git a/capnp/src/private/layout.rs b/capnp/src/private/layout.rs index 6ed860696..6f2abdcd8 100644 --- a/capnp/src/private/layout.rs +++ b/capnp/src/private/layout.rs @@ -2192,7 +2192,7 @@ pub enum CapTableBuilder { } impl CapTableBuilder { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> CapTableReader { self.into_reader() } @@ -2610,7 +2610,7 @@ impl <'a> PointerBuilder<'a> { } } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> PointerReader<'a> { self.into_reader() } @@ -2803,7 +2803,7 @@ pub struct StructBuilder<'a> { } impl <'a> StructBuilder<'a> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> StructReader<'a> { self.into_reader() } @@ -3102,7 +3102,7 @@ impl <'a> ListBuilder<'a> { } } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> ListReader<'a> { self.into_reader() } diff --git a/capnp/src/struct_list.rs b/capnp/src/struct_list.rs index 0184df89f..db02adb95 100644 --- a/capnp/src/struct_list.rs +++ b/capnp/src/struct_list.rs @@ -102,7 +102,7 @@ impl <'a, T> Builder<'a, T> where T: for<'b> ::traits::OwnedStruct<'b> { pub fn len(&self) -> u32 { self.builder.len() } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a, T> { self.into_reader() } diff --git a/capnp/src/text_list.rs b/capnp/src/text_list.rs index c588dc52b..11442c653 100644 --- a/capnp/src/text_list.rs +++ b/capnp/src/text_list.rs @@ -86,7 +86,7 @@ impl <'a> Builder<'a> { self.builder.borrow().get_pointer_element(index).set_text(value); } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a> { self.into_reader() } diff --git a/capnpc/src/codegen.rs b/capnpc/src/codegen.rs index bab6fbaaf..856dd9dbf 100644 --- a/capnpc/src/codegen.rs +++ b/capnpc/src/codegen.rs @@ -335,20 +335,32 @@ fn prim_default(value: &schema_capnp::value::Reader) -> ::capnp::Result ::capnp::Result<(String, FormattedText)> { use schema_capnp::*; match try!(field.which()) { field::Group(group) => { let the_mod = gen.scope_map[&group.get_type_id()].join("::"); - if is_reader { - Ok((format!("{}::Reader<'a>", the_mod), - Line("::capnp::traits::FromStructReader::new(self.reader)".to_string()))) + + let mut result_type = if is_reader { + format!("{}::Reader<'a>", the_mod) } else { - Ok((format!("{}::Builder<'a>", the_mod), - Line("::capnp::traits::FromStructBuilder::new(self.builder)".to_string()))) + format!("{}::Builder<'a>", the_mod) + }; + + if is_fn { + result_type = format!("-> {}", result_type); } + + let getter_code = if is_reader { + Line("::capnp::traits::FromStructReader::new(self.reader)".to_string()) + } else { + Line("::capnp::traits::FromStructBuilder::new(self.builder)".to_string()) + }; + + Ok((result_type, getter_code)) } field::Slot(reg_field) => { let offset = reg_field.get_offset() as usize; @@ -370,7 +382,7 @@ pub fn getter_text(gen: &GeneratorContext, let default_value = try!(reg_field.get_default_value()); let default = try!(default_value.which()); - let result_type = match try!(raw_type.which()) { + let mut result_type = match try!(raw_type.which()) { type_::Enum(_) => format!("::std::result::Result<{},::capnp::NotInSchema>", typ), type_::AnyPointer(_) if !try!(raw_type.is_parameter()) => typ.clone(), type_::Interface(_) => { @@ -381,8 +393,22 @@ pub fn getter_text(gen: &GeneratorContext, _ => format!("::capnp::Result<{}>", typ), }; + if is_fn { + result_type = if result_type == "()" { + "".to_string() + } else { + format!("-> {}", result_type) + } + } + let getter_code = match (try!(raw_type.which()), default) { - (type_::Void(()), value::Void(())) => Line("()".to_string()), + (type_::Void(()), value::Void(())) => { + if is_fn { + Line("".to_string()) + } else { + Line("()".to_string()) + } + }, (type_::Bool(()), value::Bool(b)) => { if b { Line(format!("self.{}.get_bool_field_mask({}, true)", member, offset)) @@ -790,7 +816,7 @@ fn generate_union(gen: &GeneratorContext, let field_name = try!(field.get_name()); let enumerant_name = capitalize_first_letter(field_name); - let (ty, get) = try!(getter_text(gen, field, is_reader)); + let (ty, get) = try!(getter_text(gen, field, is_reader, false)); getter_interior.push(Branch(vec![ Line(format!("{} => {{", dvalue)), @@ -1109,20 +1135,19 @@ fn generate_node(gen: &GeneratorContext, if !is_union_field { pipeline_impl_interior.push(try!(generate_pipeline_getter(gen, field))); - let (ty, get) = try!(getter_text(gen, &field, true)); + let (ty, get) = try!(getter_text(gen, &field, true, true)); reader_members.push( Branch(vec!( Line("#[inline]".to_string()), - Line(format!("pub fn get_{}(self) -> {} {{", styled_name, ty)), + Line(format!("pub fn get_{}(self) {} {{", styled_name, ty)), Indent(Box::new(get)), Line("}".to_string())))); - let (ty_b, get_b) = try!(getter_text(gen, &field, false)); - + let (ty_b, get_b) = try!(getter_text(gen, &field, false, true)); builder_members.push( Branch(vec!( Line("#[inline]".to_string()), - Line(format!("pub fn get_{}(self) -> {} {{", styled_name, ty_b)), + Line(format!("pub fn get_{}(self) {} {{", styled_name, ty_b)), Indent(Box::new(get_b)), Line("}".to_string())))); @@ -1345,7 +1370,7 @@ fn generate_node(gen: &GeneratorContext, Line(format!("impl <'a,{0}> Builder<'a,{0}> {1} {{", params.params, params.where_clause)), Indent( Box::new(Branch(vec![ - Line("#[deprecated(since=\"capnpc-v0.9.2\", note=\"use into_reader()\")]".to_string()), + Line("#[deprecated(since=\"0.9.2\", note=\"use into_reader()\")]".to_string()), Line(format!("pub fn as_reader(self) -> Reader<'a,{}> {{", params.params)), Indent(Box::new(Line("self.into_reader()".to_string()))), Line("}".to_string()), @@ -1665,7 +1690,7 @@ fn generate_node(gen: &GeneratorContext, )) }), Indent(Box::new(Branch( vec!( - Line("#[deprecated(since=\"capnpc-v0.9.2\", note=\"use into_client()\")]".to_string()), + Line("#[deprecated(since=\"0.9.2\", note=\"use into_client()\")]".to_string()), Line(format!("pub fn from_server<_T: ::capnp::private::capability::ServerHook>(self) -> Client{} {{", bracketed_params)), Indent( Box::new(Line("self.into_client::<_T>()".to_string()))), diff --git a/capnpc/src/schema_capnp.rs b/capnpc/src/schema_capnp.rs index a4cb6c74d..cc525ac28 100644 --- a/capnpc/src/schema_capnp.rs +++ b/capnpc/src/schema_capnp.rs @@ -162,7 +162,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -471,7 +471,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -608,7 +608,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -760,7 +760,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -915,7 +915,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -1073,7 +1073,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -1254,7 +1254,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -1394,7 +1394,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -1549,7 +1549,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -1751,7 +1751,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -2021,7 +2021,7 @@ pub mod field { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -2250,7 +2250,7 @@ pub mod field { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -2417,7 +2417,7 @@ pub mod field { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -2554,7 +2554,7 @@ pub mod field { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -2715,7 +2715,7 @@ pub mod enumerant { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -2875,7 +2875,7 @@ pub mod superclass { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -3059,7 +3059,7 @@ pub mod method { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -3378,7 +3378,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -3712,7 +3712,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -3852,7 +3852,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4000,7 +4000,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4148,7 +4148,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4308,7 +4308,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4493,7 +4493,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4662,7 +4662,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4793,7 +4793,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4921,7 +4921,7 @@ pub mod brand { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -5072,7 +5072,7 @@ pub mod brand { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -5253,7 +5253,7 @@ pub mod brand { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -5528,7 +5528,7 @@ pub mod value { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -5910,7 +5910,7 @@ pub mod annotation { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -6114,7 +6114,7 @@ pub mod capnp_version { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -6277,7 +6277,7 @@ pub mod code_generator_request { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -6468,7 +6468,7 @@ pub mod code_generator_request { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -6627,7 +6627,7 @@ pub mod code_generator_request { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() }