Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use octal values for output of tag code values. #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions pb-rs/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ impl Field {
fn write_match_tag<W: Write>(&self, w: &mut W, desc: &FileDescriptor) -> Result<()> {
// special case for FieldType::Map: destructure tuple before inserting in HashMap
if let FieldType::Map(ref key, ref value) = self.typ {
writeln!(w, " Ok({}) => {{", self.tag())?;
writeln!(w, " Ok({:#o}) => {{", self.tag())?;
writeln!(
w,
" let (key, value) = \
Expand All @@ -528,7 +528,7 @@ impl Field {

let (val, val_cow) = self.typ.read_fn(desc)?;
let name = &self.name;
write!(w, " Ok({}) => ", self.tag())?;
write!(w, " Ok({:#o}) => ", self.tag())?;
match self.frequency {
_ if self.boxed => writeln!(w, "msg.{} = Some(Box::new({})),", name, val)?,
Frequency::Optional
Expand Down Expand Up @@ -655,7 +655,7 @@ impl Field {
writeln!(
w,
" if let Some(ref s) = \
self.{} {{ w.write_with_tag({}, |w| w.{})?; }}",
self.{} {{ w.write_with_tag({:#o}, |w| w.{})?; }}",
self.name,
self.tag(),
self.typ.get_write("s", self.boxed)
Expand All @@ -664,7 +664,7 @@ impl Field {
Some(d) => {
writeln!(
w,
" if self.{} != {} {{ w.write_with_tag({}, |w| w.{})?; }}",
" if self.{} != {} {{ w.write_with_tag({:#o}, |w| w.{})?; }}",
self.name,
d,
self.tag(),
Expand All @@ -677,7 +677,7 @@ impl Field {
Frequency::Optional => {
writeln!(
w,
" if self.{} != {} {{ w.write_with_tag({}, |w| w.{})?; }}",
" if self.{} != {} {{ w.write_with_tag({:#o}, |w| w.{})?; }}",
self.name,
self.default.as_ref().map_or_else(
|| self.typ.regular_default(desc).unwrap_or("None"),
Expand All @@ -691,7 +691,7 @@ impl Field {
Frequency::Required if self.typ.is_map() => {
writeln!(
w,
" for (k, v) in self.{}.iter() {{ w.write_with_tag({}, |w| w.{})?; }}",
" for (k, v) in self.{}.iter() {{ w.write_with_tag({:#o}, |w| w.{})?; }}",
self.name,
self.tag(),
self.typ.get_write("", false)
Expand All @@ -700,21 +700,21 @@ impl Field {
Frequency::Required => {
writeln!(
w,
" w.write_with_tag({}, |w| w.{})?;",
" w.write_with_tag({:#o}, |w| w.{})?;",
self.tag(),
self.typ
.get_write(&format!("&self.{}", self.name), self.boxed)
)?;
}
Frequency::Repeated if self.packed() && self.typ.is_fixed_size() => writeln!(
w,
" w.write_packed_fixed_with_tag({}, &self.{})?;",
" w.write_packed_fixed_with_tag({:#o}, &self.{})?;",
self.tag(),
self.name
)?,
Frequency::Repeated if self.packed() => writeln!(
w,
" w.write_packed_with_tag({}, &self.{}, |w, m| w.{}, &|m| {})?;",
" w.write_packed_with_tag({:#o}, &self.{}, |w, m| w.{}, &|m| {})?;",
self.tag(),
self.name,
self.typ.get_write("m", self.boxed),
Expand All @@ -723,7 +723,7 @@ impl Field {
Frequency::Repeated => {
writeln!(
w,
" for s in &self.{} {{ w.write_with_tag({}, |w| w.{})?; }}",
" for s in &self.{} {{ w.write_with_tag({:#o}, |w| w.{})?; }}",
self.name,
self.tag(),
self.typ.get_write("s", self.boxed)
Expand Down Expand Up @@ -1453,7 +1453,7 @@ impl OneOf {
if f.boxed {
writeln!(
w,
" Ok({}) => msg.{} = {}OneOf{}::{}(Box::new({})),",
" Ok({:#o}) => msg.{} = {}OneOf{}::{}(Box::new({})),",
f.tag(),
self.name,
self.get_modules(desc),
Expand All @@ -1464,7 +1464,7 @@ impl OneOf {
} else {
writeln!(
w,
" Ok({}) => msg.{} = {}OneOf{}::{}({}),",
" Ok({:#o}) => msg.{} = {}OneOf{}::{}({}),",
f.tag(),
self.name,
self.get_modules(desc),
Expand Down Expand Up @@ -1518,7 +1518,7 @@ impl OneOf {
for f in self.fields.iter().filter(|f| !f.deprecated) {
writeln!(
w,
" {}OneOf{}::{}(ref m) => {{ w.write_with_tag({}, |w| w.{})? }},",
" {}OneOf{}::{}(ref m) => {{ w.write_with_tag({:#o}, |w| w.{})? }},",
self.get_modules(desc),
self.name,
f.name,
Expand Down