Skip to content

Implement a constructor that allows initialization of the object with the assertion expressions defined in the struct  #26

@sgmihai

Description

@sgmihai

For expresiveness and consistency, it would be nice to use the binarylang's data structure definitions, to define outgoing only data in a network protocol, that does not need to be parsed in any way, just serialized. We can do this, but the object variable still has to be initialized with the values we want, and thus the assertion expressions are just comsetic in this example. I'd like to be able to do something like

let myData = DataObject.initAssertions()

  struct(udpTrackerPing, endian = b):
    64: connection_id = 0x41727101980
    32: action = 0
    32: transaction_id = rand(int32)
  let ping = UdpTrackerPing(connection_id: 0x41727101980, action: 0, transaction_id: rand(int32))

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions