Loading system/gd/Android.bp +6 −0 Original line number Diff line number Diff line Loading @@ -468,6 +468,12 @@ rust_library { srcs: ["rust/packets/lib.rs", ":BluetoothGeneratedPackets_rust"], edition: "2018", host_supported: true, proc_macros: ["libnum_derive"], rustlibs: [ "libbytes", "libnum_traits", "libthiserror", ], } // Generates binary schema data to be bundled and source file generated Loading system/gd/packet/parser/enum_gen.cc +1 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ void EnumGen::GenLogging(std::ostream& stream) { } void EnumGen::GenRustDef(std::ostream& stream) { stream << "#[derive(FromPrimitive, ToPrimitive)]\n"; stream << "pub enum " << e_.name_ << " {"; for (const auto& pair : e_.constants_) { stream << util::ConstantCaseToCamelCase(pair.second) << " = 0x" << std::hex << pair.first << std::dec << ","; Loading system/gd/packet/parser/fields/array_field.cc +6 −0 Original line number Diff line number Diff line Loading @@ -199,3 +199,9 @@ void ArrayField::GenStringRepresentation(std::ostream& s, std::string accessor) std::string ArrayField::GetRustDataType() const { return "[" + element_field_->GetRustDataType() + "; " + std::to_string(array_size_) + "]"; } void ArrayField::GenRustGetter(std::ostream& s, Size start_offset, Size) const { s << "let " << GetName() << " = "; s << "bytes[" << start_offset.bytes() << ".."; s << start_offset.bytes() + GetSize().bytes() << "].try_into().unwrap();"; } system/gd/packet/parser/fields/array_field.h +2 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,8 @@ class ArrayField : public PacketField { virtual std::string GetRustDataType() const override; void GenRustGetter(std::ostream& s, Size start_offset, Size end_offset) const override; const std::string name_; const PacketField* element_field_{nullptr}; Loading system/gd/packet/parser/fields/body_field.cc +3 −0 Original line number Diff line number Diff line Loading @@ -79,3 +79,6 @@ void BodyField::GenStringRepresentation(std::ostream& s, std::string accessor) c std::string BodyField::GetRustDataType() const { return GetDataType(); } void BodyField::GenRustGetter(std::ostream&, Size, Size) const { } Loading
system/gd/Android.bp +6 −0 Original line number Diff line number Diff line Loading @@ -468,6 +468,12 @@ rust_library { srcs: ["rust/packets/lib.rs", ":BluetoothGeneratedPackets_rust"], edition: "2018", host_supported: true, proc_macros: ["libnum_derive"], rustlibs: [ "libbytes", "libnum_traits", "libthiserror", ], } // Generates binary schema data to be bundled and source file generated Loading
system/gd/packet/parser/enum_gen.cc +1 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ void EnumGen::GenLogging(std::ostream& stream) { } void EnumGen::GenRustDef(std::ostream& stream) { stream << "#[derive(FromPrimitive, ToPrimitive)]\n"; stream << "pub enum " << e_.name_ << " {"; for (const auto& pair : e_.constants_) { stream << util::ConstantCaseToCamelCase(pair.second) << " = 0x" << std::hex << pair.first << std::dec << ","; Loading
system/gd/packet/parser/fields/array_field.cc +6 −0 Original line number Diff line number Diff line Loading @@ -199,3 +199,9 @@ void ArrayField::GenStringRepresentation(std::ostream& s, std::string accessor) std::string ArrayField::GetRustDataType() const { return "[" + element_field_->GetRustDataType() + "; " + std::to_string(array_size_) + "]"; } void ArrayField::GenRustGetter(std::ostream& s, Size start_offset, Size) const { s << "let " << GetName() << " = "; s << "bytes[" << start_offset.bytes() << ".."; s << start_offset.bytes() + GetSize().bytes() << "].try_into().unwrap();"; }
system/gd/packet/parser/fields/array_field.h +2 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,8 @@ class ArrayField : public PacketField { virtual std::string GetRustDataType() const override; void GenRustGetter(std::ostream& s, Size start_offset, Size end_offset) const override; const std::string name_; const PacketField* element_field_{nullptr}; Loading
system/gd/packet/parser/fields/body_field.cc +3 −0 Original line number Diff line number Diff line Loading @@ -79,3 +79,6 @@ void BodyField::GenStringRepresentation(std::ostream& s, std::string accessor) c std::string BodyField::GetRustDataType() const { return GetDataType(); } void BodyField::GenRustGetter(std::ostream&, Size, Size) const { }