Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e14233d9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "PDL: Use underscores for field names"

parents ea441ea2 cdb43fe8
Loading
Loading
Loading
Loading
+1066 −1066

File changed.

Preview size limit exceeded, changes collapsed.

+229 −229

File changed.

Preview size limit exceeded, changes collapsed.

+4 −2
Original line number Diff line number Diff line
@@ -38,9 +38,11 @@ Checksum types
-------
 NOTES
-------
All Field names should be in CamelCase. Field names matching type names is supported.
All field names should be in snake_case.  Types should be in CamelCase.

The _payload_ keyword generates a getter but _body_ doesn't. Therefore, a
_payload_ must be byte aligned.

The payload keyword generates a getter but body doesn't. Therefore, a payload must be byte aligned.
Supports constraints on grandparents
Supports multiple constraints
Every field handles its own generation.
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
#include "util.h"

ChecksumStartField::ChecksumStartField(std::string name, ParseLocation loc)
    : PacketField(loc, name + "Start"), started_field_name_(name) {}
    : PacketField(loc, name + "_start"), started_field_name_(name) {}

PacketField::Type ChecksumStartField::GetFieldType() const {
  return PacketField::Type::CHECKSUM_START;
+3 −3
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ std::string CustomField::GetType() const {

void CustomField::GenGetter(std::ostream& s, Size start_offset, Size end_offset) const {
  s << GetType();
  s << " Get" << GetName() << "() const {";
  s << " Get" << util::UnderscoreToCamelCase(GetName()) << "() const {";

  s << "auto it = ";
  if (!start_offset.empty()) {
@@ -72,7 +72,7 @@ void CustomField::GenGetter(std::ostream& s, Size start_offset, Size end_offset)
}

bool CustomField::GenBuilderParameter(std::ostream& s) const {
  s << GetType() << " " << util::CamelCaseToUnderScore(GetName());
  s << GetType() << " " << GetName();
  return true;
}

@@ -85,7 +85,7 @@ void CustomField::GenParameterValidator(std::ostream&) const {
}

void CustomField::GenInserter(std::ostream& s) const {
  s << "insert(" << util::CamelCaseToUnderScore(GetName()) << "_, i);";
  s << "insert(" << GetName() << "_, i);";
}

void CustomField::GenValidator(std::ostream&) const {
Loading