1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hmz007 6d24f2138b
Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56)
3 years ago
..
fields Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
test Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
Android.bp Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
BUILD.gn Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
README Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
bison.gni Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
checksum_def.cc Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
checksum_def.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
checksum_type_checker.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
custom_field_def.cc Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
custom_field_def.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
custom_type_checker.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
declarations.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
enum_def.cc Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
enum_def.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
enum_gen.cc Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
enum_gen.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
field_list.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
flex.gni Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
gen_cpp.cc Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
gen_rust.cc Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
language_l.ll Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
language_y.yy Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
logging.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
main.cc Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
packet_def.cc Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
packet_def.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
packetgen.gni Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
parent_def.cc Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
parent_def.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
parse_location.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
size.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
struct_def.cc Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
struct_def.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
struct_parser_generator.cc Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
struct_parser_generator.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
type_def.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago
util.h Rockchip Anroid12_SDK 20220721-rkr10 (e1522e56) 3 years ago

README

This file just contains some notes about the design and usage of the PDL language.

-------
 TERMS
-------
.pdl
  The file type that defines packet definitions. You may think of each pdl file
  as its own translation unit.

Packet Views and Builders
  Generated from a packet definition. Views are used to validate packets and
  extract the fields that are defined in the pdl file.  Builders check the input
  arguments and can be serialized.

Checksum types
  checksum MyChecksumClass : 16 "path/to/the/class/"
  Checksum fields need to implement the following three methods:
    void Initialize(MyChecksumClass&);
    void AddByte(MyChecksumClass&, uint8_t);
    // Assuming a 16-bit (uint16_t) checksum:
    uint16_t GetChecksum(MyChecksumClass&);
-------------
 LIMITATIONS
-------------
  - Size fields for a variable length field MUST come before the definition
    of said field.

  - Payload fields must be byte-aligned unless they have an unknown size.
    Body fields are allowed to not be byte aligned.

  - No conditionals

  - Can not have to fields with the same name anywhere in the in an inheritence chain

  - Can't handle size for Body type fields yet since they might not be byte aligned.

  - Currently no arrays of custom types (might change later)

-------
 NOTES
-------
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.

Supports constraints on grandparents
Supports multiple constraints
Every field handles its own generation.
One pdl file will result in one header file with all the packets

Things to cover -
  Constraints
  Inheritance vs Contains

Custom fields with fixed size must extend and implement:
  packet::CustomFieldFixedSizeInterface

Custom fields with variable size need the following functions:
  static void Serialize(const Type&, MutableView&);
  static std::optional<size_t> Size(Iterator);
  static Type Parse(Iterator);
  std::string ToString();