spider-gazelle / bindata

BinData - Parsing Binary Data in Crystal Lang
MIT License
48 stars 5 forks source link

Automatically define helper methods for custom BinData types #10

Closed y8 closed 3 years ago

y8 commented 3 years ago

Thanks for this awesome library!

This pull request automatically defines DSL methods for previously defined custom types. This match BinData gem behavior and makes it easier to read binary definitions

Example:

class MacAddress < BinData 
  array octets : UInt8,  length: ->{ 6 }
end 

class DummyPacket < BinData
  mac_address :from
  mac_address :to

  string :text, length: 20
end
y8 commented 3 years ago

It's safer to merge this PR after #11 is merged to make sure it passes all checks

stakach commented 3 years ago

Thanks for the pulls @y8 awesome additions!