Loading system/gd/packet/parser/enum_gen.cc +10 −0 Original line number Original line Diff line number Diff line Loading @@ -68,6 +68,16 @@ void EnumGen::GenRustDef(std::ostream& stream) { } } stream << "}"; stream << "}"; stream << "impl fmt::Display for " << e_.name_ << " {"; stream << "fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {"; stream << "match self {"; for (const auto& pair : e_.constants_) { stream << e_.name_ << "::" << util::ConstantCaseToCamelCase(pair.second) << " => " << "write!(f, \"{:#0" << (util::RoundSizeUp(e_.size_) / 4) + 2 << "X} (" << pair.second << ")\", " << "self.to_" << util::GetRustTypeForSize(e_.size_) << "().unwrap()),"; } stream << "}}}\n"; if (e_.try_from_enum_ != nullptr) { if (e_.try_from_enum_ != nullptr) { std::vector<std::string> other_items; std::vector<std::string> other_items; for (const auto& pair : e_.try_from_enum_->constants_) { for (const auto& pair : e_.try_from_enum_->constants_) { Loading system/gd/packet/parser/gen_rust.cc +1 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ use bytes::{Bytes, BytesMut, BufMut}; use num_derive::{FromPrimitive, ToPrimitive}; use num_derive::{FromPrimitive, ToPrimitive}; use num_traits::{FromPrimitive, ToPrimitive}; use num_traits::{FromPrimitive, ToPrimitive}; use std::convert::TryInto; use std::convert::TryInto; use std::fmt; use thiserror::Error; use thiserror::Error; use std::sync::Arc; use std::sync::Arc; Loading system/gd/rust/hci/src/lib.rs +5 −5 Original line number Original line Diff line number Diff line Loading @@ -187,8 +187,8 @@ async fn dispatch( error!("failure dispatching command status {:?}", e); error!("failure dispatching command status {:?}", e); } } }, }, Some(QueuedCommand{cmd, ..}) => panic!("Waiting for {:?}, got {:?}", cmd.get_op_code(), this_opcode), Some(QueuedCommand{cmd, ..}) => panic!("Waiting for {}, got {}", cmd.get_op_code(), this_opcode), None => panic!("Unexpected status event with opcode {:?}", this_opcode), None => panic!("Unexpected status event with opcode {}", this_opcode), } } }, }, CommandComplete(evt) => { CommandComplete(evt) => { Loading @@ -200,8 +200,8 @@ async fn dispatch( error!("failure dispatching command complete {:?}", e); error!("failure dispatching command complete {:?}", e); } } }, }, Some(QueuedCommand{cmd, ..}) => panic!("Waiting for {:?}, got {:?}", cmd.get_op_code(), this_opcode), Some(QueuedCommand{cmd, ..}) => panic!("Waiting for {}, got {}", cmd.get_op_code(), this_opcode), None => panic!("Unexpected complete event with opcode {:?}", this_opcode), None => panic!("Unexpected complete event with opcode {}", this_opcode), } } }, }, LeMetaEvent(evt) => { LeMetaEvent(evt) => { Loading Loading @@ -239,7 +239,7 @@ async fn dispatch( hci_timeout.reset(Duration::from_secs(2)); hci_timeout.reset(Duration::from_secs(2)); pending = Some(queued); pending = Some(queued); }, }, _ = hci_timeout.expired() => panic!("Timed out waiting for {:?}", pending.unwrap().cmd.get_op_code()), _ = hci_timeout.expired() => panic!("Timed out waiting for {}", pending.unwrap().cmd.get_op_code()), else => break, else => break, } } } } Loading Loading
system/gd/packet/parser/enum_gen.cc +10 −0 Original line number Original line Diff line number Diff line Loading @@ -68,6 +68,16 @@ void EnumGen::GenRustDef(std::ostream& stream) { } } stream << "}"; stream << "}"; stream << "impl fmt::Display for " << e_.name_ << " {"; stream << "fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {"; stream << "match self {"; for (const auto& pair : e_.constants_) { stream << e_.name_ << "::" << util::ConstantCaseToCamelCase(pair.second) << " => " << "write!(f, \"{:#0" << (util::RoundSizeUp(e_.size_) / 4) + 2 << "X} (" << pair.second << ")\", " << "self.to_" << util::GetRustTypeForSize(e_.size_) << "().unwrap()),"; } stream << "}}}\n"; if (e_.try_from_enum_ != nullptr) { if (e_.try_from_enum_ != nullptr) { std::vector<std::string> other_items; std::vector<std::string> other_items; for (const auto& pair : e_.try_from_enum_->constants_) { for (const auto& pair : e_.try_from_enum_->constants_) { Loading
system/gd/packet/parser/gen_rust.cc +1 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ use bytes::{Bytes, BytesMut, BufMut}; use num_derive::{FromPrimitive, ToPrimitive}; use num_derive::{FromPrimitive, ToPrimitive}; use num_traits::{FromPrimitive, ToPrimitive}; use num_traits::{FromPrimitive, ToPrimitive}; use std::convert::TryInto; use std::convert::TryInto; use std::fmt; use thiserror::Error; use thiserror::Error; use std::sync::Arc; use std::sync::Arc; Loading
system/gd/rust/hci/src/lib.rs +5 −5 Original line number Original line Diff line number Diff line Loading @@ -187,8 +187,8 @@ async fn dispatch( error!("failure dispatching command status {:?}", e); error!("failure dispatching command status {:?}", e); } } }, }, Some(QueuedCommand{cmd, ..}) => panic!("Waiting for {:?}, got {:?}", cmd.get_op_code(), this_opcode), Some(QueuedCommand{cmd, ..}) => panic!("Waiting for {}, got {}", cmd.get_op_code(), this_opcode), None => panic!("Unexpected status event with opcode {:?}", this_opcode), None => panic!("Unexpected status event with opcode {}", this_opcode), } } }, }, CommandComplete(evt) => { CommandComplete(evt) => { Loading @@ -200,8 +200,8 @@ async fn dispatch( error!("failure dispatching command complete {:?}", e); error!("failure dispatching command complete {:?}", e); } } }, }, Some(QueuedCommand{cmd, ..}) => panic!("Waiting for {:?}, got {:?}", cmd.get_op_code(), this_opcode), Some(QueuedCommand{cmd, ..}) => panic!("Waiting for {}, got {}", cmd.get_op_code(), this_opcode), None => panic!("Unexpected complete event with opcode {:?}", this_opcode), None => panic!("Unexpected complete event with opcode {}", this_opcode), } } }, }, LeMetaEvent(evt) => { LeMetaEvent(evt) => { Loading Loading @@ -239,7 +239,7 @@ async fn dispatch( hci_timeout.reset(Duration::from_secs(2)); hci_timeout.reset(Duration::from_secs(2)); pending = Some(queued); pending = Some(queued); }, }, _ = hci_timeout.expired() => panic!("Timed out waiting for {:?}", pending.unwrap().cmd.get_op_code()), _ = hci_timeout.expired() => panic!("Timed out waiting for {}", pending.unwrap().cmd.get_op_code()), else => break, else => break, } } } } Loading